2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
fe-events.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"
|
2000-06-30 15:54:34 -04:00
|
|
|
#include "misc.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include "levels.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers.h"
|
|
|
|
#include "servers-redirect.h"
|
|
|
|
#include "servers-reconnect.h"
|
|
|
|
#include "queries.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "ignore.h"
|
|
|
|
|
2001-11-01 20:05:14 -05:00
|
|
|
#include "irc-servers.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "irc-channels.h"
|
|
|
|
#include "irc-nicklist.h"
|
2001-03-03 15:48:23 -05:00
|
|
|
#include "irc-masks.h"
|
2001-11-01 20:05:14 -05:00
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
#include "printtext.h"
|
2001-11-01 20:05:14 -05:00
|
|
|
#include "fe-queries.h"
|
|
|
|
#include "fe-windows.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
#include "completion.h"
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-06-12 18:57:53 -04:00
|
|
|
{
|
|
|
|
char *params, *target, *msg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-12 18:57:53 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-12 18:57:53 -04:00
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
|
|
|
if (nick == NULL) nick = server->real_address;
|
|
|
|
if (addr == NULL) addr = "";
|
|
|
|
|
2001-01-01 11:57:25 -05:00
|
|
|
if (*target == '@' && ischannel(target[1])) {
|
|
|
|
/* Hybrid 6 feature, send msg to all ops in channel */
|
|
|
|
signal_emit("message irc op_public", 5,
|
|
|
|
server, msg, nick, addr, target+1);
|
|
|
|
} else {
|
|
|
|
signal_emit(ischannel(*target) ?
|
|
|
|
"message public" : "message private", 5,
|
|
|
|
server, msg, nick, addr, target);
|
|
|
|
}
|
2000-06-12 18:57:53 -04:00
|
|
|
|
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2002-01-10 13:02:22 -05:00
|
|
|
static void ctcp_action(IRC_SERVER_REC *server, const char *data,
|
|
|
|
const char *nick, const char *addr,
|
|
|
|
const char *target)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-12 18:57:53 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-01-10 13:02:22 -05:00
|
|
|
signal_emit("message irc action", 5,
|
|
|
|
server, data, nick, addr, target);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_notice(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-12 18:57:53 -04:00
|
|
|
char *params, *target, *msg;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
|
|
|
if (nick == NULL) {
|
|
|
|
nick = server->real_address == NULL ?
|
|
|
|
server->connrec->address :
|
|
|
|
server->real_address;
|
|
|
|
}
|
|
|
|
|
2001-12-03 14:50:21 -05:00
|
|
|
signal_emit("message irc notice", 5,
|
|
|
|
server, msg, nick, addr, target);
|
2000-06-12 18:57:53 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_join(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *channel, *tmp;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
params = event_get_params(data, 1, &channel);
|
|
|
|
tmp = strchr(channel, 7); /* ^G does something weird.. */
|
|
|
|
if (tmp != NULL) *tmp = '\0';
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-10-09 20:08:23 -04:00
|
|
|
signal_emit("message join", 4, server, channel, nick, addr);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_part(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *channel, *reason;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-10-09 20:08:23 -04:00
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&channel, &reason);
|
|
|
|
signal_emit("message part", 5, server, channel, nick, addr, reason);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_quit(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
if (*data == ':') data++; /* quit message */
|
2000-10-09 20:08:23 -04:00
|
|
|
signal_emit("message quit", 4, server, nick, addr, data);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_kick(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *kicker, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *channel, *nick, *reason;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-10-09 20:08:23 -04:00
|
|
|
params = event_get_params(data, 3 | PARAM_FLAG_GETREST,
|
|
|
|
&channel, &nick, &reason);
|
|
|
|
signal_emit("message kick", 6, server, channel, nick,
|
|
|
|
kicker, addr, reason);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_kill(IRC_SERVER_REC *server, const char *data,
|
2000-11-25 20:30:05 -05:00
|
|
|
const char *nick, const char *addr)
|
|
|
|
{
|
|
|
|
char *params, *path, *reason;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
|
|
|
NULL, &path);
|
|
|
|
reason = strstr(path, " (");
|
|
|
|
if (reason == NULL || reason[strlen(reason)-1] != ')') {
|
|
|
|
/* weird server, maybe it didn't give path */
|
|
|
|
reason = path;
|
|
|
|
path = "";
|
|
|
|
} else {
|
|
|
|
/* reason inside (...) */
|
|
|
|
*reason = '\0';
|
|
|
|
reason += 2;
|
|
|
|
reason[strlen(reason)-1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (addr != NULL) {
|
|
|
|
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_KILL,
|
|
|
|
nick, addr, reason, path);
|
|
|
|
} else {
|
|
|
|
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_KILL_SERVER,
|
|
|
|
nick, reason, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_nick(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *sender, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
char *params, *newnick;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
params = event_get_params(data, 1, &newnick);
|
|
|
|
|
2001-06-10 19:38:36 -04:00
|
|
|
/* NOTE: server->nick was already changed in irc/core/irc-nicklist.c */
|
|
|
|
signal_emit(g_strcasecmp(newnick, server->nick) == 0 ?
|
2000-10-09 20:08:23 -04:00
|
|
|
"message own_nick" : "message nick", 4,
|
|
|
|
server, newnick, sender, addr);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_mode(IRC_SERVER_REC *server, const char *data,
|
2000-11-26 00:33:51 -05:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
char *params, *channel, *mode;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-11-26 00:33:51 -05:00
|
|
|
|
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&channel, &mode);
|
2000-11-30 20:31:55 -05:00
|
|
|
|
|
|
|
signal_emit("message mode", 5, server, channel, nick, addr,
|
|
|
|
g_strchomp(mode));
|
2000-11-26 00:33:51 -05:00
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_pong(IRC_SERVER_REC *server, const char *data, const char *nick)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
char *params, *host, *reply;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
if (nick == NULL) nick = server->real_address;
|
|
|
|
|
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &host, &reply);
|
|
|
|
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_PONG, host, reply);
|
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_invite(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *channel;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
params = event_get_params(data, 2, NULL, &channel);
|
2000-10-09 20:08:23 -04:00
|
|
|
signal_emit("message invite", 4, server, channel, nick, addr);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_topic(IRC_SERVER_REC *server, const char *data,
|
2000-10-09 20:08:23 -04:00
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *channel, *topic;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-10-09 20:08:23 -04:00
|
|
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
|
|
|
&channel, &topic);
|
|
|
|
signal_emit("message topic", 5, server, channel, topic, nick, addr);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_error(IRC_SERVER_REC *server, const char *data)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
if (*data == ':') data++;
|
|
|
|
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_ERROR, data);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_wallops(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
if (*data == ':') data++;
|
2000-10-09 20:08:23 -04:00
|
|
|
if (ignore_check(SERVER(server), nick, addr, NULL, data, MSGLEVEL_WALLOPS))
|
2000-06-10 20:58:15 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
if (g_strncasecmp(data, "\001ACTION", 7) != 0)
|
2000-06-10 20:58:15 -04:00
|
|
|
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_WALLOPS, nick, data);
|
|
|
|
else {
|
|
|
|
/* Action in WALLOP */
|
|
|
|
int len;
|
2000-06-12 18:57:53 -04:00
|
|
|
char *tmp;
|
2000-06-10 20:58:15 -04:00
|
|
|
|
2000-06-12 18:57:53 -04:00
|
|
|
tmp = g_strdup(data);
|
|
|
|
len = strlen(tmp);
|
|
|
|
if (tmp[len-1] == 1) tmp[len-1] = '\0';
|
|
|
|
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_ACTION_WALLOPS, nick, tmp);
|
|
|
|
g_free(tmp);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_silence(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr)
|
2000-10-01 17:00:59 -04:00
|
|
|
{
|
|
|
|
g_return_if_fail(data != NULL);
|
2000-10-09 20:08:23 -04:00
|
|
|
|
2000-10-01 17:00:59 -04:00
|
|
|
g_return_if_fail(*data == '+' || *data == '-');
|
|
|
|
|
|
|
|
printformat(server, NULL, MSGLEVEL_CRAP, *data == '+' ? IRCTXT_SILENCED : IRCTXT_UNSILENCED, data+1);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
static void channel_sync(CHANNEL_REC *channel)
|
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(channel != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
printformat(channel->server, channel->name, MSGLEVEL_CLIENTNOTICE|MSGLEVEL_NO_ACT,
|
|
|
|
IRCTXT_CHANNEL_SYNCED, channel->name, (long) (time(NULL)-channel->createtime));
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void event_connected(IRC_SERVER_REC *server)
|
|
|
|
{
|
2000-06-12 18:57:53 -04:00
|
|
|
const char *nick;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(server != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-01-27 21:37:54 -05:00
|
|
|
nick = server->connrec->nick;
|
|
|
|
if (g_strcasecmp(server->nick, nick) == 0)
|
2000-06-10 20:58:15 -04:00
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
/* someone has our nick, find out who. */
|
2001-12-03 14:50:21 -05:00
|
|
|
server_redirect_event(server, "whois", 1, nick, TRUE, NULL,
|
2001-11-11 13:59:19 -05:00
|
|
|
"event 311", "nickfind event whois",
|
|
|
|
"", "event empty", NULL);
|
2000-06-10 20:58:15 -04:00
|
|
|
irc_send_cmdv(server, "WHOIS %s", nick);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_nickfind_whois(IRC_SERVER_REC *server, const char *data)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
char *params, *nick, *user, *host, *realname;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-10 20:58:15 -04:00
|
|
|
params = event_get_params(data, 6, NULL, &nick, &user, &host, NULL, &realname);
|
|
|
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_YOUR_NICK_OWNED, nick, user, host, realname);
|
|
|
|
g_free(params);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-03-03 15:48:23 -05:00
|
|
|
static void event_ban_type_changed(void *ban_typep)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-06-10 20:58:15 -04:00
|
|
|
GString *str;
|
2001-03-03 15:48:23 -05:00
|
|
|
int ban_type;
|
2000-06-10 20:58:15 -04:00
|
|
|
|
2001-03-03 15:48:23 -05:00
|
|
|
ban_type = GPOINTER_TO_INT(ban_typep);
|
2000-06-10 20:58:15 -04:00
|
|
|
|
2001-03-03 15:48:23 -05:00
|
|
|
if (ban_type == 0) {
|
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
|
|
|
IRCTXT_BANTYPE, "Error, using Normal");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ban_type == (IRC_MASK_USER|IRC_MASK_DOMAIN)) {
|
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
|
|
|
IRCTXT_BANTYPE, "Normal");
|
|
|
|
} else if (ban_type == (IRC_MASK_HOST|IRC_MASK_DOMAIN)) {
|
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
|
|
|
IRCTXT_BANTYPE, "Host");
|
|
|
|
} else if (ban_type == IRC_MASK_DOMAIN) {
|
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
|
|
|
IRCTXT_BANTYPE, "Domain");
|
|
|
|
} else {
|
2000-06-10 20:58:15 -04:00
|
|
|
str = g_string_new("Custom:");
|
2001-03-03 15:48:23 -05:00
|
|
|
if (ban_type & IRC_MASK_NICK)
|
2000-06-10 20:58:15 -04:00
|
|
|
g_string_append(str, " Nick");
|
2001-03-03 15:48:23 -05:00
|
|
|
if (ban_type & IRC_MASK_USER)
|
2000-06-10 20:58:15 -04:00
|
|
|
g_string_append(str, " User");
|
2001-03-03 15:48:23 -05:00
|
|
|
if (ban_type & IRC_MASK_HOST)
|
2000-06-10 20:58:15 -04:00
|
|
|
g_string_append(str, " Host");
|
2001-03-03 15:48:23 -05:00
|
|
|
if (ban_type & IRC_MASK_DOMAIN)
|
2000-06-10 20:58:15 -04:00
|
|
|
g_string_append(str, " Domain");
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-03-03 15:48:23 -05:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
|
|
|
IRCTXT_BANTYPE, str->str);
|
2000-06-10 20:58:15 -04:00
|
|
|
g_string_free(str, TRUE);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void sig_whois_event_no_server(IRC_SERVER_REC *server, const char *data)
|
2000-10-14 12:02:35 -04:00
|
|
|
{
|
|
|
|
char *params, *nick;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
params = event_get_params(data, 2, NULL, &nick);
|
2001-01-02 14:15:24 -05:00
|
|
|
printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_NOT_FOUND, nick);
|
2000-10-14 12:02:35 -04:00
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void sig_whowas_event_end(IRC_SERVER_REC *server, const char *data,
|
2000-10-14 12:02:35 -04:00
|
|
|
const char *sender, const char *addr)
|
2000-06-10 17:40:00 -04:00
|
|
|
{
|
|
|
|
char *params, *nick;
|
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
if (server->whowas_found) {
|
2000-12-05 16:12:52 -05:00
|
|
|
signal_emit("event 369", 4, server, data, sender, addr);
|
2000-06-10 17:40:00 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
params = event_get_params(data, 2, NULL, &nick);
|
2001-01-02 14:15:24 -05:00
|
|
|
printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_NOT_FOUND, nick);
|
2000-06-10 17:40:00 -04:00
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
2000-12-05 16:12:52 -05:00
|
|
|
static void event_received(IRC_SERVER_REC *server, const char *data,
|
|
|
|
const char *nick, const char *addr)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-04 06:32:42 -04:00
|
|
|
char *params, *cmd, *args, *ptr;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
g_return_if_fail(data != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-01-27 15:45:59 -05:00
|
|
|
if (!i_isdigit(*data)) {
|
2000-05-04 06:32:42 -04:00
|
|
|
printtext(server, NULL, MSGLEVEL_CRAP, "%s", data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* numeric event. */
|
|
|
|
params = event_get_params(data, 3 | PARAM_FLAG_GETREST, &cmd, NULL, &args);
|
|
|
|
ptr = strstr(args, " :");
|
2000-04-26 04:03:38 -04:00
|
|
|
if (ptr != NULL) *(ptr+1) = ' ';
|
|
|
|
printtext(server, NULL, MSGLEVEL_CRAP, "%s", args);
|
|
|
|
g_free(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fe_events_init(void)
|
|
|
|
{
|
|
|
|
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
2002-01-10 13:02:22 -05:00
|
|
|
signal_add("ctcp action", (SIGNAL_FUNC) ctcp_action);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_add("event notice", (SIGNAL_FUNC) event_notice);
|
|
|
|
signal_add("event join", (SIGNAL_FUNC) event_join);
|
|
|
|
signal_add("event part", (SIGNAL_FUNC) event_part);
|
|
|
|
signal_add("event quit", (SIGNAL_FUNC) event_quit);
|
|
|
|
signal_add("event kick", (SIGNAL_FUNC) event_kick);
|
2000-11-25 20:30:05 -05:00
|
|
|
signal_add("event kill", (SIGNAL_FUNC) event_kill);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_add("event nick", (SIGNAL_FUNC) event_nick);
|
|
|
|
signal_add("event mode", (SIGNAL_FUNC) event_mode);
|
|
|
|
signal_add("event pong", (SIGNAL_FUNC) event_pong);
|
|
|
|
signal_add("event invite", (SIGNAL_FUNC) event_invite);
|
|
|
|
signal_add("event topic", (SIGNAL_FUNC) event_topic);
|
|
|
|
signal_add("event error", (SIGNAL_FUNC) event_error);
|
|
|
|
signal_add("event wallops", (SIGNAL_FUNC) event_wallops);
|
2000-10-01 17:00:59 -04:00
|
|
|
signal_add("event silence", (SIGNAL_FUNC) event_silence);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
signal_add("default event", (SIGNAL_FUNC) event_received);
|
|
|
|
|
|
|
|
signal_add("channel sync", (SIGNAL_FUNC) channel_sync);
|
|
|
|
signal_add("event connected", (SIGNAL_FUNC) event_connected);
|
|
|
|
signal_add("nickfind event whois", (SIGNAL_FUNC) event_nickfind_whois);
|
|
|
|
signal_add("ban type changed", (SIGNAL_FUNC) event_ban_type_changed);
|
2000-10-14 12:02:35 -04:00
|
|
|
signal_add("whois event noserver", (SIGNAL_FUNC) sig_whois_event_no_server);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_add("whowas event end", (SIGNAL_FUNC) sig_whowas_event_end);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void fe_events_deinit(void)
|
|
|
|
{
|
|
|
|
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
2002-01-10 13:02:22 -05:00
|
|
|
signal_remove("ctcp action", (SIGNAL_FUNC) ctcp_action);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_remove("event notice", (SIGNAL_FUNC) event_notice);
|
|
|
|
signal_remove("event join", (SIGNAL_FUNC) event_join);
|
|
|
|
signal_remove("event part", (SIGNAL_FUNC) event_part);
|
|
|
|
signal_remove("event quit", (SIGNAL_FUNC) event_quit);
|
|
|
|
signal_remove("event kick", (SIGNAL_FUNC) event_kick);
|
2000-11-25 20:30:05 -05:00
|
|
|
signal_remove("event kill", (SIGNAL_FUNC) event_kill);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
|
|
|
|
signal_remove("event mode", (SIGNAL_FUNC) event_mode);
|
|
|
|
signal_remove("event pong", (SIGNAL_FUNC) event_pong);
|
|
|
|
signal_remove("event invite", (SIGNAL_FUNC) event_invite);
|
|
|
|
signal_remove("event topic", (SIGNAL_FUNC) event_topic);
|
|
|
|
signal_remove("event error", (SIGNAL_FUNC) event_error);
|
|
|
|
signal_remove("event wallops", (SIGNAL_FUNC) event_wallops);
|
2000-10-01 17:00:59 -04:00
|
|
|
signal_remove("event silence", (SIGNAL_FUNC) event_silence);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
signal_remove("default event", (SIGNAL_FUNC) event_received);
|
|
|
|
|
|
|
|
signal_remove("channel sync", (SIGNAL_FUNC) channel_sync);
|
|
|
|
signal_remove("event connected", (SIGNAL_FUNC) event_connected);
|
|
|
|
signal_remove("nickfind event whois", (SIGNAL_FUNC) event_nickfind_whois);
|
|
|
|
signal_remove("ban type changed", (SIGNAL_FUNC) event_ban_type_changed);
|
2000-10-14 12:02:35 -04:00
|
|
|
signal_remove("whois event noserver", (SIGNAL_FUNC) sig_whois_event_no_server);
|
2000-06-10 17:40:00 -04:00
|
|
|
signal_remove("whowas event end", (SIGNAL_FUNC) sig_whowas_event_end);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|