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"
;;
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"