~aleteoryx/ntalk

185f3a5026ec9f2106c01ad45d60b58e815feb74 — Aleteoryx 2 months ago 3d9f9df
scrollbackup
3 files changed, 17 insertions(+), 3 deletions(-)

M README.md
M ntalk.tcl
A scrollbackup.sh
M README.md => README.md +7 -0
@@ 13,6 13,7 @@ probably there's a chance of the file being clobbered.
will get slower with more scrollback, cause it's just
implemented with tail and head and wc. :P


## `ntalk.tcl`: tcl/tk nanotalk client

requires you have wish(1) installed.


@@ 36,5 37,11 @@ Ctrl-Shift-R will restart the client, allowing you to test config
changes rapidly. Ctrl-Q exits.


## `scrollbackup.sh`: simple backup script

just sends HIST and QUIT and logs it to a file whose name indicates
when it was generated and from what server


[src]: https://git.phial.org/d6/nanochat
[100r]: https://git.sr.ht/~rabbits/nanotalk

M ntalk.tcl => ntalk.tcl +6 -3
@@ 182,22 182,22 @@ proc sendmsg {msg} {
	set msgid [send $msg]
	if {$msgid == $lastmsg} {
		bufpush "$msg\n"
		bufdown
	} else { skip }
	bufdown
}

proc pollmsgs {} {
	if {[poll] != "0"} { skip }
	skip
	after 10000 pollmsgs
}


### BOOT ###

focus .foot.input
set lastmsg 0
last 16
after 10000 pollmsgs

bind .foot.input <Return> [concat [bind .foot.input <Return>] ";" {
	set line [.foot.input get]
	.foot.input delete 0 end


@@ 241,3 241,6 @@ bind .foot.input <Return> [concat [bind .foot.input <Return>] ";" {
		}
	}]
}]

focus .foot.input


A scrollbackup.sh => scrollbackup.sh +4 -0
@@ 0,0 1,4 @@
#!/bin/sh

SERVER=$1
printf "HIST\nQUIT\n" | nc "$@" > $SERVER-`date +%Y-%m-%d_%H-%M.txt`