-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (30 loc) · 1.26 KB
/
Copy pathmain.py
File metadata and controls
42 lines (30 loc) · 1.26 KB
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
import asyncio
from loguru import logger
from modules import log
log.setup()
async def main():
from modules import config, db, task_gen, tasks, webhooks
from modules.telegram import games
from modules.telegram.client import aio, client, dp
await db.Users.initialize()
await client.start(bot_token=config.tokens.bot.token)
await task_gen.UpdateShopTask.create(tasks.update_shop, 2)
await task_gen.RewardsTask.create(tasks.rewards, "19:00")
await task_gen.RemoveStatesTask.create(tasks.remove_states, "17:00")
await task_gen.BackupDBTask.create(tasks.backup_db, "1:00")
await games.crocodile_onboot()
logger.info("Бот запущен.")
await webhooks.server()
await dp.start_polling(aio, handle_signals=True)
if __name__ == "__main__":
try:
try:
import uvloop
uvloop.run(main())
except ModuleNotFoundError:
logger.warning("Uvloop не найден. Использую стандартный asyncio.")
asyncio.run(main())
except KeyboardInterrupt:
logger.warning("Получен сигнал прерывания (Ctrl+C). Выход...")
except Exception as e:
logger.critical(f"Необработанное исключение: {e}")