1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

irc: create default options irc.ctcp.* when file irc.conf is created (issue #1974)

This commit is contained in:
Sébastien Helleu
2023-07-11 19:40:04 +02:00
parent 363d2d5e68
commit 5d222c8d5c
3 changed files with 44 additions and 11 deletions
+1
View File
@@ -22,6 +22,7 @@ New features::
* fset: add variable `allowed_values` in options, add options fset.color.allowed_values and fset.color.allowed_values_selected
* fset: allow long type name in type filter
* irc: display commands 716/717 in private buffer (if present) (issue #146)
* irc: create default options irc.ctcp.* when file irc.conf is created (issue #1974)
* irc: remove Git revision and compilation date from CTCP VERSION/FINGER reply (issue #1974)
* trigger: add options `-o`, `-ol`, `-i` and `-il` in command `/trigger list` (issue #1953)
+41 -11
View File
@@ -1425,10 +1425,10 @@ irc_config_reload (const void *pointer, void *data,
*/
int
irc_config_msgbuffer_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
irc_config_msgbuffer_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option;
char *name_lower;
@@ -1499,15 +1499,45 @@ irc_config_msgbuffer_create_option (const void *pointer, void *data,
return rc;
}
/*
* Writes default ctcp reply formats.
*/
int
irc_config_ctcp_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
int i;
/* make C compiler happy */
(void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (i = 0; irc_ctcp_default_reply[i].name; i++)
{
if (!weechat_config_write_line (config_file,
irc_ctcp_default_reply[i].name,
"\"%s\"",
irc_ctcp_default_reply[i].reply))
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
/*
* Sets a ctcp reply format.
*/
int
irc_config_ctcp_create_option (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
irc_config_ctcp_create_option_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option;
int rc;
@@ -3747,7 +3777,7 @@ irc_config_init ()
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
&irc_config_msgbuffer_create_option, NULL, NULL,
&irc_config_msgbuffer_create_option_cb, NULL, NULL,
NULL, NULL, NULL);
/* CTCP */
@@ -3756,8 +3786,8 @@ irc_config_init ()
1, 1,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
&irc_config_ctcp_create_option, NULL, NULL,
&irc_config_ctcp_write_default_cb, NULL, NULL,
&irc_config_ctcp_create_option_cb, NULL, NULL,
NULL, NULL, NULL);
/* ignore */
+2
View File
@@ -31,6 +31,8 @@ struct t_irc_ctcp_reply
char *reply; /* CTCP reply format */
};
extern struct t_irc_ctcp_reply irc_ctcp_default_reply[];
extern const char *irc_ctcp_get_default_reply (const char *ctcp);
extern const char *irc_ctcp_get_reply (struct t_irc_server *server,
const char *ctcp);