mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
tempfix the mentions shit
This commit is contained in:
@@ -140,19 +140,21 @@ async def on_message_process(message: discord.Message, self: Chat):
|
|||||||
#get the channel id from the database
|
#get the channel id from the database
|
||||||
c.execute("SELECT channel_id FROM data WHERE guild_id = ?", (message.guild.id,))
|
c.execute("SELECT channel_id FROM data WHERE guild_id = ?", (message.guild.id,))
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
mentions = re.findall(r"<@!?\d+>", msg.content)
|
content = msg.content
|
||||||
|
mentions = re.findall(r"<@!?\d+>", content)
|
||||||
#then replace each mention with the name of the user
|
#then replace each mention with the name of the user
|
||||||
for mention in mentions:
|
for mention in mentions:
|
||||||
#get the user id
|
#get the user id
|
||||||
id = mention[2:-1]
|
uid = mention[2:-1]
|
||||||
#get the user
|
#get the user
|
||||||
user = await self.bot.fetch_user(id)
|
user = await self.bot.fetch_user(uid)
|
||||||
#replace the mention with the name
|
#replace the mention with the name
|
||||||
msg.content = msg.content.replace(mention, user + f"<@{id}>")
|
content = content.replace(mention, f"{user.name}#{user.discriminator}:<@{uid}>")
|
||||||
|
content = content + "\nSYSTEM: Mentions have been replaced with name#discriminator:id. Botator uses only the mention, not the name or the discriminator. The discriminator is only used to prevent name clashes."
|
||||||
#get the gmt time the message was sent
|
#get the gmt time the message was sent
|
||||||
gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
##print(msg.content)
|
##print(msg.content)
|
||||||
prompt += f"{msg.author} ({gmt_time} GMT-0): {msg.content}\n"
|
prompt += f"{msg.author} ({gmt_time} GMT-0): {content}\n"
|
||||||
##print(prompt)
|
##print(prompt)
|
||||||
#get the prompt_prefix from the database
|
#get the prompt_prefix from the database
|
||||||
#check if the bot is in pretend mode
|
#check if the bot is in pretend mode
|
||||||
|
|||||||
Reference in New Issue
Block a user