diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-14 21:55:08 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-17 21:28:31 +0200 |
commit | e5996f626b573e955c78dd680211700b3f5f42b3 (patch) | |
tree | 9a938c41f10b3d5090103477b51eb684a89d9862 /src/plugins/irc/irc-protocol.c | |
parent | d8c7cf41b5bee01548243f8d8f611939e27a6fd6 (diff) | |
download | weechat-e5996f626b573e955c78dd680211700b3f5f42b3.zip |
irc: use parsed command parameters in "part" command callback
Diffstat (limited to 'src/plugins/irc/irc-protocol.c')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 853900e3d..fffc4d6ab 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -2357,32 +2357,32 @@ IRC_PROTOCOL_CALLBACK(notice) * Callback for the IRC command "PART". * * Command looks like: - * :nick!user@host PART #channel :part message + * PART #channel :part message * * On undernet server, it can be: - * :nick!user@host PART :#channel - * :nick!user@host PART #channel :part message + * PART :#channel + * PART #channel :part message */ IRC_PROTOCOL_CALLBACK(part) { - char *pos_comment, *join_string; + char *str_comment, *join_string; int join_length, local_part, display_host; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; struct t_irc_channel_speaking *ptr_nick_speaking; - IRC_PROTOCOL_MIN_ARGS(3); - IRC_PROTOCOL_CHECK_PREFIX; - - pos_comment = (argc > 3) ? - ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; + IRC_PROTOCOL_MIN_PARAMS(1); + IRC_PROTOCOL_CHECK_NICK; + IRC_PROTOCOL_CHECK_ADDRESS; - ptr_channel = irc_channel_search (server, - (argv[2][0] == ':') ? argv[2] + 1 : argv[2]); + ptr_channel = irc_channel_search (server, params[0]); if (!ptr_channel) return WEECHAT_RC_OK; + str_comment = (num_params > 1) ? + irc_protocol_string_params (params, 1, num_params - 1) : NULL; + ptr_nick = irc_nick_search (server, ptr_channel, nick); local_part = (irc_server_strcasecmp (server, nick, server->nick) == 0); @@ -2398,7 +2398,7 @@ IRC_PROTOCOL_CALLBACK(part) irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL; } display_host = weechat_config_boolean (irc_config_look_display_host_quit); - if (pos_comment) + if (str_comment && str_comment[0]) { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( @@ -2428,7 +2428,7 @@ IRC_PROTOCOL_CALLBACK(part) IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_REASON_QUIT, - pos_comment, + str_comment, IRC_COLOR_CHAT_DELIMITERS); } else @@ -2523,6 +2523,9 @@ IRC_PROTOCOL_CALLBACK(part) } } + if (str_comment) + free (str_comment); + return WEECHAT_RC_OK; } |