{"id":9,"date":"2006-08-02T22:09:33","date_gmt":"2006-08-02T22:09:33","guid":{"rendered":"http:\/\/kera.name\/articles\/?p=9"},"modified":"2006-08-07T19:00:09","modified_gmt":"2006-08-07T19:00:09","slug":"alias-nickinfo","status":"publish","type":"post","link":"https:\/\/kera.name\/articles\/2006\/08\/alias-nickinfo\/","title":{"rendered":"alias nickinfo"},"content":{"rendered":"<p>Every so often, someone pops into #mIRC on EFnet with a question that has been answered many times before. So I keep fragments of code handy, ready to post back into the channel every now and then.<\/p>\n<p>But then I got to thinking&#8230; wouldn&#039;t it be cool if I had an URL to send people instead?<\/p>\n<p>So now, the URL will be to this blog. And more specifically, to posts just like this one. <!--nextpage--><\/p>\n<p>People often try to put \/dns in an alias and straightaway access the resultant data. Due to the asynchronous nature of server lookup, there is a delay before the \/dns response comes back &#8211; after which the script has long ago finished executing. Also, results are only valid in the ON DNS event, which executes when a reply is received.<\/p>\n<p>So, your code must be placed in the ON DNS event if you want to use DNS info on a person. This doesn&#039;t mean you can&#039;t still tie the retrieval of dns information to a specific request.<\/p>\n<p>All the following code should be placed in the Remotes section of mIRC&#039;s script editor (alt+r).<\/p>\n<p>First we set up our calling alias:<\/p>\n<div class=\"code\">alias nickinfo {; Set temporary variable with where the result should go. Will unset in 5 seconds by default.set -u5 %waitfordns. [ $+ [ $$1 ] ] $active<\/p>\n<p>; Request DNS lookup from your ISP (or local cache)<\/p>\n<p>.dns $1<\/p>\n<p>}<\/p><\/div>\n<p>With that done, we have set a variable with the name of the target and also the destination window, $active. The variable will unset automatically after five seconds, but until that time we have that information available.<\/p>\n<p>And most importantly, \/dns has been called. The request has gone off to the Domain Name Servers and, as far as your alias cares, that&#039;s it. (This is why you can&#039;t make this an identifier: the eventual result has no context here.)<!--nextpage--><\/p>\n<p>When the result does come through, it triggers this event:<\/p>\n<div class=\"code\">on *:dns:{; Cycles through all returned results; sometimes there are more than one<\/p>\n<p>var %i = 1<\/p>\n<p>while $dns(%i) {<\/p>\n<p>; Only if the temporary variable was set (ie. if you used \/nickinfo)<\/p>\n<p>if (%waitfordns. [ $+ [ $dns(%i).nick ] ]) {<\/p>\n<p>; Sends data from the DNS lookup and some additional info to the chan\/query you specified in \/nickinfo<\/p>\n<p>msg $ifmatch $+(,Nick:,) $dns(%i).nick $+(,Address:,) $dns(%i).addr $+(,IP:,) $dns(%i).ip   ( $+ $+(,My Time:,) $time $+(,My Email:,) $emailaddr $+ )$+ )<\/p>\n<p>; Unsets the temporary variable; even though it unsets itself after 5secs, it never hurts to clean up.<\/p>\n<p>unset %waitfordns. [ $+ [ $dns(%i).nick ] ]<\/p>\n<p>}<\/p>\n<p>inc %i<\/p>\n<p>}<\/p>\n<p>}<\/p><\/div>\n<p>This is where our temporary variable comes in handy. When we match up the \/dns target with existing variables in existence, we essentially determine whether or not this \/dns call originated from \/nickinfo. It&#039;s not a 100% tied link but it&#039;s reasonable enough to assume you wouldn&#039;t \/dns the same person within the same fraction of a second through multiple means.<\/p>\n<p>With that variable matched, we use its value &#8211; the destination window for results &#8211; and send the information there.<\/p>\n<p>In practice, you can do whatever you like with it at that point.<\/p>\n<p><strong>Note:<\/strong> <em>As with all my mIRCscript posts, you should copy the code into mIRC&#039;s script editor and press the &#034;{}&#034; button to auto-indent it. It will make it far more readable. Posting on the web makes it difficult to present the code as it really should appear. Some lines may also have auto-wrapped in your web browser, which won&#039;t be a problem once in the script editor.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every so often, someone pops into #mIRC on EFnet with a question that has been answered many times before. So I keep fragments of code handy, ready to post back into the channel every now and then. But then I got to thinking&#8230; wouldn&#039;t it be cool if I had an URL to send people [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[8],"_links":{"self":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/9"}],"collection":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}