diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-06-18 20:23:49 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2013-06-18 20:23:49 +0200 |
commit | b5362ff7543f14bffc85dd39c5191fe91b90381c (patch) | |
tree | 45e135b20012d497acb3e611535946932edf287c /plugins | |
parent | c8700dd06e593f240f9fa43c6e6f73aae05a593c (diff) | |
download | poezio-b5362ff7543f14bffc85dd39c5191fe91b90381c.tar.gz poezio-b5362ff7543f14bffc85dd39c5191fe91b90381c.tar.bz2 poezio-b5362ff7543f14bffc85dd39c5191fe91b90381c.tar.xz poezio-b5362ff7543f14bffc85dd39c5191fe91b90381c.zip |
Add a mirror plugin
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mirror.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/mirror.py b/plugins/mirror.py new file mode 100644 index 00000000..16f2014e --- /dev/null +++ b/plugins/mirror.py @@ -0,0 +1,39 @@ +""" +Repeats the last message in the conversation. + +Installation +------------ + +You only have to load the plugin: + +.. code-block:: none + + /load mirror + +Command +------- + +.. glossary:: + + /mirror + **Usage:** ``/mirror`` + +""" +from plugin import BasePlugin +import tabs + +class Plugin(BasePlugin): + def init(self): + for tab_type in (tabs.MucTab, tabs.PrivateTab, tabs.ConversationTab): + self.api.add_tab_command(tab_type, 'mirror', + handler=self.mirror, + help='Repeat the last message from the conversation.', + short='Repeat the last message from the conversation.') + + def mirror(self, args): + messages = self.api.get_conversation_messages() + if not messages: + # Do nothing if the conversation doesn’t contain any message + return + last_message = messages[-1] + self.api.send_message(last_message.txt) |