use sender_chat instead of forward_from_chat as the sender of a channel message

This commit is contained in:
Rongrong 2021-08-29 22:14:39 +08:00
parent 8aa618cf6a
commit 6359928f03
No known key found for this signature in database
GPG Key ID: A36C9CDA260CB264

View File

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