proc crap:list {nick uhost hand chan args} {Tcl error [crap:list]: can not find channel named "fu....
set line [join $args]
sql selectdb *********
set wordlist ""
set wordcount 0
foreach row [sql "SELECT crapword FROM crapwords"] {
incr wordcount 1
append wordlist [lindex $row 0] " "
}
set pos 100
while {1} {
# this moves to $pos bytes before the end of the file
seek $wordlist -$pos end
# read to the end of the file
set data [read -nonewline $wordlist]
# we may have read multiple lines (if less than 512 bytes)
set lines [split $wordlist \n]
if {[llength $lines] > 1} {
# yup, we read at least 1 line and part of another, so we know
# we for sure have the complete last line, we're done
putserv "PRIVMSG $chan :\[\002CRAP-LIST\002\] [lindex $lines end] (Total CrapFilter words: $wordcount)"
} elseif {[tell $wordlists] < $pos} {
# This happens if the entire file is < 512 bytes, and we didn't read
# in multiple lines... therefore the file is a single line and we read the
# whole thing, so we're done.
putserv "PRIVMSG $chan :\[\002CRAP-LIST\002\] $data (Total CrapFilter words: $wordcount)"
}
# Now we just repeat the process, adding another 512 bytes
incr pos 512
}
}