times_up_delays = [60*10, 60*20]
times_up_sentences = [u"I stayed alive, you're too slow !!!"]
-ignored_pseudos = r'^Soldat\d+$'
-ignored_pan_masks = [("*!leger@zamok.crans.org", "jben!*@*")]
+blacklisted_masks = [("*!leger@zamok.crans.org", None)]
regexp_pan = re.compile(u".*(" + "|".join(config.killwords) + u").*")
def is_pan(chain):
return regexp_pan.match(unicode(chain,"utf8").lower())
-def ignore_pan(serv, ev):
- """Retourne ``True`` si il faut ignorer ce pan."""
- for (blackmask, exceptmask) in config.ignored_pan_masks:
+
+def ignore_event(serv, ev):
+ """Retourne ``True`` si il faut ignorer cet évènement."""
+ for (blackmask, exceptmask) in config.blacklisted_masks:
usermask = ev.source()
- return bool(irclib.mask_matches(usermask, blackmask) and not irclib.mask_matches(usermask, exceptmask))
+ 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
class UnicodeBotError(Exception):
pass
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:
self.serv.privmsg(to, "Scores by pseudo : "+" ; ".join(["%s %s"%(i[0],i[1]) for i in scores]))
def on_pubmsg(self, serv, ev):
- auteur = irclib.nm_to_n(ev.source())
- if re.match(config.ignored_pseudos, auteur):
+ if ignore_event(serv, ev):
return
+ auteur = irclib.nm_to_n(ev.source())
channel = ev.target()
message = ev.arguments()[0]
try:
self.sendscores(auteur)
else:
if is_pan(message):
- if ignore_pan(serv, ev):
- return
self.shot(channel, auteur)
def on_action(self, serv, ev):
+ if ignore_event(serv, ev):
+ return
action = ev.arguments()[0]
auteur = irclib.nm_to_n(ev.source())
channel = ev.target()