some small changes, just code style and removing unneccesary stuff
This commit is contained in:
parent
97bb1285cf
commit
1697928545
@ -1,37 +0,0 @@
|
|||||||
"""
|
|
||||||
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"
|
|
||||||
__license__ = "None"
|
|
||||||
|
|
||||||
import shares.share_fetcher as share_fetcher
|
|
||||||
import news.news_fetcher as news_fetcher
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import sys
|
|
||||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
||||||
|
|
||||||
'''
|
|
||||||
* * * * * code
|
|
||||||
┬ ┬ ┬ ┬ ┬
|
|
||||||
│ │ │ │ │
|
|
||||||
│ │ │ │ └──── weekday (0->Monday, 7->Sunday)
|
|
||||||
│ │ │ └────── Month (1-12)
|
|
||||||
│ │ └──────── Day (1-31)
|
|
||||||
│ └────────── Hour (0-23)
|
|
||||||
└──────────── Minute (0-59)
|
|
||||||
|
|
||||||
example 0 8 * * * -> daily update at 8am
|
|
||||||
'''
|
|
||||||
|
|
||||||
def user_updates():
|
|
||||||
"""sends timed updates automatically to user
|
|
||||||
|
|
||||||
Args:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
"""
|
|
||||||
return
|
|
@ -39,7 +39,7 @@ user_crontab = []
|
|||||||
|
|
||||||
load_dotenv(dotenv_path='.env')
|
load_dotenv(dotenv_path='.env')
|
||||||
|
|
||||||
def main_loop(): #loop? this is not a loop it is executed once (rename?)
|
def start_updater():
|
||||||
""" main loop for regularly sending updates
|
""" main loop for regularly sending updates
|
||||||
:raises: none
|
:raises: none
|
||||||
|
|
||||||
@ -49,10 +49,6 @@ def main_loop(): #loop? this is not a loop it is executed once (rename?)
|
|||||||
current_time_datetime = datetime.datetime.now()
|
current_time_datetime = datetime.datetime.now()
|
||||||
my_handler = API_Handler("https://gruppe1.testsites.info/api", str(os.getenv("BOT_EMAIL")), str(os.getenv("BOT_PASSWORD")))
|
my_handler = API_Handler("https://gruppe1.testsites.info/api", str(os.getenv("BOT_EMAIL")), str(os.getenv("BOT_PASSWORD")))
|
||||||
|
|
||||||
|
|
||||||
# update_for_user(5270256395, my_handler) # Debug (running test update for kevins shares)
|
|
||||||
|
|
||||||
|
|
||||||
update_crontab(current_time_datetime, my_handler)
|
update_crontab(current_time_datetime, my_handler)
|
||||||
|
|
||||||
|
|
||||||
@ -69,8 +65,6 @@ def update_crontab(pCurrent_Time, p_my_handler):
|
|||||||
global user_crontab
|
global user_crontab
|
||||||
global user_ids
|
global user_ids
|
||||||
|
|
||||||
#p_my_handler.set_cron_interval(user_id = 1770205310, cron_interval = "23 08 * * *")
|
|
||||||
|
|
||||||
all_users = p_my_handler.get_all_users()
|
all_users = p_my_handler.get_all_users()
|
||||||
|
|
||||||
user_ids = []
|
user_ids = []
|
||||||
@ -166,7 +160,7 @@ def update_for_user(p_user_id, p_my_handler):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def send_to_user(pText, pUser_id = 1770205310, md_mode = False):
|
def send_to_user(pText, pUser_id , md_mode = False):
|
||||||
|
|
||||||
""" Send message to user
|
""" Send message to user
|
||||||
:type pText: string
|
:type pText: string
|
||||||
@ -193,7 +187,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
print('bot_updates.py starting.')
|
print('bot_updates.py starting.')
|
||||||
try:
|
try:
|
||||||
main_loop()
|
start_updater()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Ending")
|
print("Ending")
|
||||||
|
Loading…
Reference in New Issue
Block a user