File: mirror.py

package info (click to toggle)
poezio 0.16-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,124 kB
  • sloc: python: 25,093; xml: 995; ansic: 329; makefile: 200; sh: 74; javascript: 2
file content (33 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (4)
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
26
27
28
29
30
31
32
33
"""
Repeats the last message in the conversation.

Command
-------

.. glossary::

    /mirror
        **Usage:** ``/mirror``

"""
from poezio.plugin import BasePlugin
from poezio import tabs


class Plugin(BasePlugin):
    def init(self):
        for tab_type in (tabs.MucTab, tabs.PrivateTab, tabs.DynamicConversationTab, tabs.StaticConversationTab):
            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)