我是 python 新手,我正在尝试编写一个函数,以便在按下按钮时,电报机器人执行某些操作。
我的代码是这样的
def action(msg):
chat_id = msg['chat']['id']
command = msg['text']
keyboard = InlineKeyboardMarkup(inline_keyboard=[
[InlineKeyboardButton(text='Off', callback_data='press')],
])
telegram_bot.sendMessage(chat_id, 'Click to stop looping', reply_markup=keyboard)
if(callback_data='press'):
telegram_bot.sendMessage(chat_id, 'loop end', reply_markup=keyboard)
有没有什么办法可以在单击“关闭”按钮时,机器人会发送消息?