From 92a4d4b5a7b276ab7a606d876d03fb346f4ceda4 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Fri, 23 Sep 2016 22:50:30 +0200
Subject: Better support for the KILL command
---
degesch.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
(limited to 'degesch.c')
diff --git a/degesch.c b/degesch.c
index f394a3c..f56eb12 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6460,6 +6460,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)
{
@@ -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 },
@@ -11014,6 +11029,20 @@ handle_command_whowas (struct handler_args *a)
return true;
}
+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)
{
@@ -11209,6 +11238,9 @@ g_command_handlers[] =
{ "oper", "Authenticate as an IRC operator",
" ",
handle_command_oper, HANDLER_SERVER },
+ { "kill", "Kick another user from the server",
+ " ",
+ handle_command_kill, HANDLER_SERVER },
{ "stats", "Query server statistics",
"[ []]",
handle_command_stats, HANDLER_SERVER },
--
cgit v1.2.3-54-g00ecf