Don't like ads? PRO users don't see any ads ;-)
Guest

XChat Text Substitutifier

By: a guest on Jul 5th, 2012  |  syntax: Python  |  size: 1.20 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python
  2. __module_name__ = "Text Substitutifier"
  3. __module_version__ = "0.4"
  4. __module_description__ = "Randomly replaces a word with something you specify"
  5. print __module_name__, "loaded"
  6.  
  7. import xchat
  8. import random
  9.  
  10. word_filter = "penis"
  11. activated = False
  12.  
  13. usage = """Usage: /letext <word filter>
  14. Use no filter to deactivate"""
  15.  
  16. def init_text(word, word_eol, userdata):
  17.         global activated
  18.         if (len(word) > 1):
  19.                 word_filter = word_eol[1]
  20.                 activated = True
  21.                 print "Filter activated"
  22.                 return xchat.EAT_XCHAT
  23.         else:
  24.                 if (activated):
  25.                         activated = False
  26.                         print "Filter deactivated"
  27.                         return xchat.EAT_XCHAT
  28.                 else:
  29.                         print usage
  30.  
  31. def text_replace(word, word_eol, userdata):
  32.         global word_filter, activated
  33.         chance = random.randint(0,100)
  34.         if (chance > 50 and activated):
  35.                 line = word[0:]
  36.                 to_replace = random.randint(0, len(line))
  37.                 line[(to_replace-1)] = word_filter
  38.                 to_join = ["MSG", str(xchat.get_info("channel"))]
  39.                 for i in line:
  40.                         to_join.append(i)
  41.                 command = (" ".join(to_join))
  42.                 xchat.command(command)
  43.                 return xchat.EAT_ALL
  44.         else:
  45.                 return xchat.EAT_NONE
  46.  
  47. xchat.hook_command("", text_replace)
  48. xchat.hook_command("TEXTSUB", init_text, help=usage)