All pastes #177971 Raw Edit

Stuff

public text v1 · immutable
#177971 ·published 2006-09-20 21:27 UTC
rendered paste body
/*
**
** /findu by hixxy (hixxy@mirc.net) for mIRC 6.16 or above.
**
**
** What the script does
** ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
**
** This script will let you search multiple servers at a time for a nickname. This means you can find out if someone is online before you connect.
** It also has an option to /whois the user and find out the channels they're in (providing they're not set +i).
** The script will notify you of failure, success, if you're autokilled and if there's a problem connecting.
**
** How to load
** ¯¯¯¯¯¯¯¯¯¯¯
**
** You can load this script by typing /load -rs <path to findu.mrc>
** If you saved the file in your mIRC directory you can just do /load -rs findu.mrc
** You can also just copy/paste it into remote from a website and then hit the OK button.
**
** How to use
** ¯¯¯¯¯¯¯¯¯¯
**
** The syntax is /findu [-w] <nick1[,nick2,nick3,etc]> <network> [network2 network3 network4 etc..] [port]
**
** If you specify the -w switch the script will /whois the nicks after finding them so it can tell you the channels they're in.
** <nick1[,nick2,nick3,etc]> = a list of nicks you want to find, separated by commas.
** <network> = the first network to check if they're on.
** [network2 network3 network4 etc..] = any other networks you want to check if they're on.
** If you specify the port parameter the script will use that port to connect to each network. Otherwise it defaults to 6667.
**
** Examples
** ¯¯¯¯¯¯¯¯
**
** /findu -w hixxy irc.freenode.net irc.austnet.org irc.coders-net.eu kernel.dal.net irc.dynastynet.net 6667
** /findu -w hixxy,hixxytest,mark,matt,eric irc.freenode.net irc.shadowfire.org
**
** Contact
** ¯¯¯¯¯¯¯
**
** If you have a feature suggestion, bug report or question, please send an email to hixxy@mirc.net
** If you got the script from a scripting website and I (hixxy) submitted the code, you may also leave feedback on the script's comment page.
**
*/

alias -l raisemessage {
  if (!$line($active,0)) { linesep -a }
  echo $colour(info) -a $+ $iif($1 != -e,q $1-,$chr(32) $2-)
  if ($show) || ($1 == -e) { linesep -a }
  if ($1 == -e) { halt }
}

alias -l nmr_ison { return 303 }
alias -l nmr_whoisend { return 318 }
alias -l nmr_whoischannels { return 319 }
alias -l nmr_motdend { return 376 }
alias -l nmr_autokilled { return 465 }

alias findu {
  if ($isid) { raisemessage -e * /findu: Should be called as a command }
  var %port = 6667, %whois = $false
  if ($1 == -w) {
    %whois = $true
    tokenize 32 $2-
  }
  if ($0 < 2) { raisemessage -e * /findu: Insufficient parameters }
  if ($gettok($1-,-1,32) isnum) && ($v1 !isnum 1-65535) { raisemessage -e * /findu: Invalid port }
  elseif ($gettok($1-,-1,32) isnum) { %port = $v1 }
  raisemessage * /findu: Searching...
  var %sock = $+(findu_,$1_,$2)
  if (!$sock(%sock)) {
    sockopen $+(findu_,$1_,$2) $2 %port
    sockmark $+(findu_,$1_,$2) $1 %whois $iif($gettok($2-,-1,32) isnum 1-65535,$deltok($2-,-1,32),$2-)
  }
}

on *:sockopen:findu_*:{
  if ($sockerr) {
    echo $colour(info) -a There was an error connecting to $gettok($sock($sockname).mark,3,32)
    if ($gettok($sock($sockname).mark,4-,32)) {
      var %v1 = $v1
      .findu $iif($gettok($sock($sockname).mark,2,32),-w) $gettok($sock($sockname).mark,1,32) %v1 $sock($sockname).port
    }
    return
  }
  sockwrite -n $sockname NICK findu $+ $ticks
  sockwrite -n $sockname USER findu . . bot
}
on *:sockread:findu_*:{
  var %data, %nick = $gettok($sock($sockname).mark,1,32), %tnick, %whois = $gettok($sock($sockname).mark,2,32)
  sockread %data
  tokenize 32 %data
  if ($1 == PING) { sockwrite -n $sockname PONG $2- }
  elseif ($2 == $nmr_ison) {
    if ($4- != :) {
      var %i = 1
      while ($gettok($mid($4,2),%i,32)) {
        %tnick = $v1
        echo $colour(info) -a Found $v1 on $gettok($sock($sockname).mark,3,32)
        if (%whois) { sockwrite -n $sockname WHOIS %tnick }
        inc %i
      }
      %i = 1
      while ($gettok(%nick,%i,44)) {
        %tnick = $v1
        if (!$istok($mid($4,2),%tnick,32)) { echo $colour(info) -a Could not find %tnick on $gettok($sock($sockname).mark,3,32) }
        inc %i
      }
      if (!%whois) && ($gettok($sock($sockname).mark,4-,32)) {
        var %v1 = $v1
        .findu $iif(%whois,-w) %nick %v1 $sock($sockname).port
        sockclose $sockname
      }
    }
    else {
      var %i = 1
      while ($gettok(%nick,%i,44)) {
        echo $colour(info) -a Could not find $v1 on $gettok($sock($sockname).mark,3,32)
        inc %i
      }
      if ($gettok($sock($sockname).mark,4-,32)) {
        var %v1 = $v1
        .findu $iif(%whois,-w) %nick %v1 $sock($sockname).port
      }
      sockclose $sockname
    }
  }
  elseif ($2 == $nmr_whoisend) {
    if ($gettok($sock($sockname).mark,4-,32)) {
      var %v1 = $v1
      .findu $iif(%whois,-w) %nick %v1 $sock($sockname).port
    }
    sockclose $sockname
  }
  elseif ($2 == $nmr_whoischannels) {
    echo $colour(info) -a $4 in channels $+(',$mid($5-,2),') on $gettok($sock($sockname).mark,3,32)
    if ($gettok($sock($sockname).mark,4-,32)) {
      var %v1 = $v1
      .findu $iif(%whois,-w) %nick %v1 $sock($sockname).port
    }
    sockclose $sockname
  }
  elseif ($2 == $nmr_motdend) { sockwrite -n $sockname ISON $replace(%nick,$chr(44),$chr(32)) }
  elseif ($2 == $nmr_autokilled) {
    echo $colour(info) -a You were autokilled on $gettok($sock($sockname).mark,3,32)
    if ($gettok($sock($sockname).mark,4-,32)) {
      var %v1 = $v1
      .findu $iif(%whois,-w) %nick %v1 $sock($sockname).port
    }
    sockclose $sockname
  }
}