pep8
This commit is contained in:
parent
b5c2d3d10b
commit
e5a16c908e
@ -1,16 +1,13 @@
|
||||
import asyncio
|
||||
from typing import List, Union
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from redbot.core import Config
|
||||
from redbot.core.bot import Red
|
||||
|
||||
from .source import ChatBot
|
||||
from .source.trainers import ListTrainer
|
||||
|
||||
from datetime import datetime,timedelta
|
||||
|
||||
class Chatter:
|
||||
"""
|
||||
@ -24,7 +21,7 @@ class Chatter:
|
||||
default_guild = {
|
||||
"whitelist": None,
|
||||
"days": 1
|
||||
}
|
||||
}
|
||||
|
||||
self.chatbot = ChatBot("ChatterBot")
|
||||
self.chatbot.set_trainer(ListTrainer)
|
||||
@ -34,7 +31,7 @@ class Chatter:
|
||||
|
||||
self.loop = asyncio.get_event_loop()
|
||||
|
||||
async def _get_conversation(self, ctx, in_channel: discord.TextChannel=None):
|
||||
async def _get_conversation(self, ctx, in_channel: discord.TextChannel = None):
|
||||
"""
|
||||
Compiles all conversation in the Guild this bot can get it's hands on
|
||||
Currently takes a stupid long time
|
||||
@ -43,7 +40,6 @@ class Chatter:
|
||||
out = []
|
||||
after = datetime.today() - timedelta(days=(await self.config.guild(ctx.guild).days()))
|
||||
|
||||
|
||||
for channel in ctx.guild.text_channels:
|
||||
if in_channel:
|
||||
channel = in_channel
|
||||
@ -52,7 +48,7 @@ class Chatter:
|
||||
try:
|
||||
async for message in channel.history(limit=None, reverse=True, after=after):
|
||||
if user == message.author:
|
||||
out[-1] += "\n"+message.clean_content
|
||||
out[-1] += "\n" + message.clean_content
|
||||
else:
|
||||
user = message.author
|
||||
out.append(message.clean_content)
|
||||
@ -80,6 +76,7 @@ class Chatter:
|
||||
"""
|
||||
if ctx.invoked_subcommand is None:
|
||||
await ctx.send_help()
|
||||
|
||||
@chatter.command()
|
||||
async def age(self, ctx: commands.Context, days: int):
|
||||
"""
|
||||
@ -103,7 +100,7 @@ class Chatter:
|
||||
return
|
||||
|
||||
await ctx.send("Gather successful! Training begins now\n(**This will take a long time, be patient**)")
|
||||
embed=discord.Embed(title="Loading")
|
||||
embed = discord.Embed(title="Loading")
|
||||
embed.set_image(url="http://www.loop.universaleverything.com/animations/1295.gif")
|
||||
temp_message = await ctx.send(embed=embed)
|
||||
future = await self.loop.run_in_executor(None, self._train, conversation)
|
||||
@ -137,5 +134,3 @@ class Chatter:
|
||||
if not response:
|
||||
response = ":thinking:"
|
||||
await channel.send(response)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user