41 lines
844 B
Python
41 lines
844 B
Python
import os
|
|
|
|
import discord
|
|
from dotenv import load_dotenv
|
|
|
|
from ruby_engine import RubyEngine
|
|
|
|
load_dotenv()
|
|
TOKEN = os.getenv("DISCORD_TOKEN")
|
|
if not TOKEN:
|
|
raise RuntimeError("DISCORD_TOKEN missing in .env")
|
|
|
|
# instantiate your “Ruby” engine
|
|
ruby = RubyEngine() # uses GPU if available
|
|
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
client = discord.Client(intents=intents)
|
|
|
|
|
|
@client.event
|
|
async def on_ready():
|
|
print(f"Ruby is online as {client.user}")
|
|
|
|
|
|
@client.event
|
|
async def on_message(message):
|
|
if message.author == client.user:
|
|
return
|
|
content = message.content.strip()
|
|
if not content:
|
|
return
|
|
|
|
# generate + train in one call
|
|
reply = ruby.generate(content)
|
|
await message.channel.send(reply)
|
|
ruby.train_on(f"User: {content}\nRuby: {reply}")
|
|
|
|
|
|
client.run(TOKEN)
|