2020-01-09 02:36:45 +01:00
|
|
|
import requests
|
|
|
|
import random
|
|
|
|
from util import logging
|
|
|
|
|
|
|
|
def fetch_quote() -> tuple:
|
2020-01-09 02:42:35 +01:00
|
|
|
url = "https://favqs.com/api/qotd"
|
2020-01-09 02:36:45 +01: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 02:42:35 +01:00
|
|
|
return (data["quote"]["body"], data["quote"]["author"])
|