first
This commit is contained in:
commit
305bfff516
|
@ -0,0 +1,32 @@
|
|||
"""https://discord.com/oauth2/authorize?client_id=605758711071506432&permissions=67119104&scope=bot"""
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import os
|
||||
|
||||
client = commands.Bot(command_prefix = "$")
|
||||
|
||||
|
||||
@client.command()
|
||||
@commands.is_owner()
|
||||
async def load(ctx, extension):
|
||||
client.load_extension(f'cogs.{extension}')
|
||||
|
||||
@client.command()
|
||||
@commands.is_owner()
|
||||
async def unload(ctx, extension):
|
||||
client.unload_extension(f'cogs.{extension}')
|
||||
|
||||
@client.command()
|
||||
@commands.is_owner()
|
||||
async def reload(ctx, extension):
|
||||
client.unload_extension(f'cogs.{extension}')
|
||||
client.load_extension(f'cogs.{extension}')
|
||||
|
||||
|
||||
for filename in os.listdir("./cogs"):
|
||||
if filename.endswith('.py'):
|
||||
client.load_extension(f'cogs.{filename[:-3]}')
|
||||
|
||||
|
||||
client.run('NjA1NzU4NzExMDcxNTA2NDMy.XUBKww.sI5-DZzdCCXdgW44uEACqGzaVpc')
|
|
@ -0,0 +1,14 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
class Basic(commands.Cog):
|
||||
|
||||
def __init__(self,client):
|
||||
self.client = client
|
||||
|
||||
@commands.command()
|
||||
async def ping(self, ctx):
|
||||
await ctx.send("pong!")
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(Basic(client))
|
|
@ -0,0 +1,50 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
import sqlite3
|
||||
from coffeehouse.lydia import LydiaAI
|
||||
import time
|
||||
|
||||
class Lydia(commands.Cog):
|
||||
|
||||
def __init__(self,client):
|
||||
self.lydia = LydiaAI("69e6f26aba27d05e14c6a48e38008bc0794e24c1d25591db00575e9ce93c577ca934724981a540c319c7da3209ca4c0f910098c14ad6b5e27902c346c9f5cf7f")
|
||||
self.client = client
|
||||
self.conn = sqlite3.connect('./lydia_sessions.sqlite3')
|
||||
self.cur = self.conn.cursor()
|
||||
|
||||
@commands.command(aliases=["lydia"])
|
||||
async def ai(self, ctx, *, quest):
|
||||
self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"')
|
||||
query = self.cur.fetchone()
|
||||
|
||||
if query == None:
|
||||
session = self.lydia.create_session()
|
||||
self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')")
|
||||
self.conn.commit()
|
||||
|
||||
await ctx.send(session.think_thought(quest))
|
||||
else:
|
||||
#give it a 50 second margin to avoid possible errors
|
||||
if query[2]-50 < int(time.time()):
|
||||
self.cur.execute(f'DELETE FROM sessions WHERE session_id = "{query[1]}"')
|
||||
session = self.lydia.create_session()
|
||||
self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')")
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
reply = session.think_thought(quest)
|
||||
await ctx.send(reply)
|
||||
#or alternatively
|
||||
#await ctx.send(session.think_thought(quest))
|
||||
else:
|
||||
reply = self.lydia.think_thought(query[1], quest)
|
||||
await ctx.send(reply)
|
||||
#or alternatively
|
||||
#await ctx.send(session.think_thought(quest))
|
||||
|
||||
#remember to comment this out if you use the alternatives above
|
||||
print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}")
|
||||
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(Lydia(client))
|
|
@ -0,0 +1,8 @@
|
|||
apt-get install python3
|
||||
apt-get install python3-distutils
|
||||
apt-get install wget
|
||||
wget https://bootstrap.pypa.io/get-pip.py
|
||||
python3 get-pip.py
|
||||
python3 -m pip install coffeehouse
|
||||
python3 -m pip install discord.py
|
||||
python3 -m pip install sqlite3
|
Loading…
Reference in New Issue