Code: Select all
bind pub - !google web:google
proc web:google {nick host handle chan arg} {
set text ""
set text2 ""
set data ""
set data2 ""
set arg [string map {" " "+"} $arg]
package require http
http::config -useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040614 Firefox/0.8"
set data [string map {"<b>" "" "</b>" ""} [http::data [http::geturl http://www.google.se/search?q=$arg]]]
regexp -nocase {<!--m--><a href=([\x00-\x3B\x3D\x3F-\xFF]*)>([\x00-\x3B\x3D\x3F-\xFF]*)<} $data data text text2
puthelp "PRIVMSG $chan :\002Result:\002 \037$text\037 - $text2"
}
Code: Select all
## WE NEED HTTP
package require http
bind pub - !weather www:weather
proc www:weather {nick host handle chan text} {
## <SETTINGS>
# how do we output?
#
# msg $chan = 1
# privmsg $nick = 2
# notice $nick = 3
#
# default = 3
set how 1
## </SETTINGS>
## Dont edit below here!!!
## <CODE>
if {$how == 1} {set output "PRIVMSG $chan"
} elseif {$how == 2} {set output "PRIVMSG $nick"
} elseif {$how == 3} {set output "NOTICE $nick"}
if {$text == ""} {puthelp "NOTICE $nick :!weather <country>||<town>"}
set data [http::data [http::geturl http://uk.search.weather.yahoo.com/search/weather_ukie?p=$text]]
if {![regexp {<a href="http://uk.weather.yahoo.com/([a-zA-Z0-9]*)/([a-zA-Z0-9]*)/index_c.html">} $data data match match2]} {
puthelp "$output :\002Sorry, i cant find:\002 \037$text\037 - try here: http://uk.search.weather.yahoo.com/search/weather_ukie?p="
return 0
}
set data [http::data [http::geturl http://uk.weather.yahoo.com/$match/$match2/index_c.html]]
regexp {^.*<font size=\+2 face=Arial><b>([-+0-9]*)°</b></font>.*} $data data2 temp
regexp {<a href="/">Weather</a> > <a href="/(.*)/index.html">(.*)</a> > (.*)</b></font></td><td align=right>} $data data2 [censored] country town
regexp {^.*<td rowspan=2 align=center valign=middle bgcolor=#eeeeee height=100%> <img src=http://eur.i1.yimg.com/us.yimg.com/i/us/we/intl/([0-9]*).gif width=52 height=52 alt="([a-zA-Z ]*)"><br><br>.*} $data data2 a condition
puthelp "$output :\002Weather for: $country / $town:\002 $condition ($temp C)"
## </CODE>
}
Code: Select all
# We need http package
#package req http
bind pub - !tv info:tv
proc info:tv {nick host handle chan text} {
set url "http://tvprogram.nu/cgi-tvprogram/pp1.cgi?NU-palmpilot.htm"
set data [http::data [http::geturl $url]]
if {![regexp -nocase {<b>SVT1</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time1 tv1]} {set tv1 "?"; set time1 "?"}
if {![regexp -nocase {<b>SVT2</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time2 tv2]} {set tv2 "?"; set time2 "?"}
if {![regexp -nocase {<b>TV3 SVERIGE</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time3 tv3]} {set tv3 "?"; set time3 "?"}
if {![regexp -nocase {<b>TV4</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time4 tv4]} {set tv4 "?"; set time4 "?"}
if {![regexp -nocase {<b>TV4\+</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time5 tv5]} {set tv5 "?"; set time5 "?"}
if {![regexp -nocase {<b>KANAL5</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time6 tv6]} {set tv6 "?"; set time6 "?"}
if {![regexp -nocase {<b>ZTV</b>(.*?)<b>([0-9\.]+) ([\x00-\xFF]*)</b>} $data data2 ok time7 tv7]} {set tv7 "?"; set time7 "?"}
set svt1 [lindex [split $tv1 \n] 0]
set svt2 [lindex [split $tv2 \n] 0]
set tv3 [lindex [split $tv3 \n] 0]
set tv4 [lindex [split $tv4 \n] 0]
set tv42 [lindex [split $tv5 \n] 0]
set kanal5 [lindex [split $tv6 \n] 0]
set ztv [lindex [split $tv7 \n] 0]
puthelp "PRIVMSG $chan :\002SVT1:\002 \[${time1}\] $svt1 \002SVT2:\002 \[${time2}\] $svt2 \002TV3:\002 \[${time3}\] $tv3"
puthelp "PRIVMSG $chan :\002TV4:\002 \[${time4}\] $tv4 \002TV4+:\002 \[${time5}\] $tv42 \002KANAL5:\002 \[${time6}\] $kanal5 \002ZTV:\002 \[${time7}\] $ztv" }