From 7cbd164e759449450f38fac0d087960c3b5355b8 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 19 Aug 2000 20:14:09 +0000 Subject: If nick argument isn't given to /OPER, your current nick will be used. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@616 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-commands.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index bc1c96af..479ccfd7 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -952,6 +952,28 @@ static void sig_channel_destroyed(CHANNEL_REC *channel) } } +/* SYNTAX: OPER [] */ +static void cmd_oper(const char *data, IRC_SERVER_REC *server) +{ + char *nick, *password; + void *free_arg; + + g_return_if_fail(data != NULL); + if (server == NULL || !server->connected || !irc_server_check(server)) + cmd_return_error(CMDERR_NOT_CONNECTED); + + if (!cmd_get_params(data, &free_arg, 2, &nick, &password)) + return; + if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + if (*password == '\0') { + password = nick; + nick = server->nick; + } + + irc_send_cmdv(server, "OPER %s %s", nick, password); + cmd_params_free(free_arg); +} + static void command_self(const char *data, IRC_SERVER_REC *server) { g_return_if_fail(data != NULL); @@ -1075,8 +1097,7 @@ void irc_commands_init(void) command_bind("die", NULL, (SIGNAL_FUNC) command_self); /* SYNTAX: HASH */ command_bind("hash", NULL, (SIGNAL_FUNC) command_self); - /* SYNTAX: OPER [ []] */ - command_bind("oper", NULL, (SIGNAL_FUNC) command_self); + command_bind("oper", NULL, (SIGNAL_FUNC) cmd_oper); /* SYNTAX: RESTART */ command_bind("restart", NULL, (SIGNAL_FUNC) command_self); /* SYNTAX: RPING */ @@ -1157,7 +1178,7 @@ void irc_commands_deinit(void) command_unbind("deop", (SIGNAL_FUNC) cmd_deop); command_unbind("die", (SIGNAL_FUNC) command_self); command_unbind("hash", (SIGNAL_FUNC) command_self); - command_unbind("oper", (SIGNAL_FUNC) command_self); + command_unbind("oper", (SIGNAL_FUNC) cmd_oper); command_unbind("restart", (SIGNAL_FUNC) command_self); command_unbind("rping", (SIGNAL_FUNC) command_self); command_unbind("squit", (SIGNAL_FUNC) command_2self); -- cgit v1.2.3