diff --git a/hooks/finish_review.py b/hooks/finish_review.py index c5abb3b..dbf061b 100644 --- a/hooks/finish_review.py +++ b/hooks/finish_review.py @@ -62,12 +62,24 @@ class FinishReview: # On copie ce texte sur un pad pastebin_url = "" if bot.settings.PASTEBIN_URL != "": - result = privatebinapi.send( - bot.settings.PASTEBIN_URL, - text=report, - expiration=bot.settings.PASTEBIN_EXPIRATION, - ) - pastebin_url = result["full_url"] + try: + result = privatebinapi.send( + bot.settings.PASTEBIN_URL, + text=report, + expiration=bot.settings.PASTEBIN_EXPIRATION, + ) + except: + # En cas d'erreur, on re-essaye une fois après un temps d'attente + time.sleep(int(bot.settings.PASTEBIN_WAIT)) + result = privatebinapi.send( + bot.settings.PASTEBIN_URL, + text=report, + expiration=bot.settings.PASTEBIN_EXPIRATION, + ) + try: + pastebin_url = result["full_url"] + except: + bot.send(channel, "Erreur sur le pastebin.") # On sauve le texte dans un fichier review_file = ( diff --git a/settings.py b/settings.py index e4fb647..dc3df23 100644 --- a/settings.py +++ b/settings.py @@ -27,9 +27,10 @@ REVIEW_DIRECTORY = os.environ.get("REVIEW_DIRECTORY", os.path.join(BASE_DIR, "re REVIEW_STATS = os.environ.get("REVIEW_STATS", os.path.join(REVIEW_DIRECTORY, "reviewstats.csv")) # Pastebin -PASTEBIN_URL = "https://paste.chapril.org/" +PASTEBIN_URL = os.environ.get("PASTEBIN_URL", "https://paste.chapril.org/") +PASTEBIN_WAIT = int(os.environ.get("PASTEBIN_WAIT", 5)) # Values : 5min, 10min, 1hour, 1day, 1week, 1month, 1year, never -PASTEBIN_EXPIRATION = "1week" +PASTEBIN_EXPIRATION = os.environ.get("PASTEBIN_EXPIRATION", "1week") # Scheduler REVIEW_REMINDERS = [(11, 30), (11, 45), (11, 55)]