Не работает register_next_step_handler в telebot
bot.register_next_step_handler(send, request_city) пропускается и программа сразу выводит Print ("check"). Не могу понять, тк предыдущая функция примерно такая же и всё исполняет. В чём моя ошибка, кто-нибудь подскажет?
import os
from dotenv import load_dotenv
from requests import request
import telebot
from config_parsing import new_request_command, edit_request_command, CATEGORY
from database import create_db, get_db_value
from exceptions import GET_API_ERROR
from config_parsing import new_request_command, edit_request_command
#from database import create_db
def get_commands(get_api: str):
bot = telebot.TeleBot(get_api)
requests(bot, commands=new_request_command)
def get_telegam_api() -> str:
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
telegram_bot_api = os.getenv("TELEGRAM_BOT_API")
return telegram_bot_api
else:
raise GET_API_ERROR
bot = telebot.TeleBot(get_telegam_api())
def requests(bot, commands):
if commands == new_request_command:
@bot.message_handler(commands=[commands])
def new_request(message):
send = bot.reply_to(message, "1-ый текст")
chat_id = message.chat.id
request_id = create_db(chat_id)
bot.register_next_step_handler(send, request_category, request_id)
elif commands == edit_request_command:
pass
#TODO добавить edit commands
def request_category(message, request_id):
try:
row_request = "request"
request = message.text
get_db_value(row_request,request, request_id)
send = bot.send_message(message.chat.id, """2-ой текст""")
bot.register_next_step_handler(send, request_city) #Эта часть не срабатывает
print("check")
except:
category_error = bot.send_message(message.chat.id, """Что-то пошло не так, попробуйте написать название ещё раз""")
bot.register_next_step_handler(category_error, request_category)
def request_city(message):
print("check2")
bot.send_message(message.chat.id, """3ий текст""")
bot.infinity_polling()
if __name__=="__main__":
get_commands(get_api=get_telegam_api())