Answer the question
In order to leave comments, you need to log in
Error in telegram bot API, error with keyboard, NameError: name 'types' is not defined?
Here is the code
@bot.message_handler(commands = ['choice'])
def inline(message):
key = types.InlineKeyboardMarkup()
but_1 = types.InlineKeyboardButton(text="Alfredo", callback_data="Alfredo")
but_2 = types. InlineKeyboardButton(text="Celentano", callback_data="Celentano")
key.add(but_1, but_2)
bot.send_message(message.chat.id, "Who is your idol?", reply_markup=key)
@bot.callback_query_handler(func =lambda c:True)
def inlin(c):
if c.data == 'Alfredo':
bot.send_message(c.message.chat.id, 'Yes')
if c.data == 'Celentano':
bot. send_message(c.message.chat.id, 'None')
throws an error:
NameError: name 'types' is not defined
Help with solving the problem
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question