summaryrefslogtreecommitdiff
path: root/plugins/shuffle.py
blob: 55f5cad2f6a0268d157e28fe0dced26d0b161905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
Shuffle the words in every message you send in a :ref:`muctab`
(may confuse the reader).

Installation
------------

You only have to load the plugin:

.. code-block:: none

    /load shuffle

"""
from plugin import BasePlugin
from random import shuffle

class Plugin(BasePlugin):
    def init(self):
        self.api.add_event_handler('muc_say', self.shuffle)

    def shuffle(self, msg, tab):
        split = msg['body'].split()
        shuffle(split)
        msg['body'] = ' '.join(split)