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.
|
|
|
|
|
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
#include "commands.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"
|
|
|
|
#include "irc.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
|
|
|
|
|
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;
|
|
|
|
int timeleft;
|
|
|
|
} KNOCKOUT_REC;
|
|
|
|
|
|
|
|
static GString *tmpstr;
|
|
|
|
static int knockout_tag;
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: NOTICE <targets> <message> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_notice(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *msg;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &msg))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
g_string_sprintf(tmpstr, "NOTICE %s :%s", target, msg);
|
|
|
|
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>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *ctcpcmd, *ctcpdata;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
g_strup(ctcpcmd);
|
|
|
|
if (*ctcpdata == '\0')
|
|
|
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
|
|
|
|
else
|
|
|
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
|
|
|
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>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *ctcpcmd, *ctcpdata;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
|
|
|
g_strup(ctcpcmd);
|
|
|
|
g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
|
|
|
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>] */
|
2000-08-26 11:39:44 -04: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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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 (*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");
|
2000-05-17 05:32:46 -04:00
|
|
|
irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
|
2000-04-26 04:03:38 -04:00
|
|
|
channame, msg);
|
|
|
|
|
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
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *channame, *nicks, *reason;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
|
|
|
item, &channame, &nicks, &reason))
|
|
|
|
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);
|
|
|
|
|
|
|
|
g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, reason);
|
|
|
|
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;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
irc_send_cmdv(server, *topic == '\0' &&
|
|
|
|
g_hash_table_lookup(optlist, "delete") == NULL ?
|
2000-06-01 12:49:19 -04:00
|
|
|
"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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
channame = item->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
|
|
|
/* add default redirection */
|
|
|
|
server_redirect_default((SERVER_REC *) server, "bogus command list");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
2000-06-07 14:35:15 -04:00
|
|
|
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
|
|
|
|
|
|
|
/* add default redirection */
|
|
|
|
server_redirect_default((SERVER_REC *) server, "bogus command who");
|
|
|
|
}
|
|
|
|
|
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-03-03 19:14:00 -05:00
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
2001-03-03 19:14:00 -05:00
|
|
|
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);
|
|
|
|
|
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 1, &nick))
|
|
|
|
return;
|
|
|
|
|
|
|
|
server->nick_changing = TRUE;
|
|
|
|
irc_send_cmdv(server, "NICK %s", nick);
|
2000-11-13 20:14:02 -05:00
|
|
|
|
|
|
|
nick = g_strdup_printf("%s :%s", nick, nick);
|
2000-11-08 17:55:43 -05:00
|
|
|
server_redirect_event(SERVER(server), nick, 5,
|
2001-03-15 12:39:23 -05:00
|
|
|
"event nick", "nickchange over", -1,
|
2000-11-04 11:54:58 -05:00
|
|
|
"event 433", "nickchange over", 1,
|
|
|
|
/* 437: ircnet = target unavailable,
|
|
|
|
dalnet = banned in channel,
|
|
|
|
can't change nick */
|
|
|
|
"event 437", "nickchange over", -1,
|
|
|
|
"event 432", "nickchange over", 1,
|
|
|
|
"event 438", "nickchange over", 1, NULL);
|
2000-11-13 20:14:02 -05:00
|
|
|
g_free(nick);
|
2000-11-04 11:54:58 -05:00
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void sig_nickchange_over(IRC_SERVER_REC *server, const char *data,
|
2000-11-04 11:54:58 -05:00
|
|
|
const char *nick, const char *addr)
|
|
|
|
{
|
|
|
|
char *signal;
|
|
|
|
|
|
|
|
server->nick_changing = FALSE;
|
|
|
|
|
|
|
|
signal = g_strconcat("event ", current_server_event, NULL);
|
2000-11-13 20:14:02 -05:00
|
|
|
g_strdown(signal+6);
|
2000-12-05 16:12:52 -05:00
|
|
|
signal_emit(signal, 4, server, data, nick, addr);
|
2000-11-04 11:54:58 -05:00
|
|
|
g_free(signal);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WHOIS [<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
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
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);
|
|
|
|
|
2000-10-13 18:34:19 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS,
|
|
|
|
"whois", &optlist, &qserver, &query))
|
2000-06-17 21:18:12 -04:00
|
|
|
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)
|
|
|
|
event_402 = "whois event noserver";
|
|
|
|
}
|
2000-06-14 15:40:23 -04:00
|
|
|
|
|
|
|
server->whois_found = FALSE;
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_whois_in_cmd);
|
2000-06-10 17:40:00 -04:00
|
|
|
|
|
|
|
/* do automatic /WHOWAS if any of the nicks wasn't found */
|
2000-06-14 15:40:23 -04:00
|
|
|
query = get_redirect_nicklist(query, &free_nick);
|
2000-06-10 17:40:00 -04:00
|
|
|
|
2001-01-01 09:42:22 -05:00
|
|
|
str = g_strconcat(qserver, " ", query, NULL);
|
|
|
|
server_redirect_event(SERVER(server), str, 2,
|
2000-06-10 17:40:00 -04:00
|
|
|
"event 318", "event 318", 1,
|
2001-01-01 09:42:22 -05:00
|
|
|
"event 402", event_402, 1,
|
2000-11-16 16:34:42 -05:00
|
|
|
"event 401", "whois not found", 1,
|
|
|
|
"event 311", "whois event", 1, NULL);
|
2001-01-01 09:42:22 -05:00
|
|
|
g_free(str);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-12-07 14:14:27 -05:00
|
|
|
static void sig_whois_not_found(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);
|
|
|
|
irc_send_cmdv(server, "WHOWAS %s 1", nick);
|
|
|
|
|
|
|
|
server->whowas_found = FALSE;
|
2000-11-04 11:54:58 -05:00
|
|
|
server_redirect_event(SERVER(server), nick, 1,
|
2000-06-10 17:40:00 -04:00
|
|
|
"event 369", "whowas event end", 1,
|
|
|
|
"event 314", "whowas event", 1,
|
|
|
|
"event 406", "event empty", 1, NULL);
|
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WHOWAS [<nicks> [<count>]] */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *nicks, *count;
|
|
|
|
void *free_arg;
|
2000-06-14 15:40:23 -04:00
|
|
|
int free_nick;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2, &nicks, &count))
|
|
|
|
return;
|
2000-06-14 15:40:23 -04:00
|
|
|
if (*nicks == '\0') nicks = server->nick;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 17:40:00 -04:00
|
|
|
server->whowas_found = FALSE;
|
2000-06-14 15:40:23 -04:00
|
|
|
irc_send_cmdv(server, *count == '\0' ? "WHOWAS %s" :
|
|
|
|
"WHOWAS %s %s", nicks, count);
|
|
|
|
|
|
|
|
nicks = get_redirect_nicklist(nicks, &free_nick);
|
2000-11-04 11:54:58 -05:00
|
|
|
server_redirect_event(SERVER(server), nicks, 1,
|
2000-06-14 15:40:23 -04:00
|
|
|
"event 369", "event 369", 1,
|
|
|
|
"event 314", "whowas event", 1, NULL);
|
|
|
|
if (free_nick) g_free(nicks);
|
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: PING <nicks> */
|
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;
|
|
|
|
|
|
|
|
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' || strcmp(data, "*") == 0) {
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_ITEM(item))
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_return_error(CMDERR_NOT_JOINED);
|
|
|
|
|
|
|
|
data = item->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
g_free_not_null(server->away_reason);
|
|
|
|
server->away_reason = g_strdup(reason);
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "AWAY :%s", reason);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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: DEOP <nicks> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_deop(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')
|
|
|
|
irc_send_cmdv(server, "MODE %s -o", server->nick);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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, "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)
|
|
|
|
{
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-08-26 11:39:44 -04:00
|
|
|
if (server == NULL || !IS_IRC_SERVER(server))
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
irc_send_cmd(server, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
if (!IS_SERVER(server) || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *channame, *msg, *args;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* send notice to all ops */
|
|
|
|
nicks = NULL;
|
|
|
|
g_hash_table_foreach(chanrec->nicks, (GHFunc) cmd_wall_hash, &nicks);
|
|
|
|
|
2000-06-09 11:50:04 -04:00
|
|
|
args = g_strconcat(chanrec->name, " ", msg, NULL);
|
2000-08-26 11:39:44 -04:00
|
|
|
msg = parse_special_string(settings_get_str("wall_format"),
|
2000-12-17 02:39:22 -05:00
|
|
|
SERVER(server), item, args, NULL, 0);
|
2000-06-09 11:50:04 -04:00
|
|
|
g_free(args);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
|
|
|
NICK_REC *rec = tmp->data;
|
|
|
|
|
2001-01-01 02:45:54 -05:00
|
|
|
if (rec != chanrec->ownnick)
|
2000-06-09 11:50:04 -04:00
|
|
|
irc_send_cmdv(server, "NOTICE %s :%s", rec->nick, msg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
2000-06-09 11:50:04 -04:00
|
|
|
g_free(msg);
|
2000-04-26 04:03:38 -04:00
|
|
|
g_slist_free(nicks);
|
|
|
|
|
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: CYCLE [<channel>] [<message>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_cycle(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-08-26 11:39:44 -04:00
|
|
|
IRC_CHANNEL_REC *chanrec;
|
2000-06-17 21:18:12 -04:00
|
|
|
char *channame, *msg;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN, item, &channame, &msg))
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*channame == '\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);
|
|
|
|
|
2000-05-17 05:32:46 -04:00
|
|
|
irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
|
2000-04-26 04:03:38 -04:00
|
|
|
channame, msg);
|
|
|
|
irc_send_cmdv(server, chanrec->key == NULL ? "JOIN %s" : "JOIN %s %s",
|
|
|
|
channame, chanrec->key);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
char *channel, *nicks, *reason, *str;
|
|
|
|
char **nicklist, *spacenicks;
|
2000-06-17 21:18:12 -04:00
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-12-16 21:59:16 -05:00
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
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);
|
|
|
|
|
|
|
|
str = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
|
|
|
signal_emit("command ban", 3, str, server, channel);
|
|
|
|
g_free(str);
|
|
|
|
|
|
|
|
str = g_strdup_printf("%s %s %s", chanrec->name, nicks, reason);
|
|
|
|
signal_emit("command kick", 3, str, server, channel);
|
|
|
|
g_free(str);
|
|
|
|
|
|
|
|
g_free(spacenicks);
|
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;
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
t = server->knockout_lastcheck == 0 ? 0 :
|
|
|
|
time(NULL)-server->knockout_lastcheck;
|
|
|
|
server->knockout_lastcheck = time(NULL);
|
|
|
|
|
|
|
|
for (tmp = server->knockoutlist; tmp != NULL; tmp = next) {
|
|
|
|
KNOCKOUT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
next = tmp->next;
|
|
|
|
if (rec->timeleft > t)
|
|
|
|
rec->timeleft -= t;
|
|
|
|
else {
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
/* SYNTAX: KNOCKOUT [<seconds>] <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;
|
2000-12-16 21:59:16 -05:00
|
|
|
char *nicks, *reason, *timeoutstr, *str;
|
|
|
|
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;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
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
|
|
|
|
|
|
|
if (is_numeric(data, ' ')) {
|
|
|
|
/* 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;
|
2000-05-04 06:32:42 -04:00
|
|
|
timeleft = atoi(timeoutstr);
|
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;
|
2000-12-16 21:59:16 -05:00
|
|
|
timeleft = 0;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (timeleft == 0) timeleft = settings_get_int("knockout_time");
|
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
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (*banmasks != '\0') {
|
|
|
|
str = g_strdup_printf("%s %s", channel->name, banmasks);
|
|
|
|
signal_emit("command ban", 3, str, server, channel);
|
|
|
|
g_free(str);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
str = g_strdup_printf("%s %s %s", channel->name, nicks, reason);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_emit("command kick", 3, str, server, channel);
|
|
|
|
g_free(str);
|
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
if (*banmasks == '\0')
|
|
|
|
g_free(banmasks);
|
|
|
|
else {
|
|
|
|
/* create knockout record */
|
|
|
|
rec = g_new(KNOCKOUT_REC, 1);
|
|
|
|
rec->timeleft = timeleft;
|
|
|
|
rec->channel = channel;
|
|
|
|
rec->ban = banmasks;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-12-16 21:59:16 -05:00
|
|
|
server->knockoutlist = g_slist_append(server->knockoutlist, rec);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-08-26 11:39:44 -04:00
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
2000-08-19 16:14:09 -04:00
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2000-10-01 17:00:59 -04:00
|
|
|
/* SYNTAX: UNSILENCE <nick!user@host> */
|
|
|
|
static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void sig_connected(IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
g_return_if_fail(server != NULL);
|
|
|
|
|
2000-11-16 16:34:42 -05:00
|
|
|
/* FIXME: these two aren't probably needed? this whole redirection
|
|
|
|
thing might need some rethinking :) */
|
|
|
|
/* WHOIS */
|
|
|
|
/*server_redirect_init(SERVER(server), "", 2,
|
|
|
|
"event 318", "event 402", "event 401",
|
2000-04-26 04:03:38 -04:00
|
|
|
"event 301", "event 311", "event 312", "event 313",
|
2000-11-16 16:34:42 -05:00
|
|
|
"event 317", "event 319", NULL);*/
|
|
|
|
|
|
|
|
/* NICK */
|
|
|
|
/*server_redirect_init(SERVER(server), "", 5,
|
|
|
|
"event nick", "event 433", "event 437",
|
|
|
|
"event 432", "event 438", NULL);*/
|
|
|
|
|
|
|
|
/* problem (doesn't really apply currently since there's no GUI):
|
|
|
|
|
|
|
|
second argument of server_redirect_init() is the command that
|
|
|
|
generates the redirection automatically when it's called, but the
|
|
|
|
command handler doesn't really know about the redirection itself.
|
|
|
|
|
|
|
|
every time the command is called, this redirection is generated.
|
|
|
|
this is a problem if the redirection is wanted sometimes but not
|
|
|
|
always. for example /WHO #channel could create a window with a
|
|
|
|
list of people in channel redirecting WHO's events to it's own use,
|
|
|
|
but /WHO -nogui #channel would use the default WHO handler which
|
|
|
|
doesn't know anything about redirection. with GUI /WHO the
|
|
|
|
redirection would be done twice then..
|
|
|
|
|
|
|
|
so the kludgy workaround currently is this: make the default
|
|
|
|
handler handle the redirection always.. when default WHO/LIST
|
|
|
|
handler is called, they call
|
|
|
|
server_redirect_default("bogus command who") or ..list..
|
|
|
|
|
|
|
|
this is really a problem if some script/plugin wants to override
|
|
|
|
some default command to use redirections.. */
|
2000-11-04 11:54:58 -05:00
|
|
|
server_redirect_init(SERVER(server), "bogus command who", 2, "event 401", "event 315", "event 352", NULL);
|
|
|
|
server_redirect_init(SERVER(server), "bogus command list", 1, "event 321", "event 322", "event 323", NULL);
|
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", "");
|
2000-04-26 04:03:38 -04:00
|
|
|
settings_add_int("misc", "knockout_time", 300);
|
2000-08-14 17:17:51 -04:00
|
|
|
settings_add_str("misc", "wall_format", "[Wall/$0] $1-");
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
knockout_tag = g_timeout_add(KNOCKOUT_TIMECHECK, (GSourceFunc) knockout_timeout, NULL);
|
|
|
|
|
|
|
|
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
|
|
|
|
command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
|
|
|
|
command_bind("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
|
|
|
|
command_bind("part", NULL, (SIGNAL_FUNC) cmd_part);
|
|
|
|
command_bind("kick", NULL, (SIGNAL_FUNC) cmd_kick);
|
|
|
|
command_bind("topic", NULL, (SIGNAL_FUNC) cmd_topic);
|
|
|
|
command_bind("invite", NULL, (SIGNAL_FUNC) cmd_invite);
|
|
|
|
command_bind("list", NULL, (SIGNAL_FUNC) cmd_list);
|
|
|
|
command_bind("who", NULL, (SIGNAL_FUNC) cmd_who);
|
|
|
|
command_bind("names", NULL, (SIGNAL_FUNC) cmd_names);
|
2000-11-04 11:54:58 -05:00
|
|
|
command_bind("nick", NULL, (SIGNAL_FUNC) cmd_nick);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: NOTE <command> [&<password>] [+|-<flags>] [<arguments>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("note", NULL, (SIGNAL_FUNC) command_self);
|
|
|
|
command_bind("whois", NULL, (SIGNAL_FUNC) cmd_whois);
|
|
|
|
command_bind("whowas", NULL, (SIGNAL_FUNC) cmd_whowas);
|
|
|
|
command_bind("ping", NULL, (SIGNAL_FUNC) cmd_ping);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: KILL <nick> <reason> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("kill", NULL, (SIGNAL_FUNC) command_2self);
|
|
|
|
command_bind("away", NULL, (SIGNAL_FUNC) cmd_away);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: ISON <nicks> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("ison", NULL, (SIGNAL_FUNC) command_1self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: ADMIN [<server>|<nickname>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("admin", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: INFO [<server>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("info", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: LINKS [[<server>] <mask>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("links", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: LUSERS [<server mask> [<remote server>]] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("lusers", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: MAP */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("map", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: MOTD [<server>|<nick>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("motd", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: REHASH */
|
2000-07-02 15:22:30 -04:00
|
|
|
command_bind("rehash", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: STATS <type> [<server>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("stats", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TIME [<server>|<nick>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("time", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TRACE [<server>|<nick>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("trace", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: VERSION [<server>|<nick>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("version", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SERVLIST [<server mask>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("servlist", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SILENCE [[+|-]<nick!user@host>]
|
|
|
|
SILENCE [<nick>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("silence", NULL, (SIGNAL_FUNC) command_self);
|
2000-10-01 17:00:59 -04:00
|
|
|
command_bind("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SQUERY <service> [<commands>] */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("squery", NULL, (SIGNAL_FUNC) command_2self);
|
|
|
|
command_bind("deop", NULL, (SIGNAL_FUNC) cmd_deop);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: DIE */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("die", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: HASH */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("hash", NULL, (SIGNAL_FUNC) command_self);
|
2000-08-19 16:14:09 -04:00
|
|
|
command_bind("oper", NULL, (SIGNAL_FUNC) cmd_oper);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: RESTART */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("restart", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: RPING <server> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("rping", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: SQUIT <server>|<mask> <reason> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("squit", NULL, (SIGNAL_FUNC) command_2self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: UPING <server> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("uping", NULL, (SIGNAL_FUNC) command_self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: USERHOST <nicks> */
|
2000-06-01 11:04:41 -04:00
|
|
|
command_bind("userhost", NULL, (SIGNAL_FUNC) command_self);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("quote", NULL, (SIGNAL_FUNC) cmd_quote);
|
|
|
|
command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall);
|
2000-11-30 18:13:15 -05:00
|
|
|
command_bind("wait", NULL, (SIGNAL_FUNC) cmd_wait);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WALLOPS <message> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("wallops", NULL, (SIGNAL_FUNC) command_1self);
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: WALLCHOPS <channel> <message> */
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("wallchops", NULL, (SIGNAL_FUNC) command_2self);
|
|
|
|
command_bind("cycle", NULL, (SIGNAL_FUNC) cmd_cycle);
|
|
|
|
command_bind("kickban", NULL, (SIGNAL_FUNC) cmd_kickban);
|
|
|
|
command_bind("knockout", NULL, (SIGNAL_FUNC) cmd_knockout);
|
|
|
|
|
|
|
|
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
|
|
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
2000-11-04 11:54:58 -05:00
|
|
|
signal_add("nickchange over", (SIGNAL_FUNC) sig_nickchange_over);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_add("whois not found", (SIGNAL_FUNC) sig_whois_not_found);
|
|
|
|
signal_add("whois event", (SIGNAL_FUNC) event_whois);
|
|
|
|
signal_add("whowas event", (SIGNAL_FUNC) event_whowas);
|
2001-02-18 21:15:15 -05:00
|
|
|
signal_add("server connected", (SIGNAL_FUNC) sig_connected);
|
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);
|
|
|
|
command_unbind("admin", (SIGNAL_FUNC) command_self);
|
|
|
|
command_unbind("info", (SIGNAL_FUNC) command_self);
|
|
|
|
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("deop", (SIGNAL_FUNC) cmd_deop);
|
|
|
|
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);
|
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("wallchops", (SIGNAL_FUNC) command_2self);
|
|
|
|
command_unbind("cycle", (SIGNAL_FUNC) cmd_cycle);
|
|
|
|
command_unbind("kickban", (SIGNAL_FUNC) cmd_kickban);
|
|
|
|
command_unbind("knockout", (SIGNAL_FUNC) cmd_knockout);
|
|
|
|
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
|
|
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
2000-11-04 11:54:58 -05:00
|
|
|
signal_remove("nickchange over", (SIGNAL_FUNC) sig_nickchange_over);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_remove("whois not found", (SIGNAL_FUNC) sig_whois_not_found);
|
|
|
|
signal_remove("whois event", (SIGNAL_FUNC) event_whois);
|
|
|
|
signal_remove("whowas event", (SIGNAL_FUNC) event_whowas);
|
2001-02-18 21:15:15 -05:00
|
|
|
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_string_free(tmpstr, TRUE);
|
|
|
|
}
|