3 if [ -f "$chatfile" ]; then
4 read -r channelkey x <"$chatfile"
5 channelkey="$( printf '%s-%s' "$channelkey" "$SESSION_ID" |sha256sum)"
10 if [ ! -f "$chatfile" ]; then
11 { randomid; printf ' '; STRING "$nickname"; echo; } >"$chatfile"
13 REDIRECT "$(URL "/$LOCATION")"
16 if [ -f "$chatfile" -a "$channelkey" = "$(POST channelkey)" ]; then
17 printf "%s %s: %s\n" "$(date +%F_%T)" "$(STRING "$nickname")" "$(POST message |STRING)" >>"$chatfile"
19 REDIRECT "$(URL "/$LOCATION")"
23 if [ ! -f "$chatfile" ]; then
24 yield_page create <<-EOF
25 [form #nonexist method="POST"
26 There is no channel named $(HTML "$LOCATION")
27 [submit "action" "create" Create]
31 printf '%s: %s\r\n' Refresh 1
33 [form #channel method="POST"
34 [submit "action" "submit" style="display: none;"]
35 [input type=hidden name=channelkey value="%s"]
36 [a .settings href="?settings#nick" Settings][input autocomplete="off" name="message" autofocus=true][submit "action" "submit" Send!]
39 SHESCAPE='s;[]&<>#."[];\\&;g;'
41 while sleep 10; do printf '\n'; done &
43 tail --pid $$ -n50 -f "$chatfile" \
45 /^[^ ]+ [^ ]+ [^ ]+$/{
46 h; s;^([^ ]+) ([^ ]+) ([^ ]+)$;\1;; s;.*_;;; s;.+;[p .message [span .date &];p;
47 g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;a\2;; bESC; :A s;.;;; s;(.)(.+);[span .nick [span .indicator \1]\2];p;
48 g; s;^([^ ]+) ([^ ]+) ([^ ]+)$;b\3;; bESC; :B s;.;;; s;.+;[span .message &]];p;
51 '"$UNSTRING"' '"$SHESCAPE"'