Пример #1
0
async def jk(event):
    api_key = "QlkcYlg38zhQ"
    rs = RandomStuff(api_key=api_key)
    response = rs.get_joke(_type="any")
    if response["setup"]:
        text = response["setup"] + response["delivery"]
    else:
        text = response["joke"]
    await event.reply(text)
Пример #2
0
 def setup(self):
     self.rs = RandomStuff()
Пример #3
0
import discord
import os
import json
import sqlite3
from discord.ext import commands
from prsaw import RandomStuff

client = commands.Bot(command_prefix="!!", case_insensitive=True)
client.remove_command("help")
rs = RandomStuff(async_mode=True)
conn = sqlite3.connect("dbs/main.db")

with open("config.json", "r") as f:
    config = json.load(f)
    f.close()

TOKEN = config['token']
extensions = [
    "commands",
]


@client.event
async def on_ready():
    for extension in extensions:
        client.load_extension(f"cogs.{extension}")

    if os.name == 'nt':
        os.system("cls")
    else:
        os.system('clear')
Пример #4
0
from prsaw import RandomStuff
import os

api_key = f"{os.getenv('api_key')}"
rs = RandomStuff(async_mode=True, api_key=api_key)


async def ai_response(ctx, msg):
    response = await rs.get_ai_response(msg)
    await ctx.send(response)


async def get_a_joke(ctx, joke):
    response = await rs.get_joke(_type="any")
    await ctx.send(response)


async def get_image(ctx, joke, thing=None):
    if joke != None:
        response = await rs.get_image(_type=f"{thing}")
    else:
        print(joke)
        response = await rs.get_image(_type="any")
    await ctx.send(response)
Пример #5
0
def post_message():
    message = request.form['message']
    rs = RandomStuff()
    response = rs.get_ai_response(message)
    return f"""<h1>You >> {message}<br> Spot >>> {response}<br></h1>"""
Пример #6
0
# import the module
from prsaw import RandomStuff

# initiate the object
rs = RandomStuff()

# get a response from an endpoint
response = rs.get_ai_response("How are you?")
print(response)

# close the object once done (recommended)
rs.close()
Пример #7
0
import discord
from discord.ext import commands
from prsaw import RandomStuff
import os
import aiohttp

rs = RandomStuff(api_key=os.environ.get("prsawapi"), async_mode=True)
rs.base_url = "https://api.pgamerx.com/v4"


class ChatBot(commands.Cog):
    def __init__(self, bc):
        self.bc = bc

    @commands.Cog.listener()
    async def on_message(self, msg):
        if msg.author.bot:
            return
        data = await self.bc.chatbot.find(msg.guild.id)
        if data is None:
            return
        if not data["isenabled"]:
            return
        if msg.channel.id == data["channel"]:
            async with aiohttp.ClientSession(
                    headers={"x-api-key": os.environ.get("prsawapi")
                             }) as session:
                async with session.get("https://api.pgamerx.com/v4/ai",
                                       params={
                                           'type': "stable",
                                           'message': msg.content,
Пример #8
0
 def setup(self):
     self.rs = RandomStuff(async_mode=True)
     self.loop = get_event_loop()
     self.run = self.loop.run_until_complete
Пример #9
0
from prsaw import RandomStuff

from ..Config import Config

randomstuff = RandomStuff(async_mode=True, api_key=Config.RANDOM_STUFF_API_KEY)