~aleteoryx/ntalk

d100582bea7c0ff7578a804006ae504ae9992352 — glenda 14 days ago cdd0f7e
plan 9 client!
4 files changed, 91 insertions(+), 0 deletions(-)

A 9talk/chat
A 9talk/cmd
A 9talk/log
M README.md
A 9talk/chat => 9talk/chat +6 -0
@@ 0,0 1,6 @@
#!/bin/rc

window -scroll rc -c ' \
	9talk/log & \
	9talk/cmd \
'

A 9talk/cmd => 9talk/cmd +38 -0
@@ 0,0 1,38 @@
#!/bin/rc

nick='marmalade'

if(~ $#* 0){
	addr='tcp!localhost!44322'
}
if not if(! $#* 1){
	addr=$"1
}
if not if(! ~ $#* 2){
	echo 'usage: 9talk/cmd [addr] [nick]' >[1=2]
	exit usage
}
if not {
	addr=$"1
	nick=$"2
}

fn onecmd{
	cmd=$"*
	{echo $"cmd; echo QUIT} | aux/dial -e $addr
}

while(){
	line=`{read -n 1}
	line2=`{echo $"line | tail +1c}
	switch($line){
	case !*
		onecmd SEND $"line2 >/dev/null
	case .* :*
		onecmd SEND $"nick' '$"line2 >/dev/null
	case "*
		onecmd SEND $"nick': '$"line2 >/dev/null
	case *
		onecmd SEND $"nick': '$"line >/dev/null
	}
}

A 9talk/log => 9talk/log +33 -0
@@ 0,0 1,33 @@
#!/bin/rc

if(~ $#* 0){
	addr='tcp!localhost!44322'
}
if not if(! ~ $#* 1){
	echo 'usage: 9talk/log [addr]' >[1=2]
	exit usage
}
if not
	addr=$"1

buffile=.ncbuf$pid

fn onecmd{
	cmd=$"*
	{echo $"cmd; echo QUIT} | aux/dial -e $addr
}
fn linecmd{
	onecmd $"* >$buffile
	count=`{read -n 1 $buffile}
	msgid=`{tail -1 $buffile}
	if(! ~ 0 $count)
		tail +2 $buffile | read -n $count
	rm $buffile
}

linecmd LAST 16

while(){
	sleep 5
	linecmd SKIP $msgid
}

M README.md => README.md +14 -0
@@ 46,6 46,20 @@ Ctrl-Shift-R will restart the client, allowing you to test config
changes rapidly. Ctrl-Q exits.


## `9talk`: rc client for plan 9

consists of the following scripts:

- `9talk/log [addr]`: connects to $addr, or a hard-coded default (edit it!), fetches the last
  16 messages, and updates every 5 seconds
- `9talk/cmd [addr] [nick]`: connects to $addr with $nick, or hard-coded defaults (edit them!).
  for each input line, sends one of the following:
    - '!': sends $line.
    - '.' or ':': sends $nick $line.
    - '"' or no prefix: sends $nick: $line
- `9talk/chat`: opens a window with /log and /cmd running


## `scrollbackup.sh`: simple backup script

just sends HIST and QUIT and logs it to a file whose name indicates