commit
1c097db3a5
1 changed files with 21 additions and 13 deletions
34
aitrain.py
34
aitrain.py
|
@ -2,17 +2,23 @@ from textgenrnn import textgenrnn
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import regex as re
|
import regex as re
|
||||||
|
import functools
|
||||||
|
|
||||||
textgen = textgenrnn(name="insert3")
|
textgen = textgenrnn(name="insert3")
|
||||||
client = commands.Bot(command_prefix='.')
|
client = commands.Bot(command_prefix='.')
|
||||||
boton = 0
|
boton = False
|
||||||
|
|
||||||
|
def add_to_train(clean_content):
|
||||||
|
print(clean_content)
|
||||||
|
with open("train.txt", "a") as train:
|
||||||
|
train.write(f"{clean_content} \n")
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
await client.process_commands(message)
|
await client.process_commands(message)
|
||||||
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',message.content.lower())
|
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',message.content.lower())
|
||||||
if not message.attachments:
|
if not message.attachments:
|
||||||
if boton == 1:
|
if boton:
|
||||||
if message.content.lower().startswith("$"):
|
if message.content.lower().startswith("$"):
|
||||||
pass
|
pass
|
||||||
elif urls:
|
elif urls:
|
||||||
|
@ -24,23 +30,25 @@ async def on_message(message):
|
||||||
elif message.content.lower().startswith("—"):
|
elif message.content.lower().startswith("—"):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print(message.clean_content)
|
async with message.channel.typing:
|
||||||
train = open("train.txt", "a")
|
writing_function = functools.partial(add_to_train, message.clean_content)
|
||||||
train.write(f"{message.clean_content} \n")
|
await bot.loop.run_in_executor(None, writing_function)
|
||||||
train.close()
|
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
@client.command()
|
@client.command()
|
||||||
async def train(ctx):
|
async def train(ctx):
|
||||||
if ctx.author.id == 666378959184855042:
|
global boton
|
||||||
global boton
|
boton = True
|
||||||
boton = 1
|
await ctx.send("I am now training what to say based on your messages")
|
||||||
await ctx.send("I am now training what to say based on your messages")
|
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
@client.command()
|
@client.command()
|
||||||
async def stopbot(ctx):
|
async def stopbot(ctx):
|
||||||
if ctx.author.id == 666378959184855042:
|
async with ctx.typing:
|
||||||
await ctx.send("data collection done, I will now log of discord and build an a.i")
|
training_function = functools.partial(textgen.train_from_file, 'train.txt', num_epochs=11)
|
||||||
textgen.train_from_file('train.txt', num_epochs=11)
|
await bot.loop.run_in_executor(None, training_function)
|
||||||
|
await ctx.send("data collection done, I will now log of discord and build an a.i")
|
||||||
|
await bot.logout()
|
||||||
|
|
||||||
|
|
||||||
client.run('BOTTOKEN')
|
client.run('BOTTOKEN')
|
||||||
|
|
Loading…
Reference in a new issue