add source files
This commit is contained in:
28
bot.py
Normal file
28
bot.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import barry
|
||||
import discord
|
||||
from discord import app_commands
|
||||
import os
|
||||
|
||||
intents = discord.Intents.default()
|
||||
client = discord.Client(intents=intents)
|
||||
tree = app_commands.CommandTree(client)
|
||||
|
||||
with open("training.txt") as t:
|
||||
training = t.read()
|
||||
|
||||
model = barry.train(training)
|
||||
|
||||
@tree.command(name="ask", description="Ask Barry a question")
|
||||
async def ask(interaction: discord.Interaction, question: str):
|
||||
_ = await interaction.response.send_message(barry.prompt(question, model))
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
await tree.sync()
|
||||
print(f"logged in as {client.user}")
|
||||
key = os.getenv("BARRY_TOKEN", None)
|
||||
if key == None:
|
||||
print("Set BARRY_TOKEN to the Discord token before continuing")
|
||||
exit(1)
|
||||
client.run(key)
|
||||
|
||||
Reference in New Issue
Block a user