mIRC Home    About    Download    Register    News    Help

Print Thread
a weather script for australia #17928 03/04/03 03:41 PM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
This should be simple, but as much as i've looked on the net i can't find a weather script that works to show the weather in Australia.

Does anyone here know of any script that does?

Re: a weather script for australia #17929 03/04/03 04:05 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Well if you can find a website that is url oriented, just use sockets. You auery the server, request the data on that page, and print it to the channel.


-KingTomato
Re: a weather script for australia #17930 03/04/03 04:10 PM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
how do i know if a webpage uses sockets?

Re: a weather script for australia #17931 03/04/03 04:11 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
All websites use sockets.

Re: a weather script for australia #17932 03/04/03 04:17 PM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
ok so i dont bore you with more questions - could i please have a website that can teach me what i need to know on how to use these sockets please?

Re: a weather script for australia #17933 03/04/03 04:27 PM
Joined: Jan 2003
Posts: 44
L
lambroger Offline
Ameglian cow
Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
try www.mirscripts.org

and those other links offered in the main page links section of www.mirc.com

Re: a weather script for australia #17934 04/04/03 09:14 AM
Joined: Dec 2002
Posts: 143
A
Aubs Offline
Vogon poet
Offline
Vogon poet
A
Joined: Dec 2002
Posts: 143
Take a look at this:CNN News Grabber

[edit]It's not a link to a news grabber script, just a previous thread. Thought it might help/be of interest![/edit]

It's what I found when someone asked about getting a news grabber. There's links to scripts that may be of use to you if you want to see how other scripts use sockets.

Also, a socket tutorial can be found here:Introduction to Sockets

Good luck!! wink

Last edited by Aubs; 04/04/03 09:16 AM.

Aubs.
cool

Re: a weather script for australia #17935 05/04/03 10:24 AM
Joined: Dec 2002
Posts: 17
C
Chimera Offline
Pikka bird
Offline
Pikka bird
C
Joined: Dec 2002
Posts: 17
This is a really bad example I wrote a while back, but it still happens to work for me so I haven't bothered improving it.
It lacks errorchecking, commenting, and the location and url are hardcoded into it.
Having said that you will probably find all the necessary locations at www.bom.gov.au - note that the format of the data and frequency of updates differs from page to page

/temp echos the current (accurate within 10 mins) temperature, humidity, windspeeds and barometric pressure to the active window.
/saytemp sends the same info to the active channel/query

Code:
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
  }
}