Ответ:
from aiogram import Bot, Dispatcher, executor, types
from aiogram.dispatcher import FSMContext
from aiogram.contrib.fsm_storage.memory import MemoryStorage
API_TOKEN = 'TOKEN'
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message, state: FSMContext):
await message.answer("vvedite svoi vozrast")
await state.set_state('get_age')
@dp.message_handler(state='get_age')
async def say_verdict(message: types.Message, state: FSMContext):
if message.text.isdigit():
if int(message.text) >= 18:
text = 'vi VZROSLIJ'
else:
text = 'vi REBENOK'
text = 'nekorrektnij vvod'
await message.answer(text)
await state.finish()
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
from aiogram import Bot, Dispatcher, executor, types
from aiogram.dispatcher import FSMContext
from aiogram.contrib.fsm_storage.memory import MemoryStorage
API_TOKEN = 'TOKEN'
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message, state: FSMContext):
await message.answer("vvedite svoi vozrast")
await state.set_state('get_age')
@dp.message_handler(state='get_age')
async def say_verdict(message: types.Message, state: FSMContext):
if message.text.isdigit():
if int(message.text) >= 18:
text = 'vi VZROSLIJ'
else:
text = 'vi REBENOK'
else:
text = 'nekorrektnij vvod'
await message.answer(text)
await state.finish()
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)