From ecef5d8df4714fb141e42842e6df2028b151e831 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 19 Nov 2020 02:52:39 +0100 Subject: [PATCH] remove expired connections from nick list --- channel.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/channel.sh b/channel.sh index 0f1bda7..a59a5a4 100755 --- a/channel.sh +++ b/channel.sh @@ -32,7 +32,7 @@ nicklist(){ local nickfile="${chatfile%/channel}/nicks" case $1 in enter) - trap 'sed -i -E "/^${SESSION_KEY%%-*} $$ /d" "$nickfile"' INT QUIT + trap 'nicklist leave' INT QUIT sed -i -E "/^${SESSION_KEY%%-*} /d" "$nickfile" printf '%s %i %s\n' "${SESSION_KEY%%-*}" "$$" "$nickname" >>"$nickfile" ;; @@ -43,7 +43,8 @@ nicklist(){ nicklist='NICKNAMES: ' while read -r s p nick; do - nicklist="${nicklist}/$nick/" + [ -d "/proc/$pid" ] && nicklist="${nicklist}/$nick/" \ + || sed -i -E "/^$s $p /d" "$nickfile" done <"$nickfile" if ! tail -n20 "$chatfile" |grep -qxF "$nicklist"; then printf '%s\n' "$nicklist" >>"$chatfile" -- 2.39.2