Skip to content

Instantly share code, notes, and snippets.

@ScottSteiner
Forked from Wunkolo/noise.py
Created January 4, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScottSteiner/479e980643406fbc0104 to your computer and use it in GitHub Desktop.
Save ScottSteiner/479e980643406fbc0104 to your computer and use it in GitHub Desktop.
import xchat, re, random
import string
__module_name__ = "Noise"
__module_version__ = "1.0.0"
__module_description__ = "Generates random colored string of the length specified"
def RandomWord(Length):
charlist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&\'()*+,-./:;<=>?@[\]^_`{|}~"
word = ""
for i in range(Length):
word += (randcolor() + charlist[random.randint(0,len(charlist)-1)])
return word
def randcolor():
return ("\x02" if random.randint(0,1) == 1 else "") + ("\x1D" if random.randint(0,1) == 1 else "") + ("\x1F" if random.randint(0,1) == 1 else "") + "\x03" + str(random.randrange(2,15)) + "," + str(random.randrange(2,15))
def noise(word,word_eol,userdata):
length = 32
if len(word) > 1:
try:
length = int(word[1])
except ValueError:
length = 32
(xchat.get_context()).command("say "+RandomWord(length))
xchat.hook_command("n",noise,help="/n (number)")
print "Noise script by DEElekgolo loaded. use \\n (number) to generate colored text noise"
import xchat, re, string
__module_name__ = "Rainbow"
__module_version__ = "2.0.0"
__module_description__ = "Generates rainbow colored versions of the text you enter. Post it for the specified line-count"
def Rainbow(text,offset):
colorlist = [4,7,8,9,11,12,13,6]
rainbowed = ""
for i in range(len(text)):
rainbowed += "\x03{}{}".format(colorlist[(i+offset)%len(colorlist)], text[i])
return rainbowed
def rainbowcmd(word,word_eol,userdata):
try:
count = int(word[-1])
text = ' '.join(word[1:-1])
except ValueError:
count = 1
text = ' '.join(word[1:])
for i in range(0,count):
(xchat.get_context()).command("say {}".format(Rainbow(text,i)))
xchat.hook_command("r",rainbowcmd,help="/r (text) (line count)")
print("Rainbow script by DEElekgolo loaded. use /r (text) (count) to generate rainbow-ed text")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment