mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +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))
|
total_messages = getattr(result, 'count', len(result.messages))
|
||||||
|
|
||||||
# Iterate over all the messages and find the sender User
|
# Iterate over all the messages and find the sender User
|
||||||
entities = [find_user_or_chat(msg.from_id, result.users, result.chats)
|
entities = [find_user_or_chat(m.from_id, result.users, result.chats)
|
||||||
for msg in result.messages]
|
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
|
return total_messages, result.messages, entities
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,14 @@ class InteractiveTelegramClient(TelegramClient):
|
||||||
for msg, sender in zip(
|
for msg, sender in zip(
|
||||||
reversed(messages), reversed(senders)):
|
reversed(messages), reversed(senders)):
|
||||||
# Get the name of the sender if any
|
# 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
|
# Format the message content
|
||||||
if getattr(msg, 'media', None):
|
if getattr(msg, 'media', None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user