PyTelegramBotApi NameError: name 'message' is not defined

@bot.callback_query_handler(func=lambda call:True)
def callback_inline(call):
    if call.data == "test":
        bot.send_message(message.chat.id, "hello")

NameError: name 'message' is not defined


Ответы (1 шт):

Автор решения: Andrey Dolgopolov
@bot.callback_query_handler(func=lambda call:True)
def callback_inline(call):
    if call.data == "test":
        bot.send_message(call.message.chat.id, "hello")

callback не знает что такое message, к этому атрибуту надо обратиться через call.message.chat.id

→ Ссылка