-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
33 lines (29 loc) · 957 Bytes
/
app.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
print("Modules")
import logging
import asyncio
from utils.db_api.db_file import db
from loader import dp, db
from utils.set_bot_commands import set_default_commands
from middleware.middleware import UserBanned
import data.config as config
from utils.misc.Trx import get_course
from aiogram import executor
async def update_course_pool():
while True:
try:
course = await get_course()
await db.update_course(course)
except Exception as e:
logging.error(f"Failed to update course: {e}")
await asyncio.sleep(config.rate * 60)
async def on_startup(dispatcher):
await set_default_commands(dispatcher)
dp.middleware.setup(UserBanned())
await db.check_start()
asyncio.create_task(update_course_pool())
if __name__ == '__main__':
print("main")
try:
executor.start_polling(dp, on_startup=on_startup)
except Exception as err:
logging.exception(err)