feat(*): init
This commit is contained in:
7
backend/src/bot/handlers/__init__.py
Normal file
7
backend/src/bot/handlers/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from aiogram import Router
|
||||
|
||||
from . import initialize, start
|
||||
|
||||
router = Router()
|
||||
|
||||
router.include_routers(start.router, initialize.router)
|
||||
3
backend/src/bot/handlers/initialize/__init__.py
Normal file
3
backend/src/bot/handlers/initialize/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .initializer import router
|
||||
|
||||
__all__ = ["router"]
|
||||
18
backend/src/bot/handlers/initialize/initializer.py
Normal file
18
backend/src/bot/handlers/initialize/initializer.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from aiogram import Bot, Router, types
|
||||
|
||||
from utils.logging import logger
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.startup()
|
||||
async def startup(bot: Bot) -> None:
|
||||
await bot.set_my_commands(
|
||||
[types.BotCommand(command="/start", description="Start bot")]
|
||||
)
|
||||
logger.info(f"[green]Started as[/] @{(await bot.me()).username}")
|
||||
|
||||
|
||||
@router.shutdown()
|
||||
async def shutdown() -> None:
|
||||
logger.info("Shutting down bot...")
|
||||
3
backend/src/bot/handlers/start/__init__.py
Normal file
3
backend/src/bot/handlers/start/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .start import router
|
||||
|
||||
__all__ = ["router"]
|
||||
9
backend/src/bot/handlers/start/start.py
Normal file
9
backend/src/bot/handlers/start/start.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from aiogram import Router, types
|
||||
from aiogram.filters import CommandStart
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.message(CommandStart())
|
||||
async def on_start(message: types.Message) -> None:
|
||||
await message.answer("hi")
|
||||
Reference in New Issue
Block a user