mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-03 07:45:14 +00:00
@@ -32,7 +32,7 @@ from .client.types import (
|
||||
Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, User, UserStatus,
|
||||
UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply,
|
||||
InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove,
|
||||
Poll, PollOption, ChatPreview
|
||||
Poll, PollOption, ChatPreview, StopPropagation
|
||||
)
|
||||
from .client import (
|
||||
Client, ChatAction, ParseMode, Emoji,
|
||||
|
@@ -134,24 +134,29 @@ class Dispatcher:
|
||||
parsed_update, handler_type = parser(update, users, chats)
|
||||
|
||||
for group in self.groups.values():
|
||||
for handler in group:
|
||||
args = None
|
||||
try:
|
||||
for handler in group:
|
||||
args = None
|
||||
|
||||
if isinstance(handler, RawUpdateHandler):
|
||||
args = (update, users, chats)
|
||||
elif isinstance(handler, handler_type):
|
||||
if handler.check(parsed_update):
|
||||
args = (parsed_update,)
|
||||
if isinstance(handler, RawUpdateHandler):
|
||||
args = (update, users, chats)
|
||||
elif isinstance(handler, handler_type):
|
||||
if handler.check(parsed_update):
|
||||
args = (parsed_update,)
|
||||
|
||||
if args is None:
|
||||
continue
|
||||
if args is None:
|
||||
continue
|
||||
|
||||
try:
|
||||
handler.callback(self.client, *args)
|
||||
except StopIteration:
|
||||
raise
|
||||
except Exception as e:
|
||||
log.error(e, exc_info=True)
|
||||
|
||||
try:
|
||||
handler.callback(self.client, *args)
|
||||
except Exception as e:
|
||||
log.error(e, exc_info=True)
|
||||
finally:
|
||||
break
|
||||
except StopIteration:
|
||||
break
|
||||
except Exception as e:
|
||||
log.error(e, exc_info=True)
|
||||
|
||||
|
@@ -37,3 +37,4 @@ from .user_and_chats import (
|
||||
Chat, ChatMember, ChatMembers, ChatPhoto,
|
||||
Dialog, Dialogs, User, UserStatus, ChatPreview
|
||||
)
|
||||
from .update import StopPropagation
|
||||
|
@@ -22,10 +22,11 @@ from struct import pack
|
||||
import pyrogram
|
||||
from pyrogram.api import types
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ..update import Update
|
||||
from ..user_and_chats import User
|
||||
|
||||
|
||||
class CallbackQuery(PyrogramType):
|
||||
class CallbackQuery(PyrogramType, Update):
|
||||
"""This object represents an incoming callback query from a callback button in an inline keyboard.
|
||||
If the button that originated the query was attached to a message sent by the bot, the field message
|
||||
will be present. If the button was attached to a message sent via the bot (in inline mode),
|
||||
|
@@ -26,11 +26,12 @@ from .location import Location
|
||||
from .message_entity import MessageEntity
|
||||
from ..messages_and_media.photo import Photo
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ..update import Update
|
||||
from ..user_and_chats.chat import Chat
|
||||
from ..user_and_chats.user import User
|
||||
|
||||
|
||||
class Message(PyrogramType):
|
||||
class Message(PyrogramType, Update):
|
||||
"""This object represents a message.
|
||||
|
||||
Args:
|
||||
|
@@ -22,10 +22,11 @@ import pyrogram
|
||||
from pyrogram.api import types
|
||||
from .message import Message
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ..update import Update
|
||||
from ..user_and_chats import Chat
|
||||
|
||||
|
||||
class Messages(PyrogramType):
|
||||
class Messages(PyrogramType, Update):
|
||||
"""This object represents a chat's messages.
|
||||
|
||||
Args:
|
||||
|
26
pyrogram/client/types/update.py
Normal file
26
pyrogram/client/types/update.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class StopPropagation(StopIteration):
|
||||
pass
|
||||
|
||||
|
||||
class Update:
|
||||
def stop_propagation(self):
|
||||
raise StopPropagation
|
@@ -20,9 +20,10 @@ import pyrogram
|
||||
|
||||
from pyrogram.api import types
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ..update import Update
|
||||
|
||||
|
||||
class UserStatus(PyrogramType):
|
||||
class UserStatus(PyrogramType, Update):
|
||||
"""This object represents a User status (Last Seen privacy).
|
||||
|
||||
.. note::
|
||||
|
Reference in New Issue
Block a user