From 6359928f03e571b27267df02185828a4db450440 Mon Sep 17 00:00:00 2001 From: Rongrong <15956627+Rongronggg9@users.noreply.github.com> Date: Sun, 29 Aug 2021 22:14:39 +0800 Subject: [PATCH] use `sender_chat` instead of `forward_from_chat` as the sender of a channel message --- SlashBot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SlashBot.py b/SlashBot.py index df1a72c..3d56f60 100644 --- a/SlashBot.py +++ b/SlashBot.py @@ -34,9 +34,10 @@ def find_name_by_username(username: str) -> str: def get_user(msg): if msg['from']['id'] == TELEGRAM: - return {'first_name': msg['forward_from_chat']['title'], 'id': msg['forward_from_chat']['id']} + return {'first_name': msg['sender_chat']['title'], 'id': msg['sender_chat']['id'], + 'username': msg['sender_chat'].get('username')} elif msg['from']['id'] == GROUP: - return {'first_name': msg['chat']['title'], 'id': msg['chat']['id']} + return {'first_name': msg['chat']['title'], 'id': msg['chat']['id'], 'username': msg['chat'].get('username')} else: return msg['from']