mkv

beespoiler

mkv
Apr 6th, 2013
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. __module_name__ = "beespoiler"
  2. __module_version__ = "0.1"
  3. __module_description__ = "conceal your text in a stylish bee-inspired pattern"
  4.  
  5. #    Name: Beespoiler
  6. # Authors: ed <irc.rizon.net>
  7. # Purpose: BEEEEEES
  8.  
  9. import re                                                               # RegEx, language for extracting and replacing text
  10. import xchat                                                            # opens the portal for interacting with xchat
  11. syntax = re.compile(r'\x0F\x0F([^\x0F]*)')                              # beespoiler syntax (defined with regex)
  12.  
  13. def bsp_re(m):                                                          # eats text, spits out BLACK'n YELLO'
  14.     spoiler = ""                                                        # prepare the spoiler that we'll make
  15.     text = m.group(0)                                                   # get the text extracted by regex
  16.     for position in range(0, len(text)):                                # spoiler the letters one at a time
  17.         color = 1 if position%2 else 8                                  # choose irc colour 8 for even positions, 1 for odd
  18.         spoiler += '{0}0{1},0{2}{3}'.format(                            # add all the ingredients of a single letter:
  19.                     "\x03",                                             # ...the colour control code (^C)
  20.                     color,                                              # ...the first colour
  21.                     color,                                              # ...the second colour
  22.                     text[position])                                     # ...the letter!
  23.     return spoiler
  24.  
  25. def bsp_cb(word, word_eol, userdata):                                   # SOMEONE used the /BS command!
  26.     text = word_eol[1]                                                  # get the text after the BS command itself
  27.     text = syntax.sub(bsp_re, text)                                     # let bs_re have each of the spoilers and pimp them
  28.     xchat.command('SAY {0}'.format(text))                               # send the spoilered text to the current channel
  29.     return xchat.EAT_ALL                                                # hexchat wants this for some reason, :idk:
  30.  
  31. xchat.hook_command("BSP", bsp_cb, help="/BSP some ^O^Ospoiler^O text")  # Beeeees SPoiler made into a command
Advertisement
Add Comment
Please, Sign In to add comment