trigger events *_say BEFORE generating the xhtml, making it possible to add colors in the hook
This commit is contained in:
parent
15780364cf
commit
36cd91dc9c
1 changed files with 24 additions and 16 deletions
40
src/tabs.py
40
src/tabs.py
|
@ -715,14 +715,16 @@ class MucTab(ChatTab):
|
||||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||||
msg = self.core.xmpp.make_message(self.get_name())
|
msg = self.core.xmpp.make_message(self.get_name())
|
||||||
msg['type'] = 'groupchat'
|
msg['type'] = 'groupchat'
|
||||||
if line.find('\x19') == -1:
|
msg['body'] = line
|
||||||
msg['body'] = line
|
# trigger the event BEFORE looking for colors.
|
||||||
else:
|
# This lets a plugin insert \x19xxx} colors, that will
|
||||||
msg['body'] = xhtml.clean_text(line)
|
# be converted in xhtml.
|
||||||
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
|
self.core.events.trigger('muc_say', msg)
|
||||||
|
if msg['body'].find('\x19') != -1:
|
||||||
|
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
|
||||||
|
msg['body'] = xhtml.clean_text(msg['body'])
|
||||||
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||||
msg['chat_state'] = needed
|
msg['chat_state'] = needed
|
||||||
self.core.events.trigger('muc_say', msg)
|
|
||||||
self.cancel_paused_delay()
|
self.cancel_paused_delay()
|
||||||
msg.send()
|
msg.send()
|
||||||
self.chat_state = needed
|
self.chat_state = needed
|
||||||
|
@ -1208,11 +1210,14 @@ class PrivateTab(ChatTab):
|
||||||
return
|
return
|
||||||
msg = self.core.xmpp.make_message(self.get_name())
|
msg = self.core.xmpp.make_message(self.get_name())
|
||||||
msg['type'] = 'chat'
|
msg['type'] = 'chat'
|
||||||
if line.find('\x19') == -1:
|
msg['body'] = line
|
||||||
msg['body'] = line
|
# trigger the event BEFORE looking for colors.
|
||||||
else:
|
# This lets a plugin insert \x19xxx} colors, that will
|
||||||
msg['body'] = xhtml.clean_text(line)
|
# be converted in xhtml.
|
||||||
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
|
self.core.events.trigger('private_say', msg)
|
||||||
|
if msg['body'].find('\x19') != -1:
|
||||||
|
msg['body'] = xhtml.clean_text(msg['body'])
|
||||||
|
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
|
||||||
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||||
msg['chat_state'] = needed
|
msg['chat_state'] = needed
|
||||||
|
@ -1872,11 +1877,14 @@ class ConversationTab(ChatTab):
|
||||||
def command_say(self, line):
|
def command_say(self, line):
|
||||||
msg = self.core.xmpp.make_message(self.get_name())
|
msg = self.core.xmpp.make_message(self.get_name())
|
||||||
msg['type'] = 'chat'
|
msg['type'] = 'chat'
|
||||||
if line.find('\x19') == -1:
|
msg['body'] = line
|
||||||
msg['body'] = line
|
# trigger the event BEFORE looking for colors.
|
||||||
else:
|
# This lets a plugin insert \x19xxx} colors, that will
|
||||||
msg['body'] = xhtml.clean_text(line)
|
# be converted in xhtml.
|
||||||
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
|
self.core.events.trigger('conversation_say', msg)
|
||||||
|
if msg['body'].find('\x19') != -1:
|
||||||
|
msg['body'] = xhtml.clean_text(msg['body'])
|
||||||
|
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
|
||||||
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||||
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
|
||||||
msg['chat_state'] = needed
|
msg['chat_state'] = needed
|
||||||
|
|
Loading…
Reference in a new issue