I’m trying to create a telegram bot with telethon that uses inline buttons and can’t seem to figure out how to edit my messages after a button is pressed. I have something like this to start:
@bot.on(events.NewMessage(pattern='/start'))
async def send_welcome(event):
await bot.send_message(event.from_id, 'What food do you like?', buttons=[
Button.inline('Fruits', 'fruit'),
Button.inline('Meat', 'meat')
])
@bot.on(events.CallbackQuery(data='fruit'))
async def handler(event):
await bot.edit_message(event.from_id, event.id, 'What fruits do you like?', buttons=[
Button.inline('Apple', 'apple'),
Button.inline('Pear', 'pear'),
...
])
After clicking on the Fruits button, nothing happens. Would love some help on this!
2
Answers
Like this u can edit
from the official documentation of telethon
May I suggest a solution.
It implements the exact idea of mr. Snowman’s question. But it might be useful to place conditions inside the handler.