I am coding an Python Telegram Bot with python-telegram-bot. I created a custom inline menu.
I want that the User could press a button and will get an picture. The send_photo
function needs an instance of bot an update.
But I don’t know how to pass that on to the CallBackQuery
handler.
Does anyone have an idea how to solve it?
The send photo function:
def gvu(bot, update):
bot.send_photo(update.message.chat_id, photo=open('botpic/gvu.jpg', 'rb'))
The Handler in Main Routine:
updater.dispatcher.add_handler(CallbackQueryHandler(pattern="1", callback=gvu))
return self.callback(dispatcher.bot, update, **optional_args)
The error:
TypeError: callback_handler() got an unexpected keyword argument ‘chat_data’
2
Answers
Read into documentation here:
https://core.telegram.org/bots/api#inlinequery
https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/inlinekeyboard.py
This works for me:
This will send an image, with text and 2 butttons below the text msg.
Now for the callback query, i did this in main():
Where vote , is a def that runs the code i want for that callback.
hope it makes sense.