main.py: enable MarkdownV2 formatting

This commit is contained in:
dymik739 2023-09-04 21:33:23 +03:00
parent ba353a3609
commit 12ee02cee0
1 changed files with 13 additions and 4 deletions

17
main.py
View File

@ -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")