alias temp if (%weather) echo $color(info) -a %weather | else { sockclose weather | if ($show) set -u10 %weather local | sockopen weather www.bom.gov.au 80 }
alias saytemp if ($active ischan) && (%weather) msg $active %weather | else { .temp | .timer 1 4 saytemp }
alias f2c if ($isid) return $iif($1 !isalpha,$+($round($calc(($1 - 32) * 5 / 9),1),°C),unknown°C) | else say $+($round($calc(($iif($1 isnum,$1,$?="Enter °F:") - 32) * 5 / 9),1),°C) $2-
alias c2f if ($isid) return $iif($1 !isalpha,$+($int($calc($1 * 9 / 5 + 32)),°F),unknown°F) | else say $+($int($calc($iif($1 isnum,$1,$?="Enter °C:") * 9 / 5 + 32)),°F) $2-
on *:sockopen:weather:{
sockwrite -n $sockname GET /products/IDN65066.shtml HTTP/1.1
sockwrite -n $sockname Host: www.bom.gov.au $+ $str($crlf ,2)
}
on *:sockread:weather:{
sockread %temp
if ($sockerr > 0) { echo -a $sockerr | return }
var %data = $deltok($wildtok(%temp,$+(*,Canberra Airport,$chr(44),*),1,60),5,44)
if (%data) {
var %rp = 1, %rm = $wildtok(%data,*-9999*,0,44)
while (%rp <= %rm) { var %data = $puttok(%data,unknown,$findtok(%data,$wildtok(%data,*-9999*,1,44),1,44),44) | inc %rp }
var %rp = 1, %rm = $wildtok(%data,*-, 0,44)
while (%rp <= %rm) { var %data = $puttok(%data,unknown,$findtok(%data,$wildtok(%data,*-,1,44),1,44),44) | inc %rp }
tokenize 44 $mid(%data,$calc($pos(%data,:,1) + 1),4) $+ , $+ $deltok(%data,1-3,44)
var %hour = $iif($left($1,2) isnum 1-12,$left($1,2),$iif($left($1,2) == 0,12,$calc($left($1,2) - 12)))
if (%weather == local) {
echo $color(info) -a As of $iif($1 isnum,$+($iif(%hour < 10,$right(%hour,1),%hour),:,$right($1,2),$iif($left($1,2) isnum 0-11,am,pm)),unknown time)
echo $color(info) -a Temperature: $+($2,°C) $+ ( $+ $c2f($2) $+ )
echo $color(info) -a Humidity: $3 $+ %
echo $color(info) -a Windspeeds of $+($5,km/h) $+ ( $+ $int($calc($5 * 5 / 8)) $+ mph) coming from the $4 with gusts of $+($6,km/h) $+ ( $+ $int($calc($6 * 5 / 8)) $+ mph)
echo $color(info) -a Barometric Pressure at $7
}
set -u120 %weather As of $iif($1 isnum,$+($iif(%hour < 10,$right(%hour,1),%hour),:,$right($1,2),$iif($left($1,2) isnum 0-11,am,pm)),unknown time) on $asctime(dddd) in Canberra the temp is $+($2,°C) $+ ( $+ $c2f($2) $+ ), relative humidity of $3 $+ % $+ , windspeeds of $+($5,km/h) $+ ( $+ $int($calc($5 * 5 / 8)) $+ mph) coming from the $4 with gusts of $+($6,km/h) $+ ( $+ $int($calc($6 * 5 / 8)) $+ mph) and barometric pressure is at $7
sockclose weather | unset %temp
}
}