Skip to main content

A simple wrapper for the Random Stuff API

Project description

Maintenance Maintaner Open Source? Yes!

forthebadge made-with-python

RSAP.... well it is not a proper acronym, but you can think of it as Random Stuff API Python.. It makes use of PGamerX's Random Stuff API to provide you features such as jokes, memes, images and also an AI CHATBOT!!

The installation is also very very very simple.

pip install rsap

This will install rsap with only requests module.. You need to install aioHTTP for AsyncRSAP and discord.py for DisRSAP



The module uses the logging module of python to print logs to console. Add logging.basicConfig(level=logging.NOTSET) to the top of your code and all the the logs would get printed to the console



The usage is very very very simple.. There are mainly two classes of this module (well there are three but I would consider two because third, you can't say that it is a proper "class" of the module.)



ASYNC USAGE

To use this module asynchronously, RSAP provides you with the AsyncRSAP class of the module... It uses the aioHTTP module to send GET request to the API... A small example for the same is shown below


from rsap import AsyncRSAP
import asyncio

bot = AsyncRSAP("api_key_here", "other_kwargs_here")

# For AI Response
response = asyncio.run(bot.ai_response("message_here", "unique_id"))
print(response)

# For Jokes
response = asyncio.run(bot.jokes("type"))
print(response)

# For Images
response = asyncio.run(bot.image("type"))
print(response)

The code above would use the aioHTTP module..



SYNC USAGE

To use this module synchronously, RSAP provides you with the RSAP class of the module... It uses the requests module to send the GET request to the API... A small example for the same is shown below

from rsap import RSAP

bot = RSAP("api_key_here", "other_kwargs_here")

# For AI Response
response = bot.ai_response("message", "unique_id") 
print(response)

# For Jokes
response = bot.joke("type")
print(response)

# For Images
response = bot.image("type")
print(response)

# For Closing
bot.close()

The code above would use the requests module..



So last of all that, we have that other so-called "class" known as DisRSAP class.. It is just an extension of the RSAP module, which uses the discord.py's commands.Bot module to send the bot responses in a particular Text Channel. It uses the on_message trigger to check for messages in the chat channel.. The example for the same is shown below

from rsap import DisRSAP
bot = DisRSAP("api_key_here", text_channel_id_here, command_prefix="!", "other_kwargs_here") #Don't specify any intents because "discord.Intents.all()" is already enabled in the source code.

bot.run("bot_token_here")

So the above code would simply run your bot and the bot would reply to every single message sent in that channel!!


So lemme guess, you are now thinking what are even those `kwargs` mentioned above 😁

So here is a list of kwargs that you can add to your code!!!

👉 api_key (str): The API key which you can get from https://api-info.pgamerx.com/register

👉 dev_name (str, optional): The name of the developer who coded the chatbot. Used in responses. Defaults to Hunter.

👉 unique_id (str, optional): The Unique ID to create custom sessions for each user. Defaults to a random uuid.uuid4 string.

👉 bot_name (str, optional): The name of the chatbot. Used in responses. Defaults to PyChat.

👉 type (str, optional): The type of API to use. Stable is recommended but can also be unstable. Defaults to "stable".

👉 language (str, optional): The language to chat with the chatbot in. Defaults to "en".

👉 plan (str, optional): The plan, if any, that you have subscribed to. Defaults to None

List of Types of Jokes

😆 any

😆 dev

😆 spooky

😆 pun

List of Types of Images

📸 aww

📸 duck

📸 dog

📸 cat

📸 memes

📸 dankmemes

📸 holup

📸 art

📸 harrypottermemes

📸 facepalm

List of Plans

📝 pro

📝 ultra

📝 biz

📝 mega

CONTACT ME

Need some help for some things?? Join this discord (is of a friend), and you can always find me here or add me on discord нυηтєя#8785 :D

Also, if you want to buy the pro plans of the API, be sure to check this out!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rsap-2.4.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rsap-2.4.2-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file rsap-2.4.2.tar.gz.

File metadata

  • Download URL: rsap-2.4.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.2

File hashes

Hashes for rsap-2.4.2.tar.gz
Algorithm Hash digest
SHA256 ddf29fa5a03626cf1cd6d705b84070954c07416bc5d0fa5ea529d6a0f99657a3
MD5 825f8948549c213af87343afa3327559
BLAKE2b-256 10f4e5e9f51a1ddbd696ba516afe7e884b84443659b769ffe8ba59a88731aaca

See more details on using hashes here.

File details

Details for the file rsap-2.4.2-py3-none-any.whl.

File metadata

  • Download URL: rsap-2.4.2-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.2

File hashes

Hashes for rsap-2.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7c353a6edead2f8cacf5ab0e52a1fda16c82a4c72da3b8e2dea86c9c0f19a3
MD5 1d8b359b1c5ff3abc828e7a3c2e3bf0e
BLAKE2b-256 53f2adeba0aaf6342d7617b4ab75f364607f344c906097dcea5e88acdd5a8b0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page