Skip to content

Instantly share code, notes, and snippets.

@foozzi
Last active September 21, 2023 16:17
Show Gist options
  • Select an option

  • Save foozzi/a84ed385616545e68ae75e258f99e46a to your computer and use it in GitHub Desktop.

Select an option

Save foozzi/a84ed385616545e68ae75e258f99e46a to your computer and use it in GitHub Desktop.
test.py
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