-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (29 loc) · 898 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import asyncio
import logging
import sys
from aiogram import Bot, Dispatcher
from dotenv import load_dotenv
from core import setup_routers
from core.web import start_web_app
from tools.utils import config
memes = Bot(token=config.token)
load_dotenv()
async def main():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
stream=sys.stdout,
)
worker = Dispatcher()
router = setup_routers()
worker.include_router(router)
useful_updates = worker.resolve_used_update_types()
logging.info("Starting healthz status")
await start_web_app()
logging.info("Starting bot")
await worker.start_polling(memes, allowed_updates=useful_updates)
if __name__ == '__main__':
try:
asyncio.run(main())
except (KeyboardInterrupt, SystemExit):
logging.error("Bot stopped!")