From 5b173768013a5ee7d50fa3cfd955bdad913eec16 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 15 Oct 2018 10:18:22 +0200 Subject: [PATCH] Enable dispatching of user status updates --- pyrogram/client/dispatcher/dispatcher.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index 5506cbdd..a0c5e365 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -25,7 +25,7 @@ from threading import Thread import pyrogram from pyrogram.api import types from ..ext import utils -from ..handlers import RawUpdateHandler, CallbackQueryHandler, MessageHandler, DeletedMessagesHandler +from ..handlers import RawUpdateHandler, CallbackQueryHandler, MessageHandler, DeletedMessagesHandler, UserStatusHandler log = logging.getLogger(__name__) @@ -108,6 +108,8 @@ class Dispatcher: callback_query = update.callback_query + user_status = update.user_status + if message and isinstance(handler, MessageHandler): if not handler.check(message): continue @@ -123,6 +125,11 @@ class Dispatcher: continue args = (self.client, callback_query) + elif user_status and isinstance(handler, UserStatusHandler): + if not handler.check(user_status): + continue + + args = (self.client, user_status) else: continue @@ -209,6 +216,14 @@ class Dispatcher: ) ) ) + elif isinstance(update, types.UpdateUserStatus): + self.dispatch( + pyrogram.Update( + user_status=utils.parse_user_status( + update.status, update.user_id + ) + ) + ) else: continue except Exception as e: