From 9db9db1ade061a535bf31b3c3b65241e115c5c08 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 26 Mar 2019 08:57:16 +0100 Subject: [PATCH] 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. --- telethon/events/userupdate.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/telethon/events/userupdate.py b/telethon/events/userupdate.py index 1c0144be..0ac432f7 100644 --- a/telethon/events/userupdate.py +++ b/telethon/events/userupdate.py @@ -14,6 +14,14 @@ class UserUpdate(EventBuilder): if isinstance(update, types.UpdateUserStatus): event = cls.Event(update.user_id, 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: return @@ -83,9 +91,13 @@ class UserUpdate(EventBuilder): contact (`bool`): ``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)) + # 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 \ isinstance(status, types.UserStatusOnline)