summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-05-01 18:45:32 +0200
committerFlorent Le Coz <louiz@louiz.org>2013-05-01 18:45:32 +0200
commit5ff6e2a8c62c365b1d4e6d63496ae961ef2994d1 (patch)
tree4f52aef235d5455b87db18f4012eec70d3af040f
parentf5fd428ca0d18386daa87e4c674edccc6adeda1b (diff)
downloadpoezio-5ff6e2a8c62c365b1d4e6d63496ae961ef2994d1.tar.gz
poezio-5ff6e2a8c62c365b1d4e6d63496ae961ef2994d1.tar.bz2
poezio-5ff6e2a8c62c365b1d4e6d63496ae961ef2994d1.tar.xz
poezio-5ff6e2a8c62c365b1d4e6d63496ae961ef2994d1.zip
Add a new random_nick plugin
-rw-r--r--plugins/random_nick.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/random_nick.py b/plugins/random_nick.py
new file mode 100644
index 00000000..b73ec247
--- /dev/null
+++ b/plugins/random_nick.py
@@ -0,0 +1,40 @@
+"""
+This plugin makes you have a random nick when joining a MUC.
+
+Installation
+------------
+You only have to load the plugin.::
+
+ /load random_nick
+
+Usage
+-----
+
+To have a random nick, just join a room with “RANDOM” as your nick. It will
+automatically be changed to something random, for example: ::
+
+ /join coucou@conference.example.com/RANDOM
+
+"""
+
+from plugin import BasePlugin
+from tabs import MucTab
+from random import choice
+
+class Plugin(BasePlugin):
+ def init(self):
+ self.api.add_event_handler('joining_muc', self.change_nick_to_random)
+
+ def change_nick_to_random(self, presence):
+ to = presence["to"]
+ to.resource = gen_nick(3)
+ presence["to"] = to
+
+s = ["i", "ou", "ou", "on", "a", "o", "u", "i"]
+c = ["b", "c", "d", "f", "g", "h", "j", "k", "m", "l", "n", "p", "r", "s", "t", "v", "z"]
+
+def gen_nick(size):
+ res = ''
+ for i in range(size):
+ res += '%s%s' % (choice(c), choice(s))
+ return res