Posted to tcl by sebres at Tue Feb 02 20:18:43 GMT 2021view raw
- interp create -safe chatint
- chatint eval {
- proc m {tm nick msg} {
- upvar _last_date ld _last_known lk;
- if {[info exists lk] && $tm < $lk} return;
- set lk $tm
- set tm [clock scan $tm -format "%Y-%m-%dT%H:%M:%S%Z"];
- set d [clock format $tm -format %x];
- if {![info exists ld] || $ld ne $d} {puts "\n== $d [string repeat = 20]\n"; set ld $d};
- if {$nick eq "" && [regexp {^\S+ has (?:left|become available)$} $msg]} return;
- if {[regexp {^i.chain$} $nick]} {
- if {[regexp {^\*{3} \S+ (?:joins|leaves)$} $msg]} return;
- regexp {^<([^>]+)> (.*)$} $msg _ nick msg
- }
- set pref "[clock format $tm -format %X] | [format %15s $nick]"
- set pre2 "\n[string repeat " " [string length $pref]] | "
- regsub -all {\n} $msg $pre2 msg
- puts "$pref | $msg"
- }
- }
- interp alias chatint puts {} puts
- proc chat fn {
- interp invokehidden chatint source $fn
- }
- # usage:
- # chat {2021-01-26.tcl}