on *:text:!weather *:#: {
set %zip.code $2
set %weather.chan $chan
weather
}
alias weather { write -c E:\weather.txt | write -c E:\weather2.txt | window -eh @Weather | sockopen weather weatherforyou.com 80 | .timer 1 5 reportweather }
on *:sockread:weather: {
//sockread %weather
aline 8 @Weather %weather
write weather.txt %weather
}
on *:sockopen:weather: {
sockwrite -n $sockname GET /cgi-bin/hw3/hw3.cgi?forecast=zandh&pands= $+ %zip.code $+ &Submit=Get+Forecast HTTP/1.1
sockwrite -n $sockname Host: weatherforyou.com $+ $crlf $+ $crlf
}
;http://www.weatherforyou.com/cgi-bin/hw3/hw3.cgi?forecast=zandh&pands=55110&Submit=Get+Forecast
alias reportweather {
filter -wf @Weather E:\weather2.txt *Local Forecast*
filter -wf @Weather E:\weather2.txt *°F*
filter -wf @Weather E:\weather2.txt *°C*
.timer 1 1 report2
}
alias report2 {
var %weather.one = $read(E:\weather2.txt,1)
var %weather.one = $remove(%weather.one,<span class="titlewhite">)
var %weather.one = $remove(%weather.one,Local Forecast</span><br>)
set %weather.City %weather.one
var %weather.two = $read(E:\weather2.txt,2)
var %weather.two = $remove(%weather.two,<font face="Verdana)
var %weather.two = $remove(%weather.two,Arial" size="4"><b>)
var %weather.two = $remove(%weather.two,</b></font><br>)
var %weather.two = $replace(%weather.two,&deg;,$chr(176))
set %weather.temp Current Temp: %weather.two
var %weather.three = $read(E:\weather2.txt,3)
var %weather.three = $remove(%weather.three,<)
var %weather.three = $remove(%weather.three,td align="right" class="smalldefault">)
var %weather.three = $remove(%weather.three,/td>)
var %weather.three = $replace(%weather.three,&deg;,$chr(176))
set %weather.dew Current Dewpoint: %weather.three
window -c @Weather
humidity
}
alias humidity {
var %a = $lines(E:\weather.txt)
var %b = 1
:begin
var %read = $read(E:\weather.txt, %b)
if (%b <= %a) {
if (Humidity isin %read) && (META !isin %read) {
set %humidity Humidity: $read(E:\weather.txt, $calc(%b + 1))
set %humidity $remove(%humidity,<td align="right" class="smalldefault">,</td>)
}
inc %b
goto begin
}
else { goto end }
:end
weathersay
}
alias weathersay {
msg %weather.chan %weather.City
msg %weather.chan %weather.temp
msg %weather.chan %weather.dew
msg %weather.chan $remove(%humidity,<td align="right" class="smalldefault">,</td>)
}