Update code.py

This commit is contained in:
Paillat
2022-11-29 14:35:59 +01:00
parent ba49c2840e
commit f8b837a10b

View File

@@ -259,25 +259,22 @@ async def on_message(message):
prompt = ""
#get the channel id from the database
c.execute("SELECT channel_id FROM data WHERE guild_id = ?", (message.guild.id,))
if str(message.channel.id) != str(c.fetchone()[0]):
prompt = message.author.display_name + ":" + message.content + "\n"
else:
for msg in messages:
if msg.author.bot:
prompt += f"Botator: {msg.content}\n"
else:
#replace the mentions of each user with their name
#first get all the mentions in the message
mentions = re.findall(r"<@!?\d+>", msg.content)
#then replace each mention with the name of the user
for mention in mentions:
#get the user id
id = mention[2:-1]
#get the user
user = await bot.fetch_user(id)
#replace the mention with the name
msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name)
prompt += f"{msg.author.display_name}: {msg.content}\n"
for msg in messages:
if msg.author.bot:
prompt += f"Botator: {msg.content}\n"
else:
#replace the mentions of each user with their name
#first get all the mentions in the message
mentions = re.findall(r"<@!?\d+>", msg.content)
#then replace each mention with the name of the user
for mention in mentions:
#get the user id
id = mention[2:-1]
#get the user
user = await bot.fetch_user(id)
#replace the mention with the name
msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name)
prompt += f"{msg.author.display_name}: {msg.content}\n"
#get the prompt_prefix from the database
c.execute("SELECT prompt_prefix FROM data WHERE guild_id = ?", (message.guild.id,))
prompt = f"This is a conversation with an AI in a discord chat. The AI is called \"Botator\" Only the {prompt_size} last messages are used as a prompt.\n Botator has been coded by Jérémie Cotti. His usernme in discord is \"Paillat\". He's 15 years old. No other language. Jérémie used openai's ai models to create Botator and Binded it with discord." + str(c.fetchone()[0]) + f"\n" + prompt