on *:sockread:weather*: {
sockread %temp
if (">Updated isin %temp) {
set %we.update $nohtml(%temp) | haltdef
}
if ( isin %temp) {
if ( isin $nohtml(%temp)) {
set %we.cond $remove($nohtml(%temp),$chr(9)) | haltdef
}
}
if (ALIGN="left">
Right Now for
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">*%* iswm %temp) {
set %we.hum %temp | set %we.humidity $gettok($gettok(%we.hum,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*mph* iswm %temp) {
set %we.wind %temp | set %we.windex $gettok($gettok(%we.wind,2,62),1,60) | haltdef
}
if (*CLASS="obsTextA">*°** 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* iswm %temp) {
set %we.vis %temp | set %we.visibility $gettok($gettok(%we.vis,2,62),1,60) | haltdef
}
}
on *:SOCKCLOSE:weather*:{
msg %we.chan 4,1 [^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.
}
}