This script will return the weather in the UK and Ireland using postcodes.
Usage: !ukweather pe3 6hr
or
Usage: !ukweather ng21 0st
Updated 28Jan09: Updated to allow the 7 or 6 digit postcodes. No longer able to put it together. Has to be spaced as shown in usages above.
on *:text:!ukweather*:#: {
if ($len($2) == 3 && $len($3) == 3) {
set %ukw2 $2 | set %ukw3 $3 | set %ukwchan $chan
sockopen ukweather www.accuweather.com 80
}
if ($len($2) == 4 && $len($3) == 3) {
set %ukw2 $2 | set %ukw3 $3 | set %ukwchan $chan
sockopen ukweather www.accuweather.com 80
}
}
on *:sockopen:ukweather: {
sockwrite -n $sockname GET /ukie/index-forecast.asp?postalcode= $+ $+(%ukw2,$chr(43),%ukw3) HTTP/1.1
sockwrite -n $sockname Host: www.accuweather.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:ukweather: {
if ($sockerr > 0) return
sockread %ukwtemp
if ($sockbr == 0) return
if (<div id="fcst_title"> isin %ukwtemp) { set %ukwloc $nohtml(%ukwtemp) }
if (_current_temps"> isin %ukwtemp) { set %ukwcurrent $replace($nohtml(%ukwtemp),$(°),$chr(176)) }
if (_current_rfval"> isin %ukwtemp) { set %ukwreal $replace($nohtml(%ukwtemp),$(°),$chr(176)) }
if (_curr_icon" isin %ukwtemp) { set %ukwcond1 $remove($gettok(%ukwtemp,-1,61),$chr(34),$(/>)) }
if (_current_wxtext"> isin %ukwtemp) { set %ukwcond2 $nohtml(%ukwtemp) }
if (Humidity: isin %ukwtemp) { set %ukwhumidity $remove($nohtml(%ukwtemp),Humidity:,$chr(9)) }
if (Dew Point: isin %ukwtemp) { set %ukwdewpoint $remove($replace($nohtml(%ukwtemp),$(°),$chr(176)),Dew Point:,$chr(9)) }
if (Pressure: isin %ukwtemp) { set %ukwpressure $remove($nohtml(%ukwtemp),Pressure:,$chr(9)) }
if (Visibility: isin %ukwtemp) { inc %t 1 | set %ukwvisibility $+ %t $nohtml(%ukwtemp) }
if (quicklook_curr_head" isin %ukwtemp) { set %ukwcurtime $nohtml(%ukwtemp) }
}
on *:sockclose:ukweather: {
if (!%ukwloc) { msg %ukwchan Please choose another postcode as that ones does not exists. }
if (%ukwloc) {
msg %ukwchan Location: $remove(%ukwloc ,$chr(9))
msg %ukwchan Current Condition: %ukwcond1 and $remove(%ukwcond2,$chr(9))
msg %ukwchan Currently: $remove(%ukwcurrent,$chr(9)) Feels Like: $remove(%ukwreal,$chr(9))
msg %ukwchan Humidity: %ukwhumidity Dew Point: $remove(%ukwdewpoint,$chr(32))
msg %ukwchan Pressure: %ukwpressure Visibility: $remove(%ukwvisibility1,Visibility:,$chr(32),$chr(9))
msg %ukwchan $remove(%ukwcurtime,$chr(9)) in $remove(%ukwloc,$chr(9))
msg %ukwchan http://www.accuweather.com/ukie/index-forecast.asp?postalcode= $+ $+(%ukw2,$chr(43),%ukw3)
}
unset %ukw* %t*
}
alias -l nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}