testing
This commit is contained in:
@ -2,6 +2,7 @@ from requests import get, post
|
||||
from json import loads
|
||||
from os import getenv
|
||||
from collections import namedtuple as nt
|
||||
from munch import DefaultMunch
|
||||
from globals import *
|
||||
|
||||
|
||||
@ -17,13 +18,13 @@ def notify(priority, message):
|
||||
post_endpoint = f"{bots_endpoint}/api/v1/statuses"
|
||||
api_url = 'https://dogapi.dog/api/v2/facts'
|
||||
headers = {
|
||||
"Authorization": f"Bearer {dogfacts_token}"
|
||||
"Authorization": f"Bearer {botsy_token}"
|
||||
}
|
||||
|
||||
response = get(api_url)
|
||||
if response.reason == "OK":
|
||||
dog_fact = loads(response.text, object_hook=lambda d: nt('DogFact', d.keys())(*d.values()))
|
||||
payload = {"status": f"didja know: \n {dog_fact.data[0].attributes.body}\n#RandomDogFacts", "visibility": "public"}
|
||||
dog_fact = DefaultMunch.fromDict(loads(response.text)['data'][0])
|
||||
payload = {"status": f"didja know: \n {dog_fact.attributes.body}\n#RandomDogFacts", "visibility": "mutuals_only"}
|
||||
response = post(post_endpoint, headers=headers, json=payload)
|
||||
if response.reason == "OK":
|
||||
notify(-1, loads(response.text)['uri'])
|
||||
|
@ -14,6 +14,7 @@ dogfacts_token = getenv('BOTS_DOGFACTS_TOKEN')
|
||||
newsfeed_token = getenv('BOTS_NEWSFEED_TOKEN')
|
||||
whitenonsense_token = getenv('WHITENONSENSE_TOKEN')
|
||||
randomquotes_token = getenv('BOTS_QUOTESBOT_TOKEN')
|
||||
botsy_token = getenv('BOTS_BOTSY_TOKEN')
|
||||
|
||||
# Pushover creds
|
||||
po_endpoint = getenv('PUSHOVER_ENDPOINT')
|
||||
|
Reference in New Issue
Block a user