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