Fixed some bugs, added rainbow, etc.

This commit is contained in:
Jeremy Fincher 2004-07-22 19:10:30 +00:00
parent 9e6a3ed094
commit 01435e1399

View File

@ -41,6 +41,7 @@ import plugins
import re import re
import string import string
import random import random
import itertools
import conf import conf
import utils import utils
@ -335,10 +336,11 @@ class Filter(callbacks.Privmsg):
text = privmsgs.getArgs(args) text = privmsgs.getArgs(args)
irc.reply(text[::-1]) irc.reply(text[::-1])
def _color(self, c): def _color(self, c, fg=None):
if c == ' ': if c == ' ':
return c return c
fg = str(random.randint(2, 15)).zfill(2) if fg is None:
fg = str(random.randint(2, 15)).zfill(2)
return '\x03%s%s' % (fg, c) return '\x03%s%s' % (fg, c)
def colorize(self, irc, msg, args): def colorize(self, irc, msg, args):
@ -350,6 +352,16 @@ class Filter(callbacks.Privmsg):
L = [self._color(c) for c in text] L = [self._color(c) for c in text]
irc.reply('%s%s' % (''.join(L), '\x03')) irc.reply('%s%s' % (''.join(L), '\x03'))
def rainbow(self, irc, msg, args):
"""<text>
Returns <text> colorized like a rainbow.
"""
colors = itertools.cycle([4, 7, 8, 3, 2, 12, 6])
text = privmsgs.getArgs(args)
L = [self._color(c, fg=colors.next()) for c in text]
irc.reply(''.join(L) + '\x03')
def stripcolor(self, irc, msg, args): def stripcolor(self, irc, msg, args):
"""<text> """<text>
@ -363,7 +375,7 @@ class Filter(callbacks.Privmsg):
Returns <text> as if an AOLuser had said it. Returns <text> as if an AOLuser had said it.
""" """
text = privmsg.getArgs(args) text = privmsgs.getArgs(args)
text = text.replace(' you ', ' u ') text = text.replace(' you ', ' u ')
text = text.replace(' are ', ' r ') text = text.replace(' are ', ' r ')
text = text.replace(' love ', ' <3 ') text = text.replace(' love ', ' <3 ')
@ -371,15 +383,18 @@ class Filter(callbacks.Privmsg):
text = text.replace(' too ', ' 2 ') text = text.replace(' too ', ' 2 ')
text = text.replace(' to ', ' 2 ') text = text.replace(' to ', ' 2 ')
text = text.replace(' two ', ' 2 ') text = text.replace(' two ', ' 2 ')
text = text.replace('fore', '4')
text = text.replace(' for ', ' 4 ') text = text.replace(' for ', ' 4 ')
text = text.replace(' be ', ' b ') text = text.replace('be', 'b')
text = text.replace(' four ', ' 4 ') text = text.replace('four', ' 4 ')
text = text.replace(' their ', ' there ')
text = text.replace(', ', ' ') text = text.replace(', ', ' ')
text = text.replace(',', ' ') text = text.replace(',', ' ')
text = text.replace("'", '') text = text.replace("'", '')
text = text.replace(' their ', ' there ') text = text.replace('one', '1')
smiley = random.choice(['<3', ':)', ':-)', ':D', ':-D']) smiley = random.choice(['<3', ':)', ':-)', ':D', ':-D'])
text += smiley*3 text += smiley*3
irc.reply(text)
def jeffk(self, irc, msg, args): def jeffk(self, irc, msg, args):
"""<text> """<text>