From b5362ff7543f14bffc85dd39c5191fe91b90381c Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 18 Jun 2013 20:23:49 +0200 Subject: Add a mirror plugin --- plugins/mirror.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 plugins/mirror.py 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) -- cgit v1.2.3