Fix UserUpdate not working for typing updates

The code to deal with the right chat action was there,
but the updates that could trigger that code path were
never checked.
This commit is contained in:
Lonami Exo 2019-03-26 08:57:16 +01:00
parent e71638abf1
commit 9db9db1ade

View File

@ -14,6 +14,14 @@ class UserUpdate(EventBuilder):
if isinstance(update, types.UpdateUserStatus): if isinstance(update, types.UpdateUserStatus):
event = cls.Event(update.user_id, event = cls.Event(update.user_id,
status=update.status) status=update.status)
elif isinstance(update, types.UpdateChatUserTyping):
# Unfortunately, we can't know whether `chat_id`'s type
event = cls.Event(update.user_id,
chat_id=update.chat_id,
typing=update.action)
elif isinstance(update, types.UpdateUserTyping):
event = cls.Event(update.user_id,
typing=update.action)
else: else:
return return
@ -83,9 +91,13 @@ class UserUpdate(EventBuilder):
contact (`bool`): contact (`bool`):
``True`` if what's being uploaded (selected) is a contact. ``True`` if what's being uploaded (selected) is a contact.
""" """
def __init__(self, user_id, *, status=None, typing=None): def __init__(self, user_id, *, status=None, chat_id=None, typing=None):
super().__init__(types.PeerUser(user_id)) super().__init__(types.PeerUser(user_id))
# TODO This should be passed to init, not here
# But we need to know the type beforehand
self.chat_id = chat_id
self.online = None if status is None else \ self.online = None if status is None else \
isinstance(status, types.UserStatusOnline) isinstance(status, types.UserStatusOnline)