diff --git a/CHANGELOG.md b/CHANGELOG.md index 49e8e85..1f21516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ -### v1.0.7 - Oktober 14, 2020 +### v1.1.0 - Oktober 14, 2020 * Fixed client token error +* Added amongus endpoint +* Client.view_color is no longer a coroutine +* Client.youtube_comment is no longer a coroutine +* Client.filter is no longer a coroutine ### v1.0.6 - September 6, 2020 * `Client.filter()` now returns an `Image` object diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 336674a..b1956af 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -33,6 +33,19 @@ For future reference in this documentation: when referring to 'client' we refer ## Using the wrapper: All available endpoints you can use. + +### client.amongus(username, avatar) +--- +**Premium Endpoint** +Get a gif from voting someone away as the impostor + +**WARNING:** The Image.url returned by this function will very likely not embed! You will have to use Image.read to get the bytes object and work from there! DO NOT SHARE THE URL EITHER SINCE IT CONTAINS YOUR PREMIUM KEY + +**Parameters:**\ +**- username** *(string)*: The name of the impostor +**- avatar** *(string)*: The avatar url of the impostor + +**Return type:** [Image](https://github.com/iDutchy/sr_api/blob/master/DOCUMENTATION.md#image "Image object attributes") *(object)* ### *await* client.get_image(animal) --- @@ -171,20 +184,24 @@ Get the definition from a word. **Return type:** [Definition](https://github.com/iDutchy/sr_api/blob/master/DOCUMENTATION.md#definition "Definition object attributes") *(object)* -### *await* client.filter(option, url) +### client.filter(option, url) --- **Available options:** `gay`, `wasted`, `greyscale`, `invert`, `triggered`, `blur`, `blurple`, `glass`, `pixelate`, `sepia`, `invertgreyscale`, `brightness`, `threshold`, `red`, `green`, `blue`, `spin` +**WARNING:** The Image.url returned by this function will very likely not embed! You will have to use Image.read to get the bytes object and work from there! + **Parameters:**\ **- option** *(string)*: The type of image manipulation you want to use.\ **- url** *(string)*: The url from the image you want to manipulate. **Return type:** [Image](https://github.com/iDutchy/sr_api/blob/master/DOCUMENTATION.md#image "Image object attributes") *(object)* -### *await* client.youtube_comment(avatar, username, comment) +### client.youtube_comment(avatar, username, comment) --- Generate a fake youtube comment. +**WARNING:** The Image.url returned by this function will very likely not embed! You will have to use Image.read to get the bytes object and work from there! + **Parameters:**\ **- avatar** *(string)*: The avatar you want to use.\ **- username** *(string)*: The username for the comment.\ @@ -192,10 +209,12 @@ Generate a fake youtube comment. **Return type:** [Image](https://github.com/iDutchy/sr_api/blob/master/DOCUMENTATION.md#image "Image object attributes") *(object)* -### *await* client.view_color(color) +### client.view_color(color) --- View a color. +**WARNING:** The Image.url returned by this function will very likely not embed! You will have to use Image.read to get the bytes object and work from there! + **Parameters:**\ **- color** *(string)*: The color you want an image of. Example: `"123456"` diff --git a/sr_api/client.py b/sr_api/client.py index 3aa77eb..c49203b 100644 --- a/sr_api/client.py +++ b/sr_api/client.py @@ -13,6 +13,12 @@ class InputError(Exception): __slots__ = () pass +class PremiumOnly(Exception): + __slots__ = () + pass + +https://some-random-api.ml/premium/amongus + class Client: __slots__ = ("_http_client", "key") @@ -27,6 +33,13 @@ def __init__(self, key=None): def srapi_url(self, path): return self.SR_API_BASE + path + (("&key=" + self.key) if self.key else "") + def amongus(self, username, avatar): + if self.key is None: + raise PremiumOnly("This endpoint can only be used by premium users.") + + url = self.srapi_url("premium/amongus?username=" + username + "&avatar=" + avatar) + return Image(self._http_client, url) + async def get_image(self, name=None): options = ("dog", "cat", "panda", "red_panda", "fox", "birb", "koala", "kangaroo", "racoon", "whale", "pikachu") @@ -145,7 +158,7 @@ async def get_joke(self): res = response.get("joke") return res - async def filter(self, option, url): + def filter(self, option, url): options = ( 'greyscale', 'invert', 'invertgreyscale', 'brightness', 'threshold', 'sepia', 'red', 'green', 'blue', 'blurple', 'pixelate', 'blur', 'gay', 'glass', 'wasted', 'triggered', 'spin') @@ -156,11 +169,11 @@ async def filter(self, option, url): end_url = self.srapi_url("canvas/" + str(option).lower() + "?avatar=" + url) return Image(self._http_client, end_url) - async def youtube_comment(self, avatar, username, comment): + def youtube_comment(self, avatar, username, comment): url = self.srapi_url("canvas/youtube-comment" + "?avatar=" + avatar + "&username=" + username + "&comment=" + comment.replace(" ", "+")) return Image(self._http_client, url) - async def view_color(self, color): + def view_color(self, color): color = color.replace("#", '') url = self.srapi_url("canvas/colorviewer" + "?hex=" + color) return Image(self._http_client, url)