diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 36bd24665..ecd93dbe9 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -23,6 +23,7 @@ New features:: * core: add option "certs" in command /debug * api: remember insertion order in hashtables * api: add keys/values with tags in output of irc_message_parse_to_hashtable (issue #1654) + * irc: allow signals "irc_raw_in" and "irc_in" to eat messages (issue #1657) * irc: implement IRCv3.2 SASL authentication, add command /auth, reconnect by default to the server in case of SASL authentication failure (issue #413) * irc: add support of capability "message-tags" and TAGMSG messages (issue #1654) * irc: enable all capabilities by default (if supported by server and WeeChat), change default value of option irc.server_default.capabilities to "*" (issue #320) diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index c91069732..b568e9794 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -10124,7 +10124,9 @@ List of signals sent by WeeChat and plugins: String: message. | IRC message from server (before irc plugin uses it, signal sent only if message is *not* ignored). + - Since version 2.2, the whole IRC message is sent, including tags. + Since version 2.2, the whole IRC message is sent, including tags. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_in2_yyy]] xxx,irc_in2_yyy ^(1)^ | @@ -10139,7 +10141,9 @@ List of signals sent by WeeChat and plugins: String: message. | IRC message from server (before irc plugin uses it, signal sent even if message is ignored). + - Since version 2.2, the whole IRC message is sent, including tags. + Since version 2.2, the whole IRC message is sent, including tags. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_raw_in2_yyy]] xxx,irc_raw_in2_yyy ^(1)^ + diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index b6281f3c4..00161e51d 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -10329,7 +10329,9 @@ Liste des signaux envoyés par WeeChat et les extensions : Message IRC du serveur (avant utilisation par l'extension irc, signal envoyé uniquement si le message n'est *pas* ignoré). + Depuis la version 2.2, le message IRC entier est envoyé, en incluant - les étiquettes. + les étiquettes. + + Si le code retour d'une fonction de rappel est _WEECHAT_RC_OK_EAT_, alors + le message IRC est immédiatement détruit et non traité par WeeChat. | irc | [[hook_signal_xxx_irc_in2_yyy]] xxx,irc_in2_yyy ^(1)^ | @@ -10346,7 +10348,9 @@ Liste des signaux envoyés par WeeChat et les extensions : Message IRC du serveur (avant utilisation par l'extension irc, signal envoyé même si le message est ignoré). + Depuis la version 2.2, le message IRC entier est envoyé, en incluant - les étiquettes. + les étiquettes. + + Si le code retour d'une fonction de rappel est _WEECHAT_RC_OK_EAT_, alors + le message IRC est immédiatement détruit et non traité par WeeChat. | irc | [[hook_signal_xxx_irc_raw_in2_yyy]] xxx,irc_raw_in2_yyy ^(1)^ + diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index 5b2db4819..a070798f9 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -10452,7 +10452,9 @@ List of signals sent by WeeChat and plugins: Messaggio IRC dal server (prima di essere utilizzato dal plugin irc, il segnale viene inviato solo se il messaggio *non* viene ignorato). + - Since version 2.2, the whole IRC message is sent, including tags. + Since version 2.2, the whole IRC message is sent, including tags. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. // TRANSLATION MISSING | irc | @@ -10471,7 +10473,9 @@ List of signals sent by WeeChat and plugins: Messaggio IRC dal server (prima di essere utilizzato dal plugin irc, il segnale viene inviato anche se il messaggio è stato ignorato). + - Since version 2.2, the whole IRC message is sent, including tags. + Since version 2.2, the whole IRC message is sent, including tags. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. // TRANSLATION MISSING | irc | diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index cc4cf1c6b..c6929a1e7 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -10131,12 +10131,15 @@ WeeChat とプラグインが送信するシグナルのリスト: String: 削除されたスクリプトへのパスのコンマ区切りリスト | Scheme スクリプトを削除 +// TRANSLATION MISSING | irc | [[hook_signal_xxx_irc_in_yyy]] xxx,irc_in_yyy ^(1)^ | String: メッセージ | サーバから IRC メッセージを受信 (メッセージを *無視しない* 場合のみ irc プラグインがメッセージを処理する前に、シグナルが送信される) + - バージョン 2.2 以上ではタグを含めたすべての IRC メッセージが送信されます。 + バージョン 2.2 以上ではタグを含めたすべての IRC メッセージが送信されます。 + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_in2_yyy]] xxx,irc_in2_yyy ^(1)^ | @@ -10145,13 +10148,16 @@ WeeChat とプラグインが送信するシグナルのリスト: プラグインがメッセージを処理した後に、シグナルが送信される) + バージョン 2.2 以上ではタグを含めたすべての IRC メッセージが送信されます。 +// TRANSLATION MISSING | irc | [[hook_signal_xxx_irc_raw_in_yyy]] xxx,irc_raw_in_yyy ^(1)^ + _(WeeChat バージョン 0.3.2 以上で利用可)_ | String: メッセージ | サーバから IRC メッセージを受信 (メッセージを無視する場合でも irc プラグインがメッセージを処理する前に、シグナルが送信される) + - バージョン 2.2 以上ではタグを含めたすべての IRC メッセージが送信されます。 + バージョン 2.2 以上ではタグを含めたすべての IRC メッセージが送信されます。 + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_raw_in2_yyy]] xxx,irc_raw_in2_yyy ^(1)^ + diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index 86f85ccb1..b44d86d42 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -9747,12 +9747,15 @@ struct t_hook *weechat_hook_signal (const char *signal, Стринг: листа уклоњених скрипти раздвојених запетама. | Уклоњен(а/е) Scheme скрипт(а/е). +// TRANSLATION MISSING | irc | [[hook_signal_xxx_irc_in_yyy]] xxx,irc_in_yyy ^(1)^ | Стринг: порука. | IRC порука од сервера (пре него што је употреби irc додатак, сигнал се шаље само ако се порука *не* игнорише). + - Почевши од верзије 2.2, шаље се комплетна IRC порука, заједно са ознакама. + Почевши од верзије 2.2, шаље се комплетна IRC порука, заједно са ознакама. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_in2_yyy]] xxx,irc_in2_yyy ^(1)^ | @@ -9761,13 +9764,16 @@ struct t_hook *weechat_hook_signal (const char *signal, сигнал се шаље само ако се порука *не* игнорише). + Почевши од верзије 2.2, шаље се комплетна IRC порука, заједно са ознакама. +// TRANSLATION MISSING | irc | [[hook_signal_xxx_irc_raw_in_yyy]] xxx,irc_raw_in_yyy ^(1)^ + _(WeeChat ≥ 0.3.2)_ | Стринг: порука. | IRC порука од сервера (пре него што је употреби irc додатак, сигнал се шаље чак и када се порука игнорише). + - Почевши од верзије 2.2, шаље се комплетна IRC порука, заједно са ознакама. + Почевши од верзије 2.2, шаље се комплетна IRC порука, заједно са ознакама. + + If the return code of a callback is _WEECHAT_RC_OK_EAT_, then the IRC message + is immediately destroyed and not processed by WeeChat. | irc | [[hook_signal_xxx_irc_raw_in2_yyy]] xxx,irc_raw_in2_yyy ^(1)^ + diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 7cb1bfa3d..98115d261 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -6904,14 +6904,18 @@ irc_protocol_recv_command (struct t_irc_server *server, host_no_color); /* send signal with received command, even if command is ignored */ - irc_server_send_signal (server, "irc_raw_in", msg_command, - irc_message, NULL); + return_code = irc_server_send_signal (server, "irc_raw_in", msg_command, + irc_message, NULL); + if (return_code == WEECHAT_RC_OK_EAT) + goto end; /* send signal with received command, only if message is not ignored */ if (!message_ignored) { - irc_server_send_signal (server, "irc_in", msg_command, - irc_message, NULL); + return_code = irc_server_send_signal (server, "irc_in", msg_command, + irc_message, NULL); + if (return_code == WEECHAT_RC_OK_EAT) + goto end; } /* look for IRC command */ @@ -7008,14 +7012,14 @@ irc_protocol_recv_command (struct t_irc_server *server, /* send signal with received command (if message is not ignored) */ if (!message_ignored) { - irc_server_send_signal (server, "irc_in2", msg_command, - irc_message, NULL); + (void) irc_server_send_signal (server, "irc_in2", msg_command, + irc_message, NULL); } } /* send signal with received command, even if command is ignored */ - irc_server_send_signal (server, "irc_raw_in2", msg_command, - irc_message, NULL); + (void) irc_server_send_signal (server, "irc_raw_in2", msg_command, + irc_message, NULL); end: if (nick) diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 09146a92f..0312c99d9 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -2374,15 +2374,18 @@ irc_server_reorder (const char **servers, int num_servers) * Sends a signal for an IRC message (received or sent). */ -void +int irc_server_send_signal (struct t_irc_server *server, const char *signal, const char *command, const char *full_message, const char *tags) { - int length; + int rc, length; char *str_signal, *full_message_tags; - length = strlen (server->name) + 1 + strlen (signal) + 1 + strlen (command) + 1; + rc = WEECHAT_RC_OK; + + length = strlen (server->name) + 1 + strlen (signal) + 1 + + strlen (command) + 1; str_signal = malloc (length); if (str_signal) { @@ -2396,20 +2399,22 @@ irc_server_send_signal (struct t_irc_server *server, const char *signal, { snprintf (full_message_tags, length, "%s;%s", tags, full_message); - (void) weechat_hook_signal_send (str_signal, - WEECHAT_HOOK_SIGNAL_STRING, - (void *)full_message_tags); + rc = weechat_hook_signal_send (str_signal, + WEECHAT_HOOK_SIGNAL_STRING, + (void *)full_message_tags); free (full_message_tags); } } else { - (void) weechat_hook_signal_send (str_signal, - WEECHAT_HOOK_SIGNAL_STRING, - (void *)full_message); + rc = weechat_hook_signal_send (str_signal, + WEECHAT_HOOK_SIGNAL_STRING, + (void *)full_message); } free (str_signal); } + + return rc; } /* @@ -2571,14 +2576,14 @@ irc_server_outqueue_send (struct t_irc_server *server) pos[0] = '\r'; /* send signal with command that will be sent to server */ - irc_server_send_signal ( + (void) irc_server_send_signal ( server, "irc_out", server->outqueue[priority]->command, server->outqueue[priority]->message_after_mod, NULL); tags_to_send = irc_server_get_tags_to_send ( server->outqueue[priority]->tags); - irc_server_send_signal ( + (void) irc_server_send_signal ( server, "irc_outtags", server->outqueue[priority]->command, server->outqueue[priority]->message_after_mod, @@ -2779,14 +2784,16 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, } /* send signal with command that will be sent to server */ - irc_server_send_signal (server, "irc_out", - (command) ? command : "unknown", - ptr_msg, - NULL); - irc_server_send_signal (server, "irc_outtags", - (command) ? command : "unknown", - ptr_msg, - (tags_to_send) ? tags_to_send : ""); + (void) irc_server_send_signal ( + server, "irc_out", + (command) ? command : "unknown", + ptr_msg, + NULL); + (void) irc_server_send_signal ( + server, "irc_outtags", + (command) ? command : "unknown", + ptr_msg, + (tags_to_send) ? tags_to_send : ""); if (irc_server_send (server, buffer, strlen (buffer)) <= 0) rc = 0; @@ -2896,10 +2903,10 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, if (!new_msg || new_msg[0]) { /* send signal with command that will be sent to server (before split) */ - irc_server_send_signal (server, "irc_out1", - (command) ? command : "unknown", - (new_msg) ? new_msg : items[i], - NULL); + (void) irc_server_send_signal (server, "irc_out1", + (command) ? command : "unknown", + (new_msg) ? new_msg : items[i], + NULL); /* * split message if needed (max is 512 bytes by default, diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 7058f3d00..7b1ffa5a9 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -361,10 +361,10 @@ extern struct t_irc_server *irc_server_copy (struct t_irc_server *server, const char *new_name); extern int irc_server_rename (struct t_irc_server *server, const char *new_name); extern int irc_server_reorder (const char **servers, int num_servers); -extern void irc_server_send_signal (struct t_irc_server *server, - const char *signal, const char *command, - const char *full_message, - const char *tags); +extern int irc_server_send_signal (struct t_irc_server *server, + const char *signal, const char *command, + const char *full_message, + const char *tags); extern void irc_server_set_send_default_tags (const char *tags); extern struct t_hashtable *irc_server_sendf (struct t_irc_server *server, int flags,