From 7ec72fd6c3de373c660a87245fd8d56f81a9b786 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Tue, 18 Jun 2013 19:33:35 +0200 Subject: [PATCH] Fonction de blacklist --- salesman.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/salesman.py b/salesman.py index 0897151..9717cbf 100755 --- a/salesman.py +++ b/salesman.py @@ -52,6 +52,16 @@ def log(serveur,channel,auteur=None,message=None): print chain f.close() +def ignore_event(serv, ev): + """Retourne ``True`` si il faut ignorer cet évènement.""" + for (blackmask, exceptmask) in config.blacklisted_masks: + usermask = ev.source() + if exceptmask is None: + exceptit = False + else: + exceptit = bool(irclib.mask_matches(usermask, exceptmask)) + blackit = bool(irclib.mask_matches(usermask, blackmask)) + return blackit and not exceptit def reussi(message,answer,auteur): if auteur in config.level3: @@ -185,6 +195,8 @@ class Salesman(ircbot.SingleServerIRCBot): return (False,message) def on_privmsg(self, serv, ev): + if ignore_event(serv, ev): + return message=ev.arguments()[0] auteur = irclib.nm_to_n(ev.source()) try: @@ -431,6 +443,8 @@ class Salesman(ircbot.SingleServerIRCBot): serv.privmsg(auteur,"Je n'ai pas compris. Essaye HELP…") def on_pubmsg(self, serv, ev): + if ignore_event(serv, ev): + return auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] -- 2.39.2