From 61f2df5cc32d598c2c0ab8022f8ba8b02eee0891 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 31 Aug 2015 15:52:45 +0000 Subject: [PATCH] Strip colour before applying new colour in Filter.rainbow and colorize This makes them work much better when the input text already contains colour. (cherry picked from commit jacksonmj/Limnoria@be83befabf373f551936cc623c85c1a7dde7bbaf) --- plugins/Filter/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/Filter/plugin.py b/plugins/Filter/plugin.py index bad45fa6d..267bd7147 100644 --- a/plugins/Filter/plugin.py +++ b/plugins/Filter/plugin.py @@ -393,7 +393,12 @@ class Filter(callbacks.Plugin): Returns with each character randomly colorized. """ + if minisix.PY2: + text = text.decode('utf-8') + text = ircutils.stripColor(text) L = [self._color(c) for c in text] + if minisix.PY2: + L = [c.encode('utf-8') for c in L] irc.reply('%s%s' % (''.join(L), '\x03')) colorize = wrap(colorize, ['text']) @@ -405,6 +410,7 @@ class Filter(callbacks.Plugin): """ if minisix.PY2: text = text.decode('utf-8') + text = ircutils.stripColor(text) colors = utils.iter.cycle(['05', '04', '07', '08', '09', '03', '11', '10', '12', '02', '06', '13']) L = [self._color(c, fg=next(colors)) for c in text]