This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

tvprog.tcl - even more tv stuff (!today and !tomorrow)

Support & discussion of released scripts, and announcements of new releases.
Post Reply
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

tvprog.tcl - even more tv stuff (!today and !tomorrow)

Post by greenbear »

Code: Select all

############################################
# 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."


T
TaRgEt
Voice
Posts: 4
Joined: Tue Sep 27, 2005 3:24 pm

Post by TaRgEt »

[09:19] Tcl error [pub:tfctoday]: Unknown option -crlf, can be: -timeout, -query, -headers, -protocol, -useragent

how do i fix that ?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

try using the most recent egghttp vesion.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
p
phab
Voice
Posts: 12
Joined: Mon Aug 22, 2005 6:34 am

Post by phab »

Why don't you use the http package?
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

so you get to ask stupid questions
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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 :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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

Code: Select all

 tag when posting logs, code
q
qw3rty
Voice
Posts: 4
Joined: Thu Apr 06, 2006 11:49 pm

working

Post by qw3rty »

is this working or still working for anyone else?
Post Reply