
XChat Text Substitutifier
By: a guest on
Jul 5th, 2012 | syntax:
Python | size: 1.20 KB | hits: 26 | expires: Never
#!/usr/bin/env python
__module_name__ = "Text Substitutifier"
__module_version__ = "0.4"
__module_description__ = "Randomly replaces a word with something you specify"
print __module_name__, "loaded"
import xchat
import random
word_filter = "penis"
activated = False
usage = """Usage: /letext <word filter>
Use no filter to deactivate"""
def init_text(word, word_eol, userdata):
global activated
if (len(word) > 1):
word_filter = word_eol[1]
activated = True
print "Filter activated"
return xchat.EAT_XCHAT
else:
if (activated):
activated = False
print "Filter deactivated"
return xchat.EAT_XCHAT
else:
print usage
def text_replace(word, word_eol, userdata):
global word_filter, activated
chance = random.randint(0,100)
if (chance > 50 and activated):
line = word[0:]
to_replace = random.randint(0, len(line))
line[(to_replace-1)] = word_filter
to_join = ["MSG", str(xchat.get_info("channel"))]
for i in line:
to_join.append(i)
command = (" ".join(to_join))
xchat.command(command)
return xchat.EAT_ALL
else:
return xchat.EAT_NONE
xchat.hook_command("", text_replace)
xchat.hook_command("TEXTSUB", init_text, help=usage)