0
我的解決方案中的用戶通過在電報中鍵入消息一步一步地進行。問題是服務器重啓後他的狀態沒有保存,他需要重新開始。pyTelegramBotAPI。如何在next_step_handler解決方案中保存狀態?
例如,如果'process_mid'上的用戶在重新啓動後執行了一步,他將無法進入'process_end'。用戶只能通過輸入'start'命令才能開始新的階段。
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def process_start(message):
text = 'start'
bot.send_message(message.chat.id, text)
bot.register_next_step_handler(message, process_mid)
def process_mid(message):
text = 'mid'
bot.send_message(message.chat.id, text)
bot.register_next_step_handler(message, process_end)
def process_end(message):
text = 'end'
bot.send_message(message.chat.id, text)
bot.polling(none_stop=True)