This commit is contained in:
Kellermann 2022-05-13 12:25:56 +02:00
parent 56bb9908d1
commit 6586ac2bfe

View File

@ -74,15 +74,19 @@ def update_crontab(p_my_handler):
user_ids = []
user_crontab = []
for element in all_users:
if element["cron"] != '' and element["telegram_user_id"] != '': # check if both values are existing so I have consistent data
try:
user_ids.append(int(element["telegram_user_id"]))
if all_users != None:
for element in all_users:
if element["cron"] != '' and element["telegram_user_id"] != '': # check if both values are existing so I have consistent data
try:
user_crontab.append(str(element["cron"]))
except:
user_ids.pop() # if something goes wrong with cron I have to delete matching user id
except: continue
user_ids.append(int(element["telegram_user_id"]))
try:
user_crontab.append(str(element["cron"]))
except:
user_ids.pop() # if something goes wrong with cron I have to delete matching user id
except: continue
else:
print("Error with all users from db. Retrying in update_crontab()")
update_crontab(p_my_handler)
print(user_ids)
@ -136,15 +140,17 @@ def update_for_user(p_user_id, p_my_handler):
share_amounts = []
my_portfolio = p_my_handler.get_user_portfolio(p_user_id) # get all existing shares for user
for element in my_portfolio:
if element["count"] != '' and element["isin"] != '':
print(element["count"], element["isin"])
share_symbols.append(element["isin"])
share_amounts.append(element["count"])
my_portfolio = None
if my_portfolio!=None:
for element in my_portfolio:
if element["count"] != '' and element["isin"] != '':
print(element["count"], element["isin"])
share_symbols.append(element["isin"])
share_amounts.append(element["count"])
my_user = p_my_handler.get_user(p_user_id)
send_to_user("Hello %s this is your share update for today:"%str(my_user["username"]), pUser_id=p_user_id)
send_to_user("Hello %s this is your update for today:"%str(my_user["username"]), pUser_id=p_user_id)
shares = p_my_handler.get_user_shares(p_user_id) # all interest shares