ref: d90cee2867a92e83f5098021040f816626c9b30c
dir: /gchat/
#!/bin/rc # public domain or ISC or MIT cat=read # one might want to use read instead. datefmt='hh:mm' server=tcp!cloud9p.org!900 nick=$user room=chat mnt=/n/chat/ seprator=' >' tls=false bs=false date=false annoying=false # wont work in acme well. fn clear { awk 'BEGIN { for(i = 0; i < '$1'+1; i++) printf "\x08" }' } fn readchat { if(test -f $mnt^$room) { cat $mnt^$room & } if not { echo 'no such room exist' >[1=2] exit 'no room' } } fn writechat { if(test -w $mnt^$room) { while() { $cat >/env/message # bs and annoy can be buggy together if(! ~ $bs false && ~ $annoy false) clear `{cat /env/message | wc -r} #i if(! ~ $date false) { d=`{date -u -f $datefmt} echo -n $d > /env/x } echo -n $nick^$seprator^' '> /env/x if(~ $annoying false) { cat /env/x /env/message >>$mnt^$room } if not { ifs=' ' annoy=`{cat /env/message} cat /env/x >> $mnt^$room for(i in $annoy) { echo -n ' '$i >> $mnt^$room sleep 0.01 } } } } if not { echo 'room is read-only' exit 'read-only room' } } while (~ $1 -*) { switch ($1) { case -a annoying=YEAH case -b bs=t case -d date=t case -f datefmt=$2 date=t shift case -n nick=$2 shift case -r room=$2 shift case -s seprator=$2 shift case -* echo 'usage: gchat [-abd] [-f datefmt] [-n nick] [-r room] [-s seprator] [server]' >[1=2] exit 'usage' } shift } if (~ $#* 1) { switch ($1) { case 9pzone server=tcp!chat.9p.zone!9990 case cloud9p server=tcp!cloud9p.org!900 case * server=$1 } } 9fs $server $mnt label $server: $mnt^$room readchat writechat