mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Fix .get_dialogs() failing due to IDs being marked
Also removed utils.find_user_or_chat to prevent this from happening again. Using a dict {marked_id: entity} is better.
This commit is contained in:
parent
c23c0a557a
commit
7ed3be8e6f
|
@ -338,9 +338,8 @@ class TelegramClient(TelegramBareClient):
|
|||
break
|
||||
|
||||
offset_date = r.messages[-1].date
|
||||
offset_peer = utils.find_user_or_chat(
|
||||
r.dialogs[-1].peer, entities, entities
|
||||
)
|
||||
offset_peer = entities[
|
||||
utils.get_peer_id(r.dialogs[-1].peer, add_mark=True)]
|
||||
offset_id = r.messages[-1].id & 4294967296 # Telegram/danog magic
|
||||
|
||||
dialogs = UserList(dialogs.values())
|
||||
|
|
|
@ -386,28 +386,6 @@ def resolve_id(marked_id):
|
|||
return -marked_id, PeerChat
|
||||
|
||||
|
||||
def find_user_or_chat(peer, users, chats):
|
||||
"""Finds the corresponding user or chat given a peer.
|
||||
Returns None if it was not found"""
|
||||
if isinstance(peer, PeerUser):
|
||||
peer, where = peer.user_id, users
|
||||
else:
|
||||
where = chats
|
||||
if isinstance(peer, PeerChat):
|
||||
peer = peer.chat_id
|
||||
elif isinstance(peer, PeerChannel):
|
||||
peer = peer.channel_id
|
||||
|
||||
if isinstance(peer, int):
|
||||
if isinstance(where, dict):
|
||||
return where.get(peer)
|
||||
else:
|
||||
try:
|
||||
return next(x for x in where if x.id == peer)
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
|
||||
def get_appropriated_part_size(file_size):
|
||||
"""Gets the appropriated part size when uploading or downloading files,
|
||||
given an initial file size"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user