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;
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) {