From 84754dd54f46b2b2d6ecc9f74e80cf89941ce984 Mon Sep 17 00:00:00 2001 From: Florian Kellermann Date: Tue, 5 Apr 2022 18:23:11 +0200 Subject: [PATCH] Update to bot_updates --- telegram_bot/bot_updates.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/telegram_bot/bot_updates.py b/telegram_bot/bot_updates.py index 5467aad..a709bf7 100644 --- a/telegram_bot/bot_updates.py +++ b/telegram_bot/bot_updates.py @@ -78,28 +78,49 @@ def update_crontab(pCurrent_Time): def update_based_on_crontab(pCurrent_Time): 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 - elif str(current_time_ctime).split(' ')[0] == "Tue": + elif ctime_split[0] == "Tue": current_day = 1 - elif str(current_time_ctime).split(' ')[0] == "Wed": + elif ctime_split[0] == "Wed": current_day = 3 - elif str(current_time_ctime).split(' ')[0] == "Thu": + elif ctime_split[0] == "Thu": current_day = 4 - elif str(current_time_ctime).split(' ')[0] == "Fri": + elif ctime_split[0] == "Fri": current_day = 5 - elif str(current_time_ctime).split(' ')[0] == "Sat": + elif ctime_split[0] == "Sat": current_day = 6 - elif str(current_time_ctime).split(' ')[0] == "Sun": + elif ctime_split[0] == "Sun": current_day = 7 else: print('Error with time code') sys.exit(-1) 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]) + def send_to_user(pText, pUser_id = 1770205310):