Fix global searching with from_user or filter

This commit is contained in:
penn5 2020-04-29 17:13:30 +01:00 committed by GitHub
parent 0f1f655e5d
commit a710caf86e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,14 +86,17 @@ class _MessagesIter(RequestIter):
filter = types.InputMessagesFilterEmpty() filter = types.InputMessagesFilterEmpty()
# Telegram completely ignores `from_id` in private chats # Telegram completely ignores `from_id` in private chats
ty = helpers._entity_type(self.entity) if self.entity:
if ty == helpers._EntityType.USER: ty = helpers._entity_type(self.entity)
# Don't bother sending `from_user` (it's ignored anyway), if ty == helpers._EntityType.USER:
# but keep `from_id` defined above to check it locally. # Don't bother sending `from_user` (it's ignored anyway),
from_user = None # but keep `from_id` defined above to check it locally.
from_user = None
else:
# Do send `from_user` to do the filtering server-side,
# and set `from_id` to None to avoid checking it locally.
self.from_id = None
else: else:
# Do send `from_user` to do the filtering server-side,
# and set `from_id` to None to avoid checking it locally.
self.from_id = None self.from_id = None
self.request = functions.messages.SearchRequest( self.request = functions.messages.SearchRequest(