From 61822435f45bb6f33eb8a181f265e80f28cb7419 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 27 Nov 2026 20:38:00 +0100 Subject: [PATCH] Remove channels from the tree after leaving --- README.md | 2 +- irc9.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3936025..da42bcb 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ instead. | --- | --- | | `/join #chan` | join a channel | | `/n [chan]` / `/names [chan]` | show a channel's nicklist (default: current window) | -| `/part [#chan] [reason]` / `/leave [#chan] [reason]` | leave the current or given channel | +| `/part [#chan] [reason]` / `/leave [#chan] [reason]` | leave the current or given channel and remove it from the tree | | `/nick newnick` | change nickname | | `/msg nick text` | send a private message | | `/notice target text` | send a notice | diff --git a/irc9.c b/irc9.c index 0654ae0..258b22a 100644 --- a/irc9.c +++ b/irc9.c @@ -1147,10 +1147,16 @@ static void handle_line(Server *s, char *line) if (strcasecmp(cmd, "PART") == 0) { if (narg < 1) return; - Window *w = window_get(s, arg[0], W_CHANNEL); - member_remove(w, nick); char why[MAXLINE]; if (narg > 1) snprintf(why, sizeof why, " (%s)", arg[1]); else why[0] = 0; + Window *w; + if (strcasecmp(nick, s->nick) == 0) { + window_close(s, window_find(s, arg[0])); + w = sw; + } else { + w = window_get(s, arg[0], W_CHANNEL); + member_remove(w, nick); + } appendf(w, "* %s left %s%s", hostmask ? hostmask : "someone", arg[0], why); return; }