Last active
September 21, 2023 16:17
-
-
Save foozzi/a84ed385616545e68ae75e258f99e46a to your computer and use it in GitHub Desktop.
test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import logging | |
| from aiogram.fsm.state import State, StatesGroup | |
| from aiogram.fsm.context import FSMContext | |
| from aiogram.fsm.storage.memory import SimpleEventIsolation | |
| from aiogram import Bot, Dispatcher, types, F, Router | |
| from aiogram.types import Message | |
| from aiogram.utils.keyboard import InlineKeyboardBuilder | |
| from aiogram.filters.command import Command | |
| logging.basicConfig(level=logging.INFO) | |
| router = Router() | |
| class TestState(StatesGroup): | |
| testone = State() | |
| testtwo = State() | |
| testthree = State() | |
| @router.message(Command('top')) | |
| async def testone(message: Message, state: FSMContext): | |
| await message.answer(text="First thing") | |
| await state.set_state(TestState.testone) | |
| @router.message(TestState.testone) | |
| async def testwww(message: Message, state: FSMContext): | |
| await state.set_state(TestState.testtwo) | |
| await message.reply(text=f"Second thing") | |
| @router.message(TestState.testtwo) | |
| async def testttt(message: Message, state: FSMContext): | |
| await message.answer(text="Finish") | |
| await state.set_state(TestState.testthree) | |
| async def main() -> None: | |
| bot = Bot(token="token") | |
| dp = Dispatcher(events_isolation=SimpleEventIsolation()) | |
| dp.include_router(router) | |
| await bot.delete_webhook(drop_pending_updates=True) | |
| await dp.start_polling(bot) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment