feat: Alert via discord if the nb token expires
All checks were successful
Build Docker / Build Image (push) Successful in 31s

This commit is contained in:
2023-12-12 15:10:31 +11:00
parent 96afc29328
commit e60ae30668
3 changed files with 20 additions and 4 deletions

14
main.py
View File

@@ -174,15 +174,23 @@ def update_address():
cookies = {"namebase-main": nbcookie}
headers = {"Accept": "application/json", "Content-Type": "application/json"}
r = requests.post('https://www.namebase.io/api/v0/deposit/address', data=json.dumps(payload), headers=headers, cookies=cookies)
if 'address' not in r.json():
print("Error: " + r.text,flush=True)
# Send alert via discord
webhook = os.getenv('webhook')
if webhook != None:
payload = {
"content": "Error: " + r.text
}
r = requests.post(webhook, data=json.dumps(payload), headers=headers)
return
address = r.json()['address']
print("Address updated: " + address,flush=True)
update_address()
# Schedule address update every hour
schedule.every(1).hour.do(update_address)
if __name__ == '__main__':