Just a simple script for a bot (or whatever else you want to use it for) to look up TLDs.
example:
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 www.iana.org 80
}
on *:SOCKOPEN:tld: {
sockwrite -n $sockname GET /domains/root/db/# HTTP/1.1
sockwrite -n $sockname Host: www.iana.org
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.
}
}
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.
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.
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.
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