summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-11-26 01:30:05 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-11-26 01:30:05 +0000
commit3fbd7d5c828689db053a6a20b96b344a2fa5c17e (patch)
tree62a8622090bc5786be60537f686ad30f5b30af89 /src
parent746bd9b4f0b6b54874068bd0c77b021e0dfaaaac (diff)
downloadirssi-3fbd7d5c828689db053a6a20b96b344a2fa5c17e.zip
Added KILL handling - user/server kills are now printed formatted.
If server kills you, connect back (almost) immediately, it was probably just nick collision and you really want to connect back soon. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@869 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/irc/fe-events.c34
-rw-r--r--src/fe-common/irc/module-formats.c4
-rw-r--r--src/fe-common/irc/module-formats.h2
-rw-r--r--src/irc/core/irc-servers-reconnect.c20
4 files changed, 59 insertions, 1 deletions
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index 19086b40..fb811638 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -193,6 +193,38 @@ static void event_kick(const char *data, IRC_SERVER_REC *server,
g_free(params);
}
+static void event_kill(const char *data, IRC_SERVER_REC *server,
+ 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);
+}
+
static void event_nick(const char *data, IRC_SERVER_REC *server,
const char *sender, const char *addr)
{
@@ -453,6 +485,7 @@ void fe_events_init(void)
signal_add("event part", (SIGNAL_FUNC) event_part);
signal_add("event quit", (SIGNAL_FUNC) event_quit);
signal_add("event kick", (SIGNAL_FUNC) event_kick);
+ signal_add("event kill", (SIGNAL_FUNC) event_kill);
signal_add("event nick", (SIGNAL_FUNC) event_nick);
signal_add("event mode", (SIGNAL_FUNC) event_mode);
signal_add("event pong", (SIGNAL_FUNC) event_pong);
@@ -482,6 +515,7 @@ void fe_events_deinit(void)
signal_remove("event part", (SIGNAL_FUNC) event_part);
signal_remove("event quit", (SIGNAL_FUNC) event_quit);
signal_remove("event kick", (SIGNAL_FUNC) event_kick);
+ signal_remove("event kill", (SIGNAL_FUNC) event_kill);
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
signal_remove("event mode", (SIGNAL_FUNC) event_mode);
signal_remove("event pong", (SIGNAL_FUNC) event_pong);
diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c
index 8e4c401b..578cea16 100644
--- a/src/fe-common/irc/module-formats.c
+++ b/src/fe-common/irc/module-formats.c
@@ -147,7 +147,9 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "pong", "PONG received from $0: $1", 2, { 0, 0 } },
{ "wallops", "{wallop WALLOP {wallop_nick $0}} $1", 2, { 0, 0 } },
{ "action_wallops", "{wallop WALLOP {wallop_action $0}} $1", 2, { 0, 0 } },
- { "error", "{hilight ERROR} $0", 1, { 0 } },
+ { "kill", "You were {error killed} by {nick $0} {nickhost $1} {reason $2} [Path: $3]", 4, { 0, 0, 0, 0 } },
+ { "kill_server", "You were {error killed} by {server $0} {reason $1} [Path: $2]", 3, { 0, 0, 0 } },
+ { "error", "{error ERROR} $0", 1, { 0 } },
{ "unknown_mode", "Unknown mode character $0", 1, { 0 } },
{ "not_chanop", "You're not channel operator in {channel $0}", 1, { 0 } },
diff --git a/src/fe-common/irc/module-formats.h b/src/fe-common/irc/module-formats.h
index c1ad6d9d..48df0aa2 100644
--- a/src/fe-common/irc/module-formats.h
+++ b/src/fe-common/irc/module-formats.h
@@ -118,6 +118,8 @@ enum {
IRCTXT_PONG,
IRCTXT_WALLOPS,
IRCTXT_ACTION_WALLOPS,
+ IRCTXT_KILL,
+ IRCTXT_KILL_SERVER,
IRCTXT_ERROR,
IRCTXT_UNKNOWN_MODE,
IRCTXT_NOT_CHANOP,
diff --git a/src/irc/core/irc-servers-reconnect.c b/src/irc/core/irc-servers-reconnect.c
index f5ad9d6c..2280cc0e 100644
--- a/src/irc/core/irc-servers-reconnect.c
+++ b/src/irc/core/irc-servers-reconnect.c
@@ -101,11 +101,30 @@ static void sig_connected(IRC_SERVER_REC *server)
}
}
+static void event_kill(const char *data, IRC_SERVER_REC *server,
+ const char *nick, const char *addr)
+{
+ time_t new_connect;
+
+ if (!IS_IRC_SERVER(server)/* || addr != NULL*/)
+ return;
+
+ /* after server kills we want to connect back immediately - it was
+ probably a nick collision. but no matter how hard they kill us,
+ don't connect to the server more than once in every 10 seconds. */
+
+ new_connect = server->connect_time+10 -
+ settings_get_int("server_reconnect_time");
+ if (server->connect_time > new_connect)
+ server->connect_time = new_connect;
+}
+
void irc_servers_reconnect_init(void)
{
signal_add("server connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
signal_add("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
+ signal_add("event kill", (SIGNAL_FUNC) event_kill);
}
void irc_servers_reconnect_deinit(void)
@@ -113,4 +132,5 @@ void irc_servers_reconnect_deinit(void)
signal_remove("server connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
signal_remove("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
+ signal_remove("event kill", (SIGNAL_FUNC) event_kill);
}