mIRC Home    About    Download    Register    News    Help

Print Thread
#260992 13/07/17 12:59 AM
Joined: Jul 2017
Posts: 2
F
Fips Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
F
Joined: Jul 2017
Posts: 2
Hey,
I need some help with a command to read php.
I already searched for a solution without success frown
So I start this Topic now.

The command should called !metar $2 (And a word behind)
When you do !metar the script should go to this site
http://metar.vatsim.net/metar.php?id=$2
and should post what´s displayed on the page

Example:
!metar egll
Respond: EGLL 130020Z AUTO 13006KT 9999 FEW036 16/11 Q1023 NOSIG

And if you don´t write a word behind metar like only !metar
he should respond: Please issue an ICAO code.

I hope you understand and you can help me to to a script for that smile Thanks!

Fips #260994 13/07/17 04:59 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Not saying this is 'good' code, just that it looks like it works.

Code:
on *:text:!metar *:#:{
  if ($2 isalnum) { 
    window -a $chan
    set %vatsim.ID $lower($2)
    set %vatsim.Chan #
    sockopen vatsim metar.vatsim.net 80
  }
}

on *:sockopen:vatsim: {
  sockwrite -n $sockname GET /metar.php?id= $+ %vatsim.ID HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  sockwrite -n $sockname Host: metar.vatsim.net
  ;sockwrite -n $sockname max-age: 0
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname
}

on *:sockread:vatsim: {
  if ($sockerr) { echo -a Sock $sockname Error: $sockerr | halt }
  var %test
  sockread 4000 %test
  echo -s $scriptline sockread text: %test
  if (%vatsim.ID $+ * iswm %test) { describe %vatsim.Chan respond: %test | sockclose $sockname }
}

maroon #260997 13/07/17 12:37 PM
Joined: Jul 2017
Posts: 2
F
Fips Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
F
Joined: Jul 2017
Posts: 2
Thank you very much! It works! grin


Link Copied to Clipboard