From 12ee02cee0029b2204c245534c8dbbf67761faf5 Mon Sep 17 00:00:00 2001 From: dymik739 Date: Mon, 4 Sep 2023 21:33:23 +0300 Subject: [PATCH] main.py: enable MarkdownV2 formatting --- main.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index ba08092..b3bcf64 100644 --- a/main.py +++ b/main.py @@ -189,10 +189,19 @@ def queue_processor(): if mod.enabled: if mod.version == 1 or mod.version == 2: response = mod.process(msg) + if response: + # protecting output + response = response.replace("(", "\\(") + response = response.replace(")", "\\)") + response = response.replace("!", "\\!") + response = response.replace(".", "\\.") + response = response.replace("=", "\\=") + updater.bot.send_message(chat_id=msg.chat.id, text=response, - disable_web_page_preview=True) - print(f"Responded using module {mod.path} ({mod.alias}) with text: {responce}") + disable_web_page_preview=True, + parse_mode="MarkdownV2") + print(f"Responded using module {mod.path} ({mod.alias}) with text: {response}") break del message_queue[0] @@ -203,9 +212,9 @@ def queue_processor(): break else: time.sleep(1) - except Exception: + except Exception as e: print(f"[ERROR] queue_processor: current message queue: {message_queue}") - print("[ERROR] queue_processor: error while processing message, trying to delete it...") + print(f"[ERROR] queue_processor: error while processing message ({e}), trying to delete it...") try: del message_queue[0] print("[INFO] queue_processor: deleted broken message from the queue")