summaryrefslogtreecommitdiff
path: root/plugins/shuffle.py
blob: 895c052c683ea3cb82c3d6610cc6e37186c8e49e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
Shuffle the words in every message you send in a :ref:`muctab`
(may/should confuse the reader).
"""
from poezio.plugin import BasePlugin
from random import shuffle
from poezio import xhtml


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

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