Weather
Posted by pumakuma
Friday, April 14, 2006
Description: Collects weather info by zip codes from weather.com
;;TRIGGER is .weather <zip> .. Change in on TEXT at bottom
;; My internet has been sucking lately and i can't tell if this is 100% working
;; If you notice any bugs that you can't fix just email me at pumakuma@gmail.com
alias weather {
sockclose weather- $+ $replace($1-,$chr(32),+)
sockopen weather- $+ $replace($1-,$chr(32),+) www.weather.com 80
}
on *:SOCKOPEN:weather*:{
sockwrite -n $sockname GET /weather/local/ $+ $gettok($sockname,2-,45) $+ ?lswe= $+ $gettok($sockname,2-,45) $+ &lwsa=WeatherLocalUndeclared&from=whatwhere HTTP/1.1
sockwrite -n $sockname Host: www.weather.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
sockwrite -n $sockname Authorization: Basic
sockwrite -n $sockname $crlf
}
on *:sockread:weather*: {
sockread %temp
if (Updated isin %temp) {
set %we.update $nohtml(%temp) | haltdef
}
if (</B></TD> isin %temp) {
if ( isin $nohtml(%temp)) {
set %we.cond $remove($nohtml(%temp),$chr(9)) | haltdef
}
}
if (ALIGN="left"><H2 CLASS="moduleTitleBar"><B>Right Now for</B><BR> isin %temp) {
set %we.loc $remove($remove($gettok($nohtml(%temp),3-,32),for),Save this Location) | haltdef
}
if (Feels Like isin %temp) {
set %we.temp $remove($nohtml(%temp),$chr(9)) | set %we.temperature $remove($replace($gettok(%we.temp,1,32),°, $+ $chr(176)),Feels) | set %we.feelslike $chr(40) $+ feels like $replace($gettok(%we.temp,3,32),°, $+ $chr(176)) $+ $chr(41) | haltdef
}
if (*CLASS="obsTextA">*%</td>* iswm %temp) {
set %we.hum %temp | set %we.humidity $gettok($gettok(%we.hum,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*mph</td>* iswm %temp) {
set %we.wind %temp | set %we.windex $gettok($gettok(%we.wind,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*°*</td>* iswm %temp) {
set %we.dew %temp | set %we.dewpoint $replace($gettok($gettok(%we.dew,2,62),1,60),°, $+ $chr(176)) | haltdef
}
if (sunrise: isin %temp) {
set %we.sunrise $remove($nohtml(%temp),$chr(9),sunrise:)
}
if (sunset: isin %temp) {
set %we.sunset $remove($nohtml(%temp),$chr(9),sunset:)
}
if (*CLASS="obsTextA">*miles</td>* iswm %temp) {
set %we.vis %temp | set %we.visibility $gettok($gettok(%we.vis,2,62),1,60) | haltdef
}
}
on *:SOCKCLOSE:weather*:{
msg %we.chan [^B] $+ %we.loc $+ [^B]: %we.temperature %we.feelslike - [^B]Conditions[^B]: %we.cond - [^B]Humidity[^B]: %we.humidity - [^B]Visibility[^B]: %we.visibility - [^B]Wind[^B]: %we.windex - [^B]Dew Point[^B]: %we.dewpoint - [^B]Sunrise[^B]: %we.sunrise - [^B]Sunset[^B]: %we.sunset - $chr(40) $+ %we.update $+ $chr(41) - [^B]www.weather.com[^B] | unset %we. | unset %temp
}
alias -l nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
on *:TEXT:.weather *:#:{
if ($2 isnum) && ($len($2) == 5) {
/weather $2 | set %we.chan $chan }
else {
msg $chan Incorrect zip code format.
}
}
;;TRIGGER is .weather <zip> .. Change in on TEXT at bottom
;; My internet has been sucking lately and i can't tell if this is 100% working
;; If you notice any bugs that you can't fix just email me at pumakuma@gmail.com
alias weather {
sockclose weather- $+ $replace($1-,$chr(32),+)
sockopen weather- $+ $replace($1-,$chr(32),+) www.weather.com 80
}
on *:SOCKOPEN:weather*:{
sockwrite -n $sockname GET /weather/local/ $+ $gettok($sockname,2-,45) $+ ?lswe= $+ $gettok($sockname,2-,45) $+ &lwsa=WeatherLocalUndeclared&from=whatwhere HTTP/1.1
sockwrite -n $sockname Host: www.weather.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
sockwrite -n $sockname Authorization: Basic
sockwrite -n $sockname $crlf
}
on *:sockread:weather*: {
sockread %temp
if (Updated isin %temp) {
set %we.update $nohtml(%temp) | haltdef
}
if (</B></TD> isin %temp) {
if ( isin $nohtml(%temp)) {
set %we.cond $remove($nohtml(%temp),$chr(9)) | haltdef
}
}
if (ALIGN="left"><H2 CLASS="moduleTitleBar"><B>Right Now for</B><BR> isin %temp) {
set %we.loc $remove($remove($gettok($nohtml(%temp),3-,32),for),Save this Location) | haltdef
}
if (Feels Like isin %temp) {
set %we.temp $remove($nohtml(%temp),$chr(9)) | set %we.temperature $remove($replace($gettok(%we.temp,1,32),°, $+ $chr(176)),Feels) | set %we.feelslike $chr(40) $+ feels like $replace($gettok(%we.temp,3,32),°, $+ $chr(176)) $+ $chr(41) | haltdef
}
if (*CLASS="obsTextA">*%</td>* iswm %temp) {
set %we.hum %temp | set %we.humidity $gettok($gettok(%we.hum,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*mph</td>* iswm %temp) {
set %we.wind %temp | set %we.windex $gettok($gettok(%we.wind,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*°*</td>* iswm %temp) {
set %we.dew %temp | set %we.dewpoint $replace($gettok($gettok(%we.dew,2,62),1,60),°, $+ $chr(176)) | haltdef
}
if (sunrise: isin %temp) {
set %we.sunrise $remove($nohtml(%temp),$chr(9),sunrise:)
}
if (sunset: isin %temp) {
set %we.sunset $remove($nohtml(%temp),$chr(9),sunset:)
}
if (*CLASS="obsTextA">*miles</td>* iswm %temp) {
set %we.vis %temp | set %we.visibility $gettok($gettok(%we.vis,2,62),1,60) | haltdef
}
}
on *:SOCKCLOSE:weather*:{
msg %we.chan [^B] $+ %we.loc $+ [^B]: %we.temperature %we.feelslike - [^B]Conditions[^B]: %we.cond - [^B]Humidity[^B]: %we.humidity - [^B]Visibility[^B]: %we.visibility - [^B]Wind[^B]: %we.windex - [^B]Dew Point[^B]: %we.dewpoint - [^B]Sunrise[^B]: %we.sunrise - [^B]Sunset[^B]: %we.sunset - $chr(40) $+ %we.update $+ $chr(41) - [^B]www.weather.com[^B] | unset %we. | unset %temp
}
alias -l nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
on *:TEXT:.weather *:#:{
if ($2 isnum) && ($len($2) == 5) {
/weather $2 | set %we.chan $chan }
else {
msg $chan Incorrect zip code format.
}
}