Avoid catchall DirectAsk
This commit is contained in:
parent
7ae7e381c3
commit
e83c4091bf
|
@ -14,9 +14,11 @@ from nemubot.tools.xmlparser.node import ModuleState
|
|||
|
||||
from more import Response
|
||||
|
||||
|
||||
def help_full ():
|
||||
return "This module store a lot of events: ny, we, " + (", ".join(context.datas.index.keys())) + "\n!eventslist: gets list of timer\n!start /something/: launch a timer"
|
||||
|
||||
|
||||
def load(context):
|
||||
#Define the index
|
||||
context.data.setIndex("name")
|
||||
|
@ -35,6 +37,7 @@ def fini(d, strend):
|
|||
context.data.delChild(context.data.index[strend["name"]])
|
||||
context.save()
|
||||
|
||||
|
||||
@hook.command("goûter")
|
||||
def cmd_gouter(msg):
|
||||
ndate = datetime.now(timezone.utc)
|
||||
|
@ -44,6 +47,7 @@ def cmd_gouter(msg):
|
|||
"Nous avons %s de retard pour le goûter :("),
|
||||
channel=msg.channel)
|
||||
|
||||
|
||||
@hook.command("week-end")
|
||||
def cmd_we(msg):
|
||||
ndate = datetime.now(timezone.utc) + timedelta(5 - datetime.today().weekday())
|
||||
|
@ -53,6 +57,7 @@ def cmd_we(msg):
|
|||
"Youhou, on est en week-end depuis %s."),
|
||||
channel=msg.channel)
|
||||
|
||||
|
||||
@hook.command("start")
|
||||
def start_countdown(msg):
|
||||
"""!start /something/: launch a timer"""
|
||||
|
@ -132,6 +137,7 @@ def start_countdown(msg):
|
|||
msg.date.strftime("%A %d %B %Y à %H:%M:%S")),
|
||||
nick=msg.frm)
|
||||
|
||||
|
||||
@hook.command("end")
|
||||
@hook.command("forceend")
|
||||
def end_countdown(msg):
|
||||
|
@ -151,6 +157,7 @@ def end_countdown(msg):
|
|||
else:
|
||||
return Response("%s n'est pas un compteur connu."% (msg.args[0]), channel=msg.channel, nick=msg.nick)
|
||||
|
||||
|
||||
@hook.command("eventslist")
|
||||
def liste(msg):
|
||||
"""!eventslist: gets list of timer"""
|
||||
|
@ -166,6 +173,7 @@ def liste(msg):
|
|||
else:
|
||||
return Response("Compteurs connus : %s." % ", ".join(context.data.index.keys()), channel=msg.channel)
|
||||
|
||||
|
||||
@hook.command(match=lambda msg: isinstance(msg, Command) and msg.cmd in context.data.index)
|
||||
def parseanswer(msg):
|
||||
res = Response(channel=msg.channel)
|
||||
|
@ -183,11 +191,11 @@ def parseanswer(msg):
|
|||
res.append_message(countdown_format(context.data.index[msg.cmd].getDate("start"), context.data.index[msg.cmd]["msg_before"], context.data.index[msg.cmd]["msg_after"]))
|
||||
return res
|
||||
|
||||
|
||||
RGXP_ask = re.compile(r"^.*((create|new)\s+(a|an|a\s*new|an\s*other)?\s*(events?|commande?)|(nouvel(le)?|ajoute|cr[ée]{1,3})\s+(un)?\s*([eé]v[ée]nements?|commande?)).*$", re.I)
|
||||
|
||||
@hook.ask()
|
||||
@hook.ask(match=lambda msg: RGXP_ask.match(msg.text))
|
||||
def parseask(msg):
|
||||
if RGXP_ask.match(msg.text) is not None:
|
||||
name = re.match("^.*!([^ \"'@!]+).*$", msg.text)
|
||||
if name is None:
|
||||
raise IMException("il faut que tu attribues une commande à l'événement.")
|
||||
|
|
|
@ -72,9 +72,11 @@ class Bot(threading.Thread):
|
|||
|
||||
import re
|
||||
def in_ping(msg):
|
||||
if re.match("^ *(m[' ]?entends?[ -]+tu|h?ear me|do you copy|ping)", msg.message, re.I) is not None:
|
||||
return msg.respond("pong")
|
||||
self.treater.hm.add_hook(nemubot.hooks.Message(in_ping), "in", "DirectAsk")
|
||||
self.treater.hm.add_hook(nemubot.hooks.Message(in_ping,
|
||||
match=lambda msg: re.match("^ *(m[' ]?entends?[ -]+tu|h?ear me|do you copy|ping)",
|
||||
msg.message, re.I)),
|
||||
"in", "DirectAsk")
|
||||
|
||||
def in_echo(msg):
|
||||
from nemubot.message import Text
|
||||
|
|
Loading…
Reference in New Issue
Block a user