TLD lookup

By knoeki on May 21, 2010

Just a simple script for a bot (or whatever else you want to use it for) to look up TLDs.


 21/05 10:08:21  ~ | Knoeki > !tld nl
 21/05 10:08:30  & | Miffy  > [.nl] Type: country-code - Purpose: Netherlands - Sponsoring organisation: Stichting Internet Domeinregistratie Nederland
 21/05 10:08:45  ~ | Knoeki > !tld net
 21/05 10:08:49  & | Miffy  > [.net] Type: generic - Purpose: Generic top-level domain - Sponsoring organisation: VeriSign Global Registry Services

(you can specify the TLD either with or without a . in front of it, the script will compensate).

No, I didn't use regex. What's the point? It works fine like this.

on *:TEXT:!tld *:#: {
    noop $tld($chan, $2)

alias tld {
    if ($hget(tld) != $null) {
        hfree tld
    hmake tld 20
    hadd tld chan $1
    hadd tld get $iif($left($2, 1) != ., $+(.,$2), $2)
    sockopen tld 80

on *:SOCKOPEN:tld: {
    sockwrite -n $sockname GET /domains/root/db/# HTTP/1.1
    sockwrite -n $sockname Host:
    sockwrite -n $sockname Connection: keep-alive
    sockwrite -n $sockname $crlf

on *:SOCKREAD:tld: {
    sockread %tmp    
    ;echo @tld %tmp
    if ($+(*<a href="/domains/root/db/*.html">,$hget(tld, get),</a></td><td>*</td><td>*<br/><span class="tld-table-so">*</span></td></tr>) iswm %tmp) {        
        sockclose $sockname
        var %typ $gettok($gettok(%tmp, 7, 62), 1, 60)
        var %pur $gettok($gettok(%tmp, 9, 62), 1, 60)
        var %org $gettok($gettok(%tmp, 11, 62), 1, 60)
        msg $hget(tld, chan) $+($chr(91),$hget(tld, get),$chr(93)) Type: %typ - Purpose: %pur - Sponsoring organisation: %org
    elseif (%tmp == <!-- start common-bodytail -->) {
        sockclose $sockname
        msg $hget(tld, chan) No such TLD.


Sign in to comment.
Jethro   -  May 21, 2010

Actually I'll suggest:

var %org $remove($gettok($gettok(%tmp,11-12,62),1,60),line>)

Because the length of some TLDs will result in showing an unwanted source string, and we want to remove it.

Jethro   -  May 21, 2010

The issue is this line:> var %org $gettok($gettok(%tmp,11,62),1,60)It needs to be 11 to 12, not 11:> var %org $gettok($gettok(%tmp,11-12,62),1,60)Also, this bit:> on :SOCKREAD:tld: {
sockread %tmpShould have been:> on
:SOCKREAD:tld: {
var %tmp | sockread %tmpYou missed a local variable to temporarily store the buffer. Without that local var, the buffer from the source code gets set as a global var in your variables.

knoeki   -  May 21, 2010

Have you had a chance to fix the issue I noted in my first reply? The part where it did notgive the 'Sponsoring organisation:" part right?

It's strange indeed, I'll have a look at it later.

Scakk   -  May 21, 2010

Have you had a chance to fix the issue I noted in my first reply? The part where it did notgive the 'Sponsoring organisation:" part right?

knoeki   -  May 21, 2010

you can always have a delay variable at the start of the script (or in an .ini, whatever you prefer), and do something like:

;; set delay between lines being sent:
var %delay 0
;; --- bunch-o-code goes here --
msg # blargh1
timer 1 %delay msg # blargh1
timer 1 $calc(%delay + 1) msg # blargh1
timer 1 $calc(%delay + 2) msg # blargh1

Bit rough maybe, but it probably works. Tastes differ. I prefer to keep everything on one line generally, but it depends on the case.

Scakk   -  May 21, 2010

Most of mine do not have time delays as some people want it and some do not. I just leave it out so those that do want it can add it easy enough or ask how to have it added in.

Jethro   -  May 21, 2010

Actually I agree with you, Scakk. I come across some folks who like horizontal display. Personally I find it hard to read, as all info wrap together like a big paragraph. But our tastes for something certainly are different; it's a personal preference.

Last but not least, I have, however, stumbled upon some of your socket scripts before, and they don't have timed delay in display, which is an invitation for potential a spam or flood attack.

Scakk   -  May 21, 2010

I tend to like it more vertical than horizontal as shown incase there are several long bits that need to be displayed.

Jethro   -  May 21, 2010

Scakk, You can get the output displayed horizontally rather than vertically for this. A timed delay and trigger control are recommended to safeguard the script for spam or flood attack. This is always helpful for a vertical info output.

sunslayer   -  May 21, 2010

instead of using a hash, you should look into /sockmark

Scakk   -  May 21, 2010

Using your version I got the below.

[08:46] <Goofy|AFK> !tld cc
[08:46] <MrMorden> [.cc] Type: country-code - Purpose: Cocos (Keeling) Islands - Sponsoring organisation: line

I have since rewrote it ( removing the hash tables ) and fixed that issue.

I get the below with mine.

[09:33] <Goofy|AFK> !tld cc
[09:33] <MrMorden> Domain: [.CC]
[09:33] <MrMorden> Type: country-code
[09:33] <MrMorden> Purpose: Cocos (Keeling) Islands
[09:33] <MrMorden> Sponsoring Organisation: eNIC Cocos (Keeling) Islands Ltd.
[09:33] <MrMorden> Sponsoring Organisation: Pty, d/b/a Island Internet Services
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.