2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
fe-irc-commands.c : irssi
|
|
|
|
|
|
|
|
Copyright (C) 1999-2000 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 "module-formats.h"
|
|
|
|
#include "signals.h"
|
2001-01-14 13:16:39 -05:00
|
|
|
#include "misc.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "special-vars.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include "levels.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "mode-lists.h"
|
|
|
|
#include "nicklist.h"
|
2001-11-01 20:05:14 -05:00
|
|
|
#include "irc-commands.h"
|
|
|
|
#include "irc-servers.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "irc-channels.h"
|
|
|
|
#include "irc-queries.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "fe-queries.h"
|
2000-11-17 11:27:14 -05:00
|
|
|
#include "fe-windows.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "window-items.h"
|
2000-10-28 16:14:19 -04:00
|
|
|
#include "printtext.h"
|
2001-01-04 13:01:51 -05:00
|
|
|
#include "keyboard.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-06-04 15:50:16 -04:00
|
|
|
static char *skip_target(char *target)
|
|
|
|
{
|
|
|
|
if (*target == '@') {
|
|
|
|
/* @#channel, @+#channel - Hybrid6 / Bahamut features */
|
|
|
|
if (target[1] == '+' && ischannel(target[2]))
|
|
|
|
target += 2;
|
|
|
|
else if (ischannel(target[1]))
|
|
|
|
target++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: ME <message> */
|
2001-01-28 05:16:43 -05:00
|
|
|
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
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_ITEM(item))
|
2000-04-26 04:03:38 -04:00
|
|
|
return;
|
|
|
|
|
2000-07-15 09:04:03 -04:00
|
|
|
if (server == NULL || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_action", 3, server, data, item->name);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
|
|
|
|
item->name, data);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-07-25 13:40:56 -04:00
|
|
|
/* SYNTAX: ACTION <target> <message> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_action(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
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&target, &text))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-07-15 09:04:03 -04:00
|
|
|
if (*target == '\0' || *text == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_action", 3, server, text, target);
|
|
|
|
|
2001-06-04 15:50:16 -04:00
|
|
|
target = skip_target(target);
|
2000-04-26 04:03:38 -04:00
|
|
|
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-11-03 13:36:40 -05:00
|
|
|
static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-06-03 21:36:07 -04:00
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *msg;
|
|
|
|
void *free_arg;
|
2000-06-03 21:36:07 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-06-03 21:36:07 -04:00
|
|
|
|
2001-11-03 13:36:40 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
|
|
|
PARAM_FLAG_OPTCHAN, item, &target, &msg))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-01-28 05:16:43 -05:00
|
|
|
if (*target == '\0' || *msg == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-06-03 21:36:07 -04:00
|
|
|
|
2001-06-04 15:50:16 -04:00
|
|
|
target = skip_target(target);
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_notice", 3, server, msg, target);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-06-03 21:36:07 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2000-06-17 21:18:12 -04:00
|
|
|
char *target, *ctcpcmd, *ctcpdata;
|
|
|
|
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,
|
2001-01-28 05:16:43 -05:00
|
|
|
&target, &ctcpcmd, &ctcpdata))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-01-28 05:16:43 -05:00
|
|
|
if (*target == '\0' || *ctcpcmd == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-07-15 09:04:03 -04:00
|
|
|
if (*target == '=') {
|
|
|
|
/* don't handle DCC CTCPs */
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-04 15:50:16 -04:00
|
|
|
target = skip_target(target);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_strup(ctcpcmd);
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_ctcp", 4,
|
|
|
|
server, ctcpcmd, ctcpdata, target);
|
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-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
|
|
|
{
|
2001-01-28 05:16:43 -05:00
|
|
|
char *target, *text;
|
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, 2 | PARAM_FLAG_GETREST |
|
|
|
|
PARAM_FLAG_OPTCHAN, item, &target, &text))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2001-01-28 05:16:43 -05:00
|
|
|
if (*target == '\0' || *text == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-06-04 15:50:16 -04:00
|
|
|
target = skip_target(target);
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_notice", 3, server, text, target);
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
static void cmd_wall(const char *data, IRC_SERVER_REC *server,
|
|
|
|
WI_ITEM_REC *item)
|
2000-06-09 11:50:04 -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-06-09 11:50:04 -04:00
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-06-09 11:50:04 -04:00
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
|
|
|
PARAM_FLAG_GETREST, item, &channame, &msg))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
2000-06-09 11:50:04 -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-06-09 11:50:04 -04:00
|
|
|
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
|
|
|
|
2001-01-28 05:16:43 -05:00
|
|
|
signal_emit("message irc own_wall", 3, server, msg, chanrec->name);
|
2000-06-09 11:50:04 -04:00
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-06-09 11:50:04 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 20:11:40 -04:00
|
|
|
static void bans_ask_channel(const char *channel, IRC_SERVER_REC *server,
|
2000-08-26 11:39:44 -04:00
|
|
|
WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-07-23 20:11:40 -04:00
|
|
|
GString *str;
|
|
|
|
|
|
|
|
str = g_string_new(NULL);
|
|
|
|
g_string_sprintf(str, "%s b", channel);
|
|
|
|
signal_emit("command mode", 3, str->str, server, item);
|
|
|
|
if (server->emode_known) {
|
|
|
|
g_string_sprintf(str, "%s e", channel);
|
|
|
|
signal_emit("command mode", 3, str->str, server, item);
|
|
|
|
}
|
|
|
|
g_string_free(str, TRUE);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server)
|
2000-07-23 20:11:40 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2001-01-04 12:28:26 -05:00
|
|
|
int counter;
|
|
|
|
|
|
|
|
if (!channel->synced)
|
|
|
|
cmd_return_error(CMDERR_CHAN_NOT_SYNCED);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-07-23 20:11:40 -04:00
|
|
|
if (channel->banlist == NULL && channel->ebanlist == NULL) {
|
2001-08-13 10:00:57 -04:00
|
|
|
printformat(server, channel->name, MSGLEVEL_CLIENTNOTICE,
|
2000-07-23 20:11:40 -04:00
|
|
|
IRCTXT_NO_BANS, channel->name);
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* show bans.. */
|
2001-01-04 12:28:26 -05:00
|
|
|
counter = 1;
|
2000-04-26 04:03:38 -04:00
|
|
|
for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) {
|
2000-07-23 20:11:40 -04:00
|
|
|
BAN_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
2000-08-25 06:46:47 -04:00
|
|
|
(rec->setby == NULL || *rec->setby == '\0') ?
|
|
|
|
IRCTXT_BANLIST : IRCTXT_BANLIST_LONG,
|
2001-01-04 12:28:26 -05:00
|
|
|
counter, channel->name, rec->ban, rec->setby,
|
2000-08-25 06:46:47 -04:00
|
|
|
(int) (time(NULL)-rec->time));
|
2001-01-04 12:28:26 -05:00
|
|
|
counter++;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ..and show ban exceptions.. */
|
|
|
|
for (tmp = channel->ebanlist; tmp != NULL; tmp = tmp->next) {
|
2000-07-23 20:11:40 -04:00
|
|
|
BAN_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
2000-08-25 06:46:47 -04:00
|
|
|
(rec->setby == NULL || *rec->setby == '\0') ?
|
|
|
|
IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG,
|
|
|
|
channel->name, rec->ban, rec->setby,
|
|
|
|
(int) (time(NULL)-rec->time));
|
2000-07-23 20:11:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SYNTAX: BAN [<channel>] [<nicks>] */
|
|
|
|
static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
2000-08-26 11:39:44 -04:00
|
|
|
WI_ITEM_REC *item)
|
2000-07-23 20:11:40 -04:00
|
|
|
{
|
2000-08-26 11:39:44 -04:00
|
|
|
IRC_CHANNEL_REC *chanrec;
|
2000-07-23 20:11:40 -04:00
|
|
|
char *channel, *nicks;
|
|
|
|
void *free_arg;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-07-23 20:11:40 -04:00
|
|
|
|
|
|
|
if (!cmd_get_params(data, &free_arg, 2 |
|
|
|
|
PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
|
|
|
item, &channel, &nicks))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (*nicks != '\0') {
|
|
|
|
/* setting ban - don't handle here */
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* display bans */
|
2000-08-26 11:39:44 -04:00
|
|
|
chanrec = IRC_CHANNEL(item);
|
2000-07-23 20:11:40 -04:00
|
|
|
if (chanrec == NULL && *channel == '\0')
|
|
|
|
cmd_param_error(CMDERR_NOT_JOINED);
|
|
|
|
|
|
|
|
if (*channel != '\0' && strcmp(channel, "*") != 0)
|
2000-08-26 11:39:44 -04:00
|
|
|
chanrec = irc_channel_find(server, channel);
|
2000-07-23 20:11:40 -04:00
|
|
|
|
|
|
|
if (chanrec == NULL) {
|
|
|
|
/* not joined to such channel,
|
|
|
|
but ask ban lists from server */
|
|
|
|
bans_ask_channel(channel, server, item);
|
|
|
|
} else {
|
|
|
|
bans_show_channel(chanrec, server);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
2000-04-27 07:44:55 -04:00
|
|
|
|
|
|
|
signal_stop();
|
2000-07-23 20:11:40 -04:00
|
|
|
cmd_params_free(free_arg);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: INVITELIST [<channel>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_invitelist(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 *channel, *cur_channel;
|
2000-04-26 04:03:38 -04:00
|
|
|
GSList *tmp;
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
cur_channel = IRC_CHANNEL(item);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
|
|
|
|
|
|
|
|
if (strcmp(data, "*") == 0 || *data == '\0')
|
|
|
|
channel = cur_channel;
|
|
|
|
else
|
2000-08-26 11:39:44 -04:00
|
|
|
channel = irc_channel_find(server, data);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (channel == NULL) cmd_return_error(CMDERR_CHAN_NOT_FOUND);
|
|
|
|
|
2001-08-13 10:00:57 -04:00
|
|
|
if (!channel->synced)
|
|
|
|
cmd_return_error(CMDERR_CHAN_NOT_SYNCED);
|
|
|
|
|
|
|
|
if (channel->invitelist == NULL) {
|
|
|
|
printformat(server, channel->name, MSGLEVEL_CLIENTNOTICE,
|
|
|
|
IRCTXT_NO_INVITELIST, channel->name);
|
|
|
|
} else {
|
|
|
|
for (tmp = channel->invitelist; tmp != NULL; tmp = tmp->next) {
|
|
|
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
|
|
|
IRCTXT_INVITELIST,
|
|
|
|
channel->name, tmp->data);
|
|
|
|
}
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: VER [<target>] */
|
2000-08-26 11:39:44 -04:00
|
|
|
static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
CMD_IRC_SERVER(server);
|
2000-08-26 11:39:44 -04:00
|
|
|
if (*data == '\0' && !IS_IRC_ITEM(item))
|
2000-04-26 04:03:38 -04:00
|
|
|
cmd_return_error(CMDERR_NOT_JOINED);
|
|
|
|
|
|
|
|
str = g_strdup_printf("%s VERSION", *data == '\0' ? item->name : data);
|
|
|
|
signal_emit("command ctcp", 3, str, server, item);
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
2000-11-17 09:59:32 -05:00
|
|
|
static void cmd_topic(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|
|
|
{
|
|
|
|
CHANNEL_REC *channel;
|
|
|
|
char *timestr;
|
2001-01-14 13:16:39 -05:00
|
|
|
|
2000-11-17 09:59:32 -05:00
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
channel = *data != '\0' ? channel_find(server, data) : CHANNEL(item);
|
|
|
|
if (channel == NULL) return;
|
2001-01-28 05:16:43 -05:00
|
|
|
|
2000-11-17 09:59:32 -05:00
|
|
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
|
|
|
channel->topic == NULL ? IRCTXT_NO_TOPIC : IRCTXT_TOPIC,
|
|
|
|
channel->name, channel->topic);
|
|
|
|
|
|
|
|
if (channel->topic_time > 0) {
|
2001-01-14 13:16:39 -05:00
|
|
|
timestr = my_asctime(channel->topic_time);
|
2000-11-17 09:59:32 -05:00
|
|
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
|
|
|
IRCTXT_TOPIC_INFO, channel->topic_by, timestr);
|
|
|
|
g_free(timestr);
|
|
|
|
}
|
|
|
|
signal_stop();
|
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: TS */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_ts(const char *data)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
|
|
|
CHANNEL_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_TOPIC,
|
|
|
|
rec->name, rec->topic == NULL ? "" : rec->topic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-04 13:01:51 -05:00
|
|
|
typedef struct {
|
|
|
|
IRC_SERVER_REC *server;
|
|
|
|
char *nick;
|
|
|
|
} OPER_PASS_REC;
|
|
|
|
|
|
|
|
static void cmd_oper_got_pass(const char *password, OPER_PASS_REC *rec)
|
|
|
|
{
|
|
|
|
if (*password != '\0')
|
|
|
|
irc_send_cmdv(rec->server, "OPER %s %s", rec->nick, password);
|
|
|
|
g_free(rec->nick);
|
|
|
|
g_free(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_oper(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
2001-05-17 16:13:59 -04:00
|
|
|
char *nick, *password, *format;
|
2001-01-04 13:01:51 -05:00
|
|
|
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, 2, &nick, &password))
|
|
|
|
return;
|
|
|
|
if (*password == '\0') {
|
|
|
|
/* password not given, ask it.
|
|
|
|
irc/core handles the /OPER when password is given */
|
|
|
|
OPER_PASS_REC *rec;
|
|
|
|
|
|
|
|
rec = g_new(OPER_PASS_REC, 1);
|
|
|
|
rec->server = server;
|
|
|
|
rec->nick = g_strdup(*nick != '\0' ? nick : server->nick);
|
|
|
|
|
2001-05-17 16:13:59 -04:00
|
|
|
format = format_get_text(MODULE_NAME, NULL, server, NULL,
|
|
|
|
IRCTXT_ASK_OPER_PASS);
|
|
|
|
|
2001-01-04 13:01:51 -05:00
|
|
|
keyboard_entry_redirect((SIGNAL_FUNC) cmd_oper_got_pass,
|
2001-05-17 16:13:59 -04:00
|
|
|
format,
|
2001-01-04 13:01:51 -05:00
|
|
|
ENTRY_REDIRECT_FLAG_HIDDEN, rec);
|
2001-05-17 16:13:59 -04:00
|
|
|
g_free(format);
|
2001-01-04 13:01:51 -05:00
|
|
|
|
|
|
|
signal_stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_params_free(free_arg);
|
|
|
|
}
|
|
|
|
|
2001-08-14 08:33:29 -04:00
|
|
|
/* SYNTAX: SETHOST <host> <password> (non-ircops)
|
|
|
|
SETHOST <ident> <host> (ircops) */
|
|
|
|
static void cmd_sethost(const char *data, IRC_SERVER_REC *server)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
|
|
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
/* Save all the joined channels in server to window binds, since
|
|
|
|
the server will soon /PART + /JOIN us in all channels. */
|
|
|
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
|
|
|
CHANNEL_REC *channel = tmp->data;
|
|
|
|
|
|
|
|
window_bind_add(window_item_window(channel),
|
|
|
|
server->tag, channel->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
irc_send_cmdv(server, "SETHOST %s", data);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void fe_irc_commands_init(void)
|
|
|
|
{
|
2001-11-01 20:05:14 -05:00
|
|
|
command_bind_irc_last("me", NULL, (SIGNAL_FUNC) cmd_me);
|
|
|
|
command_bind_irc_last("action", NULL, (SIGNAL_FUNC) cmd_action);
|
|
|
|
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("wall", NULL, (SIGNAL_FUNC) cmd_wall);
|
|
|
|
command_bind_irc("ban", NULL, (SIGNAL_FUNC) cmd_ban);
|
|
|
|
command_bind_irc("invitelist", NULL, (SIGNAL_FUNC) cmd_invitelist);
|
|
|
|
command_bind_irc("ver", NULL, (SIGNAL_FUNC) cmd_ver);
|
|
|
|
command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic);
|
|
|
|
command_bind_irc("ts", NULL, (SIGNAL_FUNC) cmd_ts);
|
|
|
|
command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper);
|
|
|
|
command_bind_irc("sethost", NULL, (SIGNAL_FUNC) cmd_sethost);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void fe_irc_commands_deinit(void)
|
|
|
|
{
|
|
|
|
command_unbind("me", (SIGNAL_FUNC) cmd_me);
|
|
|
|
command_unbind("action", (SIGNAL_FUNC) cmd_action);
|
2000-06-03 21:36:07 -04:00
|
|
|
command_unbind("notice", (SIGNAL_FUNC) cmd_notice);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp);
|
|
|
|
command_unbind("nctcp", (SIGNAL_FUNC) cmd_nctcp);
|
2000-06-09 11:50:04 -04:00
|
|
|
command_unbind("wall", (SIGNAL_FUNC) cmd_wall);
|
2000-04-27 07:44:55 -04:00
|
|
|
command_unbind("ban", (SIGNAL_FUNC) cmd_ban);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("invitelist", (SIGNAL_FUNC) cmd_invitelist);
|
|
|
|
command_unbind("ver", (SIGNAL_FUNC) cmd_ver);
|
2000-11-17 09:59:32 -05:00
|
|
|
command_unbind("topic", (SIGNAL_FUNC) cmd_topic);
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("ts", (SIGNAL_FUNC) cmd_ts);
|
2001-01-04 13:01:51 -05:00
|
|
|
command_unbind("oper", (SIGNAL_FUNC) cmd_oper);
|
2001-08-14 08:33:29 -04:00
|
|
|
command_unbind("sethost", (SIGNAL_FUNC) cmd_sethost);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|