From 5deaf0cc1580e13c48f3dbc7ff4c76d35640fcfc Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 24 Jan 2023 18:28:18 -0500 Subject: feat: moyaiBot -> teawieBot --- src/teawie_bot/apis/guzzle.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/teawie_bot/apis/guzzle.py (limited to 'src/teawie_bot/apis/guzzle.py') diff --git a/src/teawie_bot/apis/guzzle.py b/src/teawie_bot/apis/guzzle.py new file mode 100644 index 0000000..7599606 --- /dev/null +++ b/src/teawie_bot/apis/guzzle.py @@ -0,0 +1,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 -- cgit v1.2.3