Код: Выделить всё
bot = AsyncTeleBot(token, state_storage=StateMemoryStorage())
@bot.message_handler(commands=['start'])
async def startup(message: Message):
text = 'Hi! Lets start!'
await bot.send_message(message.chat.id, text, reply_markup=main_keyboard())
@bot.message_handler(regexp='Mark')
async def marks_main(message):
text = 'Choose option:'
await bot.send_message(message.chat.id, text, reply_markup=qa_main_keyboard())
@bot.message_handler(regexp='Add mark')
async def marks_action_handler(message):
text = 'Type your mark'
state = bot.current_states
await bot.send_message(message.chat.id, text)
await state.set_state(user_id=message.from_user.id, state=QaState.add_mark,
chat_id=message.chat.id)
@bot.message_handler(state=QaState.add_mark)
async def add_mark_func(message):
await QaDAO.add({'mark': message.text})
text = 'Mark added!'
await bot.send_message(message.chat.id, text, reply_markup=qa_main_keyboard())
Код: Выделить всё
from telebot.asyncio_handler_backends import StatesGroup, State
class QaState(StatesGroup):
add_mark = State()
all_marks = State()
Подробнее здесь: https://stackoverflow.com/questions/787 ... th-a-state