mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Handle users=None properly in ChatAction
This commit is contained in:
parent
54c8771885
commit
a2fc7dca79
|
@ -175,7 +175,14 @@ class ChatAction(EventBuilder):
|
||||||
self._kicked_by = kicked_by
|
self._kicked_by = kicked_by
|
||||||
|
|
||||||
self.created = bool(created)
|
self.created = bool(created)
|
||||||
self._user_peers = users if isinstance(users, list) else [users]
|
|
||||||
|
if isinstance(users, list):
|
||||||
|
self._user_ids = users
|
||||||
|
elif users:
|
||||||
|
self._user_ids = [users]
|
||||||
|
else:
|
||||||
|
self._user_ids = []
|
||||||
|
|
||||||
self._users = None
|
self._users = None
|
||||||
self._input_users = None
|
self._input_users = None
|
||||||
self.new_title = new_title
|
self.new_title = new_title
|
||||||
|
@ -333,8 +340,8 @@ class ChatAction(EventBuilder):
|
||||||
"""
|
"""
|
||||||
Returns the marked signed ID of the first user, if any.
|
Returns the marked signed ID of the first user, if any.
|
||||||
"""
|
"""
|
||||||
if self._user_peers:
|
if self._user_ids:
|
||||||
return utils.get_peer_id(self._user_peers[0])
|
return self._user_ids[0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def users(self):
|
def users(self):
|
||||||
|
@ -344,14 +351,14 @@ class ChatAction(EventBuilder):
|
||||||
Might be empty if the information can't be retrieved or there
|
Might be empty if the information can't be retrieved or there
|
||||||
are no users taking part.
|
are no users taking part.
|
||||||
"""
|
"""
|
||||||
if not self._user_peers:
|
if not self._user_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self._users is None:
|
if self._users is None:
|
||||||
self._users = [
|
self._users = [
|
||||||
self._entities[utils.get_peer_id(peer)]
|
self._entities[user_id]
|
||||||
for peer in self._user_peers
|
for user_id in self._user_ids
|
||||||
if utils.get_peer_id(peer) in self._entities
|
if user_id in self._entities
|
||||||
]
|
]
|
||||||
|
|
||||||
return self._users
|
return self._users
|
||||||
|
@ -360,10 +367,10 @@ class ChatAction(EventBuilder):
|
||||||
"""
|
"""
|
||||||
Returns `users` but will make an API call if necessary.
|
Returns `users` but will make an API call if necessary.
|
||||||
"""
|
"""
|
||||||
if not self._user_peers:
|
if not self._user_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self._users is None or len(self._users) != len(self._user_peers):
|
if self._users is None or len(self._users) != len(self._user_ids):
|
||||||
await self.action_message._reload_message()
|
await self.action_message._reload_message()
|
||||||
self._users = [
|
self._users = [
|
||||||
u for u in self.action_message.action_entities
|
u for u in self.action_message.action_entities
|
||||||
|
@ -376,11 +383,11 @@ class ChatAction(EventBuilder):
|
||||||
"""
|
"""
|
||||||
Input version of the ``self.users`` property.
|
Input version of the ``self.users`` property.
|
||||||
"""
|
"""
|
||||||
if self._input_users is None and self._user_peers:
|
if self._input_users is None and self._user_ids:
|
||||||
self._input_users = []
|
self._input_users = []
|
||||||
for peer in self._user_peers:
|
for user_id in self._user_ids:
|
||||||
try:
|
try:
|
||||||
self._input_users.append(self._client._entity_cache[peer])
|
self._input_users.append(self._client._entity_cache[user_id])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return self._input_users or []
|
return self._input_users or []
|
||||||
|
@ -404,5 +411,5 @@ class ChatAction(EventBuilder):
|
||||||
"""
|
"""
|
||||||
Returns the marked signed ID of the users, if any.
|
Returns the marked signed ID of the users, if any.
|
||||||
"""
|
"""
|
||||||
if self._user_peers:
|
if self._user_ids:
|
||||||
return [utils.get_peer_id(u) for u in self._user_peers]
|
return self._user_ids[:]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user