Unbannick

From Scriptwiki
Revision as of 16:30, 29 March 2006 by Doomie (talk | contribs) (first try, needs testing + comments + perhaps nicer text..)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This script provides an alias to unban a "nick" (respectivly his address) even if this user isn't on the channel. Therefor, it uses the /who command to get the current address of a nickname.

The syntax is: /unbannick <channel> <nickname>

Additionally, it will drop the one unbanning this nick a message and the one that got unbanned a notice. The part about uhexec will be without further comments.

; on disconnect we clear the hashtable uhexec has used.
on *:DISCONNECT:hdel -w uhexec $cid $+ .*
alias -l uhq return $iif($hget(uhexec,$+($cid,.,$1)),$v1,$iif($1 !isnum,0))
alias -l uhnext {
 $iif($0 > 1,hadd -m,hdel) uhexec $+($cid,.,$uhq($1) $2-)
 hadd uhexec $+($cid,.,$1) $iif($uhq($1) < 64,$calc($v1 + 1),0)
}
alias -l uhexec {
 if ($status == connected) || ($ial($1).addr != $null) {
   uhnext head $1-
   userhost $1
 }
 else $2- $ial($1).addr
}
raw $302:/^\S+( (\S+?)\*?=[+-](\S+)|) ?$/:{
 tokenize 32 $uhq($uhq(tail))
 if ($0) && (($regml(0) < 2) || ($1 == $regml(2))) {
   uhnext tail
   $2- $regml(3)
   halt
 }
}
alias -l uncb {
 ; <chan> <nick> [host]
 if ($3 == $null) return
 var %i = 1, %b, %a = $+($2,!,$3)
 while ($ibl($1,%i) != $null) {
   if ($v1 iswm %a) {
     %b = %b $v1
     if ($numtok(%b,32) == $modespl) {
       mode $1 - $+ $str(b,$numtok(%b,32)) %b
       %b =
     }
   }
   inc %i
 }
 if (%b != $null) mode $1 - $+ $str(b,$numtok(%b,32)) %b
 msg $1 Unbanned $2 upon request
 notice $2 You're now unbanned on $1
}
; actually provide the alias (Syntax: /unbannick <chan> <nick>)
alias unbannick uhexec $2 uncb $1-2