diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2018-12-01 02:15:35 +0000 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2019-12-27 18:56:27 +0100 |
commit | e8450bcf518040dbc69fc0e55b3bfc5e8612aaa2 (patch) | |
tree | 4e1bcf07d2d9fd99f42e9b5a34d1b46b774a62f1 /plugins/omemo_plugin.py | |
parent | bab9d1625b27d6622b5566937488172df8e58ba5 (diff) | |
download | poezio-e8450bcf518040dbc69fc0e55b3bfc5e8612aaa2.tar.gz poezio-e8450bcf518040dbc69fc0e55b3bfc5e8612aaa2.tar.bz2 poezio-e8450bcf518040dbc69fc0e55b3bfc5e8612aaa2.tar.xz poezio-e8450bcf518040dbc69fc0e55b3bfc5e8612aaa2.zip |
omemo: Add dummy sending command for testing purposes
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'plugins/omemo_plugin.py')
-rw-r--r-- | plugins/omemo_plugin.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/omemo_plugin.py b/plugins/omemo_plugin.py index efd64722..c25e5fea 100644 --- a/plugins/omemo_plugin.py +++ b/plugins/omemo_plugin.py @@ -15,8 +15,11 @@ import textwrap from poezio.plugin import BasePlugin from poezio.tabs import ConversationTab from poezio.xdg import CACHE_HOME +from slixmpp import JID from slixmpp.plugins.xep_0384.plugin import MissingOwnKey +from typing import List, Optional + import logging log = logging.getLogger(__name__) @@ -66,6 +69,12 @@ class Plugin(BasePlugin): help='Clear all other OMEMO devices', ) + self.api.add_command( + 'encrypted_message', + self.send_message, + help='Send OMEMO encrypted message', + ) + self.api.add_event_handler( 'conversation_say_after', self.on_conversation_say_after, @@ -101,6 +110,31 @@ class Plugin(BasePlugin): """ self.info(textwrap.dedent(info).strip()) + def send_message(self, _args): + asyncio.ensure_future( + self._send_message( + "Hello Encrypted World!", + [JID('some@jid')], + mto=JID('some@jid'), + mtype='chat', + ), + ) + + async def _send_message( + self, + payload: str, + recipients: List[JID], + mto: Optional[JID] = None, + mtype: Optional[str] = 'chat', + ) -> None: + encrypted = await self.xmpp['xep_0384'].encrypt_message(payload, recipients) + msg = self.core.xmpp.make_message(mto, mtype=mtype) + msg['body'] = 'This message is encrypted with Legacy OMEMO (eu.siacs.conversations.axolotl)' + msg['eme']['namespace'] = 'eu.siacs.conversations.axolotl' + msg.append(encrypted) + log.debug('BAR: message: %r', msg) + msg.send() + def on_conversation_say_after(self, message, tab): """ Outbound messages |