mIRC Home    About    Download    Register    News    Help

Print Thread
parsing results of /DNS as a variable #239044 19/09/12 02:29 PM
Joined: Sep 2012
Posts: 1
J
j_shutz Offline OP
Mostly harmless
OP Offline
Mostly harmless
J
Joined: Sep 2012
Posts: 1
Hi guys,

I am trying to write a script that does a /DNS lookup on an IP address, and I would like to set the result as a variable.

is this a RAW, or how would I parse the result as a variable,
so that when I do a look up I can /msg $chan %variable ?

I appreciate your help, I was unable to find the answer via google.


Thanks in advance

Re: parsing results of /DNS as a variable [Re: j_shutz] #239045 19/09/12 03:46 PM
Joined: Jan 2004
Posts: 1,273
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,273
Usage: /msgdns google.com #mychan

Code:
alias msgdns {
  var %host = $1, %chan = $$2
  set -u5 %dns $+ %host %chan
  .dns %host
}

on *:dns:{
  var %chan = %dns [ $+ [ $dns(0).addr ] ]
  unset %dns [ $+ [ $dns(0).addr ] ]

  if (!%chan) { return }

  if ($dns(1)) {
    msg %chan Dns resolved $dns(1).addr to $dns(1).ip
  }
  else {
    msg %chan Dns unable to resolve address $dns(0).addr
  }
}