[F] Fix HTTP 400 error from incomplete markdowns

This commit is contained in:
Hykilpikonna 2021-08-05 00:52:33 +08:00
parent c0488d7d9a
commit 25ec388df8
No known key found for this signature in database
GPG Key ID: 256CD01A41D7FA26

View File

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