Merge branch 'dev'

This commit is contained in:
Mylloon 2021-04-01 16:02:52 +02:00
commit 1e7d38b6cc
4 changed files with 24 additions and 17 deletions

View file

@ -7,18 +7,19 @@
[![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:
```
docker run -d \
--name="kassoubot" \
--name="KassouBot" \
mylloon/kassoubot \
--TOKEN_DISCORD="yourValue" \
--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)

View file

@ -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

View file

@ -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
@ -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)
@ -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)))

View file

@ -151,20 +151,19 @@ 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 = goodTimezone(msgID.created_at, 0)
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}"
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('Europe/Paris')))[:-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]}"
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()
@ -197,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 : {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('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 : {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é
@ -211,4 +210,10 @@ def user_or_nick(user):
else:
return f"{user.name}#{user.discriminator}"
def goodTimezone(date, type):
if type == 0:
return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').split()
elif type == 1:
return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').replace(' ', ' à ')
client.run(os.environ['TOKEN_DISCORD'])