diff --git a/irc_api/api.py b/irc_api/api.py index c2708b4..0665adb 100644 --- a/irc_api/api.py +++ b/irc_api/api.py @@ -121,6 +121,7 @@ class Bot: global PREFIX if kwargs.get('prefix'): PREFIX = kwargs.get('prefix') + self.prefix = PREFIX self.irc = IRC(*irc_params) self.history = History(kwargs.get('limit')) @@ -170,7 +171,7 @@ class Bot: if add_to_help: self.commands_help[command.name] = command - def add_commands(self, *commands): + def add_commands(self, *commands, **kwargs): """Add a list of commands to the bot. Parameters @@ -199,16 +200,21 @@ class Bot: def auto_help(bot, msg, *args): """Aide des commandes disponibles.""" if args and args[0] in bot.commands_help.keys(): - bot.send(msg.to, f"Aide sur la commande : {args[0]}") + cmnd = bot.commands_help[args[0]] + if cmnd.cmnd_type == 1: + bot.send(msg.to, f"Aide sur la commande : {bot.prefix}{args[0]}") + else: + bot.send(msg.to, f"Aide sur la commande : {args[0]}") + bot.send(msg.to, f" {bot.commands_help[args[0]].desc}") else: bot.send(msg.to, f"Liste des commandes ({PREFIX}aide pour plus d'info)") for cmnd_name in bot.commands_help.keys(): - bot.send(msg.to, f" – {cmnd_name}") + bot.send(msg.to, f" - {cmnd.name}") def parse(message): - pattern = re.compile(r"((\"[\w\ \-\']+\"\ *)|(\'[\w\ \-\"]+\'\ *)|([\w\'\-]+\ *))") + pattern = re.compile(r"((\"[^\"]+\"\ *)|(\'[^\']+\'\ *)|([^\ ]+\ *))", re.IGNORECASE) args_to_return = [] for match in re.findall(pattern, message): match = match[0].strip().rstrip() diff --git a/irc_api/irc.py b/irc_api/irc.py index f0df385..73f2f31 100644 --- a/irc_api/irc.py +++ b/irc_api/irc.py @@ -175,7 +175,7 @@ class IRC: class History: - def __init__(self, limit: int=100): + def __init__(self, limit: int): self.__content = [] if limit: self.__limit = limit