Code: Select all
set buf {}
set maxlines 5 ;# lines
set refresh 30 ;# seconds
bind pubm - "#channel *" foo
proc foo {n u h c t} {
if {[llength $::buf] == $::maxlines} {
set ::buf [lreplace $::buf 0 0]
}
lappend ::buf [list $n $t]
}
proc bar {sec} {
if ![catch {set fd [open /path/to/convo.html w]}] {
puts $fd "<html><head><title>some title</title>"
puts $fd "<meta http-equiv=\"refresh\" content=\"$sec\">"
puts $fd "</head><body>"
foreach e $::buf {
puts $fd "<[lindex $e 0]> [lindex $e 1]<br>"
}
puts $fd "</body></html>"
close $fd
}
utimer $sec [list bar $sec]
}
bar $refresh Code: Select all
set 12h(chan) "#yourchannel"; channel to log
set i2h(maxlines) "5"; # no of lines
set i2h(refresh) "30"; # no of seconds
set i2h(buffer) ""; # the buffer, dont touch
set i2h(file) "/path/to/html/file"; # the html file
if {![file exists $::i2h(file)]} {
set file [open $::i2h(file) w]; puts $file ""; close $file
}
bind pubm - "$::i2h(chan) *" i2h:log
proc i2h:log {nickname hostname handle channel text} {
if {[llength $::i2h(buffer)] >= $::i2h(maxlines)} {
set ::i2h(buffer) ""
}
lappend ::i2h(buffer) "$nickname $text"
}
proc i2h:update {} {
if {[catch { set file [open $::i2h(file) w] } err]} {
putlog "i2h file error: $err"
} else {
puts $file "<html><head><title>some title</title>"
puts $file "<meta http-equiv=\"refresh\" content=\"$sec\">"
puts $file "</head><body>"
foreach i $::i2h(buffer) {
puts $file "<[lindex [split $i] 0]> [lrange $i 1 end]<br>"
}
puts $file "</body></html>"
}
utimer $::i2h(refresh) [list i2h:update]
}
i2h:update
putlog "i2h (irc2html) loaded"
Code: Select all
...
puts $file "<[lindex $e 0]> [lindex $e 1]<br>"
...
Code: Select all
...
puts $file "<[lindex $e 0]> [lindex $e 1]<br>"
...
Code: Select all
bind pubm - "$::i2h(chan) *" i2h:log
#FIXED# IT WAS A TYPO[13:26] can't read "::i2h(chan)": no such element in array
while executing
"bind pubm - "$::i2h(chan) *" i2h:log"
(file "scripts/html2.tcl" line 11)
invoked from within
"source scripts/html2.tcl
"
It kinda looks like I need to set $sec as a time variable, how does one do that ?[13:29] can't read "sec": no such variable
while executing
"puts $file "<meta http-equiv=\"refresh\" content=\"$sec\">""
(procedure "i2h:update" line 6)
invoked from within
"i2h:update"
(file "scripts/html2.tcl" line 35)
invoked from within
"source scripts/html2.tcl
"
Code: Select all
puts $file "<meta http-equiv=\"refresh\" content=\"$sec\">"Code: Select all
puts $file "<meta http-equiv=\"refresh\" content=\"$::i2h(refresh)\">"Code: Select all
set 12h(chan) "#yourchannel"; channel to log
set i2h(maxlines) "5"; # no of lines
set i2h(refresh) "30"; # no of seconds
set i2h(buffer) ""; # the buffer, dont touch
set i2h(file) "/path/to/html/file.html"; # the html file
if {![file exists $::i2h(file)]} {
set file [open $::i2h(file) w]; puts $file ""; close $file
}
bind pubm - "$::i2h(chan) *" i2h:log
proc i2h:log {nickname hostname handle channel text} {
if {[llength $::i2h(buffer)] >= $::i2h(maxlines)} {
set ::i2h(buffer) ""
}
lappend ::i2h(buffer) "$nickname $text"
}
proc i2h:update {} {
if {[catch { set file [open $::i2h(file) w] } err]} {
putlog "i2h file error: $err"
} else {
puts $file "<html><head><title>some title</title>"
puts $file "<meta http-equiv=\"refresh\" content=\"$sec\">"
puts $file "</head><body>"
foreach i $::i2h(buffer) {
puts $file "<[lindex [split $i] 0]> [lrange $i 1 end]<br>"
}
puts $file "</body></html>"
close $file
}
utimer $::i2h(refresh) [list i2h:update]
}
i2h:update
putlog "i2h (irc2html) loaded. Logging $::i2h(chan) to [lindex [split $::i2h(file) /] end]."