diff options
author | Nils Görs <weechatter@arcor.de> | 2012-12-05 18:32:30 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-12-05 18:32:30 +0100 |
commit | dd99a1cf2cefb6eb5adcbd3235655268b8b1d9c1 (patch) | |
tree | 2e48bcbef7acaff21f2bbe1e8300a6442915f9e9 /src/plugins/irc/irc-command.c | |
parent | 2ce90d4094111e7596bef599d6e930dfea67005f (diff) | |
download | weechat-dd99a1cf2cefb6eb5adcbd3235655268b8b1d9c1.zip |
irc: add option "-auto" for command /connect (task #9340)
Diffstat (limited to 'src/plugins/irc/irc-command.c')
-rw-r--r-- | src/plugins/irc/irc-command.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 20c0c0ec7..396b7e257 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -763,7 +763,7 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { int i, nb_connect, connect_ok, all_servers, all_opened, switch_address; - int no_join; + int no_join, autoconnect; char *name; IRC_BUFFER_GET_SERVER(buffer); @@ -778,6 +778,7 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, all_opened = 0; switch_address = 0; no_join = 0; + autoconnect = 0; for (i = 1; i < argc; i++) { if (weechat_strcasecmp (argv[i], "-all") == 0) @@ -788,6 +789,8 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, switch_address = 1; else if (weechat_strcasecmp (argv[i], "-nojoin") == 0) no_join = 1; + else if (weechat_strcasecmp (argv[i], "-auto") == 0) + autoconnect = 1; } if (all_opened) @@ -823,6 +826,23 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, } return (connect_ok) ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; } + else if (autoconnect) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + if (!ptr_server->is_connected && (!ptr_server->hook_connect) + && (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOCONNECT))) + { + if (!irc_command_connect_one_server (ptr_server, + switch_address, no_join)) + { + connect_ok = 0; + } + } + } + return (connect_ok) ? WEECHAT_RC_OK : WEECHAT_RC_ERROR; + } else { nb_connect = 0; @@ -5108,7 +5128,7 @@ irc_command_init () N_("connect to IRC server(s)"), N_("<server> [<server>...] [-<option>[=<value>]] " "[-no<option>] [-nojoin] [-switch]" - " || -all|-open [-nojoin] [-switch]"), + " || -all|-auto|-open [-nojoin] [-switch]"), N_(" server: server name, which can be:\n" " - internal server name (created by " "/server add, recommended usage)\n" @@ -5124,6 +5144,8 @@ irc_command_init () "example: -nossl)\n" " -all: connect to all servers defined in " "configuration\n" + " -auto: connect to servers with autoconnect " + "enabled\n" " -open: connect to all opened servers that " "are not currently connected\n" " -nojoin: do not join any channel (even if " @@ -5137,7 +5159,7 @@ irc_command_init () " /connect my.server.org/6697 -ssl -password=test\n" " /connect irc://nick@irc.oftc.net/#channel\n" " /connect -switch"), - "%(irc_servers)|-all|-open|-nojoin|-switch|%*", + "%(irc_servers)|-all|-auto|-open|-nojoin|-switch|%*", &irc_command_connect, NULL); weechat_hook_command ("ctcp", N_("send a CTCP message (Client-To-Client Protocol)"), |