diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-05-08 21:22:02 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-05-08 21:22:02 +0100 |
commit | 8a05a928afcb914e9a62519a00f5a968f8f902a6 (patch) | |
tree | 8335b765316cb0c6c6ff05a1547f0bbae3636fa5 | |
parent | 4733b6438fe267ec896526eb468fa9892e7752c3 (diff) |
Don't PART channels when another user PARTs.
-rw-r--r-- | blabouncer.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/blabouncer.c b/blabouncer.c index 07461b8..2eabd11 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -7,7 +7,6 @@ // - Get CAP from server and relay to client // - Add blabouncer MOTD (375, 372, 376) // - "01:53:47 -!- ServerMode/#test [b] by irc.tghost.co.uk" on existing clients when new client connects -// - Other users PARTing causes us to PART // - We might not track new users JOINing a channel (only users who were already in a channel when we joined) // // Example WHOIS reply: @@ -452,10 +451,21 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc return 1; } - // Server PART received? Remove from our local channel list. + // Server PART received? Remove from our local channel list if it's us. if (strncmp(tokens[1], "PART", strlen(tokens[1])) == 0) { - printf("Server PART found and it is: %s with length %zd! Next token is '%s'. Adding to local channel list.\n", tokens[0], strlen(tokens[0]), tokens[2]); - removechannel(channels, tokens[2]); + printf("Server PART found and it is: %s with length %zd! Next token is '%s'. Adding to local channel list if it's us.\n", tokens[0], strlen(tokens[0]), tokens[2]); + + // If the user PARTing is us, then we must have left a channel, so remove it from our local channel array. + // (If it's not us, then it's another user PARTing a channel, so just pass straight through to letting all our clients know.) + // Copy to a temporary string so we still have the original in case we need it + char *prefixcopy = strdup(tokens[0]); + stripprefix(prefixcopy); + if (strncmp(prefixcopy, ircdstrings->nickuserhost, strlen(tokens[0])) == 0) { + printf("Server PART: nickuserhost is ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->nickuserhost); + removechannel(channels, tokens[2]); + } else { + printf("Server PART: nickuserhost is NOT ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->nickuserhost); + } // And then send to all clients sendtoallclients(clientsockfd, fdmax, arr_clients, str, sourcefd); |