Files
stealth-ai-relay/backend/src/bot/__init__.py
2026-01-21 01:20:13 +01:00

43 lines
892 B
Python

import asyncio
import contextlib
from rich import traceback
from utils.logging import logger, setup_logging
setup_logging()
async def runner() -> None:
from . import handlers # noqa: PLC0415
from .common import bot, dp # noqa: PLC0415
from .sync import start_sync_listener # noqa: PLC0415
dp.include_routers(handlers.router)
sync_task = asyncio.create_task(start_sync_listener(bot))
await bot.delete_webhook(drop_pending_updates=True)
try:
await dp.start_polling(bot)
finally:
sync_task.cancel()
with contextlib.suppress(asyncio.CancelledError):
await sync_task
def plugins() -> None:
traceback.install(show_locals=True)
def main() -> None:
plugins()
logger.info("Starting...")
with contextlib.suppress(KeyboardInterrupt):
asyncio.run(runner())
logger.info("[red]Stopped.[/]")