Add chat_id-like convenience properties to the events

This commit is contained in:
Lonami Exo
2018-04-08 14:22:11 +02:00
parent 259bb6ace1
commit 93b5909be5
4 changed files with 43 additions and 1 deletions

View File

@@ -251,7 +251,7 @@ class ChatAction(EventBuilder):
@property
def user(self):
"""
The single user that takes part in this action (e.g. joined).
The first user that takes part in this action (e.g. joined).
Might be ``None`` if the information can't be retrieved or
there is no user taking part.
@@ -267,6 +267,14 @@ class ChatAction(EventBuilder):
if self.input_users:
return self._input_users[0]
@property
def user_id(self):
"""
Returns the marked signed ID of the first user, if any.
"""
if self.input_users:
return utils.get_peer_id(self._input_users[0])
@property
def users(self):
"""
@@ -311,3 +319,11 @@ class ChatAction(EventBuilder):
except (TypeError, ValueError):
pass
return self._input_users
@property
def user_ids(self):
"""
Returns the marked signed ID of the users, if any.
"""
if self.input_users:
return [utils.get_peer_id(u) for u in self._input_users]