diff options
author | Seve <seve@delape.net> | 2018-03-31 16:00:47 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-05-16 11:37:19 +0200 |
commit | 40bc7e66471f1b8dfc3403c282cf5a5b8ff308fe (patch) | |
tree | c013f7636666c84fdd41d8c63f649622baf59110 | |
parent | 9753b302c16af045d176d21b1b00a7de08943804 (diff) | |
download | poezio-40bc7e66471f1b8dfc3403c282cf5a5b8ff308fe.tar.gz poezio-40bc7e66471f1b8dfc3403c282cf5a5b8ff308fe.tar.bz2 poezio-40bc7e66471f1b8dfc3403c282cf5a5b8ff308fe.tar.xz poezio-40bc7e66471f1b8dfc3403c282cf5a5b8ff308fe.zip |
Initial start with the embed command
-rw-r--r-- | plugins/embed.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/embed.py b/plugins/embed.py new file mode 100644 index 00000000..717fc3c5 --- /dev/null +++ b/plugins/embed.py @@ -0,0 +1,45 @@ +""" +Display an image URL as an embedded image in some clients like Conversations. +Uses: https://xmpp.org/extensions/xep-0066.html#x-oob + +Usage +----- + +.. glossary:: + + /embed <image_url> + + Run this command to send the <image_url> as an + embedded image in your contact's client. +""" + +from poezio import tabs +from poezio.plugin import BasePlugin +from poezio.theming import get_theme + +class Plugin(BasePlugin): + + def init(self): + for tab_t in [tabs.MucTab, tabs.ConversationTab, tabs.PrivateTab]: + self.api.add_tab_command(tab_t, 'embed', self.embed_image_url, + help='Embed an image url into the contact\'s client', + usage='<image_url>') + + def embed_image_url(self, args): + tab = self.api.current_tab() + message = self.core.xmpp.make_message(tab.name) + message['body'] = args + message['oob']['url'] = args + if isinstance(tab, tabs.MucTab): + message['type'] = 'groupchat' + else: + message['type'] = 'chat' + tab.add_message( + message['body'], + nickname=tab.core.own_nick, + nick_color=get_theme().COLOR_OWN_NICK, + identifier=message['id'], + jid=tab.core.xmpp.boundjid, + typ=1, + ) + message.send() |