Add three new events to modify a message JUST before we send it. It is NOT safe, and the doc says that pretty clearly. It is used to encrypt messages just before sending them (this way we can remove ALL potential in-clear bodies).
This commit is contained in:
parent
6b9d166e1c
commit
744af2459d
3 changed files with 45 additions and 0 deletions
|
@ -154,6 +154,17 @@ The handlers for this event are called whenever you say something in a MUC
|
|||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*muc_say_after*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you say something in a MUC
|
||||
(through the /say command or by direct input). The difference with muc_say is
|
||||
just that *muc_say_after* hook is called AFTER the xhtm-im body has been
|
||||
generated. So you *MUST* not insert any color attribute in the body using this
|
||||
hook. The hook is less safe that *muc_say* and most of the time you should not
|
||||
use it at all. The parameters given to the handlers are:
|
||||
|
||||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*private_say*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you say something in a private
|
||||
conversaton in a MUC (through the /say command or by direct input). The
|
||||
|
@ -162,6 +173,20 @@ The handlers for this event are called whenever you say something in a private
|
|||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*private_say_after*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you say something in a MUC
|
||||
(through the /say command or by direct input). The difference with private_say
|
||||
is just that *private_say_after* hook is called AFTER the xhtm-im body has
|
||||
been generated and the message has been displayed on the conversation, this
|
||||
means that if you modify the body, the message that will be sent will not be
|
||||
the same that the one displayed in the text buffer. So you *MUST* not insert
|
||||
any color attribute in the body using this hook. The hook is less safe that
|
||||
*private_say* and most of the time you should not use it at all. The
|
||||
parameters given to the handlers are:
|
||||
|
||||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*conversation_say*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you say something in direct
|
||||
conversation (through the /say command or by direct input). The parameters
|
||||
|
@ -170,6 +195,20 @@ The handlers for this event are called whenever you say something in direct
|
|||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*conversation_say_after*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you say something in a MUC
|
||||
(through the /say command or by direct input). The difference with
|
||||
*conversation_say* is just that *conversation_say_after* hook is called AFTER
|
||||
the xhtm-im body has been generated and the message has been displayed on the
|
||||
conversation, this means that if you modify the body, the message that will be
|
||||
sent will not be the same that the one displayed in the text buffer. So you
|
||||
*MUST* not insert any color attribute in the body using this hook. The hook is
|
||||
less safe that *conversation_say* and most of the time you should not use it at
|
||||
all. The parameters given to the handlers are:
|
||||
|
||||
* _message_: Message to be sent.
|
||||
* _tab_: Tab in which the message will be sent.
|
||||
|
||||
*muc_msg*:: +message+, +tab+ +
|
||||
The handlers for this event are called whenever you receive a message in a MUC.
|
||||
The parameters given to the handler are:
|
||||
|
|
|
@ -22,8 +22,11 @@ class EventHandler(object):
|
|||
self.events = {
|
||||
'highlight': [],
|
||||
'muc_say': [],
|
||||
'muc_say_after': [],
|
||||
'conversation_say': [],
|
||||
'conversation_say_after': [],
|
||||
'private_say': [],
|
||||
'private_say_after': [],
|
||||
'conversation_msg': [],
|
||||
'private_msg': [],
|
||||
'muc_msg': [],
|
||||
|
|
|
@ -771,6 +771,7 @@ class MucTab(ChatTab):
|
|||
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||
msg['chat_state'] = needed
|
||||
self.cancel_paused_delay()
|
||||
self.core.events.trigger('muc_say_after', msg, self)
|
||||
msg.send()
|
||||
self.chat_state = needed
|
||||
|
||||
|
@ -1268,6 +1269,7 @@ class PrivateTab(ChatTab):
|
|||
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'
|
||||
msg['chat_state'] = needed
|
||||
self.core.events.trigger('private_say_after', msg, self)
|
||||
msg.send()
|
||||
self.cancel_paused_delay()
|
||||
self.text_win.refresh()
|
||||
|
@ -1958,6 +1960,7 @@ class ConversationTab(ChatTab):
|
|||
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'
|
||||
msg['chat_state'] = needed
|
||||
self.core.events.trigger('conversation_say_after', msg, self)
|
||||
msg.send()
|
||||
logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)
|
||||
self.cancel_paused_delay()
|
||||
|
|
Loading…
Reference in a new issue