From 25ec388df8ec2729b7e2807069d0a01a90aa11e8 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Thu, 5 Aug 2021 00:52:33 +0800 Subject: [PATCH] [F] Fix HTTP 400 error from incomplete markdowns --- SlashBot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SlashBot.py b/SlashBot.py index 6a3af66..1eed29e 100644 --- a/SlashBot.py +++ b/SlashBot.py @@ -95,12 +95,13 @@ def get_text(mention_from, mention_rpl, command): def reply(update, context): print(update.to_dict()) msg = update.to_dict()['message'] - command = msg['text'] from_user, rpl_user = get_users(msg) - mention_from, mention_rpl = mention(from_user), mention(rpl_user) + # Escape markdown + command = msg['text'] + command = command.replace("_", "\\_").replace("*", "\\*").replace("[", "\\[").replace("`", "\\`") - text = get_text(mention_from, mention_rpl, command) + text = get_text(mention(from_user), mention(rpl_user), command) print(text, end='\n\n') update.effective_message.reply_text(text, parse_mode='Markdown')