Fix get_message_history ignoring chats and enhance find_user_or_chat

This commit is contained in:
Lonami Exo
2017-06-14 14:06:35 +02:00
parent 96d8ca94cf
commit fc915b2284
2 changed files with 18 additions and 18 deletions

View File

@@ -67,19 +67,22 @@ def find_user_or_chat(peer, users, chats):
Returns None if it was not found"""
try:
if isinstance(peer, PeerUser):
user = next(u for u in users if u.id == peer.user_id)
return user
return next(u for u in users if u.id == peer.user_id)
elif isinstance(peer, PeerChat):
chat = next(c for c in chats if c.id == peer.chat_id)
return chat
return next(c for c in chats if c.id == peer.chat_id)
elif isinstance(peer, PeerChannel):
channel = next(c for c in chats if c.id == peer.channel_id)
return channel
return next(c for c in chats if c.id == peer.channel_id)
except StopIteration:
return None
except StopIteration: return
if isinstance(peer, int):
try: return next(u for u in users if u.id == peer)
except StopIteration: pass
try: return next(c for c in chats if c.id == peer)
except StopIteration: pass
def get_appropriated_part_size(file_size):