]> PatchyGit - patchyircd.git/commitdiff
add KILL
authorEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 18:53:45 +0000 (20:53 +0200)
committerEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 18:57:24 +0000 (20:57 +0200)
irc.c

diff --git a/irc.c b/irc.c
index 85d9980..7d30c82 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -355,6 +355,31 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                if (client == cl)
                        return 0; // FIXME: error message
                killConnection(cl, false);
+       } else if(strcmp(command, "KILL") == 0) {
+               if (!is_registered(client))
+                       return err_notregistered(client), sendbuf(client), 0;
+               if (!(client->umode & UMODE_OPER)) {
+                       copy_strf(&databuf, ":%s 481 %s :Permission Denied- You're not an IRC operator\r\n", hostname, client->nick);
+                       sendbuf(client);
+                       return 0;
+               }
+               if (argc < 1)
+                       return err_needmoreparams(client, command), sendbuf(client), 0;
+               struct client_data *cl = findClient(args[0]);
+               if (!cl)
+                       return 0; // FIXME: error message
+               if (client == cl)
+                       return 0; // FIXME: error message
+               msg_kill(client, cl, args[1] ? args[1] : "(no reason)");
+               struct trie_find *f = NULL;
+               if (trie_findfirst(&f, &client_map) == 1)
+                       do {
+                               struct client_data *cl2 = f->n->value;
+                               if (cl2->umode & UMODE_OPER)
+                                       sendbuf(cl2);
+                       } while (trie_findnext(&f) == 1);
+               // FIXME: add appropraite QUIT message
+               killConnection(cl, false);
        } else if(strcmp(command, "JEDGAR") == 0) {
                if (!is_registered(client))
                        return err_notregistered(client), sendbuf(client), 0;