Skip to content

Instantly share code, notes, and snippets.

@ttepasse
Created August 21, 2009 21:50
Show Gist options
  • Save ttepasse/172460 to your computer and use it in GitHub Desktop.
Save ttepasse/172460 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Zensiert Benjamins Mutter
In den Xchat-Ordner legen (~/xchat2 oder so), um es automatisch laden zu lassen.
"""
__module_name__ = "benji"
__module_version__ = "1.0"
__module_description__ = "Zensiert Bens Mutter"
import re
import xchat
print "benjamin.py loaded!"
censorship_is_visible = True
censor_string = u"█████ ██████"
ben = re.compile(r"jamin_*$", re.U)
mama = re.compile(r"deine mutter", re.I | re.U)
def censor(word, word_eol, event_type):
username = unicode(word[0])
text = unicode(word[1], encoding='utf-8')
if ben.search(username) and mama.search(text):
if censorship_is_visible:
replacement = mama.sub(censor_string, text)
xchat.emit_print(event_type,
username.encode("utf-8"),
replacement.encode("utf-8"))
return xchat.EAT_ALL
else:
return xchat.EAT_NONE
events = ("Your Message", "Channel Message", "Channel Msg Hilight",
"Your Action", "Channel Action", "Channel Action Hilight")
for event_type in events:
xchat.hook_print(event_type, censor, event_type)
def unload(foo):
print "benjamin.py unloaded!"
xchat.hook_unload(unload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment