-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotifications.py
More file actions
57 lines (41 loc) · 1.59 KB
/
Copy pathNotifications.py
File metadata and controls
57 lines (41 loc) · 1.59 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import time
import datetime
from datetime import datetime
import multiprocessing as mp
import data_module
import sedo
from handlers import bot
import asyncio
def send_not(FIO, id_tg, id_sedo):
asyncio.run(bot.send_message(chat_id=id_tg, text=sedo.sogl_update(FIO, id_sedo)))
try:
asyncio.run(bot.session.close())
except:
pass
def notific():
while True:
time_now = datetime.now()
time_now = datetime.strftime(time_now, '%H:%M')
print(time_now)
a, b = data_module.notification_search(time_now)
if len(a) > 0:
for item in a:
#Вот сюда вписать инициализацию функции проверки соглов, вывод - готовое сообщение, функция из
#sedo.py
a = item['Worker'].split()[0] + ' ' + item['Worker'].split()[1][0] + '.' + item['Worker'].split()[2][0] + '.'
p = mp.Process(target=send_not, args=(a, item['TG_id'], item['SEDO_id']))
p.start()
if len(b) > 0:
for item in b:
asyncio.run(bot.send_message(chat_id=item['TG_id'], text=item['text']))
asyncio.run(bot.session.close())
# if time_now in time_list_:
# notification = notification1.format(time_now=time_now)
# Bot = bot.send_message(chat_id=260399228, text=notification)
# asyncio.run(Bot)
# asyncio.run(bot.session.close())
# print('HEY')
time.sleep(60)
return
if __name__ == "__main__":
notific()