mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Fix get(_input)_users in ChatAction with no service msg
This commit is contained in:
@@ -381,7 +381,8 @@ class ChatAction(EventBuilder):
|
||||
if not self._user_ids:
|
||||
return []
|
||||
|
||||
if self._users is None or len(self._users) != len(self._user_ids):
|
||||
# Note: we access the property first so that it fills if needed
|
||||
if (self.users is None or len(self._users) != len(self._user_ids)) and self.action_message:
|
||||
await self.action_message._reload_message()
|
||||
self._users = [
|
||||
u for u in self.action_message.action_entities
|
||||
@@ -397,19 +398,31 @@ class ChatAction(EventBuilder):
|
||||
if self._input_users is None and self._user_ids:
|
||||
self._input_users = []
|
||||
for user_id in self._user_ids:
|
||||
# First try to get it from our entities
|
||||
try:
|
||||
self._input_users.append(utils.get_input_peer(self._entities[user_id]))
|
||||
continue
|
||||
except (KeyError, TypeError) as e:
|
||||
pass
|
||||
|
||||
# If missing, try from the entity cache
|
||||
try:
|
||||
self._input_users.append(self._client._entity_cache[user_id])
|
||||
continue
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self._input_users or []
|
||||
|
||||
async def get_input_users(self):
|
||||
"""
|
||||
Returns `input_users` but will make an API call if necessary.
|
||||
"""
|
||||
self._input_users = None
|
||||
if self._input_users is None:
|
||||
await self.action_message._reload_message()
|
||||
if not self._user_ids:
|
||||
return []
|
||||
|
||||
# Note: we access the property first so that it fills if needed
|
||||
if (self.input_users is None or len(self._input_users) != len(self._user_ids)) and self.action_message:
|
||||
self._input_users = [
|
||||
utils.get_input_peer(u)
|
||||
for u in self.action_message.action_entities
|
||||
|
Reference in New Issue
Block a user