Skip to content

Commit 1386886

Browse files
committed
Added seperate Sync & Async Clients
1 parent 6f1dc98 commit 1386886

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

animu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
__version__ = "0.1.0"
1717

1818

19-
from animu.client import Client
19+
from animu.client import Client, AsyncClient

animu/client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
import aiohttp
2+
import requests
3+
24
from animu import model
35

46
class Client:
7+
def __init__(self, token: str):
8+
self._header = {"Auth": token}
9+
self._baseurl = "https://animu.ml/api/"
10+
11+
def _endpoint(self, endpoint: str):
12+
response = requests.get(f"{self._baseurl}{endpoint}", headers=self._header)
13+
result = response.json()
14+
return result
515

16+
def fact(self):
17+
data = self._endpoint('fact')
18+
return model.Fact(data)
19+
20+
def password(self):
21+
data = self._endpoint('password')
22+
return model.Password(data)
23+
24+
def quote(self):
25+
data = self._endpoint('quote')
26+
return model.Quote(data)
27+
28+
def roleplay(self, query: str):
29+
data = self._endpoint(query)
30+
return model.Roleplay(data)
31+
32+
def waifu(self):
33+
data = self._endpoint('waifu')
34+
return model.Waifu(data)
35+
36+
37+
class AsyncClient:
638
def __init__(self, token: str):
739
self._header = {"Auth": token}
840
self._baseurl = "https://animu.ml/api/"

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
aiohttp
1+
aiohttp
2+
requests

0 commit comments

Comments
 (0)