From 443eacc8448d00482541f56f6a3fd0ab1c24a353 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 27 Nov 2020 16:58:37 +0100 Subject: [PATCH] print wallet address on low funds --- setup-scripts/bot_utils.py | 8 ++++++++ setup-scripts/funds-checker.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/setup-scripts/bot_utils.py b/setup-scripts/bot_utils.py index 7ca0e726..0f317780 100644 --- a/setup-scripts/bot_utils.py +++ b/setup-scripts/bot_utils.py @@ -161,6 +161,14 @@ class siad: def load_json(resp): return json.loads(resp.decode("utf-8")) + @staticmethod + def get(endpoint): + if not setup_done: + setup() + + resp = urllib.request.urlopen(api_endpoint + endpoint).read() + return siad.load_json(resp) + @staticmethod def get_wallet(): if not setup_done: diff --git a/setup-scripts/funds-checker.py b/setup-scripts/funds-checker.py index 2bd615a0..d7c8fdbc 100755 --- a/setup-scripts/funds-checker.py +++ b/setup-scripts/funds-checker.py @@ -64,7 +64,9 @@ async def check_funds(): # Send an alert if there is less than 1 allowance worth of money left. if balance < allowance_funds: - message = "__Wallet balance running low!__ {}".format(balance_msg) + wallet_address_res = siad.get("/wallet/address") + wallet_msg = "Address: {}".format(wallet_address_res["address"]) + message = "__Wallet balance running low!__ {} {}".format(balance_msg, wallet_msg) return await send_msg(client, message, force_notify=True) # Alert devs when only a fraction of the allowance is remaining.