2020-01-09 01:36:45 +00:00
|
|
|
import requests
|
|
|
|
import random
|
|
|
|
from util import logging
|
|
|
|
|
|
|
|
def fetch_quote() -> tuple:
|
2020-01-09 01:42:35 +00:00
|
|
|
url = "https://favqs.com/api/qotd"
|
2020-01-09 01:36:45 +00:00
|
|
|
response = requests.get(url)
|
|
|
|
|
|
|
|
if not response.ok:
|
|
|
|
logging.error(f"Failed to access Quotes API: {response.status_code} [{url}]")
|
|
|
|
return ()
|
|
|
|
|
|
|
|
data = response.json()
|
2020-01-09 01:42:35 +00:00
|
|
|
return (data["quote"]["body"], data["quote"]["author"])
|