Допустим вот такой код:
def start(message):
markup = types.InlineKeyboardMarkup()
button1 = types.InlineKeyboardButton(text="Самара", callback_data="Самара")
button2 = types.InlineKeyboardButton(text="Москва", callback_data="Москва")
markup.add(button1, button2)
bot.send_message(chat_id=message.chat.id, text="Хде погоду узнать хош?", reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def longname(call):
if call.data == "Самара":
bot.send_message(chat_id=message.chat.id, text="/Нетакважно/")
Ноо, такое не работает и кидает ошибку:
Код ошибкиTraceback (most recent call last):
File "/usr/lib/python3.7/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "chabyinbot.py", line 38, in longname
bot.send_message(chat_id=message.chat.id, text="/Нетакважно/")
NameError: name 'message' is not defined
"
Traceback (most recent call last):
File "chabyinbot.py", line 41, in
bot.polling()
File "/usr/lib/python3.7/site-packages/telebot/__init__.py", line 389, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "/usr/lib/python3.7/site-packages/telebot/__init__.py", line 413, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/usr/lib/python3.7/site-packages/telebot/util.py", line 108, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
File "/usr/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/usr/lib/python3.7/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "chabyinbot.py", line 38, in longname
bot.send_message(chat_id=message.chat.id, text="/Нетакважно/")
NameError: name 'message' is not defined
Попытки добавить @bot.message_handler над или под @bot.callback_query_handler(func=lambda call: True) - не увенчались успехом