2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
irc-commands.c : irssi
|
|
|
|
|
|
|
|
Copyright (C) 1999 Timo Sirainen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2007-05-08 14:41:10 -04:00
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2000-04-26 04:03:38 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "special-vars.h"
|
|
|
|
#include "settings.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "window-item-def.h"
|
|
|
|
|
2000-11-25 21:09:15 -05:00
|
|
|
#include "servers-reconnect.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers-redirect.h"
|
|
|
|
#include "servers-setup.h"
|
2000-09-02 14:53:58 -04:00
|
|
|
#include "nicklist.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
#include "bans.h"
|
2001-11-01 20:05:14 -05:00
|
|
|
#include "irc-commands.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "irc-servers.h"
|
|
|
|
#include "irc-channels.h"
|
|
|
|
#include "irc-queries.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-01 20:36:54 -04:00
|
|
|
/* How often to check if there's anyone to be unbanned in knockout list */
|
|
|
|
#define KNOCKOUT_TIMECHECK 10000
|
|
|
|
|
2001-01-04 03:49:48 -05:00
|
|
|
/* /LIST: Max. number of channels in IRC network before -yes option
|
|
|
|
is required */
|
|
|
|
#define LIST_MAX_CHANNELS_PASS 1000
|
|
|
|
|
2001-08-14 09:19:06 -04:00
|
|
|
/* When /PARTing a channel, if there's more messages in output queue
|
|
|
|
than this, purge the output for channel. The idea behind this is that
|
|
|
|
if you accidentally pasted some large text and /PART the channel, the
|
|
|
|
text won't be fully pasted. Note that this counter is the whole size
|
|
|
|
of the output queue, not channel specific.. */
|
|
|
|
#define MAX_COMMANDS_ON_PART_UNTIL_PURGE 10
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
typedef struct {
|
2000-08-26 11:39:44 -04:00
|
|
|
IRC_CHANNEL_REC *channel;
|
2000-04-26 04:03:38 -04:00
|
|
|
char *ban;
|
2002-03-10 09:31:07 -05:00
|
|
|
time_t unban_time;
|
2000-04-26 04:03:38 -04:00
|
|
|
} KNOCKOUT_REC;
|
|
|
|
|
|
|
|
static GString *tmpstr;
|
|
|
|
static int knockout_tag;
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: NOTICE <targets> <message> */
|
2001-11-03 13:36:40 -05:00
|
|
|
static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2002-05-15 20:34:37 -04:00
|
|
|
const char *target, *msg;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-04 09:36:51 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&target, &msg))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-11-04 09:36:51 -05:00
|
|
|
if (strcmp(target, "*") == 0)
|
2002-05-15 20:34:37 -04:00
|
|
|
target = item == NULL ? NULL : window_item_get_target(item);
|
2001-11-04 09:36:51 -05:00
|
|
|
if (*target == '\0' || *msg == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
g_string_sprintf(tmpstr, "NOTICE %s :%s", target, msg);
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: CTCP <targets> <ctcp command> [<ctcp data>] */
|
2001-11-03 13:36:40 -05:00
|
|
|
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2002-05-15 20:34:37 -04:00
|
|
|
const char *target;
|
|
|
|
char *ctcpcmd, *ctcpdata;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-04 09:36:51 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
2001-11-03 13:36:40 -05:00
|
|
|
&target, &ctcpcmd, &ctcpdata))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-11-04 09:36:51 -05:00
|
|
|
if (strcmp(target, "*") == 0)
|
2002-05-15 20:34:37 -04:00
|
|
|
target = item == NULL ? NULL : window_item_get_target(item);
|
2001-11-04 09:36:51 -05:00
|
|
|
if (*target == '\0' || *ctcpcmd == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_strup(ctcpcmd);
|
|
|
|
if (*ctcpdata == '\0')
|
|
|
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
|
2004-08-19 20:03:40 -04:00
|
|
|
else {
|
2008-02-16 18:28:53 -05:00
|
|
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
2004-08-19 20:03:40 -04:00
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: NCTCP <targets> <ctcp command> [<ctcp data>] */
|
2001-11-03 13:36:40 -05:00
|
|
|
static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2002-05-15 20:34:37 -04:00
|
|
|
const char *target;
|
2008-02-16 18:28:53 -05:00
|
|
|
char *ctcpcmd, *ctcpdata;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-03 13:36:40 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
|
|
|
&target, &ctcpcmd, &ctcpdata))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-11-04 09:36:51 -05:00
|
|
|
if (strcmp(target, "*") == 0)
|
2002-05-15 20:34:37 -04:00
|
|
|
target = item == NULL ? NULL : window_item_get_target(item);
|
2001-11-04 09:36:51 -05:00
|
|
|
if (*target == '\0' || *ctcpcmd == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_strup(ctcpcmd);
|
2008-02-16 18:28:53 -05:00
|
|
|
g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: PART [<channels>] [<message>] */
|
2001-11-03 13:36:40 -05:00
|
|
|
static void cmd_part(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *channame, *msg;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-04 13:11:59 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
|
|
|
PARAM_FLAG_OPTCHAN, item, &channame, &msg))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
2000-11-25 22:24:36 -05:00
|
|
|
if (*msg == '\0') msg = (char *) settings_get_str("part_message");
|
2001-08-14 09:19:06 -04:00
|
|
|
|
|
|
|
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
|
|
|
|
irc_server_purge_output(server, channame);
|
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
|
|
|
|
channame, msg);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: KICK [<channel>] <nicks> [<reason>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2008-02-16 18:28:53 -05:00
|
|
|
char *channame, *nicks, *reason;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-03 13:36:40 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST |
|
|
|
|
PARAM_FLAG_OPTCHAN, item,
|
|
|
|
&channame, &nicks, &reason))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
if (!ischannel(*channame)) cmd_param_error(CMDERR_NOT_JOINED);
|
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, reason);
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmd_split(server, tmpstr->str, 3, server->max_kicks_in_cmd);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TOPIC [-delete] [<channel>] [<topic>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
GHashTable *optlist;
|
|
|
|
char *channame, *topic;
|
2008-02-16 18:28:53 -05:00
|
|
|
int set = 0;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-20 06:14:15 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
2000-06-17 21:18:12 -04:00
|
|
|
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
|
|
|
|
item, "topic", &optlist, &channame, &topic))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2004-08-19 20:03:40 -04:00
|
|
|
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
|
2008-02-16 18:28:53 -05:00
|
|
|
set = 1;
|
|
|
|
irc_send_cmdv(server, !set ? "TOPIC %s" : "TOPIC %s :%s",
|
|
|
|
channame, topic);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: INVITE <nick> [<channel>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *nick, *channame;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2, &nick, &channame))
|
|
|
|
return;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
if (*channame == '\0' || strcmp(channame, "*") == 0) {
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_CHANNEL(item))
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_param_error(CMDERR_NOT_JOINED);
|
|
|
|
|
2002-05-15 20:34:37 -04:00
|
|
|
channame = IRC_CHANNEL(item)->name;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "INVITE %s %s", nick, channame);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: LIST [-yes] [<channel>] */
|
2001-01-04 03:49:48 -05:00
|
|
|
static void cmd_list(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
GHashTable *optlist;
|
|
|
|
char *str;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
2000-06-20 15:28:19 -04:00
|
|
|
PARAM_FLAG_GETREST, "list", &optlist, &str))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-04 03:49:48 -05:00
|
|
|
if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL &&
|
|
|
|
(server->channels_formed <= 0 ||
|
|
|
|
server->channels_formed > LIST_MAX_CHANNELS_PASS))
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_param_error(CMDERR_NOT_GOOD_IDEA);
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "LIST %s", str);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-03-03 19:14:00 -05:00
|
|
|
/* SYNTAX: WHO [<nicks> | <channels> | **] */
|
|
|
|
static void cmd_who(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *channel, *rest;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-20 05:21:54 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &channel, &rest))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
if (strcmp(channel, "*") == 0 || *channel == '\0') {
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_CHANNEL(item))
|
2000-06-28 13:15:37 -04:00
|
|
|
cmd_param_error(CMDERR_NOT_JOINED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-05-15 20:34:37 -04:00
|
|
|
channel = IRC_CHANNEL(item)->name;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
if (strcmp(channel, "**") == 0) {
|
|
|
|
/* ** displays all nicks.. */
|
|
|
|
*channel = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
irc_send_cmdv(server, *rest == '\0' ? "WHO %s" : "WHO %s %s",
|
|
|
|
channel, rest);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-03-03 19:14:00 -05:00
|
|
|
static void cmd_names(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2001-03-03 19:14:00 -05:00
|
|
|
GHashTable *optlist;
|
|
|
|
char *channel;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-03-03 19:14:00 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
|
|
|
PARAM_FLAG_GETREST, "names", &optlist, &channel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (strcmp(channel, "*") == 0 || *channel == '\0') {
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_CHANNEL(item))
|
2001-03-03 19:14:00 -05:00
|
|
|
cmd_param_error(CMDERR_NOT_JOINED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-05-15 20:34:37 -04:00
|
|
|
channel = IRC_CHANNEL(item)->name;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-03-03 19:14:00 -05:00
|
|
|
if (strcmp(channel, "**") == 0) {
|
|
|
|
/* ** displays all nicks.. */
|
|
|
|
irc_send_cmd(server, "NAMES");
|
|
|
|
} else {
|
|
|
|
irc_send_cmdv(server, "NAMES %s", channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-11-04 11:54:58 -05:00
|
|
|
/* SYNTAX: NICK <new nick> */
|
|
|
|
static void cmd_nick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|
|
|
{
|
|
|
|
char *nick;
|
|
|
|
void *free_arg;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-11-04 11:54:58 -05:00
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 1, &nick))
|
|
|
|
return;
|
|
|
|
|
2002-01-28 00:28:25 -05:00
|
|
|
g_free(server->last_nick);
|
|
|
|
server->last_nick = g_strdup(nick);
|
|
|
|
|
2000-11-04 11:54:58 -05:00
|
|
|
irc_send_cmdv(server, "NICK %s", nick);
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2000-06-14 15:40:23 -04:00
|
|
|
static char *get_redirect_nicklist(const char *nicks, int *free)
|
|
|
|
{
|
|
|
|
char *str, *ret;
|
|
|
|
|
|
|
|
if (strchr(nicks, ',') == NULL) {
|
|
|
|
*free = FALSE;
|
|
|
|
return (char *) nicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
*free = TRUE;
|
|
|
|
|
|
|
|
str = g_strdup(nicks);
|
|
|
|
g_strdelimit(str, ",", ' ');
|
|
|
|
ret = g_strconcat(str, " ", nicks, NULL);
|
|
|
|
g_free(str);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-03-23 15:47:51 -05:00
|
|
|
/* SYNTAX: WHOIS [-<server tag>] [<server>] [<nicks>] */
|
2000-10-14 10:37:01 -04:00
|
|
|
static void cmd_whois(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-10-13 18:34:19 -04:00
|
|
|
GHashTable *optlist;
|
2001-01-01 09:42:22 -05:00
|
|
|
char *qserver, *query, *event_402, *str;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-06-14 15:40:23 -04:00
|
|
|
int free_nick;
|
2000-06-10 17:40:00 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2004-03-23 15:47:51 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
|
|
|
PARAM_FLAG_UNKNOWN_OPTIONS,
|
2000-10-13 18:34:19 -04:00
|
|
|
"whois", &optlist, &qserver, &query))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
|
|
|
|
2004-03-23 15:47:51 -05:00
|
|
|
/* -<server tag> */
|
2004-09-12 18:45:36 -04:00
|
|
|
server = IRC_SERVER(cmd_options_get_server("whois", optlist,
|
2004-03-23 15:47:51 -05:00
|
|
|
SERVER(server)));
|
|
|
|
if (server == NULL) {
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-10 17:40:00 -04:00
|
|
|
if (*query == '\0') {
|
2000-10-13 18:34:19 -04:00
|
|
|
query = qserver;
|
2000-06-10 17:40:00 -04:00
|
|
|
qserver = "";
|
|
|
|
}
|
2000-10-14 10:37:01 -04:00
|
|
|
if (*query == '\0') {
|
|
|
|
QUERY_REC *queryitem = QUERY(item);
|
2001-01-17 15:28:42 -05:00
|
|
|
if (queryitem == NULL)
|
|
|
|
query = server->nick;
|
|
|
|
else
|
|
|
|
query = qserver = queryitem->name;
|
2000-10-14 10:37:01 -04:00
|
|
|
}
|
2000-10-13 18:34:19 -04:00
|
|
|
|
|
|
|
if (strcmp(query, "*") == 0 &&
|
|
|
|
g_hash_table_lookup(optlist, "yes") == NULL)
|
|
|
|
cmd_param_error(CMDERR_NOT_GOOD_IDEA);
|
2000-06-10 17:40:00 -04:00
|
|
|
|
2000-10-14 12:02:35 -04:00
|
|
|
event_402 = "event 402";
|
2000-06-10 17:40:00 -04:00
|
|
|
if (*qserver == '\0')
|
|
|
|
g_string_sprintf(tmpstr, "WHOIS %s", query);
|
2000-10-14 12:02:35 -04:00
|
|
|
else {
|
2000-06-10 17:40:00 -04:00
|
|
|
g_string_sprintf(tmpstr, "WHOIS %s %s", qserver, query);
|
2000-10-14 12:02:35 -04:00
|
|
|
if (g_strcasecmp(qserver, query) == 0)
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
event_402 = "whois event not found";
|
2000-10-14 12:02:35 -04:00
|
|
|
}
|
2000-06-14 15:40:23 -04:00
|
|
|
|
|
|
|
query = get_redirect_nicklist(query, &free_nick);
|
2000-06-10 17:40:00 -04:00
|
|
|
|
2003-12-10 17:57:51 -05:00
|
|
|
str = g_strconcat(qserver, " ", query, NULL);
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
server_redirect_event(server, "whois", 1, str, TRUE,
|
|
|
|
NULL,
|
|
|
|
"event 318", "whois end",
|
|
|
|
"event 402", event_402,
|
|
|
|
"event 301", "whois away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
|
|
|
"event 313", "whois oper",
|
|
|
|
"event 401", (settings_get_bool("auto_whowas") ? "whois try whowas" : "whois event not found"),
|
|
|
|
"event 311", "whois event",
|
|
|
|
"", "whois default event", NULL);
|
2001-01-01 09:42:22 -05:00
|
|
|
g_free(str);
|
|
|
|
|
2001-11-11 13:59:19 -05:00
|
|
|
server->whois_found = FALSE;
|
|
|
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_whois_in_cmd);
|
|
|
|
|
2000-06-14 15:40:23 -04:00
|
|
|
if (free_nick) g_free(query);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-06-10 17:40:00 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_whois(IRC_SERVER_REC *server, const char *data,
|
2000-11-04 11:54:58 -05:00
|
|
|
const char *nick, const char *addr)
|
2000-06-10 17:40:00 -04:00
|
|
|
{
|
|
|
|
server->whois_found = TRUE;
|
2000-12-05 16:12:52 -05:00
|
|
|
signal_emit("event 311", 4, server, data, nick, addr);
|
2000-06-10 17:40:00 -04:00
|
|
|
}
|
|
|
|
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
static void sig_whois_try_whowas(IRC_SERVER_REC *server, const char *data)
|
2000-06-10 17:40:00 -04:00
|
|
|
{
|
|
|
|
char *params, *nick;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
params = event_get_params(data, 2, NULL, &nick);
|
|
|
|
|
|
|
|
server->whowas_found = FALSE;
|
2001-11-12 17:15:04 -05:00
|
|
|
server_redirect_event(server, "whowas", 1, nick, -1, NULL,
|
2001-11-11 13:59:19 -05:00
|
|
|
"event 314", "whowas event",
|
|
|
|
"event 369", "whowas event end",
|
2001-11-15 11:18:11 -05:00
|
|
|
"event 406", "event empty", NULL);
|
2001-11-11 13:59:19 -05:00
|
|
|
irc_send_cmdv(server, "WHOWAS %s 1", nick);
|
|
|
|
|
2000-06-10 17:40:00 -04:00
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2001-11-18 12:41:10 -05:00
|
|
|
static void event_end_of_whois(IRC_SERVER_REC *server, const char *data,
|
|
|
|
const char *nick, const char *addr)
|
|
|
|
{
|
|
|
|
signal_emit("event 318", 4, server, data, nick, addr);
|
|
|
|
server->whois_found = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_whowas(IRC_SERVER_REC *server, const char *data,
|
|
|
|
const char *nick, const char *addr)
|
2000-06-10 17:40:00 -04:00
|
|
|
{
|
|
|
|
server->whowas_found = TRUE;
|
2000-12-05 16:12:52 -05:00
|
|
|
signal_emit("event 314", 4, server, data, nick, addr);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
/* SYNTAX: WHOWAS [<nicks> [<count> [server]]] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
char *nicks, *rest, *nicks_redir;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-06-14 15:40:23 -04:00
|
|
|
int free_nick;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &nicks, &rest))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-06-14 15:40:23 -04:00
|
|
|
if (*nicks == '\0') nicks = server->nick;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-11 13:59:19 -05:00
|
|
|
nicks_redir = get_redirect_nicklist(nicks, &free_nick);
|
2001-11-12 17:15:04 -05:00
|
|
|
server_redirect_event(server, "whowas", 1, nicks_redir, -1, NULL,
|
2001-11-19 17:34:50 -05:00
|
|
|
"event 301", "whowas away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
2001-11-11 13:59:19 -05:00
|
|
|
"event 314", "whowas event", NULL);
|
|
|
|
if (free_nick) g_free(nicks_redir);
|
|
|
|
|
2000-06-10 17:40:00 -04:00
|
|
|
server->whowas_found = FALSE;
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
irc_send_cmdv(server, *rest == '\0' ? "WHOWAS %s" :
|
|
|
|
"WHOWAS %s %s", nicks, rest);
|
2000-06-14 15:40:23 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2007-11-17 11:35:47 -05:00
|
|
|
/* SYNTAX: PING [<nick> | <channel> | *] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GTimeVal tv;
|
|
|
|
char *str;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2007-11-17 11:35:47 -05:00
|
|
|
if (*data == '\0') {
|
|
|
|
if (!IS_QUERY(item))
|
|
|
|
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2002-05-15 20:34:37 -04:00
|
|
|
data = window_item_get_target(item);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
g_get_current_time(&tv);
|
|
|
|
|
|
|
|
str = g_strdup_printf("%s PING %ld %ld", data, tv.tv_sec, tv.tv_usec);
|
|
|
|
signal_emit("command ctcp", 3, str, server, item);
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void server_send_away(IRC_SERVER_REC *server, const char *reason)
|
|
|
|
{
|
2000-09-27 21:38:50 -04:00
|
|
|
if (!IS_IRC_SERVER(server))
|
|
|
|
return;
|
|
|
|
|
2001-06-26 18:33:43 -04:00
|
|
|
if (*reason != '\0' || server->usermode_away) {
|
|
|
|
g_free_and_null(server->away_reason);
|
|
|
|
if (*reason != '\0')
|
|
|
|
server->away_reason = g_strdup(reason);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-06-26 18:33:43 -04:00
|
|
|
irc_send_cmdv(server, "AWAY :%s", reason);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: AWAY [-one | -all] [<reason>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_away(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
GHashTable *optlist;
|
|
|
|
char *reason;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
|
|
|
PARAM_FLAG_GETREST, "away", &optlist, &reason)) return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-20 15:28:19 -04:00
|
|
|
if (g_hash_table_lookup(optlist, "one") != NULL)
|
2000-04-26 04:03:38 -04:00
|
|
|
server_send_away(server, reason);
|
2000-06-01 21:19:06 -04:00
|
|
|
else
|
|
|
|
g_slist_foreach(servers, (GFunc) server_send_away, reason);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SCONNECT <new server> [[<port>] <existing server>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "CONNECT %s", data);
|
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: QUOTE <data> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_quote(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2001-11-15 13:37:33 -05:00
|
|
|
if (server != NULL && !IS_IRC_SERVER(server))
|
|
|
|
return;
|
2001-11-29 14:19:29 -05:00
|
|
|
if (server == NULL || server->connect_time == 0)
|
2001-11-15 13:37:33 -05:00
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2006-01-30 13:48:44 -05:00
|
|
|
if (!server->connected)
|
|
|
|
irc_send_cmd_now(server, data);
|
|
|
|
else
|
|
|
|
irc_send_cmd(server, data);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_wall_hash(gpointer key, NICK_REC *nick, GSList **nicks)
|
|
|
|
{
|
|
|
|
if (nick->op) *nicks = g_slist_append(*nicks, nick);
|
|
|
|
}
|
|
|
|
|
2000-11-30 18:13:15 -05:00
|
|
|
/* SYNTAX: WAIT [-<server tag>] <milliseconds> */
|
|
|
|
static void cmd_wait(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
GHashTable *optlist;
|
|
|
|
char *msecs;
|
|
|
|
void *free_arg;
|
|
|
|
int n;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-11-30 18:13:15 -05:00
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
|
|
|
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
|
|
|
NULL, &optlist, &msecs))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (*msecs == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
/* -<server tag> */
|
|
|
|
server = IRC_SERVER(cmd_options_get_server(NULL, optlist,
|
|
|
|
SERVER(server)));
|
|
|
|
|
|
|
|
n = atoi(msecs);
|
|
|
|
if (server != NULL && n > 0) {
|
|
|
|
g_get_current_time(&server->wait_cmd);
|
|
|
|
server->wait_cmd.tv_sec += n/1000;
|
|
|
|
server->wait_cmd.tv_usec += n%1000;
|
|
|
|
if (server->wait_cmd.tv_usec >= 1000) {
|
|
|
|
server->wait_cmd.tv_sec++;
|
|
|
|
server->wait_cmd.tv_usec -= 1000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WALL [<channel>] <message> */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2008-02-16 18:28:53 -05:00
|
|
|
char *channame, *msg, *args;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-08-26 11:39:44 -04:00
|
|
|
IRC_CHANNEL_REC *chanrec;
|
2000-04-26 04:03:38 -04:00
|
|
|
GSList *tmp, *nicks;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
|
|
|
PARAM_FLAG_GETREST, item, &channame, &msg))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
chanrec = irc_channel_find(server, channame);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
|
|
|
|
2004-01-20 05:57:57 -05:00
|
|
|
/* See if the server has advertised support of wallchops */
|
|
|
|
if (g_hash_table_lookup(chanrec->server->isupport, "statusmsg") ||
|
|
|
|
g_hash_table_lookup(chanrec->server->isupport, "wallchops"))
|
|
|
|
irc_send_cmdv(server, "NOTICE @%s :%s", chanrec->name, msg);
|
|
|
|
else {
|
|
|
|
/* Fall back to manually noticing each op */
|
|
|
|
nicks = NULL;
|
|
|
|
g_hash_table_foreach(chanrec->nicks,
|
|
|
|
(GHFunc) cmd_wall_hash, &nicks);
|
|
|
|
|
|
|
|
args = g_strconcat(chanrec->name, " ", msg, NULL);
|
|
|
|
msg = parse_special_string(settings_get_str("wall_format"),
|
|
|
|
SERVER(server), item, args, NULL, 0);
|
|
|
|
g_free(args);
|
|
|
|
|
|
|
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
|
|
|
NICK_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec != chanrec->ownnick) {
|
|
|
|
irc_send_cmdv(server, "NOTICE %s :%s",
|
2008-02-16 18:28:53 -05:00
|
|
|
rec->nick, msg);
|
2004-01-20 05:57:57 -05:00
|
|
|
}
|
|
|
|
}
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2004-01-20 05:57:57 -05:00
|
|
|
g_free(msg);
|
|
|
|
g_slist_free(nicks);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-11-29 18:31:16 -05:00
|
|
|
/* SYNTAX: WALLCHOPS <channel> <message> */
|
2004-01-20 05:57:57 -05:00
|
|
|
/* ircu is the only major server i can see which supports this
|
|
|
|
and it supports NOTICE @#channel anyway */
|
2001-11-29 18:31:16 -05:00
|
|
|
static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|
|
|
{
|
2008-02-16 18:28:53 -05:00
|
|
|
char *channame, *msg;
|
2001-11-29 18:31:16 -05:00
|
|
|
void *free_arg;
|
|
|
|
|
|
|
|
CMD_IRC_SERVER(server);
|
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
|
|
|
PARAM_FLAG_GETREST, item, &channame, &msg))
|
|
|
|
return;
|
|
|
|
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, msg);
|
2001-11-29 18:31:16 -05:00
|
|
|
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
/* SYNTAX: KICKBAN [<channel>] <nicks> <reason> */
|
|
|
|
static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-12-16 21:59:16 -05:00
|
|
|
IRC_CHANNEL_REC *chanrec;
|
2008-02-16 18:28:53 -05:00
|
|
|
char *channel, *nicks, *reason, *kickcmd, *bancmd;
|
2000-12-16 21:59:16 -05:00
|
|
|
char **nicklist, *spacenicks;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
|
|
|
item, &channel, &nicks, &reason))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (*channel == '\0' || *nicks == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
chanrec = irc_channel_find(server, channel);
|
|
|
|
if (chanrec == NULL)
|
|
|
|
cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
|
|
|
if (!chanrec->wholist)
|
|
|
|
cmd_param_error(CMDERR_CHAN_NOT_SYNCED);
|
|
|
|
|
|
|
|
nicklist = g_strsplit(nicks, ",", -1);
|
|
|
|
spacenicks = g_strjoinv(" ", nicklist);
|
|
|
|
g_strfreev(nicklist);
|
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, reason);
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2001-05-11 08:00:23 -04:00
|
|
|
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
2000-12-16 21:59:16 -05:00
|
|
|
g_free(spacenicks);
|
2001-05-11 08:00:23 -04:00
|
|
|
|
|
|
|
if (settings_get_bool("kick_first_on_kickban")) {
|
2001-05-14 18:23:51 -04:00
|
|
|
signal_emit("command kick", 3, kickcmd, server, chanrec);
|
|
|
|
signal_emit("command ban", 3, bancmd, server, chanrec);
|
2001-05-11 08:00:23 -04:00
|
|
|
} else {
|
2001-05-14 18:23:51 -04:00
|
|
|
signal_emit("command ban", 3, bancmd, server, chanrec);
|
|
|
|
signal_emit("command kick", 3, kickcmd, server, chanrec);
|
2001-05-11 08:00:23 -04:00
|
|
|
}
|
|
|
|
g_free(kickcmd);
|
|
|
|
g_free(bancmd);
|
2001-05-11 12:08:48 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void knockout_destroy(IRC_SERVER_REC *server, KNOCKOUT_REC *rec)
|
|
|
|
{
|
|
|
|
server->knockoutlist = g_slist_remove(server->knockoutlist, rec);
|
|
|
|
g_free(rec->ban);
|
|
|
|
g_free(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* timeout function: knockout */
|
|
|
|
static void knockout_timeout_server(IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
GSList *tmp, *next;
|
2002-03-10 09:31:07 -05:00
|
|
|
time_t now;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_return_if_fail(server != NULL);
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_SERVER(server))
|
2000-07-15 09:08:39 -04:00
|
|
|
return;
|
|
|
|
|
2002-03-10 09:31:07 -05:00
|
|
|
now = time(NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
for (tmp = server->knockoutlist; tmp != NULL; tmp = next) {
|
|
|
|
KNOCKOUT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
next = tmp->next;
|
2002-03-10 09:31:07 -05:00
|
|
|
if (rec->unban_time <= now) {
|
2000-04-26 04:03:38 -04:00
|
|
|
/* timeout, unban. */
|
|
|
|
ban_remove(rec->channel, rec->ban);
|
|
|
|
knockout_destroy(server, rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int knockout_timeout(void)
|
|
|
|
{
|
|
|
|
g_slist_foreach(servers, (GFunc) knockout_timeout_server, NULL);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-12-28 12:54:13 -05:00
|
|
|
/* SYNTAX: KNOCKOUT [<time>] <nicks> <reason> */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|
|
|
IRC_CHANNEL_REC *channel)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
KNOCKOUT_REC *rec;
|
2008-02-16 18:28:53 -05:00
|
|
|
char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd;
|
2000-12-16 21:59:16 -05:00
|
|
|
char **nicklist, *spacenicks, *banmasks;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
int timeleft;
|
2007-06-06 13:57:28 -04:00
|
|
|
GSList *ptr;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_CHANNEL(channel))
|
|
|
|
cmd_return_error(CMDERR_NOT_JOINED);
|
2000-12-16 21:59:16 -05:00
|
|
|
if (!channel->wholist)
|
2001-01-11 04:25:16 -05:00
|
|
|
cmd_return_error(CMDERR_CHAN_NOT_SYNCED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-12-28 12:54:13 -05:00
|
|
|
if (i_isdigit(*data)) {
|
2000-04-26 04:03:38 -04:00
|
|
|
/* first argument is the timeout */
|
2000-12-16 21:59:16 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
|
|
|
&timeoutstr, &nicks, &reason))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2002-12-28 12:54:13 -05:00
|
|
|
|
|
|
|
if (!parse_time_interval(timeoutstr, &timeleft))
|
|
|
|
cmd_param_error(CMDERR_INVALID_TIME);
|
2000-04-26 04:03:38 -04:00
|
|
|
} else {
|
2000-12-16 21:59:16 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&nicks, &reason))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2002-12-28 12:54:13 -05:00
|
|
|
timeleft = settings_get_time("knockout_time");
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (*nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
nicklist = g_strsplit(nicks, ",", -1);
|
|
|
|
spacenicks = g_strjoinv(" ", nicklist);
|
|
|
|
g_strfreev(nicklist);
|
|
|
|
|
2001-03-03 15:48:23 -05:00
|
|
|
banmasks = ban_get_masks(channel, spacenicks, 0);
|
2000-12-16 21:59:16 -05:00
|
|
|
g_free(spacenicks);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2008-02-16 18:28:53 -05:00
|
|
|
kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, reason);
|
2004-08-19 20:03:40 -04:00
|
|
|
|
2001-05-11 08:00:23 -04:00
|
|
|
bancmd = *banmasks == '\0'? NULL :
|
|
|
|
g_strdup_printf("%s %s", channel->name, banmasks);
|
|
|
|
|
|
|
|
if (settings_get_bool("kick_first_on_kickban")) {
|
|
|
|
signal_emit("command kick", 3, kickcmd, server, channel);
|
|
|
|
if (bancmd != NULL)
|
|
|
|
signal_emit("command ban", 3, bancmd, server, channel);
|
|
|
|
} else {
|
|
|
|
if (bancmd != NULL)
|
|
|
|
signal_emit("command ban", 3, bancmd, server, channel);
|
|
|
|
signal_emit("command kick", 3, kickcmd, server, channel);
|
2000-12-16 21:59:16 -05:00
|
|
|
}
|
2001-05-11 08:00:23 -04:00
|
|
|
g_free(kickcmd);
|
|
|
|
g_free_not_null(bancmd);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (*banmasks == '\0')
|
|
|
|
g_free(banmasks);
|
|
|
|
else {
|
2007-06-06 13:57:28 -04:00
|
|
|
/* check if we already have this knockout */
|
|
|
|
for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) {
|
|
|
|
rec = ptr->data;
|
|
|
|
if (channel == rec->channel &&
|
|
|
|
!strcmp(rec->ban, banmasks))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ptr == NULL) {
|
|
|
|
rec = g_new(KNOCKOUT_REC, 1);
|
|
|
|
rec->channel = channel;
|
|
|
|
rec->ban = banmasks;
|
|
|
|
server->knockoutlist = g_slist_append(server->knockoutlist, rec);
|
|
|
|
}
|
2002-12-28 12:54:13 -05:00
|
|
|
rec->unban_time = time(NULL)+timeleft/1000;
|
2000-12-16 21:59:16 -05:00
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-08-14 09:19:06 -04:00
|
|
|
/* SYNTAX: SERVER PURGE [<target>] */
|
|
|
|
static void cmd_server_purge(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
char *target;
|
|
|
|
void *free_arg;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2001-08-14 09:19:06 -04:00
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 1, &target))
|
|
|
|
return;
|
|
|
|
|
|
|
|
irc_server_purge_output(server, *target == '\0' ? NULL : target);
|
|
|
|
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* destroy all knockouts in server */
|
|
|
|
static void sig_server_disconnected(IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
g_return_if_fail(server != NULL);
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_SERVER(server))
|
2000-07-30 13:19:16 -04:00
|
|
|
return;
|
|
|
|
|
2005-06-24 12:43:18 -04:00
|
|
|
g_free(server->last_nick);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
while (server->knockoutlist != NULL)
|
|
|
|
knockout_destroy(server, server->knockoutlist->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy all knockouts in channel */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp, *next;
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_CHANNEL(channel) || !IS_IRC_SERVER(channel->server))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
for (tmp = channel->server->knockoutlist; tmp != NULL; tmp = next) {
|
|
|
|
KNOCKOUT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
next = tmp->next;
|
|
|
|
if (rec->channel == channel)
|
|
|
|
knockout_destroy(channel->server, rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-04 13:01:51 -05:00
|
|
|
/* SYNTAX: OPER [<nick> [<password>]] */
|
2000-08-19 16:14:09 -04:00
|
|
|
static void cmd_oper(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
char *nick, *password;
|
|
|
|
void *free_arg;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-08-19 16:14:09 -04:00
|
|
|
|
2001-01-04 13:01:51 -05:00
|
|
|
/* asking for password is handled by fe-common */
|
2000-08-19 16:14:09 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2, &nick, &password))
|
|
|
|
return;
|
2001-01-04 13:01:51 -05:00
|
|
|
if (*password == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-08-19 16:14:09 -04:00
|
|
|
|
|
|
|
irc_send_cmdv(server, "OPER %s %s", nick, password);
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2007-06-08 14:49:24 -04:00
|
|
|
/* SYNTAX: ACCEPT [[-]nick,...] */
|
|
|
|
static void cmd_accept(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
CMD_IRC_SERVER(server);
|
|
|
|
|
|
|
|
if (*data == '\0')
|
|
|
|
irc_send_cmd(server, "ACCEPT *");
|
|
|
|
else
|
|
|
|
irc_send_cmdv(server, "ACCEPT %s", data);
|
|
|
|
}
|
|
|
|
|
2000-10-01 17:00:59 -04:00
|
|
|
/* SYNTAX: UNSILENCE <nick!user@host> */
|
|
|
|
static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-10-01 17:00:59 -04:00
|
|
|
|
|
|
|
if (*data == '\0')
|
|
|
|
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "SILENCE -%s", data);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
static void command_self(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
irc_send_cmdv(server, *data == '\0' ? "%s" : "%s %s", current_command, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void command_1self(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "%s :%s", current_command, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void command_2self(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *text;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*target == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
irc_send_cmdv(server, "%s %s :%s", current_command, target, text);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void irc_commands_init(void)
|
|
|
|
{
|
|
|
|
tmpstr = g_string_new(NULL);
|
|
|
|
|
2000-11-25 22:24:36 -05:00
|
|
|
settings_add_str("misc", "part_message", "");
|
2002-12-28 12:54:13 -05:00
|
|
|
settings_add_time("misc", "knockout_time", "5min");
|
2000-08-14 17:17:51 -04:00
|
|
|
settings_add_str("misc", "wall_format", "[Wall/$0] $1-");
|
2001-05-11 08:00:23 -04:00
|
|
|
settings_add_bool("misc", "kick_first_on_kickban", FALSE);
|
2003-12-10 17:57:51 -05:00
|
|
|
settings_add_bool("misc", "auto_whowas", TRUE);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
knockout_tag = g_timeout_add(KNOCKOUT_TIMECHECK, (GSourceFunc) knockout_timeout, NULL);
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("notice", NULL, (SIGNAL_FUNC) cmd_notice);
|
|
|
|
command_bind_irc("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
|
|
|
|
command_bind_irc("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
|
|
|
|
command_bind_irc("part", NULL, (SIGNAL_FUNC) cmd_part);
|
|
|
|
command_bind_irc("kick", NULL, (SIGNAL_FUNC) cmd_kick);
|
|
|
|
command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic);
|
|
|
|
command_bind_irc("invite", NULL, (SIGNAL_FUNC) cmd_invite);
|
|
|
|
command_bind_irc("list", NULL, (SIGNAL_FUNC) cmd_list);
|
|
|
|
command_bind_irc("who", NULL, (SIGNAL_FUNC) cmd_who);
|
|
|
|
command_bind_irc("names", NULL, (SIGNAL_FUNC) cmd_names);
|
|
|
|
command_bind_irc("nick", NULL, (SIGNAL_FUNC) cmd_nick);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: NOTE <command> [&<password>] [+|-<flags>] [<arguments>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("note", NULL, (SIGNAL_FUNC) command_self);
|
|
|
|
command_bind_irc("whois", NULL, (SIGNAL_FUNC) cmd_whois);
|
|
|
|
command_bind_irc("whowas", NULL, (SIGNAL_FUNC) cmd_whowas);
|
|
|
|
command_bind_irc("ping", NULL, (SIGNAL_FUNC) cmd_ping);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: KILL <nick> <reason> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("kill", NULL, (SIGNAL_FUNC) command_2self);
|
|
|
|
command_bind_irc("away", NULL, (SIGNAL_FUNC) cmd_away);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: ISON <nicks> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("ison", NULL, (SIGNAL_FUNC) command_1self);
|
2007-06-08 14:49:24 -04:00
|
|
|
command_bind_irc("accept", NULL, (SIGNAL_FUNC) cmd_accept);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: ADMIN [<server>|<nickname>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("admin", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: INFO [<server>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("info", NULL, (SIGNAL_FUNC) command_self);
|
2004-09-18 16:56:33 -04:00
|
|
|
/* SYNTAX: KNOCK <channel> */
|
|
|
|
command_bind_irc("knock", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: LINKS [[<server>] <mask>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("links", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: LUSERS [<server mask> [<remote server>]] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("lusers", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: MAP */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("map", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: MOTD [<server>|<nick>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("motd", NULL, (SIGNAL_FUNC) command_self);
|
2007-06-08 11:59:02 -04:00
|
|
|
/* SYNTAX: REHASH [<option>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("rehash", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: STATS <type> [<server>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("stats", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TIME [<server>|<nick>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("time", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TRACE [<server>|<nick>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("trace", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: VERSION [<server>|<nick>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("version", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SERVLIST [<server mask>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("servlist", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SILENCE [[+|-]<nick!user@host>]
|
|
|
|
SILENCE [<nick>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("silence", NULL, (SIGNAL_FUNC) command_self);
|
|
|
|
command_bind_irc("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence);
|
|
|
|
command_bind_irc("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SQUERY <service> [<commands>] */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("squery", NULL, (SIGNAL_FUNC) command_2self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: DIE */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("die", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: HASH */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("hash", NULL, (SIGNAL_FUNC) command_self);
|
|
|
|
command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: RESTART */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("restart", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: RPING <server> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("rping", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SQUIT <server>|<mask> <reason> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("squit", NULL, (SIGNAL_FUNC) command_2self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: UPING <server> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("uping", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: USERHOST <nicks> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("userhost", NULL, (SIGNAL_FUNC) command_self);
|
|
|
|
command_bind_irc("quote", NULL, (SIGNAL_FUNC) cmd_quote);
|
|
|
|
command_bind_irc("wall", NULL, (SIGNAL_FUNC) cmd_wall);
|
2001-11-29 18:31:16 -05:00
|
|
|
command_bind_irc("wallchops", NULL, (SIGNAL_FUNC) cmd_wallchops);
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("wait", NULL, (SIGNAL_FUNC) cmd_wait);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WALLOPS <message> */
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc("wallops", NULL, (SIGNAL_FUNC) command_1self);
|
|
|
|
command_bind_irc("kickban", NULL, (SIGNAL_FUNC) cmd_kickban);
|
|
|
|
command_bind_irc("knockout", NULL, (SIGNAL_FUNC) cmd_knockout);
|
|
|
|
command_bind_irc("server purge", NULL, (SIGNAL_FUNC) cmd_server_purge);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
|
|
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
signal_add("whois try whowas", (SIGNAL_FUNC) sig_whois_try_whowas);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_add("whois event", (SIGNAL_FUNC) event_whois);
|
2001-11-18 12:41:10 -05:00
|
|
|
signal_add("whois end", (SIGNAL_FUNC) event_end_of_whois);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_add("whowas event", (SIGNAL_FUNC) event_whowas);
|
2000-06-17 21:18:12 -04:00
|
|
|
|
2001-02-18 21:15:15 -05:00
|
|
|
command_set_options("connect", "+ircnet");
|
2000-07-04 15:36:36 -04:00
|
|
|
command_set_options("topic", "delete");
|
2000-06-17 21:18:12 -04:00
|
|
|
command_set_options("list", "yes");
|
|
|
|
command_set_options("away", "one all");
|
2000-10-13 18:34:19 -04:00
|
|
|
command_set_options("whois", "yes");
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void irc_commands_deinit(void)
|
|
|
|
{
|
|
|
|
g_source_remove(knockout_tag);
|
|
|
|
|
|
|
|
command_unbind("notice", (SIGNAL_FUNC) cmd_notice);
|
|
|
|
command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp);
|
|
|
|
command_unbind("nctcp", (SIGNAL_FUNC) cmd_nctcp);
|
|
|
|
command_unbind("part", (SIGNAL_FUNC) cmd_part);
|
|
|
|
command_unbind("kick", (SIGNAL_FUNC) cmd_kick);
|
|
|
|
command_unbind("topic", (SIGNAL_FUNC) cmd_topic);
|
|
|
|
command_unbind("invite", (SIGNAL_FUNC) cmd_invite);
|
|
|
|
command_unbind("list", (SIGNAL_FUNC) cmd_list);
|
|
|
|
command_unbind("who", (SIGNAL_FUNC) cmd_who);
|
|
|
|
command_unbind("names", (SIGNAL_FUNC) cmd_names);
|
2000-11-04 11:54:58 -05:00
|
|
|
command_unbind("nick", (SIGNAL_FUNC) cmd_nick);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("note", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("whois", (SIGNAL_FUNC) cmd_whois);
|
|
|
|
command_unbind("whowas", (SIGNAL_FUNC) cmd_whowas);
|
|
|
|
command_unbind("ping", (SIGNAL_FUNC) cmd_ping);
|
|
|
|
command_unbind("kill", (SIGNAL_FUNC) command_2self);
|
|
|
|
command_unbind("away", (SIGNAL_FUNC) cmd_away);
|
|
|
|
command_unbind("ison", (SIGNAL_FUNC) command_1self);
|
2007-06-08 14:49:24 -04:00
|
|
|
command_unbind("accept", (SIGNAL_FUNC) cmd_accept);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("admin", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("info", (SIGNAL_FUNC) command_self);
|
2004-09-18 16:56:33 -04:00
|
|
|
command_unbind("knock", (SIGNAL_FUNC) command_self);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("links", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("lusers", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("map", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("motd", (SIGNAL_FUNC) command_self);
|
2000-07-02 15:22:30 -04:00
|
|
|
command_unbind("rehash", (SIGNAL_FUNC) command_self);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("stats", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("time", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("trace", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("version", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("servlist", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("silence", (SIGNAL_FUNC) command_self);
|
2000-10-01 17:00:59 -04:00
|
|
|
command_unbind("unsilence", (SIGNAL_FUNC) cmd_unsilence);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("sconnect", (SIGNAL_FUNC) cmd_sconnect);
|
|
|
|
command_unbind("squery", (SIGNAL_FUNC) command_2self);
|
|
|
|
command_unbind("die", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("hash", (SIGNAL_FUNC) command_self);
|
2000-08-19 16:14:09 -04:00
|
|
|
command_unbind("oper", (SIGNAL_FUNC) cmd_oper);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("restart", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("rping", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("squit", (SIGNAL_FUNC) command_2self);
|
|
|
|
command_unbind("uping", (SIGNAL_FUNC) command_self);
|
2000-06-01 11:04:41 -04:00
|
|
|
command_unbind("userhost", (SIGNAL_FUNC) command_self);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("quote", (SIGNAL_FUNC) cmd_quote);
|
|
|
|
command_unbind("wall", (SIGNAL_FUNC) cmd_wall);
|
2001-11-29 18:31:16 -05:00
|
|
|
command_unbind("wallchops", (SIGNAL_FUNC) cmd_wallchops);
|
2000-11-30 18:13:15 -05:00
|
|
|
command_unbind("wait", (SIGNAL_FUNC) cmd_wait);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("wallops", (SIGNAL_FUNC) command_1self);
|
|
|
|
command_unbind("kickban", (SIGNAL_FUNC) cmd_kickban);
|
|
|
|
command_unbind("knockout", (SIGNAL_FUNC) cmd_knockout);
|
2001-08-14 09:19:06 -04:00
|
|
|
command_unbind("server purge", (SIGNAL_FUNC) cmd_server_purge);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
|
|
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
- rename "whois not found" to "whois try whowas", because that's what needs to be done when the signal is sent (and it doesn't mean whois_not_found should be printed)
- rename "whois event noserver" to "whois event not found", because the signal means the nickname wasn't found (but it comes as a "no such server" because it was a /whois nick nick), whois_not_found should be printed, and so it makes sense to also use it for the next fix:
- send "whois event not found" for 401, when auto_whowas is off, so the message is displayed correctly (Bug 295)
- handle 402 the same with auto_whowas off as with on, (fixes /whois with not existing server specified, with auto_whowas off).
- and since the auto_whowas on and off cases are similar now, merge them together, so they stay consistent.
- pass every argument given to /whowas to the server, not just the first (count). Fixes remote whowas (Bug 256)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3988 dbcabf3a-b0e7-0310-adc4-f8d773084564
2005-09-09 21:36:06 -04:00
|
|
|
signal_remove("whois try whowas", (SIGNAL_FUNC) sig_whois_try_whowas);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_remove("whois event", (SIGNAL_FUNC) event_whois);
|
2001-11-18 12:41:10 -05:00
|
|
|
signal_remove("whois end", (SIGNAL_FUNC) event_end_of_whois);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_remove("whowas event", (SIGNAL_FUNC) event_whowas);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_string_free(tmpstr, TRUE);
|
|
|
|
}
|