Bot into main #71

Merged
NormalParameter merged 55 commits from bot into main 2022-04-25 15:02:35 +00:00
Showing only changes of commit cac5883b99 - Show all commits

View File

@ -3,7 +3,7 @@ script for regularly sending updates on shares and news based on user interval
""" """
__author__ = "Florian Kellermann, Linus Eickhoff" __author__ = "Florian Kellermann, Linus Eickhoff"
__date__ = "05.04.2022" __date__ = "05.04.2022"
__version__ = "0.0.1" __version__ = "1.0.1"
__license__ = "None" __license__ = "None"
from calendar import month from calendar import month
@ -14,7 +14,6 @@ import datetime
from bot import bot from bot import bot
import sys import sys
from multiprocessing import Process from multiprocessing import Process
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
from api_handling.api_handler import API_Handler 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): 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 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() my_scheduler.start()
print("60 second sleep") time.sleep( 600 )
time.sleep( 60 )
my_scheduler.shutdown() my_scheduler.shutdown()
def update_for_user(p_user_id, p_my_handler): 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_symbols = []
share_amounts = [] share_amounts = []
share_courses = [] share_courses = []
@ -146,7 +168,7 @@ def send_to_user(pText, pUser_id = 1770205310):
if __name__ == "__main__": if __name__ == "__main__":
print('This script shall not be run directly. Starting main_loop for debugging purposes.') print('bot_updates.py starting.')
try: try:
main_loop() main_loop()
sys.exit(-1) sys.exit(-1)