diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-23 22:50:30 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-23 22:50:30 +0200 |
commit | 92a4d4b5a7b276ab7a606d876d03fb346f4ceda4 (patch) | |
tree | d5ccf6d7cf73e2feb5050b7e7d09aa47beaf7e26 | |
parent | 26f94d24592e0deecbfe10d39fde1a6e1d83d9dd (diff) | |
download | xK-92a4d4b5a7b276ab7a606d876d03fb346f4ceda4.tar.gz xK-92a4d4b5a7b276ab7a606d876d03fb346f4ceda4.tar.xz xK-92a4d4b5a7b276ab7a606d876d03fb346f4ceda4.zip |
Better support for the KILL command
-rw-r--r-- | degesch.c | 32 | ||||
-rw-r--r-- | kike.c | 5 |
2 files changed, 37 insertions, 0 deletions
@@ -6461,6 +6461,20 @@ irc_handle_kick (struct server *s, const struct irc_message *msg) } static void +irc_handle_kill (struct server *s, const struct irc_message *msg) +{ + if (!msg->prefix || msg->params.len < 2) + return; + + const char *target = msg->params.vector[0]; + const char *comment = msg->params.vector[1]; + + if (irc_is_this_us (s, target)) + log_server_status (s, s->buffer, + "You've been killed by #n (#m)", msg->prefix, comment); +} + +static void irc_handle_mode (struct server *s, const struct irc_message *msg) { if (!msg->prefix || msg->params.len < 1) @@ -6959,6 +6973,7 @@ static struct irc_handler g_irc_handlers[] = { "INVITE", irc_handle_invite }, { "JOIN", irc_handle_join }, { "KICK", irc_handle_kick }, + { "KILL", irc_handle_kill }, { "MODE", irc_handle_mode }, { "NICK", irc_handle_nick }, { "NOTICE", irc_handle_notice }, @@ -11015,6 +11030,20 @@ handle_command_whowas (struct handler_args *a) } static bool +handle_command_kill (struct handler_args *a) +{ + if (!*a->arguments) + return false; + + char *target = cut_word (&a->arguments); + if (*a->arguments) + irc_send (a->s, "KILL %s :%s", target, a->arguments); + else + irc_send (a->s, "KILL %s", target); + return true; +} + +static bool handle_command_nick (struct handler_args *a) { if (!*a->arguments) @@ -11209,6 +11238,9 @@ g_command_handlers[] = { "oper", "Authenticate as an IRC operator", "<name> <password>", handle_command_oper, HANDLER_SERVER }, + { "kill", "Kick another user from the server", + "<user> <comment>", + handle_command_kill, HANDLER_SERVER }, { "stats", "Query server statistics", "[<query> [<target>]]", handle_command_stats, HANDLER_SERVER }, @@ -2991,6 +2991,11 @@ irc_handle_kill (const struct irc_message *msg, struct client *c) struct client *target; if (!(target = str_map_find (&c->ctx->users, msg->params.vector[0]))) RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHNICK, msg->params.vector[0]); + + client_send (target, ":%s!%s@%s KILL %s :%s", + c->nickname, c->username, c->hostname, + target->nickname, msg->params.vector[1]); + char *reason = xstrdup_printf ("Killed by %s: %s", c->nickname, msg->params.vector[1]); client_close_link (target, reason); |