bot new commands and funcs + api updates

This commit is contained in:
Linus E
2022-04-17 12:20:53 +02:00
parent 543c51397e
commit b06b024326
3 changed files with 55 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ __license__ = "None"
import sys
import os
import requests as r
from croniter import croniter
@@ -32,7 +33,6 @@ class API_Handler:
delete_share(user_id, symbol): deletes the share of the user
get_user_transactions(user_id): gets the transactions of the user
set_transaction(user_id, transaction): sets the transaction of the user
delete_transaction(user_id, transaction): deletes the transaction of the user
get_user_portfolio(user_id): gets the portfolio of the user
set_portfolio(user_id, portfolio): sets the portfolio of the user
delete_portfolio(user_id, portfolio): deletes the portfolio of the user
@@ -322,6 +322,10 @@ class API_Handler:
Returns:
int: status code
"""
if not croniter.is_valid(cron_interval):
print("Error: Invalid cron format")
return -1
with r.Session() as s:
headers = {'Authorization': 'Bearer ' + self.token + ":" + str(user_id)}
req = s.put(self.db_adress + "/user/setCron", json={"cron": cron_interval}, headers=headers)