Skip to content

Commit

Permalink
Added 9 Text convert functions in | Added reddit_search
Browse files Browse the repository at this point in the history
  • Loading branch information
FusionSid committed Mar 10, 2022
1 parent 36bb518 commit 6a4dbff
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

0.0.7 (10/03/2022)
-------------------
- Added 9 Text convert functions in `fusionsid.Text()`
- Added reddit_search

0.0.6 (09/03/2022)
-------------------
Expand Down
3 changes: 2 additions & 1 deletion examples/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ async def main():
fact = await Fun().fact()
print(fact)

# There is more endpoints (eg 8ball) these are just some examples
search = await Fun().reddit_search("discord bots")
print(search)

loop = asyncio.new_event_loop()
loop.run_until_complete(main())
16 changes: 16 additions & 0 deletions examples/text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import asyncio
from fusionsid import Text

async def main():
text_convert = Text()

print(await text_convert.text_to_binary("Hello"))

print(await text_convert.encrypt("lol"))

print(await text_convert.binary_to_text("1101100 1101111 1101100"))

print(await text_convert.expand("6c 6f 6c"))

loop = asyncio.new_event_loop()
loop.run_until_complete(main())
5 changes: 3 additions & 2 deletions fusionsid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fusionsid.image import *
from fusionsid.misc import *
from fusionsid.fun import *
from fusionsid.errors import *
from fusionsid.text import *
from fusionsid.http import *

"""
Expand All @@ -11,7 +12,7 @@
__title__ = "fusionsidapi"
__license__ = "MIT"
__author__ = "FusionSid"
__version__ = "0.0.6"
__version__ = "0.0.7"
__url__ = "https://fusionsidapi.herokuapp.com"
__github__ = "https://github.com/FusionSid/FusionSidAPI.py"
__api_github__ = "https://github.com/FusionSid/FusionSidsAPI"
Expand Down
19 changes: 17 additions & 2 deletions fusionsid/misc.py → fusionsid/fun.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .http import HTTPClient
from typing import Dict
from typing import Dict, List
from .errors import *

class Fun():
Expand All @@ -16,6 +16,8 @@ class Fun():
dare() : Returns a dare
truth_or_dare() : Returns a Dict with a truth, dare and random choice
fact() : Returns a fact
wordle() : Gets the wordle answer for today
reddit_search(keyword : str) : Searches reddit
"""

async def eightball(self) -> str:
Expand Down Expand Up @@ -88,4 +90,17 @@ async def wordle(self) -> str:
>>> print(await Fun().wordle())
"""
data = await HTTPClient().get_json("wordle")
return data["wordle"]
return data["wordle"]

async def reddit_search(self, keyword : str) -> List[Dict]:
"""
Args:
keyword (str) : The search query to search on reddit
Example
-------
>>> print(await Fun().reddit_search(keyword="Meme"))
"""
data = await HTTPClient().get_json(f"""searchreddit?keyword={keyword}""")

return data
170 changes: 170 additions & 0 deletions fusionsid/text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
from .http import HTTPClient
from typing import Dict
from .errors import *


class Text():
"""
A bunch of Text functions
----
Methods
-------
text_to_binary(text : str) : Converts text to binary
text_to_hex(text : str) : Converts text to hex
binary_to_text(binary : str) : Converts binary to text
hex_to_text(hex : str) : Converts hex to text
encrypt(text : str) : Encrypts text (Can not be decrypted)
password(text : str, length : str = None) : Generates a password
expand(text : str) : Expands Text
drunkify(text : str) : Drunkifies Text
reverse(text : str) : Reverses Text
"""

async def text_to_binary(self, text : str) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
Example
-------
>>> print(await Text().text_to_binary(text="Hello"))
"""

data = await HTTPClient().get_json(f"""texttobinary?text={text}""")

return data["binary"]


async def text_to_hex(self, text : str) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
Example
-------
>>> print(await Text().text_to_hex(text="Hello"))
"""
data = await HTTPClient().get_json(f"""texttohex?text={text}""")

return data["hex"]


async def binary_to_text(self, binary : str) -> Dict:
"""
Args:
binary (str) : The binary you want to convert to text
Example
-------
>>> print(await Text().text_to_binary(binary=""))
"""
data = await HTTPClient().get_json(f"""binarytotext?binary_text={binary}""")

return data["text"]


async def hex_to_text(self, hex : str) -> Dict:
"""
Args:
hex (str) : The hex you want to convert to text
Example
-------
>>> print(await Text().hext_to_text(hex=""))
"""
data = await HTTPClient().get_json(f"""hextotext?hex_text={hex}""")

return data["text"]


async def encrypt(self, text : str) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
Example
-------
>>> print(await Text().encrypt(text="Hello"))
"""
data = await HTTPClient().get_json(f"""encrypt?text={text}""")

return data["encrypted"]


async def password(self, text : str, length : int = 8) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
length (int Optional) : The length of the password
Example
-------
>>> print(await Text().password(text="Hello", length=8))
"""
data = await HTTPClient().get_json(f"""password?text={text}?length={length}""")

return data["password"]


async def expand(self, text : str, space : int = 5) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
space (str Optional) : The space between each letter
Example
-------
>>> print(await Text().expand(text="Hello", space=5))
"""
data = await HTTPClient().get_json(f"""expand?text={text}?space={space}""")

return data["text"]


async def reverse(self, text : str) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
Example
-------
>>> print(await Text().reverse(text="Hello"))
"""
data = await HTTPClient().get_json(f"""reverse?text={text}""")

return data["text"]


async def drunkify(self, text : str) -> Dict:
"""
Args
-----
text (str) : The text you want to convert
Example
-------
>>> print(await Text().drunkify(text="Hello"))
"""

data = await HTTPClient().get_json(f"""drunkify?text={text}""")

return data["text"]



3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.0.6'
VERSION = '0.0.7'
DESCRIPTION = "An asynchronous api wrapper for FusionSidsAPI."

setup(
Expand All @@ -21,5 +21,4 @@

# python3 setup.py bdist_wheel
# twine upload dist/*
# twine upload --skip-existing dist/*
# sudo rm -rf ./build ./dist ./*egg-info

0 comments on commit 6a4dbff

Please sign in to comment.