-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.py
More file actions
37 lines (28 loc) · 1.08 KB
/
Copy pathnotification.py
File metadata and controls
37 lines (28 loc) · 1.08 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
import asyncio
import aioschedule
import time
import bot_reply_markup
import common
import config
import randomize
from db import select_actions
from db import dml_actions
async def notify_user(user):
await common.send_message(user.tg_id, "Время дарить подарки!", reply_markup=bot_reply_markup.time_to_gift())
dml_actions.add_notification_log(user.user_id, user.time_zone, user.notification_time, "1")
config.logger.info("Notification sent to " + str(user.tg_id))
async def notify():
user_id_list = select_actions.get_user_id_by_time(time.strftime("%H:%M", time.gmtime()))
for user_id in user_id_list:
user = common.get_user(user_id=user_id)
if user.check() and randomize.send_or_not(user):
await notify_user(user)
else:
dml_actions.add_notification_log(user.user_id, user.notification_time, "0")
async def scheduler(bot):
aioschedule.every().minute.do(notify)
while True:
await aioschedule.run_pending()
await asyncio.sleep(1)
async def run(dp):
asyncio.create_task(scheduler(dp.bot))