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:
parent
5ea9dd8043
commit
360956cca0
@ -1180,49 +1180,49 @@ cmd_execute_default(const char * const inp)
|
|||||||
recipient_jid = recipient;
|
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
|
#ifdef PROF_HAVE_LIBOTR
|
||||||
if (otr_is_secure(recipient)) {
|
if (otr_is_secure(recipient)) {
|
||||||
char *encrypted = otr_encrypt_message(recipient, new_message);
|
char *encrypted = otr_encrypt_message(recipient, plugin_message);
|
||||||
if (encrypted != NULL) {
|
if (encrypted != NULL) {
|
||||||
message_send(encrypted, recipient);
|
message_send(encrypted, recipient);
|
||||||
otr_free_message(encrypted);
|
otr_free_message(encrypted);
|
||||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_outgoing_msg("me", recipient, new_message);
|
ui_outgoing_msg("me", recipient, plugin_message);
|
||||||
} else {
|
} else {
|
||||||
cons_show_error("Failed to send message.");
|
cons_show_error("Failed to send message.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message_send(new_message, recipient);
|
message_send(plugin_message, recipient);
|
||||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_outgoing_msg("me", recipient, new_message);
|
ui_outgoing_msg("me", recipient, plugin_message);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
message_send(new_message, recipient);
|
message_send(plugin_message, recipient);
|
||||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_outgoing_msg("me", recipient, new_message);
|
ui_outgoing_msg("me", recipient, plugin_message);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
free(new_message);
|
free(plugin_message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -919,47 +919,49 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
usr_jid = usr;
|
usr_jid = usr;
|
||||||
}
|
}
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
|
char *plugin_message = plugins_on_message_send(usr_jid, msg);
|
||||||
#ifdef PROF_HAVE_LIBOTR
|
#ifdef PROF_HAVE_LIBOTR
|
||||||
if (otr_is_secure(usr_jid)) {
|
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) {
|
if (encrypted != NULL) {
|
||||||
message_send(encrypted, usr_jid);
|
message_send(encrypted, usr_jid);
|
||||||
otr_free_message(encrypted);
|
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)) {
|
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cons_show_error("Failed to encrypt and send message,");
|
cons_show_error("Failed to encrypt and send message,");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message_send(msg, usr_jid);
|
message_send(plugin_message, usr_jid);
|
||||||
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)) {
|
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
message_send(msg, usr_jid);
|
message_send(plugin_message, usr_jid);
|
||||||
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)) {
|
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||||
const char *jid = jabber_get_fulljid();
|
const char *jid = jabber_get_fulljid();
|
||||||
Jid *jidp = jid_create(jid);
|
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);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
free(plugin_message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const char * jid = NULL;
|
const char * jid = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user