From ade13d422554af834a8500c7623ea533eb5c4199 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 3 Feb 2023 21:18:52 +0200 Subject: [PATCH] add WALLOPS --- irc.c | 18 ++++++++++++++++++ ircfmt.c | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/irc.c b/irc.c index 6c465fe..897ebd9 100644 --- a/irc.c +++ b/irc.c @@ -355,6 +355,24 @@ 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, "WALLOPS") == 0) { + if (!is_registered(client)) + return err_notregistered(client), sendbuf(client), 0; + if (argc < 1) + return err_needmoreparams(client, command), 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; + } + msg_wallops(client, args[0]); + struct trie_find *f = NULL; + if (trie_findfirst(&f, &client_map) == 1) + do { + struct client_data *cl = f->n->value; + if (cl->umode & UMODE_WALLOPS) + sendbuf(cl); + } while (trie_findnext(&f) == 1); } else if(strcmp(command, "KILL") == 0) { if (!is_registered(client)) return err_notregistered(client), sendbuf(client), 0; diff --git a/ircfmt.c b/ircfmt.c index 4e03793..d47c701 100644 --- a/ircfmt.c +++ b/ircfmt.c @@ -110,13 +110,11 @@ void msg_kill(struct client_data *src, struct client_data *dst, const char *reas copy_strf(&databuf, ":%s!%s@%s KILL %s :%s\r\n", src->nick, src->username, src->hostname, dst->nick, reason); } -#if 0 void msg_wallops(struct client_data *src, const char *msg) { copy_strf(&databuf, ":%s!%s@%s WALLOPS :%s\r\n", src->nick, src->username, src->hostname, msg); } -#endif void rpl_welcome(struct client_data *client) // 001 { copy_strf(&databuf, ":%s 001 %s :Welcome to the Patchy Network, %s\r\n", hostname, client->nick, client->nick); -- 2.56.0