summaryrefslogtreecommitdiff
path: root/plugins/rainbow.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-09 01:26:54 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-09 01:26:54 +0100
commit75ae1772e49a59b373c26d1c942f25edd473921c (patch)
tree65d8faee081db6c3800a48eff7007a4b626e4252 /plugins/rainbow.py
parent8f02b6eb8e022ed1d34e0a0b0c7376eaf58acc32 (diff)
parent23d81901e7725bf67363113bc36a6e171bdb2033 (diff)
downloadpoezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.gz
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.bz2
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.xz
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.zip
Merge branch 'master' of http://git.louiz.org/poezio
Diffstat (limited to 'plugins/rainbow.py')
-rw-r--r--plugins/rainbow.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/rainbow.py b/plugins/rainbow.py
new file mode 100644
index 00000000..0f242027
--- /dev/null
+++ b/plugins/rainbow.py
@@ -0,0 +1,20 @@
+from plugin import BasePlugin
+import xhtml
+import random
+
+possible_colors = list(range(256))
+# remove the colors that are almost white or almost black
+for col in [16, 232, 233, 234, 235, 236, 237, 15, 231, 255, 254, 253, 252, 251]:
+ possible_colors.remove(col)
+
+def rand_color():
+ return '\x19%s}' % (random.choice(possible_colors),)
+
+class Plugin(BasePlugin):
+ def init(self):
+ self.add_poezio_event_handler('muc_say', self.rainbowize)
+ self.add_poezio_event_handler('private_say', self.rainbowize)
+ self.add_poezio_event_handler('conversation_say', self.rainbowize)
+
+ def rainbowize(self, msg):
+ msg['body'] = ''.join(['%s%s' % (rand_color(),char,) for char in xhtml.clean_text(msg['body'])])