From ff39c8eeb34e830ae5af325787e24da495b99ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 22 Sep 2021 23:57:42 +0200 Subject: [PATCH] bot error reporting does not use colors & truncates at 2500 chars --- tgbot/kollagen-bot/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tgbot/kollagen-bot/main.py b/tgbot/kollagen-bot/main.py index 63af7b0..e1325d4 100644 --- a/tgbot/kollagen-bot/main.py +++ b/tgbot/kollagen-bot/main.py @@ -180,6 +180,9 @@ class KollagenBot: check=True, capture_output=True, timeout=60, + env={ + 'NO_COLOR': "1" + } ) ntf.seek(0) @@ -218,11 +221,13 @@ class KollagenBot: if isinstance(update, Update): if isinstance(context.error, subprocess.CalledProcessError): - update.message.reply_text( - f"Something is fucked!\n{context.error.stderr.decode('utf-8')}" - ) + error_display = context.error.stderr.decode('utf-8') else: - update.message.reply_text(f"Something is fucked!\n{context.error}") + error_display = str(context.error) + error_display = error_display[:2500] + update.message.reply_text( + f"Something is fucked!\n{error_display}" + ) def start_idle(self): self.updater.start_polling()