Answer the question
In order to leave comments, you need to log in
Error AttributeError: 'function' object has no attribute 'chat' how to deal with it?
import telebot
import config
bot = telebot.TeleBot(config.bottoken)
@bot.message_handler(commands=['start'])
def cmd_start(message):
bot.send_message(message.chat.id, "Привет друг! Я помогу тебе понять курс валют и их соотношения с твоей :)\n"
"Введи команду /help и узнай список комманд",
)
@bot.message_handler(commands=['help'])
def cmd_help(message):
bot.send_message(message.chat.id, "Вот мой список комманд: \n"
"/start\n"
"/help\n"
"/exchange\n")
@bot.message_handler(commands=["exchange"])
def handler_m(message):
chat_id = message.chat.id
msg = bot.message_handler(chat_id, "Вы попали в меню обменника")
bot.register_next_step_handler(msg, user_answer)
def user_answer(message):
if message.text == "Обмен валют":
bot.register_next_step_handler(message, f_v_handler)
elif message.text == "Курс валют":
pass
def f_v_handler(message):
msg = bot.message_handler(message.chat.id, "Выберите валюту")
bot.register_next_step_handler(msg, handler_valuee)
def handler_valuee(message):
if message.text == "USD":
bot.send_message(message.chat.id, "Выберите валютную пару: ")
elif message.text == "RUB":
bot.send_message(message.chat.id, "Выберите валютную пару: ")
elif message.text == "UAH":
bot.send_message(message.chat.id, "Выберите валютную пару: ")
else:
bot.send_message(message.chat.id, "Я не понимаю что вы сказали попробуйте ещё раз")
print('I am ready!')
bot.enable_save_next_step_handlers(delay=2)
bot.load_next_step_handlers()
bot.polling(none_stop=True)
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