Skip to content

Commit

Permalink
big changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iDutchy committed Oct 13, 2020
1 parent eea1560 commit 69c25ad
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 22 additions & 3 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---
Expand Down Expand Up @@ -171,31 +184,37 @@ 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.\
**- comment** *(string)*: The content of the 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"`

Expand Down
19 changes: 16 additions & 3 deletions sr_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit 69c25ad

Please sign in to comment.