update timezone : using env variable
This commit is contained in:
parent
568aa99270
commit
69445cd6a0
4 changed files with 12 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
10
src/main.py
10
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é
|
||||
|
|
Reference in a new issue