summaryrefslogtreecommitdiff
path: root/teawie_bot/apis/guzzle.py
blob: 7599606d9ba4d7904c0db70c61b5066b089c6eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import requests

GUZZLE: str = "https://guzzle.gay/api"


def get_random_teawie() -> str:
	resp: requests.Response
	try:
		resp = requests.get(GUZZLE + "/get_random_teawie", timeout=30)
	except (requests.RequestException, requests.ConnectionError,
	        requests.HTTPError, requests.JSONDecodeError):
		return "something went wrong :("
	if not resp.status_code == 200:
		return "api request failed :("

	try:
		ret = resp.json()["url"]
	except KeyError:
		return "couldn't get url from api response :("
	return ret