New command [!chat]

Now it's possible to chat with the cleverbot
This commit is contained in:
Markus
2016-01-16 18:09:36 +01:00
parent f4fd244554
commit c1d73c3038
2 changed files with 195 additions and 0 deletions

19
red.py
View File

@@ -16,6 +16,7 @@ import aiohttp
import traceback
import re
import youtube_dl
import cleverbot3
import os
import asyncio
import glob
@@ -44,6 +45,7 @@ help = """**Commands list:**
!roll [number] - Random number between 0 and [number]
!gif [text] - GIF search
!urban [text] - Search definitions in the urban dictionary
!chat [text] - Chat with the Cleverbot
!customcommands - Custom commands' list
!addcom [command] [text] - Add a custom command
!editcom [command] [text] - Edit a custom command
@@ -202,6 +204,8 @@ async def on_message(message):
await gif(message)
elif message.content.startswith('!urban'):
await urban(message)
elif message.content.startswith('!chat'):
await chat(message)
elif message.content.startswith('!uptime'):
await uptime(message)
elif message.content.startswith('!avatar'):
@@ -844,6 +848,21 @@ async def urban(message):
else:
await client.send_message(message.channel, "!urban [text]")
async def chat(message):
msg = message.content.split()
if len(msg) > 1:
try:
msg.remove(msg[0])
msg = "+".join(msg)
question = msg
answer = cleverbot_client.ask(question)
if msg != "":
await client.send_message(message.channel, "{}: ".format(message.author.mention) + answer)
except:
await client.send_message(message.channel, "Error.")
else:
await client.send_message(message.channel, "!chat [text]")
async def gif(message):
msg = message.content.split()
if len(msg) > 1: