ajout commande changelogs
This commit is contained in:
parent
1520fa7495
commit
904149fcb0
2 changed files with 44 additions and 4 deletions
|
@ -5,7 +5,7 @@ from discord.ext import commands, tasks
|
||||||
from random import randint, shuffle
|
from random import randint, shuffle
|
||||||
from discord_slash import cog_ext
|
from discord_slash import cog_ext
|
||||||
from utils.reminder import Reminder
|
from utils.reminder import Reminder
|
||||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick, mentionToUser
|
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick, mentionToUser, getChangelogs
|
||||||
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom
|
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
|
@ -482,7 +482,7 @@ class Utils(commands.Cog):
|
||||||
|
|
||||||
@commands.command(name='reminder', aliases=["remind", "remindme", "rappel"])
|
@commands.command(name='reminder', aliases=["remind", "remindme", "rappel"])
|
||||||
async def _reminder(self, ctx, time, *reminder):
|
async def _reminder(self, ctx, time, *reminder):
|
||||||
"""Met en place un rappel.\n ➡ Syntaxe: {PREFIX}reminder/remind/remindme/rappel <temps>[@] [message] """
|
"""Met en place un rappel.\n ➡ Syntaxe: {PREFIX}reminder/remind/remindme/rappel <temps>[@] [message]"""
|
||||||
fromSlash = False
|
fromSlash = False
|
||||||
if len(reminder) > 0:
|
if len(reminder) > 0:
|
||||||
if reminder[-1] == True:
|
if reminder[-1] == True:
|
||||||
|
@ -599,7 +599,7 @@ class Utils(commands.Cog):
|
||||||
|
|
||||||
@commands.command(name='reminderlist', aliases=["remindlist", "rl", "rappeliste"])
|
@commands.command(name='reminderlist', aliases=["remindlist", "rl", "rappeliste"])
|
||||||
async def _reminderlist(self, ctx, *utilisateur):
|
async def _reminderlist(self, ctx, *utilisateur):
|
||||||
"""Affiche la liste des rappels d'un utilisateur.\n ➡ Syntaxe: {PREFIX}reminderlist/rl/remindlist/rappeliste [utilisateur] """
|
"""Affiche la liste des rappels d'un utilisateur.\n ➡ Syntaxe: {PREFIX}reminderlist/rl/remindlist/rappeliste [utilisateur]"""
|
||||||
fromSlash = False
|
fromSlash = False
|
||||||
if len(utilisateur) > 0:
|
if len(utilisateur) > 0:
|
||||||
if utilisateur[-1] == True:
|
if utilisateur[-1] == True:
|
||||||
|
@ -642,7 +642,7 @@ class Utils(commands.Cog):
|
||||||
|
|
||||||
@commands.command(name='reminderdelete', aliases=["reminddelete", "rd"])
|
@commands.command(name='reminderdelete', aliases=["reminddelete", "rd"])
|
||||||
async def _reminderdelete(self, ctx, *id):
|
async def _reminderdelete(self, ctx, *id):
|
||||||
"""Suppprime un rappel.\n ➡ Syntaxe: {PREFIX}reminderdelete/rd <id> """
|
"""Suppprime un rappel.\n ➡ Syntaxe: {PREFIX}reminderdelete/rd <id>"""
|
||||||
fromSlash = False
|
fromSlash = False
|
||||||
if len(id) > 0:
|
if len(id) > 0:
|
||||||
if id[-1] == True:
|
if id[-1] == True:
|
||||||
|
@ -669,3 +669,30 @@ class Utils(commands.Cog):
|
||||||
@cog_ext.cog_slash(name="reminderdelete", description = "Suppprime un rappel.")
|
@cog_ext.cog_slash(name="reminderdelete", description = "Suppprime un rappel.")
|
||||||
async def __reminderdelete(self, ctx, id):
|
async def __reminderdelete(self, ctx, id):
|
||||||
return await self._reminderdelete(ctx, id, True)
|
return await self._reminderdelete(ctx, id, True)
|
||||||
|
|
||||||
|
@commands.command(name='changelogs', aliases=["changelog", "changement", "changements"])
|
||||||
|
async def _changelogs(self, ctx, *version):
|
||||||
|
"""Affiche les changements de la dernière version ou d'une version précise.\n ➡ Syntaxe: {PREFIX}changelogs/changelog/changement/changements [version] """
|
||||||
|
fromSlash = False
|
||||||
|
if len(version) > 0:
|
||||||
|
if version[-1] == True:
|
||||||
|
fromSlash = version[-1]
|
||||||
|
version = version[:-1]
|
||||||
|
if len(version) > 0:
|
||||||
|
version = version[0]
|
||||||
|
else:
|
||||||
|
version = 'latest'
|
||||||
|
changes = getChangelogs(version)
|
||||||
|
if changes == None:
|
||||||
|
if fromSlash != True:
|
||||||
|
await ctx.message.add_reaction(emoji = '❌')
|
||||||
|
return await ctx.send("Veuillez renseigner un numéro de version valide et existant.")
|
||||||
|
if fromSlash != True:
|
||||||
|
await ctx.message.add_reaction(emoji = '✅')
|
||||||
|
await ctx.send(f"url: {changes[0]}\nnum de version: {changes[1]}\ntaille du message de changements: {len(changes[2])}")
|
||||||
|
@cog_ext.cog_slash(name="changelogs", description = "Affiche les changements de la dernière version ou d'une version précise.")
|
||||||
|
async def __changelogs(self, ctx, version: int = None):
|
||||||
|
if version == None:
|
||||||
|
return await self._reminderlist(ctx, True)
|
||||||
|
else:
|
||||||
|
return await self._reminderlist(ctx, version, True)
|
||||||
|
|
|
@ -109,4 +109,17 @@ def ligneFormatage(ligne):
|
||||||
return ligne
|
return ligne
|
||||||
|
|
||||||
def mentionToUser(mention: str):
|
def mentionToUser(mention: str):
|
||||||
|
"""Récupère une mention et renvois son ID"""
|
||||||
return int(mention[2:-1].replace("!",""))
|
return int(mention[2:-1].replace("!",""))
|
||||||
|
|
||||||
|
def getChangelogs(version = 'latest'):
|
||||||
|
"""Récupère les changements d'une version (par défaut, la dernière en date) et renvois dans l'ordre : url, n° version, changements"""
|
||||||
|
if version != 'latest':
|
||||||
|
version = f'tags/v{version}'
|
||||||
|
changements = requests.get(f"https://api.github.com/repos/Confrerie-du-Kassoulait/KassouBot/releases/{version}").json()
|
||||||
|
try:
|
||||||
|
changements["message"] # renvois None si aucune version correspondante n'a été trouvée
|
||||||
|
return None
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return (changements["html_url"], changements["tag_name"][1:], changements["body"])
|
||||||
|
|
Reference in a new issue