plasticuproject / cleverbotfree

Free alternative for the Cleverbot API
GNU General Public License v3.0
58 stars 6 forks source link

Docs? #14

Closed Hunter2809 closed 3 years ago

Hunter2809 commented 3 years ago

Hey!

I want to use your module, and I want some docs to use the bot. Are there any docs or something for it? I want to embed this into a discord bot...

plasticuproject commented 3 years ago

I didn't really feel a need to make any documentation for this, as it's pretty simple, only does a couple things, and most everything is covered in the installation and example in the README.md

The easiest way to add this to a discord bot using discord.py would be something like:

import discord
from discord.ext import commands
from cleverbotfree.cbfree import Cleverbot

bot = commands.Bot(command_prefix='&')
send_cb = Cleverbot().single_exchange

@bot.command()
async def chat(ctx, *args):
    user_input = ' '.join(args)
    response = send_cb(user_input)
    await ctx.send(response)
Hunter2809 commented 3 years ago

Oh ok. Thanks! How to make it run more than once. Like how to make it run till the user doesn't say something like !stop? @plasticuproject

plasticuproject commented 3 years ago

Using the code I posted above, when a user queries the bot it will open up a headless browser on the server running your bot that will stay open. Every time someone queries the bot after that it will send the data to headless browser, and they will get a response from the bot in discord until your bot application is closed.

Hunter2809 commented 3 years ago

So I should just remove that single_exchange thingy? And then, how to close the connection?

plasticuproject commented 3 years ago

No, use the function I posted above, it works. single_exchange works because the discord code is asynchronous. The headless browser will close when you when you exit your discord bot application.

You're delving into implementation territory with your questions now. My examples show basic usage with this module, you'll have to poke around to figure out how to implement it with various frameworks on your own, as it's out of scope of what this module is by itself. This module is just a very basic, limited api to interface the cleverbot website with python.

Here is an example of how I used this module in a discord bot that I created. https://github.com/plasticuproject/clevercord

Hunter2809 commented 3 years ago

Hey @plasticuproject, when I used this, I got a biiig error in my repl.it . Is it something like I can't use it with repl?

plasticuproject commented 3 years ago

Please read the README.md This module requires you to set up firefox, gekodriver, and selenium. You can't run this on some sandbox webapp, it needs to be run from a server or PC.

I'm closing this issue out as there is no underlying issue here.