Python
1
Вклад в тег
from aiogram import *
from aiogram.types import *
from aiogram.dispatcher import *
from aiogram.utils.markdown import hlink
from aiogram.dispatcher.filters.state import *
from aiogram.contrib.fsm_storage.memory import *
storage = MemoryStorage()
bot = Bot(token='***************************', parse_mode=ParseMode.HTML)
dp = Dispatcher(bot, storage=MemoryStorage())
class Input(StatesGroup):
waiting_name = State()
@dp.message_handler(lambda message: message.text == "Русский")
async def russian(message: types.Message):
await Input.waiting_name.set()
await bot.send_message(message.from_user.id, f'Пожалуйста, перед заказом пройдите регистрацию:\nВведите имя:')
@dp.message_handler(state=Input.waiting_name)
async def waiting_name(message: types.Message, state: FSMContext):
if message.text == "отмена":
await bot.send_message(message.from_user.id, f'отмена заказа')
await state.finish()
else:
name = message.text
await Input.waiting_name.set()
await bot.send_message(message.from_user.id, f'Ваше имя: {name}')
if __name__ == '__main__':
executor.start_polling(dp)