From: Paul Hänsch Date: Thu, 19 Nov 2020 01:52:39 +0000 (+0100) Subject: remove expired connections from nick list X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=ecef5d8df4714fb141e42842e6df2028b151e831;p=httpchat remove expired connections from nick list --- 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"