diff --git a/hooks.py b/hooks.py index 76f50c2..9affe3c 100644 --- a/hooks.py +++ b/hooks.py @@ -138,16 +138,18 @@ class MessagesHook: def treat_answer(self, msg): """Treat a normal message""" + treated = False + # First, treat simple hook if msg.content in self.msg_hook: for h in self.msg_hook[msg.content]: - h.run(msg) + treated |= h.run(msg) self.check_rest_times(self.msg_hook, h) # Then, treat regexp based hook for hook in self.msg_rgxp: if hook.is_matching(msg.content, msg.channel): - hook.run(msg) + treated |= hook.run(msg) self.check_rest_times(self.msg_rgxp, hook) # Finally, treat default hooks if not catched before diff --git a/importer.py b/importer.py index 4277763..2d84011 100644 --- a/importer.py +++ b/importer.py @@ -214,7 +214,7 @@ def register_hooks(module, context, prompt): if hasattr(module, "parseask"): context.hooks.add_hook(context.hooks.ask_default, Hook(module.parseask)) if hasattr(module, "parselisten"): - context.hooks.add_hook(context.hooks.ask_default, Hook(module.parselisten)) + context.hooks.add_hook(context.hooks.msg_default, Hook(module.parselisten)) ########################## # # diff --git a/modules/ycc/__init__.py b/modules/ycc/__init__.py index ab53721..d96980c 100644 --- a/modules/ycc/__init__.py +++ b/modules/ycc/__init__.py @@ -19,7 +19,7 @@ def help_full (): def reload(): imp.reload(Tinyfier) -def cmd_ycc(data, msg): +def cmd_ycc(msg): global LAST_URLS if len(msg.cmd) == 1: if msg.channel in LAST_URLS and len(LAST_URLS[msg.channel]) > 0: @@ -27,7 +27,7 @@ def cmd_ycc(data, msg): t = Tinyfier.Tinyfier(url, msg) t.start() else: - msg.send_chn("%s: je n'ai pas d'autre URL reduire" % msg.nick) + msg.send_chn("%s: je n'ai pas d'autre URL à réduire" % msg.nick) else: if len(msg.cmd) < 6: for url in msg.cmd[1:]: @@ -41,7 +41,7 @@ def cmd_ycc(data, msg): LAST_URLS = dict() -def parselisten(data, msg): +def parselisten(msg): global LAST_URLS if re.match(".*(https?://|www\.)[^ ]+.*", msg.content) is not None: res = re.match(".*(((ht|f)tps?://|www\.)[^ ]+).*", msg.content)