From b1c84785defabadb54ae3f3768b36b371dae0786 Mon Sep 17 00:00:00 2001 From: jigsaw Date: Wed, 13 Nov 2024 15:26:08 +0800 Subject: [PATCH] :memo: update callback_query example --- example/inline.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/inline.py b/example/inline.py index 4e022c9..3edc562 100644 --- a/example/inline.py +++ b/example/inline.py @@ -4,6 +4,7 @@ from nonebot import on from nonebot.adapters.telegram import Bot +from nonebot.adapters.telegram.utils import resolve_inline_message_id from nonebot.adapters.telegram.event import InlineQueryEvent, CallbackQueryEvent from nonebot.adapters.telegram.model import ( InlineKeyboardButton, @@ -53,8 +54,7 @@ async def _(bot: Bot, event: InlineQueryEvent): @on("inline").handle() async def _(bot: Bot, event: CallbackQueryEvent): - if event.message: - await bot.edit_message_text( - "Hello CallbackQuery!", event.message.chat.id, event.message.message_id + if event.data == "hello": + await bot.answer_callback_query( + show_alert=True, callback_query_id=event.id, text="Hello CallbackQuery!" ) - await bot.answer_callback_query(event.id, text="Hello CallbackQuery!")