Global Whois

By DarthReven on May 19, 2005

This is a snippet that uses sockets to join to a server and run a whois on each server for a specified nick. I sugest that you be on the server with the socket though nither has to be in a room.
It has only been tested for a 3 server depending on your bandwith you may be able to get more.
you will also need to create a txt file called server.txt for where the servers you want the bots to connect to ie: irc.undernet.org one server per line

;AUTHOR'S WARNING: Over use of a bot like this on some servers and get you glined from that server. Please use this sparingly or use a perminate bot on the server to return whois replys to you.

alias gserv {
  if (!$read(server.txt,s,$1)) && ($numtok($1,46) == 3) { .write server.txt $1 | echo 12 -ate [Global Whois] - Added $1 to server's list }
  else { echo 4 -ate [Error] -$1 is already in the server's list }
}
alias gwhois {
  if ($1) {
    echo 12 -ate [Global Whois] Retreaving Data on $1 $+ ...
    %whonick = $1
    var %y 1
    while ($read(server.txt,%y)) {
      if (!$sock($+(whoisbawt,%y))) { sockopen $+(whoisbawt,%y) $read(server.txt,%y) 6667 | inc %y }
      else { sockwrite -n $+(whoisbawt,%y) WHOIS %whonick | inc %y }
    }
  }
  else { echo 4 -aet [Error] - No nick was given }
}
on *:sockopen:whoisbawt*: {
  if ($sockerr) { echo 4 -ate [Error] - $sockname was unable to connect to $read(server.txt,$right($sockname,1)) }
  else {
    sockwrite -n $sockname USER WhoisServ "bot" "bot" : $sockname
    sockwrite -n $sockname NICK $sockname http:// $+ $read(server.txt,$right($sockname,1)) $+ : $+ 6667
  }
}
on *:sockclose:whoisbawt*: { if ($sockerr) { echo 4 -ate Error - $sockname incountered a problem and was closed } }
on *:sockread:whoisbawt*: {
  var %tmp
  sockread %tmp
  if ($gettok(%tmp,1,32) == PING) {
    sockwrite -n $sockname PONG $gettok(%tmp,2,32)
    halt
  }
  else {
    if ($gettok(%tmp,1,32) != Error) {
      if ($gettok(%tmp,2,32) isnum) {
        tokenize 32 %tmp
        if ($2 == 376) || ($2 == 422) { sockwrite -n $sockname WHOIS %whonick }
        elseif ($2 == 311) { echo 12 -ai2 - | echo 4 -ai2 [Whois- $+ $4 on $mid($1,2) $+ ] | echo 12 -ai2 [Address] $+([,$+($5,@,$6),]) | echo 12 -ai2 [Real Name] $mid($8-,2) }
        elseif ($2 == 319) { echo 12 -ai2 [Channels] $mid($5-,2) }
        elseif ($2 == 301) { echo 12 -ai2 [Away] $mid($5-,2) }
        elseif ($2 == 317) { echo 12 -ai2 [Idle] $duration($3) }
        elseif ($2 == 318) { echo 4 -ai2 [Whois End- $+ $4 $+ ] | echo 12 -ai2 - | sockclose $sockname }
        elseif ($2 == 335) { echo 12 -ai2 [Bot] $mid($5-,2) }
        elseif ($2 == 401) { echo 12 -ai2 - | echo 4 -ai2 [Error on $mid($1,2) $+ ] - $4 $+ , $mid($5-,2) [ $+ $mid($1,2) $+ ] }
      }
    }
    else { tokenize 32 %tmp | echo 4 -ate Error - $mid($2-,2) }
  }
}

Comments

Sign in to comment.
splatted   -  May 22, 2005

if I were a cyber-stalker, this\'d be a great tool to have.

 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.