2013-11-09 18:22:51 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
rainbow.py - Rainbows
|
|
|
|
Copyright 2013, sfan5
|
|
|
|
"""
|
|
|
|
import random
|
|
|
|
|
2014-01-04 16:06:51 +01:00
|
|
|
rainbowcolors = ["4", "7", "8", "3", "12", "6", "13"]
|
2014-06-22 12:32:15 +02:00
|
|
|
#maybe TODO: make this rainbow better (can't really make it that better because IRC colors suck)
|
2014-01-04 16:06:51 +01:00
|
|
|
|
2013-11-09 18:22:51 +01:00
|
|
|
def colorize(text):
|
|
|
|
out = ""
|
2014-01-04 16:06:51 +01:00
|
|
|
i = 0
|
2014-01-04 16:19:19 +01:00
|
|
|
j = 0
|
2013-11-09 18:22:51 +01:00
|
|
|
for c in text:
|
2013-11-09 20:53:47 +01:00
|
|
|
if c in list(str(i) for i in range(10)):
|
|
|
|
c = u"\u200b" + c # 'ZERO WIDTH SPACE' cuz IRC clients are stupid
|
2014-01-04 16:06:51 +01:00
|
|
|
out += "\x03" + str(rainbowcolors[i]) + c
|
2014-01-04 16:19:19 +01:00
|
|
|
j += 1
|
|
|
|
if j >= 3:
|
|
|
|
i += 1
|
|
|
|
j = 0
|
2014-01-04 16:06:51 +01:00
|
|
|
if i >= len(rainbowcolors):
|
|
|
|
i = 0
|
2013-11-09 18:22:51 +01:00
|
|
|
return out
|
|
|
|
|
|
|
|
def rainbow(phenny, input):
|
|
|
|
arg = input.group(2)
|
|
|
|
if not arg:
|
2013-11-09 20:53:47 +01:00
|
|
|
return phenny.say(colorize("Rainbow") + "\x03 What?")
|
2013-11-11 18:50:13 +01:00
|
|
|
if arg.startswith("#") and ' ' in arg and input.admin:
|
|
|
|
ch = arg.split(" ")[0]
|
|
|
|
arg = " ".join(arg.split(" ")[1:])
|
|
|
|
phenny.write(['PRIVMSG', ch], colorize(arg))
|
|
|
|
else:
|
|
|
|
phenny.say(colorize(arg))
|
2013-11-09 18:22:51 +01:00
|
|
|
|
|
|
|
rainbow.commands = ['rainbow']
|