fix exception error
This commit is contained in:
parent
bacbdc2ccb
commit
79d341443c
1 changed files with 5 additions and 3 deletions
8
main.py
8
main.py
|
@ -6,6 +6,7 @@ from random import choice
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
|
from json import loads
|
||||||
|
|
||||||
def load(variables) -> dict:
|
def load(variables) -> dict:
|
||||||
"""Load environment variables."""
|
"""Load environment variables."""
|
||||||
|
@ -100,9 +101,10 @@ class Listener(StreamListener):
|
||||||
self.api.update_status(status = choice(answer), in_reply_to_status_id = status._json["id"], auto_populate_reply_metadata = True)
|
self.api.update_status(status = choice(answer), in_reply_to_status_id = status._json["id"], auto_populate_reply_metadata = True)
|
||||||
print(f"{status._json['user']['screen_name']} s'est fait {answer[0]} !")
|
print(f"{status._json['user']['screen_name']} s'est fait {answer[0]} !")
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if error.code == 385:
|
error = loads(error.response.text)["errors"][0]
|
||||||
error.message = "Tweet supprimé ou auteur en privé/bloqué."
|
if error["code"] == 385:
|
||||||
print(f"{errorMessage[:-2]} ({error.code}) ! {error.message}")
|
error["message"] = "Tweet supprimé ou auteur en privé/bloqué."
|
||||||
|
print(f"{errorMessage[:-2]} ({error['code']}) ! {error['message']}")
|
||||||
else:
|
else:
|
||||||
if keys["VERBOSE"]:
|
if keys["VERBOSE"]:
|
||||||
print("Annulation car le dernier mot n'est pas intéressant.")
|
print("Annulation car le dernier mot n'est pas intéressant.")
|
||||||
|
|
Reference in a new issue