Correction sur la gestion du paste pour que le bot ne plante pas.

This commit is contained in:
Mindiell 2024-06-25 20:29:50 +02:00
parent 59a1a79c82
commit 25f5c9ecb7
2 changed files with 21 additions and 8 deletions

View File

@ -62,12 +62,24 @@ class FinishReview:
# On copie ce texte sur un pad # On copie ce texte sur un pad
pastebin_url = "" pastebin_url = ""
if bot.settings.PASTEBIN_URL != "": if bot.settings.PASTEBIN_URL != "":
try:
result = privatebinapi.send( result = privatebinapi.send(
bot.settings.PASTEBIN_URL, bot.settings.PASTEBIN_URL,
text=report, text=report,
expiration=bot.settings.PASTEBIN_EXPIRATION, 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"] pastebin_url = result["full_url"]
except:
bot.send(channel, "Erreur sur le pastebin.")
# On sauve le texte dans un fichier # On sauve le texte dans un fichier
review_file = ( review_file = (

View File

@ -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")) REVIEW_STATS = os.environ.get("REVIEW_STATS", os.path.join(REVIEW_DIRECTORY, "reviewstats.csv"))
# Pastebin # 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 # Values : 5min, 10min, 1hour, 1day, 1week, 1month, 1year, never
PASTEBIN_EXPIRATION = "1week" PASTEBIN_EXPIRATION = os.environ.get("PASTEBIN_EXPIRATION", "1week")
# Scheduler # Scheduler
REVIEW_REMINDERS = [(11, 30), (11, 45), (11, 55)] REVIEW_REMINDERS = [(11, 30), (11, 45), (11, 55)]