;;
esac
+nicklist(){
+ local nickfile="${chatfile%/channel}/nicks"
+ case $1 in
+ enter)
+ trap 'nicklist leave' INT QUIT
+ sed -i -E "/^${SESSION_KEY%%-*} /d" "$nickfile"
+ printf '%s %i %s\n' "${SESSION_KEY%%-*}" "$$" "$nickname" >>"$nickfile"
+ ;;
+ leave)
+ sed -i -E "/^${SESSION_KEY%%-*} $$ /d" "$nickfile"
+ ;;
+ esac
+
+ nicklist='NICKNAMES: '
+ while read -r s p nick; do
+ [ -d "/proc/$p" ] && nicklist="${nicklist}/$nick/" \
+ || sed -i -E "/^$s $p /d" "$nickfile"
+ done <"$nickfile"
+ if ! tail -n20 "$chatfile" |tac |grep -m1 '^NICKNAMES: ' |grep -qxF "$nicklist"; then
+ printf '%s\n' "$nicklist" >>"$chatfile"
+ fi
+}
+
if [ ! -f "$chatfile" ]; then
yield_page create <<-EOF
+ [h1 No such Channel]
[form #nonexist method="POST"
There is no channel named $(HTML "$LOCATION")
- [submit "action" "create" Create]
+ [submit "action" "create" Set Up]
]
EOF
else
+ nicklist enter
+
printf '%s: %s\r\n' Refresh 1
{ printf '
[form #channel method="POST"
printf '[div #chat'
tail --pid $$ -n50 -f "$chatfile" \
| sed -nuE '
- /^[^ ]+ [^ ]+ [^ ]+$/{
+ /^[0-9-]{10}_[0-9:]{8}+ [^ ]+ [^ ]+$/{
h; s;^([^ ]+) ([^ ]+) ([^ ]+)$;\1;; s;.*_;;; s;.+;[p .message [span .date &];p;
g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;a\2;; bESC; :A s;.;;; s;(.)(.+);[span .nick [span .indicator \1]\2];p;
g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;b\3;; bESC; :B s;.;;; s;.+;[span .message &]];p;
+ b;
+ }
+ /^NICKNAMES: .*/{
+ s;^NICKNAMES: ;;; h; s;^.*$;[div .nicklist [h2 Nicknames];p; g;
+ :NICKLIST
+ h; s;^/([^/]+)/.*$;c\1;; bESC :C
+ s;^.([^?])(.*)$;[a .nick href="/~\1\2" \1\2];p;
+ s;^.(\?)(.*)$;[span .nick [span .indcator \1]\2];p;
+ g; s;/[^/]+/;;; /.+/bNICKLIST s;^.*$;];p;
+ b;
}
b; :ESC
'"$UNSTRING"' '"$SHESCAPE"'
- /^a/bA; /^b/bB;
+ /^a/bA; /^b/bB; /^c/bC;
'
} |yield_page channel
+
+ nicklist leave
fi