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

Use the new parsers in dispatcher.py

This commit is contained in:
Dan 2018-12-17 16:40:06 +01:00
parent 2a1a6301a6
commit 1344e95be6

View File

@ -22,9 +22,9 @@ from collections import OrderedDict
from queue import Queue
from threading import Thread
import pyrogram
from pyrogram.api import types
from ..ext import utils
from ..handlers import CallbackQueryHandler, MessageHandler, DeletedMessagesHandler, UserStatusHandler, RawUpdateHandler
from ..handlers import CallbackQueryHandler, MessageHandler, RawUpdateHandler, UserStatusHandler, DeletedMessagesHandler
log = logging.getLogger(__name__)
@ -40,7 +40,7 @@ class Dispatcher:
types.UpdateEditChannelMessage
)
DELETE_MESSAGE_UPDATES = (
DELETE_MESSAGES_UPDATES = (
types.UpdateDeleteMessages,
types.UpdateDeleteChannelMessages
)
@ -62,16 +62,18 @@ class Dispatcher:
self.update_parsers = {
Dispatcher.MESSAGE_UPDATES:
lambda upd, usr, cht: (utils.parse_messages(self.client, upd.message, usr, cht), MessageHandler),
lambda upd, usr, cht: (pyrogram.Message.parse(self.client, upd.message, usr, cht), MessageHandler),
Dispatcher.DELETE_MESSAGE_UPDATES:
lambda upd, usr, cht: (utils.parse_deleted_messages(upd), DeletedMessagesHandler),
Dispatcher.DELETE_MESSAGES_UPDATES:
lambda upd, usr, cht: (pyrogram.Messages.parse_deleted(self.client, upd), DeletedMessagesHandler),
Dispatcher.CALLBACK_QUERY_UPDATES:
lambda upd, usr, cht: (utils.parse_callback_query(self.client, upd, usr), CallbackQueryHandler),
lambda upd, usr, cht: (pyrogram.CallbackQuery.parse(self.client, upd, usr), CallbackQueryHandler),
(types.UpdateUserStatus,):
lambda upd, usr, cht: (utils.parse_user_status(upd.status, upd.user_id), UserStatusHandler)
lambda upd, usr, cht: (
pyrogram.UserStatus.parse(self.client, upd.status, upd.user_id), UserStatusHandler
)
}
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}