From 7f4eb9aac8c551ff73cb085a78433d3742eb8b1d Mon Sep 17 00:00:00 2001 From: Rongrong <15956627+Rongronggg9@users.noreply.github.com> Date: Mon, 26 Oct 2020 15:36:12 +0800 Subject: [PATCH] =?UTF-8?q?add=20'=E8=87=AA=E5=B7=B1'=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlashBot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SlashBot.py b/SlashBot.py index 3d694dd..c57f973 100644 --- a/SlashBot.py +++ b/SlashBot.py @@ -21,13 +21,17 @@ def reply(update, context): msg = update.to_dict()['message'] msg_from = msg['from'] command = msg['text'].lstrip('/') - if 'reply_to_message' in msg.keys(): + + if 'reply_to_message' in msg.keys() and msg['reply_to_message']['from'] != msg_from: msg_rpl = msg['reply_to_message']['from'] else: - msg_rpl = msg_from + msg_rpl = {'first_name': '自己', 'id': msg_from['id']} - update.effective_message.reply_text(f'{mention(msg_from)} {command} 了 {mention(msg_rpl)}!', - parse_mode='Markdown') + mention_from = mention(msg_from) + mention_rpl = mention(msg_rpl) + text = f"{mention_from} {command} 了 {mention_rpl}!" + + update.effective_message.reply_text(text, parse_mode='Markdown') updater = Updater(token=Token, use_context=True)