Add events for modifying outgoing stuff before it gets sent
Problem
I'm working on turning the otr branch into a plugin. I need to be able to encrypt the outgoing message body (I could overwrite send_message in ChatControl, but then we'd have the messages encrypted in the history) or to tell my contacts that we are about to go offline and that the encryption context is going to be invalid.
Analysis
I couldn't find a way to intercept and modify "outgoing events", i.e. outgoing messages or status changes before they actually get posted to server.
Enhancement recommendation
Create new events, e.g. "message-sending" and "status-changing". Move the actual sending code (see below) into the corresponding event handler, CORE priority. I could hook into message-sending with POSTCORE and modify the message body or the status or whatever.
My first idea would be moving CommonConnection.change_status and the callback function in Connection.send_message into event handlers.
I'll see if I can provide a patch.