diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-16 11:36:08 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-17 21:28:31 +0200 |
commit | 3a5a2abeead301d4454e613ddb30da19781f2284 (patch) | |
tree | 40a4145846a01e1d677e8c0c611006571d3bd12c /src | |
parent | de567aa1d312bce9e147fa666dd11173b9c2af58 (diff) | |
download | weechat-3a5a2abeead301d4454e613ddb30da19781f2284.zip |
irc: use parsed command parameters in "332" command callback
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 6a7c714c2..2f1aa9a98 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -4602,31 +4602,30 @@ IRC_PROTOCOL_CALLBACK(331) * Callback for the IRC command "332": topic of channel. * * Command looks like: - * :server 332 mynick #channel :topic of channel + * 332 mynick #channel :topic of channel */ IRC_PROTOCOL_CALLBACK(332) { - char *pos_topic, *topic_no_color, *topic_color; + char *str_topic, *topic_no_color, *topic_color; struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; - IRC_PROTOCOL_MIN_ARGS(4); + IRC_PROTOCOL_MIN_PARAMS(2); - pos_topic = NULL; - if (argc >= 5) - pos_topic = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; + str_topic = (num_params >= 3) ? + irc_protocol_string_params (params, 2, num_params - 1) : NULL; - ptr_channel = irc_channel_search (server, argv[3]); + ptr_channel = irc_channel_search (server, params[1]); if (ptr_channel && ptr_channel->nicks) { - if (pos_topic) + if (str_topic) { topic_no_color = (weechat_config_boolean (irc_config_network_colors_receive)) ? - NULL : irc_color_decode (pos_topic, 0); + NULL : irc_color_decode (str_topic, 0); irc_channel_set_topic (ptr_channel, - (topic_no_color) ? topic_no_color : pos_topic); + (topic_no_color) ? topic_no_color : str_topic); if (topic_no_color) free (topic_no_color); } @@ -4636,10 +4635,11 @@ IRC_PROTOCOL_CALLBACK(332) ptr_buffer = server->buffer; topic_color = NULL; - if (pos_topic) + if (str_topic) { - topic_color = irc_color_decode (pos_topic, - (weechat_config_boolean (irc_config_network_colors_receive)) ? 1 : 0); + topic_color = irc_color_decode ( + str_topic, + (weechat_config_boolean (irc_config_network_colors_receive)) ? 1 : 0); } if (!ptr_channel @@ -4654,10 +4654,10 @@ IRC_PROTOCOL_CALLBACK(332) _("%sTopic for %s%s%s is \"%s%s%s\""), weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, - argv[3], + params[1], IRC_COLOR_RESET, IRC_COLOR_TOPIC_CURRENT, - (topic_color) ? topic_color : ((pos_topic) ? pos_topic : ""), + (topic_color) ? topic_color : ((str_topic) ? str_topic : ""), IRC_COLOR_RESET); } @@ -4667,6 +4667,9 @@ IRC_PROTOCOL_CALLBACK(332) if (ptr_channel) weechat_hashtable_set (ptr_channel->join_msg_received, command, "1"); + if (str_topic) + free (str_topic); + return WEECHAT_RC_OK; } |