From 568aa99270e132f621ef516f7ff91a01fa6016df Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 27 Mar 2021 00:02:01 +0100 Subject: [PATCH 1/6] =?UTF-8?q?am=C3=A9lioration=20lisibilit=C3=A9=20citat?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index a851d14..d84bbf3 100644 --- a/src/main.py +++ b/src/main.py @@ -155,16 +155,15 @@ async def on_message(message): edit = "" if msgID.edited_at: date_edit = str(msgID.edited_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() - edit = f"(Dernier edit : {date_edit[0][8:]}/{date_edit[0][5:-3]}/{date_edit[0][:4]} à {date_edit[1]})" - message_1 = f"Date : {date_1[0][8:]}/{date_1[0][5:-3]}/{date_1[0][:4]} à {date_1[1]} {edit}" + 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 = str(message.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}" - cite = "" if auteur == "Auteur": - cite = f"\nCité par {user_or_nick(message.author)} le {date_2}" - embed.set_footer(icon_url = icon_url, text = f"{message_1}{cite}") + messageDuBas = messageDuBas + f"\nCité par {user_or_nick(message.author)} le {date_2}" + embed.set_footer(icon_url = icon_url, text = messageDuBas) if message.content == linkURL.replace(' ',''): await message.channel.send(embed = embed) await message.delete() From 69445cd6a06c24aab2169e2f45337a37ca5940bf Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 27 Mar 2021 00:08:53 +0100 Subject: [PATCH 2/6] update timezone : using env variable --- README.md | 5 +++-- docker-compose.yml | 1 + src/cogs/utils.py | 6 +++--- src/main.py | 10 +++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9b47931..75371fd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Github forks](https://img.shields.io/github/forks/Confrerie-du-Kassoulait/KassouBot?label=Github%20Forks&style=for-the-badge)](https://github.com/Confrerie-du-Kassoulait/KassouBot/network) ## __Setting up__ -You have to replace `TOKEN_DISCORD`, `TOKEN_GENIUS`, `TOKEN_REDDIT_CLIENT_ID`, `TOKEN_REDDIT_CLIENT_SECRET` and `TOKEN_REDDIT_USER_AGENT` with your desired values. +You have to replace `TOKEN_DISCORD`, `TOKEN_GENIUS`, `TOKEN_REDDIT_CLIENT_ID`, `TOKEN_REDDIT_CLIENT_SECRET`, `TOKEN_REDDIT_USER_AGENT` and [`TIMEZONE`](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) with your desired values. With a [docker-compose](https://github.com/Confrerie-du-Kassoulait/KassouBot/blob/master/docker-compose.yml) or in command line: ``` @@ -18,7 +18,8 @@ docker run -d \ --TOKEN_GENIUS="yourValue" \ --TOKEN_REDDIT_CLIENT_ID="yourValue" \ --TOKEN_REDDIT_CLIENT_SECRET="yourValue" \ - --TOKEN_REDDIT_USER_AGENT="yourValue" + --TOKEN_REDDIT_USER_AGENT="yourValue" \ + --TIMEZONE="yourTimezone" ``` To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and here are the instructions: ![instructions](https://i.imgur.com/tEzYKDA.png) diff --git a/docker-compose.yml b/docker-compose.yml index b958fad..e438608 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,5 @@ services: - TOKEN_REDDIT_CLIENT_ID=your-reddit-client-id - TOKEN_REDDIT_CLIENT_SECRET=your-reddit-client-secret - TOKEN_REDDIT_USER_AGENT=your-reddit-user-agent + - TIMEZONE=your-timezone # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones restart: unless-stopped diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 9dcd53c..3c13886 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -1,4 +1,4 @@ -import discord, pytz, time +import discord, pytz, time, os from discord.ext import commands from random import randint, shuffle from datetime import datetime @@ -246,14 +246,14 @@ class Utils(commands.Cog): embed.add_field(name = "ID", value = user[0].id) - value = str(user[0].created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() + value = str(user[0].created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() embed.add_field(name = "Compte créé le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Âge du compte", value = self._age_layout(self._get_age(user[0].created_at))) embed.add_field(name = "Mention", value = user[0].mention) - value = str(user[0].joined_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() + value = str(user[0].joined_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Est sur le serveur depuis", value = self._age_layout(self._get_age(user[0].joined_at))) diff --git a/src/main.py b/src/main.py index d84bbf3..4f20cf7 100644 --- a/src/main.py +++ b/src/main.py @@ -151,14 +151,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 = str(msgID.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() + date_1 = str(msgID.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() edit = "" if msgID.edited_at: - date_edit = str(msgID.edited_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() + date_edit = str(msgID.edited_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() 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 = str(message.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() + date_2 = str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}" if auteur == "Auteur": @@ -196,9 +196,9 @@ async def on_message_delete(message): embed.set_author(name = user_or_nick(message.author), icon_url = message.author.avatar_url) if not user_suppressed: - embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé le {datetime.now(pytz.timezone('Europe/Paris')).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).strftime('%d/%m/%Y à %H:%M:%S')}") else: - embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.timezone('Europe/Paris')).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).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é From 22b5924c290a82ebe4e9a9cbb843d6813893cc46 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 28 Mar 2021 01:38:28 +0100 Subject: [PATCH 3/6] grouping timezone format in one command --- src/main.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index 4f20cf7..e92e17e 100644 --- a/src/main.py +++ b/src/main.py @@ -151,14 +151,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 = str(msgID.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + date_1 = goodTimezone(msgID.created_at, 0) edit = "" if msgID.edited_at: - date_edit = str(msgID.edited_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + date_edit = goodTimezone(msgID.edited_at, 0) 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 = str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + date_2 = goodTimezone(message.created_at, 0) date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}" if auteur == "Auteur": @@ -196,9 +196,9 @@ async def on_message_delete(message): embed.set_author(name = user_or_nick(message.author), icon_url = message.author.avatar_url) if not user_suppressed: - embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1)}\nSupprimé le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).strftime('%d/%m/%Y à %H:%M:%S')}") else: - embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {str(message.created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ')}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).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, 1)}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).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é @@ -210,4 +210,10 @@ def user_or_nick(user): else: return f"{user.name}#{user.discriminator}" +def goodTimezone(date, type): + if type == 0: + return str(date.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + elif type == 1: + return str(date.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ') + client.run(os.environ['TOKEN_DISCORD']) From bd8b256e6d63f4aa1d717ba39445295ae729b465 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 28 Mar 2021 01:41:54 +0100 Subject: [PATCH 4/6] fix issue #2 --- src/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index e92e17e..a178da4 100644 --- a/src/main.py +++ b/src/main.py @@ -212,8 +212,8 @@ def user_or_nick(user): def goodTimezone(date, type): if type == 0: - return str(date.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').split() elif type == 1: - return str(date.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').replace(' ', ' à ') + return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').replace(' ', ' à ') client.run(os.environ['TOKEN_DISCORD']) From 3ff644c5de4fe05939b33cb08f12d805b6bb4c26 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 28 Mar 2021 14:41:34 +0200 Subject: [PATCH 5/6] adding uppercase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75371fd..1132453 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ With a [docker-compose](https://github.com/Confrerie-du-Kassoulait/KassouBot/blo ``` docker run -d \ - --name="kassoubot" \ + --name="KassouBot" \ mylloon/kassoubot \ --TOKEN_DISCORD="yourValue" \ --TOKEN_GENIUS="yourValue" \ From 733027e8c61373f0d89c746a27e76ebc808c73dc Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 1 Apr 2021 16:01:43 +0200 Subject: [PATCH 6/6] update map amongus --- src/cogs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 3c13886..33c392e 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -225,7 +225,7 @@ class Utils(commands.Cog): await ctx.send(embed = embed) await ctx.message.add_reaction(emoji = '✅') elif map.lower() in self._map_list_among_us("airship"): - image = "https://i.imgur.com/CYbPlQ6.png" + image = "https://i.imgur.com/cm8Wogw.png" embed = discord.Embed(title = f"Map Airship d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed.set_image(url = image) await ctx.send(embed = embed)