Update to bot_updates

This commit is contained in:
Florian Kellermann 2022-04-05 18:23:11 +02:00
parent aee793deb4
commit 84754dd54f

View File

@ -78,27 +78,48 @@ def update_crontab(pCurrent_Time):
def update_based_on_crontab(pCurrent_Time): def update_based_on_crontab(pCurrent_Time):
current_time_ctime = time.ctime() current_time_ctime = time.ctime()
ctime_split = str(current_time_ctime).split(' ')
if str(current_time_ctime).split(' ')[0] == "Mon": if [0] == "Mon":
current_day = 0 current_day = 0
elif str(current_time_ctime).split(' ')[0] == "Tue": elif ctime_split[0] == "Tue":
current_day = 1 current_day = 1
elif str(current_time_ctime).split(' ')[0] == "Wed": elif ctime_split[0] == "Wed":
current_day = 3 current_day = 3
elif str(current_time_ctime).split(' ')[0] == "Thu": elif ctime_split[0] == "Thu":
current_day = 4 current_day = 4
elif str(current_time_ctime).split(' ')[0] == "Fri": elif ctime_split[0] == "Fri":
current_day = 5 current_day = 5
elif str(current_time_ctime).split(' ')[0] == "Sat": elif ctime_split[0] == "Sat":
current_day = 6 current_day = 6
elif str(current_time_ctime).split(' ')[0] == "Sun": elif ctime_split[0] == "Sun":
current_day = 7 current_day = 7
else: else:
print('Error with time code') print('Error with time code')
sys.exit(-1) sys.exit(-1)
for i in range(len(user_crontab)): for i in range(len(user_crontab)):
print('tbd') day_match = False
hour_match = False
user_crontab[i] = user_crontab.strip()
contrab_split = str(user_crontab[i]).split(' ')
if ',' in contrab_split[4]: # if the user wants to be alerted on multiple specific days
contrab_days = contrab_split[4].split(',')
else:
contrab_days = contrab_days
for element in contrab_days:
if str(current_day) == element or element=='*':
hour_match = True
if hour_match and day_match:
send_to_user("regular update", pUser_id=user_crontab[i])