diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-10 18:27:18 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-17 21:28:30 +0200 |
commit | cbc40738158f4b230de612500bae91aafa30d27f (patch) | |
tree | 5b6b071e0cd2d497d6b5b86f643309d049dd0c00 | |
parent | c4b4d80936b5b1fe9f179a481f5c3a325ff8e42e (diff) | |
download | weechat-cbc40738158f4b230de612500bae91aafa30d27f.zip |
irc: send parsed parameters to IRC command callbacks
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 56 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.h | 9 |
2 files changed, 50 insertions, 15 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index d6a5800cb..bc2b84e55 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3326,7 +3326,8 @@ IRC_PROTOCOL_CALLBACK(001) irc_protocol_cb_numeric (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); /* connection to IRC server is OK! */ server->is_connected = 1; @@ -3448,7 +3449,8 @@ IRC_PROTOCOL_CALLBACK(005) irc_protocol_cb_numeric (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); /* save prefix */ pos = strstr (argv_eol[3], "PREFIX="); @@ -6005,7 +6007,8 @@ IRC_PROTOCOL_CALLBACK(432) irc_protocol_cb_generic_error (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); if (!server->is_connected) { @@ -6090,8 +6093,9 @@ IRC_PROTOCOL_CALLBACK(433) { return irc_protocol_cb_generic_error (server, date, tags, nick, address, host, - command, ignored, argc, argv, - argv_eol); + command, ignored, + argc, argv, argv_eol, + params, num_params); } return WEECHAT_RC_OK; @@ -6111,7 +6115,8 @@ IRC_PROTOCOL_CALLBACK(437) irc_protocol_cb_generic_error (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); if (!server->is_connected) { @@ -6213,7 +6218,8 @@ IRC_PROTOCOL_CALLBACK(470) irc_protocol_cb_generic_error (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); if ((argc >= 5) && !irc_channel_search (server, argv[3])) { @@ -6700,7 +6706,8 @@ IRC_PROTOCOL_CALLBACK(901) { irc_protocol_cb_numeric (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); } return WEECHAT_RC_OK; @@ -6723,7 +6730,8 @@ IRC_PROTOCOL_CALLBACK(sasl_end_ok) irc_protocol_cb_numeric (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); if (!server->is_connected) irc_server_sendf (server, 0, NULL, "CAP END"); @@ -6752,7 +6760,8 @@ IRC_PROTOCOL_CALLBACK(sasl_end_fail) irc_protocol_cb_numeric (server, date, tags, nick, address, host, command, - ignored, argc, argv, argv_eol); + ignored, argc, argv, argv_eol, + params, num_params); sasl_fail = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_FAIL); if (!server->is_connected @@ -6786,8 +6795,8 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *msg_channel) { int i, cmd_found, return_code, argc, decode_color, keep_trailing_spaces; - int message_ignored, flags; - char *message_colors_decoded, *pos_space, *tags; + int message_ignored, flags, num_params; + char *message_colors_decoded, *pos_space, *tags, **params; struct t_irc_channel *ptr_channel; t_irc_recv_func *cmd_recv_func; const char *cmd_name, *ptr_msg_after_tags; @@ -7110,7 +7119,9 @@ irc_protocol_recv_command (struct t_irc_server *server, } } else + { message_colors_decoded = NULL; + } argv = weechat_string_split (message_colors_decoded, " ", NULL, WEECHAT_STRING_SPLIT_STRIP_LEFT | WEECHAT_STRING_SPLIT_STRIP_RIGHT @@ -7124,10 +7135,29 @@ irc_protocol_recv_command (struct t_irc_server *server, argv_eol = weechat_string_split (message_colors_decoded, " ", NULL, flags, 0, NULL); + irc_message_parse (server, + message_colors_decoded, + NULL, /* tags */ + NULL, /* message_without_tags */ + NULL, /* nick */ + NULL, /* user */ + NULL, /* host */ + NULL, /* command */ + NULL, /* channel */ + NULL, /* arguments */ + NULL, /* text */ + ¶ms, + &num_params, + NULL, /* pos_command */ + NULL, /* pos_arguments */ + NULL, /* pos_channel */ + NULL); /* pos_text */ + return_code = (int) (cmd_recv_func) (server, date, hash_tags, nick, address_color, host_color, cmd_name, message_ignored, - argc, argv, argv_eol); + argc, argv, argv_eol, + params, num_params); if (return_code == WEECHAT_RC_ERROR) { diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h index c34b4bdae..95e0aca3a 100644 --- a/src/plugins/irc/irc-protocol.h +++ b/src/plugins/irc/irc-protocol.h @@ -34,7 +34,9 @@ int ignored, \ int argc, \ char **argv, \ - char **argv_eol) + char **argv_eol, \ + char **params, \ + int num_params) #define IRCB(__message, __decode_color, __keep_trailing_spaces, \ __func_cb) \ { #__message, \ @@ -52,6 +54,8 @@ (void) ignored; \ (void) argv; \ (void) argv_eol; \ + (void) params; \ + (void) num_params; \ if (argc < __min_args) \ { \ weechat_printf (server->buffer, \ @@ -81,7 +85,8 @@ typedef int (t_irc_recv_func)(struct t_irc_server *server, const char *nick, const char *address, const char *host, const char *command, int ignored, - int argc, char **argv, char **argv_eol); + int argc, char **argv, char **argv_eol, + char **params, int num_params); struct t_irc_protocol_msg { |