Add multi-file bot example

This commit adds a multi-file bot example to the repository. .
This commit is contained in:
latan 2023-08-10 09:31:13 +03:00
parent 68c0516f69
commit 77dc4e7752
4 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.enums import ParseMode
from examples.multi_file_bot import handlers
# Bot token can be obtained via https://t.me/BotFather
TOKEN = "42:TOKEN"
async def main() -> None:
# Dispatcher is a root router
dp = Dispatcher()
# Register all the routers from handlers package (make sure they are imported into handlers/__init__.py)
dp.include_routers(
handlers.start.start_router,
handlers.echo.echo_router,
)
# Initialize Bot instance with a default parse mode which will be passed to all API calls
bot = Bot(TOKEN, parse_mode=ParseMode.HTML)
# And the run events dispatching
await dp.start_polling(bot)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())