1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Call plugins on /msg command

This commit is contained in:
James Booth 2014-01-12 21:42:18 +00:00
parent 5ea9dd8043
commit 360956cca0
2 changed files with 22 additions and 20 deletions

View File

@ -1180,49 +1180,49 @@ cmd_execute_default(const char * const inp)
recipient_jid = recipient;
}
char *new_message = plugins_on_message_send(recipient_jid, inp);
char *plugin_message = plugins_on_message_send(recipient_jid, inp);
#ifdef PROF_HAVE_LIBOTR
if (otr_is_secure(recipient)) {
char *encrypted = otr_encrypt_message(recipient, new_message);
char *encrypted = otr_encrypt_message(recipient, plugin_message);
if (encrypted != NULL) {
message_send(encrypted, recipient);
otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
ui_outgoing_msg("me", recipient, new_message);
ui_outgoing_msg("me", recipient, plugin_message);
} else {
cons_show_error("Failed to send message.");
}
} else {
message_send(new_message, recipient);
message_send(plugin_message, recipient);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
ui_outgoing_msg("me", recipient, new_message);
ui_outgoing_msg("me", recipient, plugin_message);
}
#else
message_send(new_message, recipient);
message_send(plugin_message, recipient);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
ui_outgoing_msg("me", recipient, new_message);
ui_outgoing_msg("me", recipient, plugin_message);
#endif
free(new_message);
free(plugin_message);
}
break;

View File

@ -919,47 +919,49 @@ cmd_msg(gchar **args, struct cmd_help_t help)
usr_jid = usr;
}
if (msg != NULL) {
char *plugin_message = plugins_on_message_send(usr_jid, msg);
#ifdef PROF_HAVE_LIBOTR
if (otr_is_secure(usr_jid)) {
char *encrypted = otr_encrypt_message(usr_jid, msg);
char *encrypted = otr_encrypt_message(usr_jid, plugin_message);
if (encrypted != NULL) {
message_send(encrypted, usr_jid);
otr_free_message(encrypted);
ui_outgoing_msg("me", usr_jid, msg);
ui_outgoing_msg("me", usr_jid, plugin_message);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
} else {
cons_show_error("Failed to encrypt and send message,");
}
} else {
message_send(msg, usr_jid);
ui_outgoing_msg("me", usr_jid, msg);
message_send(plugin_message, usr_jid);
ui_outgoing_msg("me", usr_jid, plugin_message);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
}
return TRUE;
#else
message_send(msg, usr_jid);
ui_outgoing_msg("me", usr_jid, msg);
message_send(plugin_message, usr_jid);
ui_outgoing_msg("me", usr_jid, plugin_message);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
return TRUE;
#endif
free(plugin_message);
} else {
const char * jid = NULL;