diff --git a/telegram_bot/bot_updates.py b/telegram_bot/bot_updates.py index b0501c4..6269b5e 100644 --- a/telegram_bot/bot_updates.py +++ b/telegram_bot/bot_updates.py @@ -3,7 +3,7 @@ script for regularly sending updates on shares and news based on user interval """ __author__ = "Florian Kellermann, Linus Eickhoff" __date__ = "05.04.2022" -__version__ = "0.0.1" +__version__ = "1.0.1" __license__ = "None" from calendar import month @@ -14,7 +14,6 @@ import datetime from bot import bot import sys from multiprocessing import Process -from apscheduler.schedulers.blocking import BlockingScheduler from apscheduler.schedulers.background import BackgroundScheduler from api_handling.api_handler import API_Handler @@ -85,9 +84,22 @@ def update_crontab(pCurrent_Time, p_my_handler): def update_based_on_crontab(p_user_ids, p_user_crontab, p_my_handler): - my_scheduler = BackgroundScheduler() + """ Check all the crontab codes and add jobs to start in time + :type p_user_ids: array + :param p_user_ids: user id array of all users + + :type p_user_crontab: array + :param p_user_crontab: crontabs for all users equivalent to the user array + + :type p_my_handler: Api_Handler + :param p_my_handler: get database stuff + + :raises: none + + :rtype: none + """ - print("update based on cron") + my_scheduler = BackgroundScheduler() print(len(user_ids)) #Debug @@ -98,12 +110,22 @@ def update_based_on_crontab(p_user_ids, p_user_crontab, p_my_handler): my_scheduler.start() - print("60 second sleep") - time.sleep( 60 ) + time.sleep( 600 ) my_scheduler.shutdown() def update_for_user(p_user_id, p_my_handler): + """ Pull shares and send updates for specific user id + :type p_user_id: integer + :param p_user_id: user id of user that shall receive update + + :type p_my_handler: Api_Handler + :param p_my_handler: handle the api and pull from database + + :raises: none + + :rtype: none + """ share_symbols = [] share_amounts = [] share_courses = [] @@ -146,7 +168,7 @@ def send_to_user(pText, pUser_id = 1770205310): if __name__ == "__main__": - print('This script shall not be run directly. Starting main_loop for debugging purposes.') + print('bot_updates.py starting.') try: main_loop() sys.exit(-1)