irc: make default chantypes configurable

This commit is contained in:
Matti Virkkunen 2021-01-30 01:01:51 +02:00
parent dc8df133ea
commit bad6dc8a57
6 changed files with 35 additions and 4 deletions

View File

@ -26,6 +26,7 @@ New features::
* core: add option "recreate" in command /filter
* core: add evaluation of conditions in evaluation of expressions with "eval_cond:" (issue #1582)
* trigger: add variable "${tg_trigger_name}" in command trigger evaluated strings (issue #1580)
* irc: make the default chantypes to use when the server does not specify them configurable (irc.server.xxx.default_chantypes)
Bug fixes::

View File

@ -673,10 +673,13 @@ irc_channel_is_channel (struct t_irc_server *server, const char *string)
first_char[0] = string[0];
first_char[1] = '\0';
return (strpbrk (first_char,
(server && server->chantypes) ?
server->chantypes : irc_channel_default_chantypes)) ?
1 : 0;
return strpbrk(
first_char,
(server ?
(server->chantypes ?
server->chantypes :
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES))
: irc_channel_default_chantypes)) ? 1 : 0;
}
/*

View File

@ -5112,6 +5112,14 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " charset_message. . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_CHARSET_MESSAGE]));
/* chantypes */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_CHANTYPES]))
weechat_printf (NULL, " chantypes. . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES));
else
weechat_printf (NULL, " chantypes. . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_CHANTYPES]));
}
else
{

View File

@ -2434,6 +2434,23 @@ irc_config_server_new_option (struct t_config_file *config_file,
callback_change_data,
NULL, NULL, NULL);
break;
case IRC_SERVER_OPTION_DEFAULT_CHANTYPES:
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
N_("channel type prefixes to use if the server does not "
"specify them (default is #&)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
callback_check_value,
callback_check_value_pointer,
callback_check_value_data,
callback_change,
callback_change_pointer,
callback_change_data,
NULL, NULL, NULL);
break;
case IRC_SERVER_NUM_OPTIONS:
break;
}

View File

@ -119,6 +119,7 @@ char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
{ "notify", "" },
{ "split_msg_max_length", "512" },
{ "charset_message", "message" },
{ "default_chantypes", "#&" },
};
char *irc_server_casemapping_string[IRC_SERVER_NUM_CASEMAPPING] =

View File

@ -92,6 +92,7 @@ enum t_irc_server_option
IRC_SERVER_OPTION_NOTIFY, /* notify list */
IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH, /* max length of messages */
IRC_SERVER_OPTION_CHARSET_MESSAGE, /* what to decode/encode in msg */
IRC_SERVER_OPTION_DEFAULT_CHANTYPES, /* chantypes if server doesn't say */
/* number of server options */
IRC_SERVER_NUM_OPTIONS,
};