diff options
-rw-r--r-- | plugins/simple_notify.py | 4 | ||||
-rw-r--r-- | src/core.py | 13 | ||||
-rw-r--r-- | src/xhtml.py | 7 |
3 files changed, 12 insertions, 12 deletions
diff --git a/plugins/simple_notify.py b/plugins/simple_notify.py index a44a6902..f08fa259 100644 --- a/plugins/simple_notify.py +++ b/plugins/simple_notify.py @@ -65,7 +65,7 @@ Options defined """ from plugin import BasePlugin -from xhtml import clean_text, get_body_from_message_stanza +from xhtml import get_body_from_message_stanza from timed_events import DelayedEvent import shlex @@ -88,7 +88,7 @@ class Plugin(BasePlugin): self.do_notify(message, fro) def do_notify(self, message, fro): - body = clean_text(get_body_from_message_stanza(message)) + body = get_body_from_message_stanza(message, use_xhtml=False) if not body: return command_str = self.config.get('command', '').strip() diff --git a/src/core.py b/src/core.py index f9c6d5e3..af0c6348 100644 --- a/src/core.py +++ b/src/core.py @@ -2941,7 +2941,8 @@ class Core(object): elif message['type'] == 'headline' and message['body']: return self.information('%s says: %s' % (message['from'], message['body']), 'Headline') - body = xhtml.get_body_from_message_stanza(message) + use_xhtml = config.get('enable_xhtml_im', 'true') == 'true' + body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml) if not body: return @@ -2983,7 +2984,7 @@ class Core(object): self.events.trigger('conversation_msg', message, conversation) if not message['body']: return - body = xhtml.get_body_from_message_stanza(message) + body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml) delayed, date = common.find_delayed_tag(message) def try_modify(): @@ -3199,7 +3200,8 @@ class Core(object): return self.events.trigger('muc_msg', message, tab) - body = xhtml.get_body_from_message_stanza(message) + use_xhtml = config.get('enable_xhtml_im', 'true') == 'true' + body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml) if not body: return @@ -3246,7 +3248,8 @@ class Core(object): return self.on_groupchat_message(message) room_from = jid.bare - body = xhtml.get_body_from_message_stanza(message) + use_xhtml = config.get('enable_xhtml_im', 'true') == 'true' + body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml) tab = self.get_tab_by_name(jid.full, tabs.PrivateTab) # get the tab with the private conversation ignore = config.get_by_tabname('ignore_private', 'false', room_from).lower() == 'true' @@ -3260,7 +3263,7 @@ class Core(object): self.xmpp.send_message(mto=jid.full, mbody=msg, mtype='chat') return self.events.trigger('private_msg', message, tab) - body = xhtml.get_body_from_message_stanza(message) + body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml) if not body or not tab: return replaced_id = message['replace']['id'] diff --git a/src/xhtml.py b/src/xhtml.py index a1628574..85e764ba 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -20,9 +20,6 @@ from io import BytesIO from xml import sax from xml.sax import saxutils -from config import config -import logging - digits = '0123456789' # never trust the modules XHTML_NS = 'http://www.w3.org/1999/xhtml' @@ -184,13 +181,13 @@ xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]') xhtml_simple_attr_re = re.compile(r'\x19\d') -def get_body_from_message_stanza(message): +def get_body_from_message_stanza(message, use_xhtml=False): """ Returns a string with xhtml markups converted to poezio colors if there's an xhtml_im element, or the body (without any color) otherwise """ - if config.get('enable_xhtml_im', 'true') == 'true': + if use_xhtml: xhtml = message['html'].xml xhtml_body = xhtml.find('{http://www.w3.org/1999/xhtml}body') if xhtml_body: |