]> PatchyGit - patchyircd.git/commitdiff
add WALLOPS
authorEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 19:18:52 +0000 (21:18 +0200)
committerEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 19:24:59 +0000 (21:24 +0200)
irc.c
ircfmt.c

diff --git a/irc.c b/irc.c
index 6c465fe..897ebd9 100644 (file)
--- 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;
index 4e03793..d47c701 100644 (file)
--- 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);