This commit is contained in:
2025-06-08 14:22:24 -05:00
parent 2db85fb6c0
commit 7d930b7096
2 changed files with 5 additions and 3 deletions

View File

@ -2,6 +2,7 @@ from requests import get, post
from json import loads from json import loads
from os import getenv from os import getenv
from collections import namedtuple as nt from collections import namedtuple as nt
from munch import DefaultMunch
from globals import * from globals import *
@ -17,13 +18,13 @@ def notify(priority, message):
post_endpoint = f"{bots_endpoint}/api/v1/statuses" post_endpoint = f"{bots_endpoint}/api/v1/statuses"
api_url = 'https://dogapi.dog/api/v2/facts' api_url = 'https://dogapi.dog/api/v2/facts'
headers = { headers = {
"Authorization": f"Bearer {dogfacts_token}" "Authorization": f"Bearer {botsy_token}"
} }
response = get(api_url) response = get(api_url)
if response.reason == "OK": if response.reason == "OK":
dog_fact = loads(response.text, object_hook=lambda d: nt('DogFact', d.keys())(*d.values())) dog_fact = DefaultMunch.fromDict(loads(response.text)['data'][0])
payload = {"status": f"didja know: \n {dog_fact.data[0].attributes.body}\n#RandomDogFacts", "visibility": "public"} payload = {"status": f"didja know: \n {dog_fact.attributes.body}\n#RandomDogFacts", "visibility": "mutuals_only"}
response = post(post_endpoint, headers=headers, json=payload) response = post(post_endpoint, headers=headers, json=payload)
if response.reason == "OK": if response.reason == "OK":
notify(-1, loads(response.text)['uri']) notify(-1, loads(response.text)['uri'])

View File

@ -14,6 +14,7 @@ dogfacts_token = getenv('BOTS_DOGFACTS_TOKEN')
newsfeed_token = getenv('BOTS_NEWSFEED_TOKEN') newsfeed_token = getenv('BOTS_NEWSFEED_TOKEN')
whitenonsense_token = getenv('WHITENONSENSE_TOKEN') whitenonsense_token = getenv('WHITENONSENSE_TOKEN')
randomquotes_token = getenv('BOTS_QUOTESBOT_TOKEN') randomquotes_token = getenv('BOTS_QUOTESBOT_TOKEN')
botsy_token = getenv('BOTS_BOTSY_TOKEN')
# Pushover creds # Pushover creds
po_endpoint = getenv('PUSHOVER_ENDPOINT') po_endpoint = getenv('PUSHOVER_ENDPOINT')