mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Fix get_message_history not returning sender on channels (closes #110)
This commit is contained in:
parent
fc915b2284
commit
92088383f7
|
@ -447,8 +447,10 @@ class TelegramClient(TelegramBareClient):
|
|||
total_messages = getattr(result, 'count', len(result.messages))
|
||||
|
||||
# Iterate over all the messages and find the sender User
|
||||
entities = [find_user_or_chat(msg.from_id, result.users, result.chats)
|
||||
for msg in result.messages]
|
||||
entities = [find_user_or_chat(m.from_id, result.users, result.chats)
|
||||
if m.from_id is not None else
|
||||
find_user_or_chat(m.to_id, result.users, result.chats)
|
||||
for m in result.messages]
|
||||
|
||||
return total_messages, result.messages, entities
|
||||
|
||||
|
|
|
@ -162,7 +162,14 @@ class InteractiveTelegramClient(TelegramClient):
|
|||
for msg, sender in zip(
|
||||
reversed(messages), reversed(senders)):
|
||||
# Get the name of the sender if any
|
||||
name = sender.first_name if sender else '???'
|
||||
if sender:
|
||||
name = getattr(sender, 'first_name', None)
|
||||
if not name:
|
||||
name = getattr(sender, 'title')
|
||||
if not name:
|
||||
name = '???'
|
||||
else:
|
||||
name = '???'
|
||||
|
||||
# Format the message content
|
||||
if getattr(msg, 'media', None):
|
||||
|
|
Loading…
Reference in New Issue
Block a user