From 96b5c0b21e1ec8d11b05fd7b659ae0dd1a8d0a84 Mon Sep 17 00:00:00 2001 From: NNTin Date: Thu, 20 Sep 2018 14:37:33 +0200 Subject: [PATCH] Refactoring: Move discord twitter bot in a folder (#23) * refactoring: move in folders * More detailed error information --- .gitignore | 9 +-------- Procfile | 2 +- config.py => bot/config.py | 0 dataIO.py => bot/dataIO.py | 0 data_example.json => bot/data_example.json | 0 launcher.py => bot/launcher.py | 0 main.py => bot/main.py | 22 ++++++++++++++++++++++ discord-twitter-bot.sh | 16 ---------------- 8 files changed, 24 insertions(+), 25 deletions(-) rename config.py => bot/config.py (100%) rename dataIO.py => bot/dataIO.py (100%) rename data_example.json => bot/data_example.json (100%) rename launcher.py => bot/launcher.py (100%) rename main.py => bot/main.py (91%) delete mode 100644 discord-twitter-bot.sh diff --git a/.gitignore b/.gitignore index 7c9d44f9..16ca4974 100644 --- a/.gitignore +++ b/.gitignore @@ -144,11 +144,4 @@ $RECYCLE.BIN/ *.lnk *.xml .idea/discord-twitter-bot.iml -createJson.py -createJson2.py -info.py -info2.txt -test.py -info.txt -debug.json -debug.py +experiment/ \ No newline at end of file diff --git a/Procfile b/Procfile index c009dadb..88516b0f 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -bot: python main.py \ No newline at end of file +bot: python bot/main.py \ No newline at end of file diff --git a/config.py b/bot/config.py similarity index 100% rename from config.py rename to bot/config.py diff --git a/dataIO.py b/bot/dataIO.py similarity index 100% rename from dataIO.py rename to bot/dataIO.py diff --git a/data_example.json b/bot/data_example.json similarity index 100% rename from data_example.json rename to bot/data_example.json diff --git a/launcher.py b/bot/launcher.py similarity index 100% rename from launcher.py rename to bot/launcher.py diff --git a/main.py b/bot/main.py similarity index 91% rename from main.py rename to bot/main.py index 1d1e2baf..326fb7e4 100644 --- a/main.py +++ b/bot/main.py @@ -181,6 +181,28 @@ def _on_status(self, status): webhook.send(embed=embed, content=data_discord["custom_message"]) else: webhook.send(embed=embed) + except discord.errors.NotFound as error: + print('---------Error---------') + print('discord.errors.NotFound') + print("The Webhook URL you provided does not exist.") + print(error) + print('-----------------------') + except discord.errors.Forbidden as error: + print('---------Error---------') + print('discord.errors.Forbidden') + print("The authorization token for your Webhook is incorrect.") + print(error) + print('-----------------------') + pass + except discord.errors.InvalidArgument as error: + print('---------Error---------') + print('discord.errors.InvalidArgument') + print("This should never happen. Contakt me https://discord.gg/JV5eUB " + "and send me what follows below:") + print(error) + print(data) + print('-----------------------') + pass except discord.errors.HTTPException as error: print('---------Error---------') print('discord.errors.HTTPException') diff --git a/discord-twitter-bot.sh b/discord-twitter-bot.sh deleted file mode 100644 index b97b88ad..00000000 --- a/discord-twitter-bot.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -repository="https://github.com/NNTin/discord-twitter-bot.git" -localFolder="/home/pi/Desktop/discord-twitter-bot" -sensitive="/home/pi/Desktop/sensitive/discord-twitter-bot" - -cd "$localFolder" - -git pull "$repository" - -cp "$sensitive/data.json" "$localFolder/data.json" - -until python3 main.py; do - echo "Respawning.." >&2 - sleep 1 -done \ No newline at end of file