diff options
| author | Nakidai <nakidai@disroot.org> | 2026-01-07 00:43:50 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-01-07 00:43:50 +0300 |
| commit | 62f4f17989622a91aa39834b73d4e527a96ce211 (patch) | |
| tree | a693349fb3f6545cd6f793286cbd11f070eeb5cc /handle.c | |
| parent | 63c0a8860459c0c9bf3b66d4d4ec631ece4bf56e (diff) | |
| download | libreircd-62f4f17989622a91aa39834b73d4e527a96ce211.tar.gz libreircd-62f4f17989622a91aa39834b73d4e527a96ce211.zip | |
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
Diffstat (limited to 'handle.c')
| -rw-r--r-- | handle.c | 34 |
1 files changed, 34 insertions, 0 deletions
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; } |