From 62f4f17989622a91aa39834b73d4e527a96ce211 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Wed, 7 Jan 2026 00:43:50 +0300 Subject: Move quit announcement code to quit() Well, it's more appropriate for that function to handle this rather than for ircd(). Now code looks simpler, ircd() is not that complex, and support for optional quit message is present --- handle.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'handle.c') diff --git a/handle.c b/handle.c index 61b34f7..87dfa77 100644 --- a/handle.c +++ b/handle.c @@ -159,6 +159,40 @@ privmsg(struct Message *msg, struct Peer *peer) static int quit(struct Message *msg, struct Peer *peer) { + size_t i, j; + + ensure(peer->type, (void)0, 1) + + writef( + peer->fd, + ":%s!%s@%s QUIT :%s", + getnick(peer), + peer->user, + peer->host, + msg->params[0] ? msg->params[0] : "Client Quit" + ); + + for (i = 0; i < peer->channels_c; ++i) + { + channel_exit(peer->channels[i], peer); + for (j = 0; j < peer->channels[i]->users_c; ++j) + peer->channels[i]->users[j]->flags |= ANNOUNCE; + } + + for (i = 0; i < peers_c; ++i) + if (peers[i].flags & ANNOUNCE) + { + writef( + peers[i].fd, + ":%s!%s@%s QUIT :%s", + getnick(peer), + peer->user, + peer->host, + msg->params[0] ? msg->params[0] : "Client Quit" + ); + peers[i].flags &= ~ANNOUNCE; + } + return 1; } -- cgit 1.4.1