Add chatterbot.py
This commit is contained in:
27
chatterbot/chatterbot.py
Normal file
27
chatterbot/chatterbot.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
try:
|
||||
from chatterbot import ChatBot
|
||||
chatbotInstalled = True
|
||||
except:
|
||||
chatbotInstalled = False
|
||||
|
||||
class Chatterbot:
|
||||
"""Chatter with the bot."""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def chatterbot(self, ctx, message):
|
||||
"""Talk with the bot via ChatterBot."""
|
||||
chatbot = ChatBot('Red-DiscordBot', trainer='chatterbot.trainers.ChatterBotCorpusTrainer')
|
||||
chatbot.train("chatterbot.corpus.english")
|
||||
await self.bot.say(chatbot.get_response(message))
|
||||
|
||||
def setup(bot):
|
||||
if chatbotInstalled is False:
|
||||
raise RuntimeError("Install ChatterBot:\n"
|
||||
"[p]debug bot.pip_install('ChatterBot')\n"
|
||||
"Then [p]load chatterbot")
|
||||
bot.add_cog(Chatterbot(bot))
|
||||
9
chatterbot/info.json
Normal file
9
chatterbot/info.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"AUTHOR" : "aikaterna",
|
||||
"INSTALL_MSG" : "Thanks for installing ChatterBot. This is still in testing.",
|
||||
"NAME" : "Chatterbot",
|
||||
"SHORT" : "Chat with the bot.",
|
||||
"REQUIREMENTS" : ["ChatterBot"],
|
||||
"DESCRIPTION" : "ChatterBot is a machine-learning based conversational dialog engine, check it out at: https://github.com/gunthercox/ChatterBot",
|
||||
"TAGS" : ["chatter", "chat"]
|
||||
}
|
||||
Reference in New Issue
Block a user