-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
40 lines (30 loc) · 990 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
34
35
36
37
38
39
40
import logging
import sys
from aiogram.utils import executor
import asyncio
from aiogram import executor
from loader import dp, bot
from register_handlers import register_handlers
from utils import api
register_handlers(dp)
async def on_startup(dp):
me = await bot.get_me()
logging.error(f'Running {me.username}')
import courier
import shop
import user
async def shop_notify(wait):
while True:
while True:
notify = await api.get_notifications()
for user_id, (text, keyboard) in notify.items():
try:
await bot.send_message(user_id, text, reply_markup=keyboard)
except Exception as e:
logging.error(e)
if len(notify) == 0:
await asyncio.sleep(wait)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(shop_notify(5*60)) # every 5 min
executor.start_polling(dp, skip_updates=True, on_startup=on_startup)