2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Enable dispatching of user status updates

This commit is contained in:
Dan 2018-10-15 10:18:22 +02:00
parent d567b878b1
commit 5b17376801

View File

@ -25,7 +25,7 @@ from threading import Thread
import pyrogram import pyrogram
from pyrogram.api import types from pyrogram.api import types
from ..ext import utils from ..ext import utils
from ..handlers import RawUpdateHandler, CallbackQueryHandler, MessageHandler, DeletedMessagesHandler from ..handlers import RawUpdateHandler, CallbackQueryHandler, MessageHandler, DeletedMessagesHandler, UserStatusHandler
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -108,6 +108,8 @@ class Dispatcher:
callback_query = update.callback_query callback_query = update.callback_query
user_status = update.user_status
if message and isinstance(handler, MessageHandler): if message and isinstance(handler, MessageHandler):
if not handler.check(message): if not handler.check(message):
continue continue
@ -123,6 +125,11 @@ class Dispatcher:
continue continue
args = (self.client, callback_query) 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: else:
continue 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: else:
continue continue
except Exception as e: except Exception as e: