NoneType Fix #196

Merged
FlorianKellermann merged 4 commits from bot into main 2022-05-13 10:33:11 +00:00
Showing only changes of commit 6586ac2bfe - Show all commits

View File

@ -74,15 +74,19 @@ def update_crontab(p_my_handler):
user_ids = [] user_ids = []
user_crontab = [] user_crontab = []
for element in all_users: if all_users != None:
if element["cron"] != '' and element["telegram_user_id"] != '': # check if both values are existing so I have consistent data for element in all_users:
try: if element["cron"] != '' and element["telegram_user_id"] != '': # check if both values are existing so I have consistent data
user_ids.append(int(element["telegram_user_id"]))
try: try:
user_crontab.append(str(element["cron"])) user_ids.append(int(element["telegram_user_id"]))
except: try:
user_ids.pop() # if something goes wrong with cron I have to delete matching user id user_crontab.append(str(element["cron"]))
except: continue 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) print(user_ids)
@ -136,15 +140,17 @@ def update_for_user(p_user_id, p_my_handler):
share_amounts = [] share_amounts = []
my_portfolio = p_my_handler.get_user_portfolio(p_user_id) # get all existing shares for user my_portfolio = p_my_handler.get_user_portfolio(p_user_id) # get all existing shares for user
my_portfolio = None
for element in my_portfolio:
if element["count"] != '' and element["isin"] != '': if my_portfolio!=None:
print(element["count"], element["isin"]) for element in my_portfolio:
share_symbols.append(element["isin"]) if element["count"] != '' and element["isin"] != '':
share_amounts.append(element["count"]) 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) 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 shares = p_my_handler.get_user_shares(p_user_id) # all interest shares