Add accents and specials caracters into arguments parsing
This commit is contained in:
parent
c77a5db520
commit
9c4b6916be
|
@ -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 <cmnd> 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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue