1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 08:13:14 +02:00

irc: add server option "autojoin_delay" (closes #862)

The server option "autojoin_delay" adds a delay before autojoin.

The server option "command_delay" is now used to add a delay before the
execution of the command.

On upgrade from an old version, the option "command_delay" is copied to
"autojoin_delay" (in old versions, "command_delay" was applied after the
execution of command and before the autojoin).
This commit is contained in:
Sébastien Helleu
2024-02-11 09:12:57 +01:00
parent f153b6e6c3
commit 0cfc61a17e
23 changed files with 409 additions and 179 deletions
+8 -52
View File
@@ -4004,10 +4004,7 @@ IRC_PROTOCOL_CALLBACK(warn)
IRC_PROTOCOL_CALLBACK(001)
{
char **commands, **ptr_command, *command2, *command3, *slash_command;
char *away_msg, *usermode;
const char *ptr_server_command;
int length;
IRC_PROTOCOL_MIN_PARAMS(1);
@@ -4061,57 +4058,16 @@ IRC_PROTOCOL_CALLBACK(001)
free (usermode);
/* execute command when connected */
ptr_server_command = IRC_SERVER_OPTION_STRING(ctxt->server,
IRC_SERVER_OPTION_COMMAND);
if (ptr_server_command && ptr_server_command[0])
{
/* split command on ';' which can be escaped with '\;' */
commands = weechat_string_split_command (ptr_server_command, ';');
if (commands)
{
for (ptr_command = commands; *ptr_command; ptr_command++)
{
command2 = irc_server_eval_expression (ctxt->server, *ptr_command);
if (command2)
{
command3 = irc_message_replace_vars (ctxt->server, NULL,
command2);
if (command3)
{
if (weechat_string_is_command_char (command3))
{
weechat_command (ctxt->server->buffer, command3);
}
else
{
length = 1 + strlen (command3) + 1;
slash_command = malloc (length);
if (slash_command)
{
snprintf (slash_command, length,
"/%s", command3);
weechat_command (ctxt->server->buffer,
slash_command);
free (slash_command);
}
}
free (command3);
}
free (command2);
}
}
weechat_string_free_split_command (commands);
}
if (IRC_SERVER_OPTION_INTEGER(ctxt->server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0)
ctxt->server->command_time = time (NULL) + 1;
else
irc_server_autojoin_channels (ctxt->server);
}
if (IRC_SERVER_OPTION_INTEGER(ctxt->server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0)
ctxt->server->command_time = time (NULL) + 1;
else
irc_server_execute_command (ctxt->server);
/* auto-join of channels */
if (IRC_SERVER_OPTION_INTEGER(ctxt->server, IRC_SERVER_OPTION_AUTOJOIN_DELAY) > 0)
ctxt->server->autojoin_time = time (NULL) + 1;
else
{
irc_server_autojoin_channels (ctxt->server);
}
return WEECHAT_RC_OK;
}