mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-18 19:16:43 +00:00
Check from_user client-side for PMs in iter_messages
This commit is contained in:
parent
09ea8ffe0b
commit
8c5bbdf7eb
@ -129,6 +129,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
|
|||||||
if offset_id - min_id <= 1:
|
if offset_id - min_id <= 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
from_id = None
|
||||||
limit = float('inf') if limit is None else int(limit)
|
limit = float('inf') if limit is None else int(limit)
|
||||||
if search is not None or filter or from_user:
|
if search is not None or filter or from_user:
|
||||||
if filter is None:
|
if filter is None:
|
||||||
@ -150,6 +151,13 @@ class MessageMethods(UploadMethods, MessageParseMethods):
|
|||||||
if from_user else None
|
if from_user else None
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if isinstance(entity, types.InputPeerUser):
|
||||||
|
# Telegram completely ignores `from_id` in private
|
||||||
|
# chats, so we need to do this check client-side.
|
||||||
|
if isinstance(request.from_id, types.InputPeerSelf):
|
||||||
|
from_id = (await self.get_me(input_peer=True)).user_id
|
||||||
|
else:
|
||||||
|
from_id = request.from_id
|
||||||
else:
|
else:
|
||||||
request = functions.messages.GetHistoryRequest(
|
request = functions.messages.GetHistoryRequest(
|
||||||
peer=entity,
|
peer=entity,
|
||||||
@ -194,8 +202,9 @@ class MessageMethods(UploadMethods, MessageParseMethods):
|
|||||||
if message.id <= min_id:
|
if message.id <= min_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(message, types.MessageEmpty)\
|
if (isinstance(message, types.MessageEmpty)
|
||||||
or message.id >= last_id:
|
or message.id >= last_id
|
||||||
|
or (from_id and message.from_id != from_id)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# There has been reports that on bad connections this method
|
# There has been reports that on bad connections this method
|
||||||
|
Loading…
Reference in New Issue
Block a user