mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Add UpdateBusinessBotCallbackQuery in callback_query handler
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
0387a09079
commit
3232a3f139
2 changed files with 21 additions and 8 deletions
|
|
@ -61,7 +61,8 @@ from pyrogram.raw.types import (
|
|||
UpdateBotChatInviteRequester, UpdateStory,
|
||||
UpdateBotMessageReaction,
|
||||
UpdateBotMessageReactions,
|
||||
UpdateBotShippingQuery
|
||||
UpdateBotShippingQuery,
|
||||
UpdateBusinessBotCallbackQuery
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -74,7 +75,7 @@ class Dispatcher:
|
|||
EDIT_BOT_BUSINESS_MESSAGE_UPDATES = (UpdateBotEditBusinessMessage,)
|
||||
DELETE_MESSAGES_UPDATES = (UpdateDeleteMessages, UpdateDeleteChannelMessages)
|
||||
DELETE_BOT_BUSINESS_MESSAGES_UPDATES = (UpdateBotDeleteBusinessMessage,)
|
||||
CALLBACK_QUERY_UPDATES = (UpdateBotCallbackQuery, UpdateInlineBotCallbackQuery)
|
||||
CALLBACK_QUERY_UPDATES = (UpdateBotCallbackQuery, UpdateInlineBotCallbackQuery, UpdateBusinessBotCallbackQuery)
|
||||
CHAT_MEMBER_UPDATES = (UpdateChatParticipant, UpdateChannelParticipant, UpdateBotStopped,)
|
||||
USER_STATUS_UPDATES = (UpdateUserStatus,)
|
||||
BOT_INLINE_QUERY_UPDATES = (UpdateBotInlineQuery,)
|
||||
|
|
|
|||
|
|
@ -102,13 +102,25 @@ class CallbackQuery(Object, Update):
|
|||
message = await client.get_messages(chat_id, message_id)
|
||||
elif isinstance(callback_query, raw.types.UpdateInlineBotCallbackQuery):
|
||||
inline_message_id = utils.pack_inline_message_id(callback_query.msg_id)
|
||||
|
||||
elif isinstance(callback_query, raw.types.UpdateBusinessBotCallbackQuery):
|
||||
message = await types.Message._parse(
|
||||
client,
|
||||
callback_query.message,
|
||||
users,
|
||||
chats,
|
||||
is_scheduled=False,
|
||||
replies=0,
|
||||
business_connection_id=callback_query.connection_id,
|
||||
raw_reply_to_message=getattr(callback_query, "reply_to_message", None)
|
||||
)
|
||||
# Try to decode callback query data into string. If that fails, fallback to bytes instead of decoding by
|
||||
# ignoring/replacing errors, this way, button clicks will still work.
|
||||
try:
|
||||
data = callback_query.data.decode()
|
||||
except (UnicodeDecodeError, AttributeError):
|
||||
data = callback_query.data
|
||||
data = getattr(callback_query, "data", None)
|
||||
if data:
|
||||
try:
|
||||
data = data.decode()
|
||||
except (UnicodeDecodeError, AttributeError):
|
||||
data = data
|
||||
|
||||
return CallbackQuery(
|
||||
id=str(callback_query.query_id),
|
||||
|
|
@ -117,7 +129,7 @@ class CallbackQuery(Object, Update):
|
|||
inline_message_id=inline_message_id,
|
||||
chat_instance=str(callback_query.chat_instance),
|
||||
data=data,
|
||||
game_short_name=callback_query.game_short_name,
|
||||
game_short_name=getattr(callback_query, "game_short_name", None),
|
||||
client=client
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue