TLD scanner

By knoeki on Jun 27, 2009

Scan channels and show the amount of each found TLs (Top Level Domain).

Works cross-channel, and has pretty decent error checking.

Also included is a TLD lookup trigger, to find out what a TLD means.

Usage:
!tldscan [channel]
!tld

What it looks like:
[15:51:01] !tldscan
[15:51:02] <&Miffy> TLDscan for #zomgwtfbbq complete: info: 9, ca: 3, Net: 8, nl: 2, com: 7, org: 2, dk: 1, us: 1, dj: 1, sg: 1, be: 1.

PLEASE NOTE: This script assumes that you have a file called tld.txt in the \data\ dir. this dir should be in the same place as the script. Modify as neccisary. No, I won't do it for you. Do it yourself, damnit. If you don't know how, Learn to script, it's not that hard.

You can get the list of TLDs here.

Constructive criticism, suggestions and praise welcome, flames to /dev/null.

on *:TEXT:!tldscan*:#: {
   if ($2 != $null) {
      if ($left($2,1) == $chr(35)) {
         if ($me ison $2) {
            var %chan $2
         }
         else {
            msg $chan I'm not on $+($2,.)
            halt
         }
      }
      else {
         msg $chan Invalid channelname.
         halt
      }
   }
   else {
      var %chan $chan
   }
   var %x 1
   while (%x <= $nick($chan, 0)) {
      if ($read($scriptdir\data\tld.txt, s, $gettok($address($nick(%chan, %x), 2), -1, 46)) != $null) {
         var %tld.get.tmp $gettok($address($nick(%chan, %x), 2), -1, 46)
         inc %tld. [ $+ [ %tld.get.tmp ] ]
         var %tld.found $addtok(%tld.found, %tld.get.tmp,46)
      }
      inc %x
   }
   var %x 1
   while (%x <= $numtok(%tld.found,46)) {
      var %tld.output $+(%tld.output,$gettok(%tld.found, %x, 46),:,$chr(32),%tld. [ $+ [ $gettok(%tld.found, %x, 46) ] ],$chr(44),$str($chr(32),2))
      inc %x
   }
   msg $chan TLDscan for %chan complete: $+($left(%tld.output, $calc($len(%tld.output) - 3)),.)
   unset %tld.*
}

on *:TEXT:!tld *:#: {
   if ($read($scriptdir\data\tld.txt, s, $2) != $null) {
      msg $chan $read($scriptdir\data\tld.txt, s, $2)
   }
}

Comments

Sign in to comment.
knoeki   -  Jun 28, 2009

i suspect english is not his native language knoeki. he sure knows his coding though

That's not a excuse for not using punctuation.

Also, english isn't my native language either ;_)

WorldDMT: The whole point was returning a single space. I had to use 2 spaces for god knows what reason, because one space didn't work.

 Respond  
WorldDMT   -  Jun 28, 2009

4) "$str($chr(32),2) dont work".. what? sure it does. it works fine for me. I generally test my code before posting it here.

try //echo -a $+(bla,$str($chr(32),2),blo) will return bla blo with only one space

and more //echo -a $+(bla,$str($chr(32),6),blo) will return also bla blo with one space

but //echo -a $+(bla,$str($chr(160),2),blo) will return bla blo with 2 spaces

and //echo -a $+(bla,$str($chr(160),6),blo) will return bla blo with 6 spaces :)

for $qt() no need to use it with $read u r rigth becose some command dont take spaces so we have to put "" and $qt() did

sorry i dont speak verry well english i speak french :D

 Respond  
Cheiron   -  Jun 28, 2009

i suspect english is not his native language knoeki. he sure knows his coding though

 Respond  
knoeki   -  Jun 28, 2009

see /help $v1 no need for "halt" no need to unset the variable is not global and $str($chr(32),2) dont work must be with 160 $str($chr(160),2) finaly for $read need to add $qt() better if a file had a space that will not work

1) I'll read up on $v1, as others also suggested.

2) Yes, the halt isn't needed. I could have also made an IF condition at the end, but I didn't, because why go through the trouble of executing the rest of the script when an error has occured anyways? :_)

3) read my code again. there is a reason I'm unsetting the variable; if you create a variable by INC'ing it, it's a global variable by default, or so it seems.

4) "$str($chr(32),2) dont work".. what? sure it does. it works fine for me. I generally test my code before posting it here.

5) $qt(), I should have used that indeed.

and last but not least:

6) learn to use punctuation, it makes your text more readable, and on top of that you won't come across as a moron.

 Respond  
WorldDMT   -  Jun 27, 2009

hi

see /help $v1 no need for "halt" no need to unset the variable is not global and $str($chr(32),2) dont work must be with 160 $str($chr(160),2) finaly your code can be like this take an idea if you need

on *:text:*:#:{
  if $strip($1) == !tldscan {
    if $2 {
      if $left($2,1) == $chr(35) {
        if ($me ison $2) var %chan $2
        else msg # I'm not on $+($2,.)
      }
      else msg # Invalid channelname.
    }
    else var %chan #
    if %chan {
      var %x 1
      while $nick(%chan,%x) {
        var %a $gettok($address($v1,2),-1,46)
        if $read($qt($scriptdirdata\tld.txt),s,%a) {
          inc $+(%,tld.,%a)
          var %tld.found $addtok(%tld.found,$(%a,2),46)
        }
        inc %x
      }
      %x = 1
      while ($gettok(%tld.found,%x,46)) var %tld.output $+(%tld.output,$v1,:,$chr(32),$($+(%,tld.,$v1),2),$chr(44),$str($chr(160),2)),%x %x + 1
      msg # TLDscan for %chan complete: $+($iif(%tld.output,$left($v1,-3),No Result),.)
    }
  }
  elseif ($strip($1) == !tld) if ($read($qt($scriptdirdata\tld.txt),s,$2)) msg # $v1
}
 Respond  
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.