From 36a2c9c321ea9f8d4dd1a0007fd0e315b22f1cb5 Mon Sep 17 00:00:00 2001 From: NodeStorm <36058792+QLG1@users.noreply.github.com> Date: Sat, 15 Aug 2020 21:53:41 +0300 Subject: [PATCH] Add files via upload --- bot.py | 27 +++++++++++++++++++++++++-- cogs/basic.py | 11 +++++++++++ cogs/lydia.py | 22 +++++++++++----------- db.sqlite3 | Bin 0 -> 12288 bytes 4 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 db.sqlite3 diff --git a/bot.py b/bot.py index 5880151..654cff4 100644 --- a/bot.py +++ b/bot.py @@ -2,10 +2,33 @@ import discord from discord.ext import commands -import os +import os, sqlite3 -client = commands.Bot(command_prefix = "$") +def get_prefix(client, message): + conn = sqlite3.connect('db.sqlite3') + curr = conn.cursor() + curr.execute(f'SELECT * FROM guilds WHERE guild_id="{message.guild.id}"') + query = curr.fetchone() + if query == None: + curr.execute(f"INSERT INTO guilds VALUES ('{message.guild.id}','$')") + conn.commit() + return "$" + else: + return query[1] + +client = commands.Bot(command_prefix = get_prefix) + +@client.event +async def on_guild_join(guild): + print(dir(guild)) + print(guild.id) + + conn = sqlite3.connect('db.sqlite3') + curr = conn.cursor() + curr.execute(f"INSERT INTO guilds VALUES ('{guild.id}','$')") + conn.commit() + conn.close() @client.command() @commands.is_owner() diff --git a/cogs/basic.py b/cogs/basic.py index bc29e91..f9645f1 100644 --- a/cogs/basic.py +++ b/cogs/basic.py @@ -1,5 +1,6 @@ import discord from discord.ext import commands +import sqlite3 class Basic(commands.Cog): @@ -10,5 +11,15 @@ class Basic(commands.Cog): async def ping(self, ctx): await ctx.send("pong!") + @commands.command() + @commands.guild_only() + @commands.has_permissions(manage_messages=True) + async def changeprefix(self, ctx, *, prefix): + conn = sqlite3.connect('./db.sqlite3') + curr = conn.cursor() + curr.execute(f'UPDATE guilds SET prefix = "{prefix}" WHERE guild_id = "{ctx.guild.id}"') + conn.commit() + await ctx.send(f"Prefix changed to `{prefix}`") + def setup(client): client.add_cog(Basic(client)) diff --git a/cogs/lydia.py b/cogs/lydia.py index b5a5e07..6eeaa93 100644 --- a/cogs/lydia.py +++ b/cogs/lydia.py @@ -9,10 +9,10 @@ class Lydia(commands.Cog): def __init__(self,client): self.lydia = LydiaAI("69e6f26aba27d05e14c6a48e38008bc0794e24c1d25591db00575e9ce93c577ca934724981a540c319c7da3209ca4c0f910098c14ad6b5e27902c346c9f5cf7f") self.client = client - self.conn = sqlite3.connect('./lydia_sessions.sqlite3') + self.conn = sqlite3.connect('./db.sqlite3') self.cur = self.conn.cursor() - @commands.command(aliases=["lydia"]) + @commands.command(aliases=["lydia"], brief="Have a chat with Lydia", usage="") async def ai(self, ctx, *, quest): self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"') query = self.cur.fetchone() @@ -31,19 +31,19 @@ class Lydia(commands.Cog): 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) + await ctx.send(session.think_thought(quest)) #or alternatively - #await ctx.send(session.think_thought(quest)) + #reply = session.think_thought(quest) + #await ctx.send(reply) + else: - reply = self.lydia.think_thought(query[1], quest) - await ctx.send(reply) + await ctx.send(self.lydia.think_thought(query[1], quest)) #or alternatively - #await ctx.send(session.think_thought(quest)) + #reply = self.lydia.think_thought(query[1], quest) + #await ctx.send(reply) - #remember to comment this out if you use the alternatives above - print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}") + #uncomment this if you use the alternatives + #print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}") def setup(client): diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..90fcf97179ba00b9951f179f25e33a5f316f4eef GIT binary patch literal 12288 zcmeI#ze~eF6bJCTrna_N;uZ=PGB{W$k|r@tH>(5@iqINF9BlLBB7tg4(n8(rC6UQyzZD$UTOyj_4mZD@YV4gp0 zXH4VN%oYQh777JAs?6$!EDZhbRXE=h-)qm)arHsSf}h1d{+Okw7fdf?!=4{pfA)|q zPT%H~9}|AepDhVL+JpcEAOHafKmY;|fB*y_009X6FM)>zx6`02sZlOTU(cWJqtZ;( zRZaFR%hs9ZNM)&7l{DA!Y{ijuMOLe2TPwS&>bcI2z{}fB*y_009U<00Izz00bcLhXQMqOYy6v=eL&|!fn0--UDUl literal 0 HcmV?d00001