2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Use pack_inline_message_id util function in CallbackQuery

This commit is contained in:
Dan 2022-04-24 11:56:07 +02:00
parent 4e6c1690d2
commit 91e4716872

View File

@ -16,8 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from base64 import b64encode
from struct import pack
from typing import Union, List, Match, Optional from typing import Union, List, Match, Optional
import pyrogram import pyrogram
@ -102,15 +100,7 @@ class CallbackQuery(Object, Update):
if not message: if not message:
message = await client.get_messages(chat_id, message_id) message = await client.get_messages(chat_id, message_id)
elif isinstance(callback_query, raw.types.UpdateInlineBotCallbackQuery): elif isinstance(callback_query, raw.types.UpdateInlineBotCallbackQuery):
inline_message_id = b64encode( inline_message_id = utils.pack_inline_message_id(callback_query.msg_id)
pack(
"<iqq",
callback_query.msg_id.dc_id,
callback_query.msg_id.id,
callback_query.msg_id.access_hash
),
b"-_"
).decode().rstrip("=")
# Try to decode callback query data into string. If that fails, fallback to bytes instead of decoding by # 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. # ignoring/replacing errors, this way, button clicks will still work.