mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
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
This commit is contained in:
parent
746bd9b4f0
commit
3fbd7d5c82
@ -193,6 +193,38 @@ static void event_kick(const char *data, IRC_SERVER_REC *server,
|
|||||||
g_free(params);
|
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,
|
static void event_nick(const char *data, IRC_SERVER_REC *server,
|
||||||
const char *sender, const char *addr)
|
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 part", (SIGNAL_FUNC) event_part);
|
||||||
signal_add("event quit", (SIGNAL_FUNC) event_quit);
|
signal_add("event quit", (SIGNAL_FUNC) event_quit);
|
||||||
signal_add("event kick", (SIGNAL_FUNC) event_kick);
|
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 nick", (SIGNAL_FUNC) event_nick);
|
||||||
signal_add("event mode", (SIGNAL_FUNC) event_mode);
|
signal_add("event mode", (SIGNAL_FUNC) event_mode);
|
||||||
signal_add("event pong", (SIGNAL_FUNC) event_pong);
|
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 part", (SIGNAL_FUNC) event_part);
|
||||||
signal_remove("event quit", (SIGNAL_FUNC) event_quit);
|
signal_remove("event quit", (SIGNAL_FUNC) event_quit);
|
||||||
signal_remove("event kick", (SIGNAL_FUNC) event_kick);
|
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 nick", (SIGNAL_FUNC) event_nick);
|
||||||
signal_remove("event mode", (SIGNAL_FUNC) event_mode);
|
signal_remove("event mode", (SIGNAL_FUNC) event_mode);
|
||||||
signal_remove("event pong", (SIGNAL_FUNC) event_pong);
|
signal_remove("event pong", (SIGNAL_FUNC) event_pong);
|
||||||
|
@ -147,7 +147,9 @@ FORMAT_REC fecommon_irc_formats[] = {
|
|||||||
{ "pong", "PONG received from $0: $1", 2, { 0, 0 } },
|
{ "pong", "PONG received from $0: $1", 2, { 0, 0 } },
|
||||||
{ "wallops", "{wallop WALLOP {wallop_nick $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 } },
|
{ "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 } },
|
{ "unknown_mode", "Unknown mode character $0", 1, { 0 } },
|
||||||
{ "not_chanop", "You're not channel operator in {channel $0}", 1, { 0 } },
|
{ "not_chanop", "You're not channel operator in {channel $0}", 1, { 0 } },
|
||||||
|
|
||||||
|
@ -118,6 +118,8 @@ enum {
|
|||||||
IRCTXT_PONG,
|
IRCTXT_PONG,
|
||||||
IRCTXT_WALLOPS,
|
IRCTXT_WALLOPS,
|
||||||
IRCTXT_ACTION_WALLOPS,
|
IRCTXT_ACTION_WALLOPS,
|
||||||
|
IRCTXT_KILL,
|
||||||
|
IRCTXT_KILL_SERVER,
|
||||||
IRCTXT_ERROR,
|
IRCTXT_ERROR,
|
||||||
IRCTXT_UNKNOWN_MODE,
|
IRCTXT_UNKNOWN_MODE,
|
||||||
IRCTXT_NOT_CHANOP,
|
IRCTXT_NOT_CHANOP,
|
||||||
|
@ -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)
|
void irc_servers_reconnect_init(void)
|
||||||
{
|
{
|
||||||
signal_add("server connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
|
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("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
|
||||||
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
|
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
|
||||||
|
signal_add("event kill", (SIGNAL_FUNC) event_kill);
|
||||||
}
|
}
|
||||||
|
|
||||||
void irc_servers_reconnect_deinit(void)
|
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 connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
|
||||||
signal_remove("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
|
signal_remove("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
|
||||||
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
|
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
|
||||||
|
signal_remove("event kill", (SIGNAL_FUNC) event_kill);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user