1

I am new to python and I am trying to code a function such that upon a button press, the telegram bot perform something.

My code goes something like this

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)
            

Is there any way such that when the button 'Off' is clicked, the bot will send a message?

LatteCat
  • 31
  • 4

0 Answers0