-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (25 loc) · 759 Bytes
/
main.py
File metadata and controls
38 lines (25 loc) · 759 Bytes
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
import asyncio
import tracemalloc
import aioschedule
from aiogram import executor
import handlers
from broadcster import broadcast
from create_bot import dp
async def scheduler():
"""
Планировщик рассылки
"""
aioschedule.every(1).hour.at(':00').do(lambda: asyncio.create_task(broadcast()))
while True:
await aioschedule.run_pending()
await asyncio.sleep(10)
async def on_startup(_):
handlers.setup(dp)
asyncio.create_task(scheduler())
print('bot is online')
await broadcast()
async def on_shutdown(_):
aioschedule.clear()
if __name__ == '__main__':
tracemalloc.start()
executor.start_polling(dp, skip_updates=True, on_startup=on_startup, on_shutdown=on_shutdown)