mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add multi-file bot example
This commit adds a multi-file bot example to the repository. .
This commit is contained in:
parent
68c0516f69
commit
77dc4e7752
4 changed files with 70 additions and 0 deletions
30
examples/multi_file_bot/bot.py
Normal file
30
examples/multi_file_bot/bot.py
Normal 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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue