############################################
# tvprog.tcl v0.1 by greenbear at gmail.com
#
# Parse the tv-program for today and
# tomorrow from thefutoncritic.com.
#
# Enable with .chanset #channel +tv
#
bind pub - !today pub:tfctoday
bind pub - !tomorrow pub:tfctomorrow
if ![info exists egghttp(version)] {
putlog "egghttp.tcl was NOT successfully loaded."
}
setudef flag tv
proc pub:tfctoday {nick uhost hand chan text} {
if ![channel get $chan tv] return
set sock [egghttp:geturl http://www.thefutoncritic.com/cgi/calendar.cgi?view=whatsnew [list parse:tfc $chan 0] -crlf 1]
}
proc pub:tfctomorrow {nick uhost hand chan text} {
if ![channel get $chan tv] return
set sock [egghttp:geturl http://www.thefutoncritic.com/cgi/calendar.cgi?view=whatsnew [list parse:tfc $chan 1] -crlf 1]
}
proc parse:tfc {chan type sock} {
set data [egghttp:data $sock]
egghttp:cleanup $sock
set data [string map {"\n" ""} $data]
set data [string map {"<td>" "<td>\n" "</td>" "</td>\n"} $data]
set data [string map {"</a><br><i>" " - "} $data]
set data [string map {"</p>" "</p>\n" "<br>" "<br>\n"} $data]
if {$type} {
scan [clock format [clock scan tomorrow] -format "%m/%d/%Y"] %d/%d/%d m d y
} {
scan [strftime "%m/%d/%Y"] %d/%d/%d m d y
}
set when "$m/$d/$y"
set parse 0
foreach line [split $data \n] {
if {!$parse&&[string match -noc "*$when*" $line]} {set parse 1}
if {$parse&&[string match -noc "*middle*content*ends*" $line]} {return}
if {$parse} {
regsub -all {<(.|\n)*?>} $line {} clean
set out [join $clean]
if {$out==""} {return}
putserv "PRIVMSG $chan :$out"
}
}
}
putlog "* tvprog.tcl loaded."
many users had issues with http package crashing the bot. I never got known which systems were affected, but it might have been a windrop pre TCL 8.4.9 issue (windrop admin changed something in the way he compiled TCL for cygwin). So it might nolonger be neccesary to use egghttp, but it would be a hassle to rewrite it back to http .
other than personal preferences and habits (everyone has theirs), there couldn't possibly exist a single reason for choosing egghttp over Tcl's built-in http package - the latter is much superior to the former
egghttp might have been much more useful several years ago, but since then both eggdrop and Tcl have made huge improvements
from egghttp's header:
# I noticed the need when using the http package for tcl,
# and it would not, for some reason or other, properly
# use asynchronous connections or not do anything at all when
# trying to use async connections.
# ^- As it turns out, eggdrop1.1.5 (and I believe 1.3.x) does
# not have Tcl_DoOneEvent in the source, so the http package fails
# for async connections, thus the need for this script.
#
# Realizing eggdrop already had the ability to make async connections,
# I created this considerably smaller tcl (in comparison to the http
# package).
none of these points is valid today; I use async [http::geturl] on multiple rss feeds (HTTP connections) simultaneously, without the slightest problem or bogging down the bot, let alone crashing it
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use