caesar wrote:Code: Select all
bind dcc n|n dns2 dcc:dns2
proc dcc:dns2 {handle idx nick} {
global ip
set host [lindex [split [getchanhost $nick] @] end]
set lookup [dnslookup $host lookup]
putdcc $idx "Result: $host $lookup"
}
proc lookup { ip hostname status } {
return $ip
}
This is working fine to me.
Result: caesar.u2.something.ro 192.168.108.55
This is still incorrect, and only works if the information is cached.
Try doing it on a few nicks, and you may find it fails on some.
What the command does is this.
1: You do a lookup on the hostname, or IP. Along with it, you specify a command and any argument you want ot pass to it.
2: If the data is allready cached, return this cached information.
3: Do a lookup if needed
4: If details are not cached, cache them for later.
5: Call the command specified with the details.
6: The command should then continue where the other script left off.
With your "return $ip", it doesn't make it return the data to the previously runnign script.
Asycronous means, that the bot doesn't feeze while it obtains the data, and is able to continue, to prevent possible PING timeouts.
It simply continues with the script.
IOnce the result of the DNS is in, if it be 1 second, or 1 hour, the command will then be called.
The command with the return code in, is no more usful that the original post, as it doesn't return to the original code.