I
I
Ivan2020-07-05 16:54:21
Python
Ivan, 2020-07-05 16:54:21

How to fix a bug with callback inline keyboard?

The code:

if message.text == 'startgame':
        kb = types.InlineKeyboardMarkup()
        b = types.InlineKeyboardButton(text='Initialization', callback_data='initialization')
        kb.add(b)
        bot.send_message(message.chat.id, 'hi', reply_markup=kb)

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    if call.data == 'initialization':
        k = telebot.types.ReplyKeyboardMarkup(True, True)
        k.row('Connect')
        bot.edit_message_text(chat_id=call.message.chat.id, text='Initialization 0% (##########)', message_id=call.message.message_id)
        bot.edit_message_text(chat_id=call.message.chat.id, text='Initialization 25% (//########)', message_id=call.message.message_id)
        bot.edit_message_text(chat_id=call.message.chat.id, text='Initialization 60% (//////####)', message_id=call.message.message_id)
        edituser(message.from_user.id, maine='start')
        bot.edit_message_text(chat_id=call.message.chat.id, text='Initialization 100% (//////////)', message_id=call.message.message_id, reply_markup=k)

Mistake:
File "<string>", line 199, in send_message
NameError: name 'types' is not defined


How to fix it all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-05
@mlneko

Import types
from telebot import types

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question