pull/5/head
bobloy 7 years ago
parent 2cd594c36a
commit fd0e383b03

@ -4,7 +4,7 @@ from typing import List, Union
import discord import discord
from discord.ext import commands from discord.ext import commands
from redbot.core import Config from redbot.core import Config, RedContext
from redbot.core.bot import Red from redbot.core.bot import Red
from .source import ChatBot from .source import ChatBot
@ -12,6 +12,7 @@ from .source.trainers import ListTrainer
from datetime import datetime,timedelta from datetime import datetime,timedelta
class Chatter: class Chatter:
""" """
This cog trains a chatbot that will talk like members of your Guild This cog trains a chatbot that will talk like members of your Guild
@ -74,14 +75,14 @@ class Chatter:
return True return True
@commands.group() @commands.group()
async def chatter(self, ctx: commands.Context): async def chatter(self, ctx: RedContext):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help() await ctx.send_help()
@chatter.command() @chatter.command()
async def age(self, ctx: commands.Context, days: int): async def age(self, ctx: RedContext, days: int):
""" """
Sets the number of days to look back Sets the number of days to look back
Will train on 1 day otherwise Will train on 1 day otherwise
@ -91,7 +92,7 @@ class Chatter:
await ctx.send("Success") await ctx.send("Success")
@chatter.command() @chatter.command()
async def train(self, ctx: commands.Context, channel: discord.TextChannel = None): async def train(self, ctx: RedContext, channel: discord.TextChannel = None):
""" """
Trains the bot based on language in this guild Trains the bot based on language in this guild
""" """
@ -118,7 +119,7 @@ class Chatter:
else: else:
await ctx.send("Error occurred :(") await ctx.send("Error occurred :(")
async def on_message(self, message): async def on_message(self, message: discord.Message):
""" """
Credit to https://github.com/Twentysix26/26-Cogs/blob/master/cleverbot/cleverbot.py Credit to https://github.com/Twentysix26/26-Cogs/blob/master/cleverbot/cleverbot.py
for on_message recognition of @bot for on_message recognition of @bot
@ -126,6 +127,7 @@ class Chatter:
author = message.author author = message.author
channel = message.channel channel = message.channel
if message.author.id != self.bot.user.id: if message.author.id != self.bot.user.id:
to_strip = "@" + author.guild.me.display_name + " " to_strip = "@" + author.guild.me.display_name + " "
text = message.clean_content text = message.clean_content

Loading…
Cancel
Save