diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-11-12 00:15:00 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-11-12 00:15:00 +0100 |
commit | ccceb19c60b7874a2e003e375847ce89089410cc (patch) | |
tree | f197a79c034bd2e454b294e2f27fc3866e583158 /src/tabs.py | |
parent | 971aaada27d0385c35a2e3c2e8b5edad9a901e16 (diff) | |
parent | a6bcb244f71996de6b873a4148bff081e5fb55eb (diff) | |
download | poezio-ccceb19c60b7874a2e003e375847ce89089410cc.tar.gz poezio-ccceb19c60b7874a2e003e375847ce89089410cc.tar.bz2 poezio-ccceb19c60b7874a2e003e375847ce89089410cc.tar.xz poezio-ccceb19c60b7874a2e003e375847ce89089410cc.zip |
Merge branch 'master' of https://git.louiz.org/poezio
Diffstat (limited to 'src/tabs.py')
-rw-r--r-- | src/tabs.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tabs.py b/src/tabs.py index e0419fda..02678e7e 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -46,6 +46,7 @@ from os import getenv, path from logger import logger from datetime import datetime, timedelta +from xml.etree import cElementTree as ET SHOW_NAME = { 'dnd': _('busy'), @@ -308,6 +309,7 @@ class ChatTab(Tab): self.commands['say'] = (self.command_say, _("""Usage: /say <message>\nSay: Just send the message. Useful if you want your message to begin with a '/'."""), None) + self.commands['xhtml'] = (self.command_xhtml, _("Usage: /xhtml <custom xhtml>\nXHTML: Send custom XHTML."), None) self.chat_state = None self.update_commands() @@ -339,6 +341,29 @@ class ChatTab(Tab): self.command_say(xhtml.convert_simple_to_full_colors(txt)) self.cancel_paused_delay() + def command_xhtml(self, arg): + """" + /xhtml <custom xhtml> + """ + if not arg: + return + try: + body = xhtml.clean_text(xhtml.xhtml_to_poezio_colors(arg)) + ET.fromstring(arg) + except: + self.core.information('Could not send custom xhtml', 'Error') + return + + msg = self.core.xmpp.make_message(self.get_name()) + msg['body'] = body + msg['xhtml_im'] = arg + if isinstance(self, MucTab): + msg['type'] = 'groupchat' + if isinstance(self, ConversationTab): + self.core.add_message_to_text_buffer(self._text_buffer, body, None, self.core.own_nick) + self.refresh() + msg.send() + def send_chat_state(self, state, always_send=False): """ Send an empty chatstate message |