From c249ece3a51517f78f9c604280a0ddf31e1a454a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 6 Jun 2021 23:46:41 +0200 Subject: [PATCH] goodtimezone better args --- src/cogs/confreriedukassoulait.py | 4 ++-- src/main.py | 6 +++--- src/utils/core.py | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cogs/confreriedukassoulait.py b/src/cogs/confreriedukassoulait.py index 4fcdf62..2e0bf86 100644 --- a/src/cogs/confreriedukassoulait.py +++ b/src/cogs/confreriedukassoulait.py @@ -96,9 +96,9 @@ class ConfrerieDuKassoulait(commands.Cog): embed.set_author(name = userOrNick(message.author), icon_url = message.author.avatar_url) if not user_suppressed: - embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1, customTimezone)}\nSupprimé le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, customTimezone, 1)}\nSupprimé le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}") else: - embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1, customTimezone)}\nSupprimé par {userOrNick(user_suppressed)} le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, customTimezone, 1)}\nSupprimé par {userOrNick(user_suppressed)} le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}") await channel.send(embed = embed) # ne fonctionne pas quand un message a été supprimé avant que le bot ai démarré diff --git a/src/main.py b/src/main.py index 5db30ed..3adaaf1 100644 --- a/src/main.py +++ b/src/main.py @@ -110,14 +110,14 @@ async def on_message(message): embed.set_author(name = "Citation", icon_url = msgID.author.avatar_url) icon_url = message.author.avatar_url - date_1 = goodTimezone(msgID.created_at, 0, customTimezone) + date_1 = goodTimezone(msgID.created_at, customTimezone) edit = "" if msgID.edited_at: - date_edit = goodTimezone(msgID.edited_at, 0, customTimezone) + date_edit = goodTimezone(msgID.edited_at, customTimezone) edit = f" et modifié le {date_edit[0][8:]}/{date_edit[0][5:-3]}/{date_edit[0][:4]} à {date_edit[1]}" messageDuBas = f"Posté le {date_1[0][8:]}/{date_1[0][5:-3]}/{date_1[0][:4]} à {date_1[1]}{edit}" - date_2 = goodTimezone(message.created_at, 0, customTimezone) + date_2 = goodTimezone(message.created_at, customTimezone) date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}" if auteur == "Auteur": diff --git a/src/utils/core.py b/src/utils/core.py index 809804a..0dde06e 100644 --- a/src/utils/core.py +++ b/src/utils/core.py @@ -8,7 +8,7 @@ from datetime import datetime, timedelta myTimezone = os.environ['TIMEZONE'] -def goodTimezone(date, type, tz): +def goodTimezone(date, tz, type = 0): """renvoie une date en fonction d'un timezone""" if type == 0: return str(timezone(tz).fromutc(date))[:-13].replace('-', '/').split() @@ -204,3 +204,7 @@ def timedeltaToString(time): age[2] = f"{age[2]}m " if a[2] == 1 else '' age[3] = f"{age[3]}s" if a[3] == 1 else '' return ''.join(age) + +def timestampFR(timestamp): + date_edit = str(timestamp).replace('-', '/').split(' ') + return f"{date_edit[0][8:]}/{date_edit[0][5:-3]}/{date_edit[0][:4]} à {date_edit[1]}"