summaryrefslogtreecommitdiff
path: root/teawie_bot/apis
diff options
context:
space:
mode:
authorseth <[email protected]>2023-02-04 23:12:58 -0500
committerseth <[email protected]>2023-03-14 20:40:13 -0400
commit52e58d2da91d2980823612d6c55e41ed6af0382e (patch)
tree41cedd7715dca1e15e51fbba0351f2d69dd54dd4 /teawie_bot/apis
parentd7c0dd5ac7ce11ca24f4d05c35820182957fa075 (diff)
feat: bit of a refactor
- moved teawie_bot to root directory - added nix flake
Diffstat (limited to 'teawie_bot/apis')
-rw-r--r--teawie_bot/apis/guzzle.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/teawie_bot/apis/guzzle.py b/teawie_bot/apis/guzzle.py
new file mode 100644
index 0000000..7599606
--- /dev/null
+++ b/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