-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (39 loc) · 1.54 KB
/
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
38
39
40
41
42
43
44
45
46
import asyncio
import logging
from data.config import config
from data.loader import scheduler, bot, dp, setup_db
from handlers.admin import admin_router
from handlers.advert import advert_router
from handlers.get_music import music_router
from handlers.get_video import video_router
from handlers.lang import lang_router
from handlers.stats import stats_router
from handlers.user import user_router
from misc.stats import update_overall_stats, update_daily_stats
from misc.utils import backup_dp
if config["logs"]["stats_chat"] != "0":
# Split message mode - run both immediately
scheduler.add_job(update_overall_stats, misfire_grace_time=None)
scheduler.add_job(update_daily_stats, misfire_grace_time=None)
# Schedule separate updates
scheduler.add_job(update_overall_stats, "interval", hours=1, id='stats_overall', misfire_grace_time=None)
scheduler.add_job(update_daily_stats, "interval", minutes=5, id='stats_daily', misfire_grace_time=None)
# Schedule daily backup at midnight
scheduler.add_job(backup_dp, "cron", args=[config["logs"]["backup_logs"]], hour=0, misfire_grace_time=None)
async def main() -> None:
await setup_db()
scheduler.start()
dp.include_routers(
user_router,
lang_router,
admin_router,
advert_router,
stats_router,
video_router,
music_router
)
bot_info = await bot.get_me()
logging.info(f'{bot_info.full_name} [@{bot_info.username}, id:{bot_info.id}]')
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())