[events] Avoid catchall hook

This commit is contained in:
nemunaire 2015-11-11 17:57:08 +01:00
parent 0f4a904a77
commit 2ebd86b80f

View File

@ -1,5 +1,3 @@
# coding=utf-8
"""Create countdowns and reminders"""
import re
@ -9,12 +7,11 @@ from nemubot import context
from nemubot.exception import IMException
from nemubot.event import ModuleEvent
from nemubot.hooks import hook
from nemubot.message import Command
from nemubot.tools.countdown import countdown_format, countdown
from nemubot.tools.date import extractDate
from nemubot.tools.xmlparser.node import ModuleState
nemubotversion = 3.4
from more import Response
def help_full ():
@ -169,9 +166,8 @@ def liste(msg):
else:
return Response("Compteurs connus : %s." % ", ".join(context.data.index.keys()), channel=msg.channel)
@hook.command()
@hook.command(match=lambda msg: isinstance(msg, Command) and msg.cmd in context.data.index)
def parseanswer(msg):
if msg.cmd in context.data.index:
res = Response(channel=msg.channel)
# Avoid message starting by ! which can be interpreted as command by other bots