Extend parsing to single quote and update auto_help with help command by command on demand
This commit is contained in:
parent
637574f39d
commit
e90c98a75f
|
@ -10,10 +10,11 @@ def greetings_bye(bot, msg, *args):
|
|||
@api.channel("#glados")
|
||||
@api.on(
|
||||
event=lambda m: "bonjour glados" in m.text.lower(),
|
||||
desc="Réagis au 'bonjour glados' uniquement si le message est envoyé depuis le channel"\
|
||||
desc="Réagis au 'bonjour glados' uniquement si le message est envoyé depuis le channel "\
|
||||
"#glados."
|
||||
)
|
||||
def greetings_hello(bot, msg, *args):
|
||||
bot.send(msg.to, args)
|
||||
bot.send(msg.to, f"Oh un utilisateur sur #glados :o")
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ def command(name, desc=""):
|
|||
name=name,
|
||||
func=func,
|
||||
events=[lambda m: m.text.startswith(PREFIX + name)],
|
||||
desc=desc
|
||||
desc=desc,
|
||||
)
|
||||
return decorator
|
||||
|
||||
|
@ -131,6 +131,11 @@ class Bot:
|
|||
@command("aide")
|
||||
def auto_help(bot, msg, *args):
|
||||
"""Aide des commandes disponibles."""
|
||||
bot.irc.send(msg.to, f"Aide des commandes")
|
||||
for cmnd in bot.irc.callbacks:
|
||||
bot.irc.send(msg.to, f" – {cmnd.name} : {cmnd.desc}")
|
||||
known_cmnds = {cmnd.name: cmnd for cmnd in bot.irc.callbacks}
|
||||
if args and args[0] in known_cmnds.keys():
|
||||
bot.send(msg.to, f"Aide sur la commande : {args[0]}")
|
||||
bot.send(msg.to, f" {known_cmnds[args[0]].desc}")
|
||||
else:
|
||||
bot.irc.send(msg.to, f"Aide des commandes")
|
||||
for cmnd in bot.irc.callbacks:
|
||||
bot.irc.send(msg.to, f" – {cmnd.name}")
|
||||
|
|
|
@ -235,5 +235,5 @@ class Message:
|
|||
|
||||
|
||||
def parse(message):
|
||||
pattern = re.compile(r"((\"[\w\ \-]+\"\ *)|([\w\-]+\ *))")
|
||||
pattern = re.compile(r"(((\"|\')[\w\ \-]+(\"|\')\ *)|([\w\'\-]+\ *))")
|
||||
return [match[0].strip("\" ").rstrip("\" ") for match in re.findall(pattern, message)]
|
||||
|
|
Loading…
Reference in New Issue