2013-06-18 18:23:49 +00:00
|
|
|
|
"""
|
|
|
|
|
Repeats the last message in the conversation.
|
|
|
|
|
|
|
|
|
|
Command
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
.. glossary::
|
|
|
|
|
|
|
|
|
|
/mirror
|
|
|
|
|
**Usage:** ``/mirror``
|
|
|
|
|
|
|
|
|
|
"""
|
2016-06-27 23:10:52 +00:00
|
|
|
|
from poezio.plugin import BasePlugin
|
|
|
|
|
from poezio import tabs
|
2013-06-18 18:23:49 +00:00
|
|
|
|
|
2018-08-15 11:13:17 +00:00
|
|
|
|
|
2013-06-18 18:23:49 +00:00
|
|
|
|
class Plugin(BasePlugin):
|
|
|
|
|
def init(self):
|
2019-07-19 16:55:16 +00:00
|
|
|
|
for tab_type in (tabs.MucTab, tabs.PrivateTab, tabs.DynamicConversationTab, tabs.StaticConversationTab):
|
2018-08-15 11:13:17 +00:00
|
|
|
|
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.')
|
2013-06-18 18:23:49 +00:00
|
|
|
|
|
|
|
|
|
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)
|