-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_tg_bot.py
32 lines (24 loc) · 901 Bytes
/
start_tg_bot.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
import asyncio
from aiogram import executor
from tortoise import Tortoise
import aioschedule
from tg_bot.load_all import bot
async def on_shutdown(dp):
await bot.close()
await dp.storage.close()
await dp.storage.wait_closed()
await Tortoise.close_connections()
# inst_bot.logout()
async def on_startup(dp):
print("!!!!!!!!!!!!!1STARTING!!!!!!!!!!!!!!!!!!")
asyncio.create_task(scheduler())
async def scheduler():
# aioschedule.every(1).minutes.do(delete_old_tasks)
# aioschedule.every(1).minutes.do(delete_old_messages)
# aioschedule.every(1).minutes.do(send_autoposts_by_datetime)
while True:
await aioschedule.run_pending()
await asyncio.sleep(1)
from tg_bot.dialogs.chats.handlers import dp
from tg_bot.dialogs.admin.handlers import dp
executor.start_polling(dp, on_shutdown=on_shutdown, on_startup=on_startup, skip_updates=True)