Code: Select all
# tvprogram.nu.tcl v1.0 by Pixelz
# public trigger
set tvpnu(trg) "!tv"
## code below ##
package require http
setudef flag tv
set tvpnu(ver) "v1.0"
proc tvpnu_get {url} {
global tvnu
if {[catch {::http::geturl $url -timeout 20000} tok]} {
return 0
} else {
set d [::http::data $tok]
::http::cleanup $tok
regsub -all -- "\n" $d "" d
regsub -all -nocase -- "<br>" $d "\n" d
regsub -all -nocase -- "<a.*?>.*?</a>" $d "" d
foreach i [split $d "\n"] {
if {[string match *<b>* $i]} {
append x "$i\n"
}
}
regsub -all -- "<.*?>" $x "" x
foreach i [split $x "\n"] {
if {![string match "* - " $i]} {
set i [string replace $i 2 2 :]
append ret "$i\n"
}
}
if {[info exists ret]} { return $ret } else { return 0 }
}
}
proc tvpnu_urlget {chan} {
set x "http://tvprogram.nu/cgi-tvprogram/pp1.cgi?"
switch [string tolower $chan] {
svt1 { set url "${x}SVT1" }
svt2 { set url "${x}SVT2" }
tv3 { set url "${x}TV3_SVERIGE" }
tv4 { set url "${x}TV4" }
kanal5 { set url "${x}KANAL5" }
femman { set url "${x}KANAL5" }
tv6 { set url "${x}TV6" }
ztv { set url "${x}ZTV" }
tv8 { set url "${x}TV8" }
mtv { set url "${x}MTV" }
canal+ { set url "${x}CANAL+" }
canal+gul { set url "${x}CANAL+GUL" }
gul { set url "${x}CANAL+GUL" }
tv1000 { set url "${x}TV1000" }
tv1000_cinema { set url "${x}TV1000_CINEMA" }
cinema { set url "${x}TV1000_CINEMA" }
bbc_prime { set url "${x}BBC_Prime" }
bbcprime { set url "${x}BBC_Prime" }
bbc_world { set url "${x}BBC_World" }
bbcworld { set url "${x}BBC_World" }
eurosport { set url "${x}Eurosport" }
default { return 0 }
}
return "${url}-palmpilot.htm"
}
proc tvpnu_current {data} {
set cnt 0
foreach i [lsort [split $data "\n"]] {
if {$i == ""} { continue }
lappend lst "[incr cnt] [clock scan "[string range $i 0 4]:00"] $i"
}
foreach i $lst {
if {[lindex $i 1] > [clock seconds]} {
set place [expr [lindex $i 0] - 1]
break
}
}
if {![info exists place]} { set place $cnt }
if {$place == [expr $cnt - 1]} { set place 1 } elseif {$place == "0"} { set place $cnt }
set x 0
foreach i $lst {
incr x
if {$x == $place} { return [lrange $i 2 end] }
}
return 0
}
bind pub - $tvpnu(trg) pub_tvpnu
proc pub_tvpnu {nick uhost hand chan text} {
set text [split $text]
global tvpnu
set chans "SVT1, SVT2, TV3, Kanal5, TV6, ZTV, TV8, MTV, Canal+, Canal+Gul, TV1000, TV1000_Cinema, BBC_Prime, BBC_World, Eurosport"
if {![string match *+tv* [channel info $chan]]} {
return 0
} elseif {$text == ""} {
putserv "NOTICE $nick :$tvpnu(trg) <channels>"
return 0
} elseif {[string tolower $text] == "help"} {
putserv "NOTICE $nick :Known channels: $chans"
return 0
} elseif {[llength $text] > 1} {
foreach i $text {
if {[tvpnu_urlget $i] == "0"} {
putserv "NOTICE $nick :$i is not a known channel. Known channels: $chans"
return 0
} else {
set data [tvpnu_get [tvpnu_urlget $i]]
if {$data == "0"} {
putserv "NOTICE $nick :Data fetch failed!"
return 0
} else {
set data [tvpnu_current $data]
if {$data == "0"} {
putserv "NOTICE $nick :Parse error!"
return 0
} else {
set len 0
foreach c $text {
set c [string length $c]
if {$c > $len} { set len $c }
}
putserv "PRIVMSG $chan :[format "%-${len}s %1s" "$i" "$data"]"
}
}
}
}
return 1
} elseif {[tvpnu_urlget $text] == "0"} {
putserv "NOTICE $nick :[join $text] is not a known channel. Known channels: $chans"
return 0
} else {
set data [tvpnu_get [tvpnu_urlget $text]]
if {$data == "0"} {
putserv "NOTICE $nick :Data fetch failed!"
return 0
} else {
set data [tvpnu_current $data]
if {$data == "0"} {
putserv "NOTICE $nick :Parse error!"
return 0
} else {
putserv "PRIVMSG $chan :$data"
}
}
return 1
}
}
putlog "tv.tcl Loaded!"
This works but it a bit bad .. i have to type !tv <tvchan> .. to se whats on that chan insted of using just !tv and get like svt1, svt2, tv3, tv4, kanal5, ztv, mtv on one line anyone kind anuff to help me with that .. im new to tcl .. used to code mirc script .. and i have be asking alot of questions and i know im a bit anoing