From: Egor Date: Fri, 3 Feb 2023 18:53:45 +0000 (+0200) Subject: add KILL X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=57105e099a5d691f5a26b02cf7c148d4dce746bc;p=patchyircd.git add KILL --- diff --git a/irc.c b/irc.c index 85d9980..7d30c82 100644 --- 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;