From: Egor Date: Fri, 6 May 2022 18:33:17 +0000 (+0300) Subject: limit PRIVMSG visibility, add NOTICEs X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=abe38d9d6c417e63a037894f150b845f6817c697;p=patchyircd.git limit PRIVMSG visibility, add NOTICEs --- diff --git a/irc.c b/irc.c index cb2bdf4..66e7548 100644 --- a/irc.c +++ b/irc.c @@ -19,6 +19,15 @@ void sendbuf_chan(struct channel *chan) { sendbuf(cl); } while (trie_findnext(&f) == 1); } +void sendbuf_chan_sans_self(struct client_data *client, struct channel *chan) { + struct trie_find *f = NULL; + if (trie_findfirst(&f, &chan->members) == 1) + do { + struct client_data *cl = f->n->value; + if (client != cl) + sendbuf(cl); + } while (trie_findnext(&f) == 1); +} int parsePacket(struct client_data *client) { char *source = NULL; char *command = NULL; @@ -219,20 +228,21 @@ int processPacket(struct client_data *client, char *source, char *command, int a msg_topic(client, chan); sendbuf_chan(chan); } - } else if(strcmp(command, "PRIVMSG") == 0) { + } else if(strcmp(command, "PRIVMSG") == 0 || strcmp(command, "NOTICE") == 0) { if (!is_registered(client)) return err_notregistered(client), sendbuf(client), 0; if (argc < 2) // FIXME: error message return 0; (command[0] == 'P' ? msg_privmsg : msg_notice)(client, args[0], args[1]); if (args[0][0] == '#' || args[0][0] == '&') { - sendall_log(client->FD, databuf.buf, databuf.len, 0); // TODO: limit visibility + struct channel *chan = findChannel(args[0]); + if (!chan) + return err_nosuchchannel(client, args[0]), sendbuf(client), 0; + sendbuf_chan_sans_self(client, chan); } else { struct client_data *cl = findClient(args[0]); if (!cl) { - err_nosuchnick(client, args[0]); - sendbuf(client); - return 0; + return err_nosuchnick(client, args[0]), sendbuf(client), 0; } else { sendbuf(cl); if (cl->away) {