;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NAMESEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;info: ; ; by wiebe @ QuakeNet ; version 1.0 (written and tested on mIRC 6.14) ; ; ; last edit: Sat Mar 27 2004 ; ; ;What does this script do? ; ; requests the names list for a channel and sends the replies from the server to an alias ; ; ;How to use this script? ; ; /namesexec [-dp] [params] ; ; the -d switch can be used to request the names list of hidden users (chanmode D/d on asuka/bircd) ; the -p switch (passive) makes the script respond when it gets the names list, but wont request it ; ; WARNING: DO NOT USE HALT IN AN ALIAS, USE RETURN! ; halt also halts the calling alias/event, return only stops the current alias ; and gives control back to the calling alias/event ; using halt in alias'es that are called from this script can cause it not to work 100% ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS NAMESEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; /namesexec [params..] alias namesexec { ; on irc if ($status == connected) { ; set var var %p = 1, %d ; switch is used and $3 is there if ($left($1,1) == -) && ($3) { ; -d is there if (d isin $1) { ; set var var %d = -d } ; -p switch is there if (p isin $1) { ; set var var %p = 0 } ; tokenize tokenize 32 $2- } ; $2 is there, $1 is a channel if ($2) && ($left($1,1) isin $chantypes) { ; add to hash table hadd -m $+(namesexec.,$cid) $namesexec.lower($1) $1 $2- ; check p switch if (%p == 1) { ; request names .quote names %d $1 } } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 353 NAMES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 353 me =|*|@ channel :nicks raw 353:& & & *: { ; check hash table if ($hget($+(namesexec.,$cid),$namesexec.lower($3))) { ; set var var %t = $hget($+(namesexec.,$cid),$namesexec.lower($3)) ; send info to alias $gettok(%t,2-,32) 353 $gettok(%t,1,32) $4- ; stop raw haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 355 NAMES HIDDEN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 355 me =|*|@ channel :nicks raw 355:& & & *: { ; check hash table if ($hget($+(namesexec.,$cid),$namesexec.lower($3))) { ; set var var %t = $hget($+(namesexec.,$cid),$namesexec.lower($3)) ; send info to hash table $gettok(%t,2-,32) 355 $gettok(%t,1,32) $4- ; stop raw haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 366 NAMES END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 366 me channel :End of /NAMES list. raw 366:& & End of /NAMES list*: { ; check hash table if ($hget($+(namesexec.,$cid),$namesexec.lower($2))) { ; set var var %t = $hget($+(namesexec.,$cid),$namesexec.lower($2)) ; send info to hash table $gettok(%t,2-,32) 366 $gettok(%t,1,32) End of /NAMES list ; remove from hash table hdel $+(namesexec.,$cid) $namesexec.lower($2) ; check hash table if ($hget($+(namesexec.,$cid),0).item == 0) { ; free hash table hfree $+(namesexec.,$cid) } ; stop raw haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS NAMESEXEC.LOWER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $namesexec.lower(chan) alias -l namesexec.lower { ; on IRC these chars are upper(lower) case of eachother: { = [, } = ], | = \, ~ = ^ ; so here we replace them to make sure we compare the right things right return $replace($1,$chr(123),$chr(91),$chr(125),$chr(93),$chr(124),$chr(92),$chr(126),$chr(94)) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:disconnect:{ ; free hash table hfree -w $+(namesexec.,$cid) } ; EXAMPLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JOIN EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:join:#:{ if ($nick == $me) { namesexec -p $chan userinfo } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS USERINFO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l userinfo { if ($1 == 366) && ($me ison $2) { var %x = 1 var %y = total $nick($2,0) (100%) while (%x <= $len($prefix)) { var %p = $mid($prefix,%x,1) var %e = $remove($prefix $+ r,$mid($prefix,%x,1)) var %y = %y -- %p $nick($2,0,%p,%e) ( $+ $round($calc($nick($2,0,%p,%e) / $nick($2,0) * 100),1) $+ $chr(37) $+ ) inc %x } var %y = %y ---- regulars $nick($2,0,r) ( $+ $round($calc($nick($2,0,r) / $nick($2,0) * 100),1) $+ $chr(37) $+ ) echo -t $2 * Names -- %y } }