def parse_callback_query(client, update, users): message = None inline_message_id = None if isinstance(update, types.UpdateBotCallbackQuery): peer = update.peer if isinstance(peer, types.PeerUser): peer_id = peer.user_id elif isinstance(peer, types.PeerChat): peer_id = -peer.chat_id else: peer_id = int("-100" + str(peer.channel_id)) message = client.get_messages(peer_id, update.msg_id) elif isinstance(update, types.UpdateInlineBotCallbackQuery): inline_message_id = b64encode( pack("<iqq", update.msg_id.dc_id, update.msg_id.id, update.msg_id.access_hash), b"-_").decode().rstrip("=") return pyrogram_types.CallbackQuery( id=str(update.query_id), from_user=parse_user(users[update.user_id]), message=message, inline_message_id=inline_message_id, chat_instance=str(update.chat_instance), data=update.data.decode(), game_short_name=update.game_short_name, client=client)
def parse_inline_callback_query(callback_query, users): return pyrogram_types.CallbackQuery( id=str(callback_query.query_id), from_user=parse_user(users[callback_query.user_id]), chat_instance=str(callback_query.chat_instance), inline_message_id=b64encode( pack("<iqq", callback_query.msg_id.dc_id, callback_query.msg_id.id, callback_query.msg_id.access_hash), b"-_").decode().rstrip("="), game_short_name=callback_query.game_short_name)
def parse_callback_query(client, callback_query, users): peer = callback_query.peer if isinstance(peer, types.PeerUser): peer_id = peer.user_id elif isinstance(peer, types.PeerChat): peer_id = -peer.chat_id else: peer_id = int("-100" + str(peer.channel_id)) return pyrogram_types.CallbackQuery( id=str(callback_query.query_id), from_user=parse_user(users[callback_query.user_id]), message=client.get_messages(peer_id, callback_query.msg_id), chat_instance=str(callback_query.chat_instance), data=callback_query.data.decode(), game_short_name=callback_query.game_short_name)