diff options
Diffstat (limited to 'plugins/embed.py')
-rw-r--r-- | plugins/embed.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/embed.py b/plugins/embed.py index 9895a927..4a68f035 100644 --- a/plugins/embed.py +++ b/plugins/embed.py @@ -16,6 +16,7 @@ Usage from poezio import tabs from poezio.plugin import BasePlugin from poezio.theming import get_theme +from poezio.ui.types import Message class Plugin(BasePlugin): @@ -28,21 +29,22 @@ class Plugin(BasePlugin): help='Embed an image url into the contact\'s client', usage='<image_url>') - def embed_image_url(self, args): - tab = self.api.current_tab() + def embed_image_url(self, url, tab=None): + tab = tab or self.api.current_tab() message = self.core.xmpp.make_message(tab.jid) - message['body'] = args - message['oob']['url'] = args - if isinstance(tab, tabs.MucTab): - message['type'] = 'groupchat' - else: + message['body'] = url + message['oob']['url'] = url + message['type'] = 'groupchat' + if not isinstance(tab, tabs.MucTab): 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( + message['body'], + nickname=tab.core.own_nick, + nick_color=get_theme().COLOR_OWN_NICK, + identifier=message['id'], + jid=tab.core.xmpp.boundjid, + ), ) message.send() + self.core.refresh_window() |