rendered paste body; iplookup.mrc
; ------------
; USAGE: /ipl <target IP match>
on *:DNS: {
if (%ipl == 1) {
hadd ipl %ipl_num $dns(1).ip
hadd ipln %ipl_num $dns(1).nick
inc %ipl_num
if (%ipl_num > %ipl_count) {
ipl_handle
set %ipl 0
}
halt
}
}
alias ipl {
ipl_make
set %ipl 1
set %ipl_num 1
set %ipl_target $$1
set %ipl_channel $active
set %ipl_count $nick(%ipl_channel,0)
var %i = 1
echo %ipl_channel Starting DNS lookup for %ipl_count nick $+ $iif(%ipl_count == 1, $null, s) $+ ...
while (%i <= %ipl_count) {
.dns $nick(%ipl_channel,%i)
inc %i
}
}
alias ipl_handle {
var %i = 1, %j = 1
echo %ipl_channel DNS lookup for " $+ %ipl_target $+ " complete! Posting results:
while (%i <= $hget(ipl).size) {
if ($hget(ipl,%i) == $null) {
break
}
else {
if ($mid($hget(ipl,%i),1,$len(%ipl_target)) == %ipl_target) {
echo %ipl_channel $chr(160) $chr(160) $chr(160) Match: $hget(ipln,%i) ( $+ $hget(ipl,%i) $+ )
inc %j
}
}
inc %i
}
echo %ipl_channel Found $calc(%j - 1) result $+ $iif($calc(%j - 1) == 1, $null, s) $+ .
ipl_del
ipl_unset
}
alias ipl_make {
hmake ipl
hmake ipln
}
alias ipl_del {
hfree -w ipl
hfree -w ipln
}
alias ipl_unset {
unset %ipl
unset %ipl_channel
unset %ipl_count
unset %ipl_num
unset %ipl_target
}