added the ability to the bot tonow what tie it's in gmt 0

This commit is contained in:
Paillat
2022-12-16 15:55:03 +01:00
parent 3c6361f3ba
commit 8cacb541af

View File

@@ -5,6 +5,7 @@ import openai
from config import debug, c, max_uses, cp, conn, connp from config import debug, c, max_uses, cp, conn, connp
import random import random
import threading import threading
import time
class Chat (discord.Cog) : class Chat (discord.Cog) :
def __init__(self, bot: discord.Bot): def __init__(self, bot: discord.Bot):
super().__init__() super().__init__()
@@ -41,7 +42,7 @@ class Chat (discord.Cog) :
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
thread = threading.Thread(target=asyncio.run_coroutine_threadsafe, args=(on_message_process(message_to_redo, self), loop)) thread = threading.Thread(target=asyncio.run_coroutine_threadsafe, args=(on_message_process(message_to_redo, self), loop))
thread.start() thread.start()
await ctx.respond("Message redone !", delete_after=5) await ctx.respond("Message redone !", delete_after=1)
async def on_message_process(message: discord.Message, self: Chat): async def on_message_process(message: discord.Message, self: Chat):
#my code #my code
@@ -137,21 +138,19 @@ 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:
if msg.author.bot: mentions = re.findall(r"<@!?\d+>", msg.content)
prompt += f"Botator: {msg.content}\n" #then replace each mention with the name of the user
else: for mention in mentions:
#replace the mentions of each user with their name #get the user id
#first get all the mentions in the message id = mention[2:-1]
mentions = re.findall(r"<@!?\d+>", msg.content) #get the user
#then replace each mention with the name of the user user = await self.bot.fetch_user(id)
for mention in mentions: #replace the mention with the name
#get the user id msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name + f"<@{id}>")
id = mention[2:-1] #get the gmt time the message was sent
#get the user gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S")
user = await self.bot.fetch_user(id) print(f"{gmt_time}")
#replace the mention with the name prompt += f"{msg.author.display_name} ({gmt_time} GMT-0): {msg.content}\n"
msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name + f"<@{id}>")
prompt += f"{msg.author.display_name}: {msg.content}\n"
#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
c.execute("SELECT pretend_enabled FROM data WHERE guild_id = ?", (message.guild.id,)) c.execute("SELECT pretend_enabled FROM data WHERE guild_id = ?", (message.guild.id,))