Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -167,8 +167,17 @@ or
|
|
167 |
|
168 |
@client.event
|
169 |
async def on_message(message):
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
if len(args) == 0:
|
173 |
embed = discord.Embed(title="Error", description="No args provided. Use `--help` for command help.")
|
174 |
await message.reply(embed=embed)
|
@@ -186,6 +195,8 @@ async def on_message(message):
|
|
186 |
return 0
|
187 |
c = client.get_channel(cid)
|
188 |
if c in message.guild.text_channels:
|
|
|
|
|
189 |
embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{cid}>")
|
190 |
await message.reply(embed=embed)
|
191 |
return 0
|
@@ -203,6 +214,8 @@ async def on_message(message):
|
|
203 |
try:
|
204 |
c = discord.utils.get(client.get_all_channels(), guild__id=message.guild.id, name=cname)
|
205 |
if c != None:
|
|
|
|
|
206 |
embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{c.id}>")
|
207 |
message.reply(embed=embed)
|
208 |
return 0
|
@@ -255,14 +268,6 @@ async def on_message(message):
|
|
255 |
message.content = message.content.replace(f"<@{user.id}>",
|
256 |
f"<@{str(user)}>")
|
257 |
try:
|
258 |
-
msgchannel = message.channel
|
259 |
-
try:
|
260 |
-
msgchannel_name = msgchannel.name
|
261 |
-
guild = message.guild
|
262 |
-
guild_name = guild.name
|
263 |
-
except:
|
264 |
-
guild_name = "Direct"
|
265 |
-
msgchannel_name = str(message.author)
|
266 |
s = f":green[{message.author}]: :violet[{message.content}] :blue[{msgchannel_name}] :orange[{guild_name}]"
|
267 |
if message.author == client.user:
|
268 |
return
|
@@ -312,7 +317,9 @@ async def on_message(message):
|
|
312 |
)
|
313 |
with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
|
314 |
context = f.read()
|
315 |
-
|
|
|
|
|
316 |
async with msgchannel.typing():
|
317 |
context += f"GPT4 Correct Assistant:"
|
318 |
load = random.choice(
|
|
|
167 |
|
168 |
@client.event
|
169 |
async def on_message(message):
|
170 |
+
msgchannel = message.channel
|
171 |
+
try:
|
172 |
+
msgchannel_name = msgchannel.name
|
173 |
+
guild = message.guild
|
174 |
+
guild_name = guild.name
|
175 |
+
except:
|
176 |
+
guild_name = "Direct"
|
177 |
+
msgchannel_name = str(message.author)
|
178 |
+
if message.content.startswith("--setup"):
|
179 |
+
args = message.content.split()
|
180 |
+
del args[0]
|
181 |
if len(args) == 0:
|
182 |
embed = discord.Embed(title="Error", description="No args provided. Use `--help` for command help.")
|
183 |
await message.reply(embed=embed)
|
|
|
195 |
return 0
|
196 |
c = client.get_channel(cid)
|
197 |
if c in message.guild.text_channels:
|
198 |
+
with open(f"{guild_name}.guild", "a") as f:
|
199 |
+
f.write(f"{c.id}\n")
|
200 |
embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{cid}>")
|
201 |
await message.reply(embed=embed)
|
202 |
return 0
|
|
|
214 |
try:
|
215 |
c = discord.utils.get(client.get_all_channels(), guild__id=message.guild.id, name=cname)
|
216 |
if c != None:
|
217 |
+
with open(f"{guild_name}.guild", "a") as f:
|
218 |
+
f.write(f"{c.id}\n")
|
219 |
embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{c.id}>")
|
220 |
message.reply(embed=embed)
|
221 |
return 0
|
|
|
268 |
message.content = message.content.replace(f"<@{user.id}>",
|
269 |
f"<@{str(user)}>")
|
270 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
s = f":green[{message.author}]: :violet[{message.content}] :blue[{msgchannel_name}] :orange[{guild_name}]"
|
272 |
if message.author == client.user:
|
273 |
return
|
|
|
317 |
)
|
318 |
with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
|
319 |
context = f.read()
|
320 |
+
with open(f"{guild_name}.guild", "r") as f:
|
321 |
+
o = f.read()
|
322 |
+
if str(message.channel.id) in o.split("\n") or guild_name == "Direct":
|
323 |
async with msgchannel.typing():
|
324 |
context += f"GPT4 Correct Assistant:"
|
325 |
load = random.choice(
|