From 27858a3b5993eacd16da6d5004d8c6f23394259f Mon Sep 17 00:00:00 2001 From: Linus E <75929322+Rripped@users.noreply.github.com> Date: Tue, 12 Apr 2022 10:08:41 +0200 Subject: [PATCH] added crontab put function --- telegram_bot/api_handling/api_handler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/telegram_bot/api_handling/api_handler.py b/telegram_bot/api_handling/api_handler.py index 88810ce..bc8bc8a 100644 --- a/telegram_bot/api_handling/api_handler.py +++ b/telegram_bot/api_handling/api_handler.py @@ -263,7 +263,20 @@ class API_Handler: else: return self.get_user_portfolio(user_id, max_retries-1) + def set_cron_interval(self, user_id, cron_interval): + """sets the cron interval of the user + Args: + user_id (int): id of the user + cron_interval (String): Update interval in cron format => see https://crontab.guru/ for formatting + + Returns: + int: status code + """ + 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) + return req.status_code if __name__ == "__main__":