author:tye
www.mirc.net
alias showclones {
if ($hget(clones)) hfree clones
hmake clones 10
var %x = $nick($1,0)
while (%x) {
var %addr = $address($nick($1,%x),2)
var %g = $clones(%addr,$1)
var %n = $gettok(%g,2-,32), %g = $gettok(%g,1,32)
if (%n) && (!$hget(clones,%addr)) && (!$is_clone_prot($address($nick($1,%x),5))) {
if ($2 = -k) && (%g > $thresh($chan)) && (!$is_clone_prot($address($nick($1,%x),5))) {
var %xx = $ialchan(%addr,$1,0)
while (%xx) {
if ($ialchan(%addr,$1,%xx).nick isreg $1) { kick $chan $ifmatch Clones from %addr }
dec %xx
}
}
hinc clones %addr
}
dec %x
}
hfree clones
}
alias clones {
var %x = $ialchan($1,$2,0)
if (%x = 1) { return 1 }
if (%x > 80) { return %x Too many to list }
var %r
while (%x) {
%r = %r $ialchan($1,$2,%x).nick
dec %x
}
return $ialchan($1,$2,0) %r
}
menu channel {
Clone Utilities
.Show clones in $chan:showclones #
.Kick/Ban current clones:if ($input(Are you sure you want to kick/ban all clones in $chan $+ ?,y)) { showclones # -k }
.$iif($($+(%,clones.join),2),$style(1)) Show clones on join:if ($($+(%,clones.join),2)) { set $+(%,clones.join) 0 } | else { set $+(%,clones.join) 1 }
.-
.$iif($($+(%,clones.kick.,$chan),2),$style(1)) Kick/Ban clones on join:if ($($+(%,clones.kick.,$chan),2)) { set $+(%,clones.kick.,$chan) 0 } | else { set $+(%,clones.kick.,$chan) 1 }
.Clone threshold - $thresh($chan).1:set $+(%,clones.th.,$chan) $input(Enter how many clones a site is allowed in the channel [0 means only 1 user/host $+ $chr(44) 1 means 2 users/host]:,e)
}
menu nicklist {
$iif(!$is_clone_prot($address($$1,5)),Clone Utilities)
.Protect User
..$submenu($getmasks($1))
$iif($is_clone_prot($address($$1,5)),Clone Utilities)
.Unprotect $is_clone_prot($address($$1,5)).addr:ruser $is_clone_prot($address($$1,5)).addr
}
alias -l getmasks {
if ($1 > 19) { return }
return $1 $address($snick($active,1),$1) $+ :auser cloneprotect $address($snick($active,1),$1)
}
alias is_clone_prot {
var %x = $ulist(*,cloneprotect,0)
while (%x) {
var %a = $ulist(*,cloneprotect,%x)
if (%a iswm $1) { return $iif($prop = addr,%a,$true) }
dec %x
}
return $false
}
ON *:JOIN:#: {
var %n = $clones($wildsite,$chan)
if ($($+(%,clones.join),2)) && (!$is_clone_prot($fulladdress)) {
if ($gettok(%n,2-,32)) {
echo -tc info2 $chan * $gettok(%n,1,32) clones from $wildsite $+ : $gettok(%n,2-,32)
}
}
if ($me isop $chan) && ($gettok(%n,1,32) > $thresh($chan)) && ($($+(%,clones.kick.,$chan),2)) && (!$is_clone_prot($fulladdress)) {
if (!$($+(%,clonekicking,$cid,$chan,$wildsite),2)) {
set -u10 $+(%,clonekicking,$cid,$chan,$wildsite) 1
}
var %x = $ialchan($wildsite,$chan,0)
while (%x) {
if ($ialchan($wildsite,$chan,%x).nick isreg $chan) && (!$($+(%,clonekicking,$cid,$chan,$ifmatch),2)) {
var %nick = $ialchan($wildsite,$chan,%x).nick
$kick.limit
set -u10 $+(%,clonekicking,$cid,$chan,%nick) 1
}
dec %x
}
}
}
alias -l thresh {
if ($gettok($($+(%,clones.th.,$1),2),1,32) != $null) { return $calc($ifmatch + 1 - $prop) }
return $calc(1 - $prop)
}
alias -l kick.limit {
.hinc -u15m dy dx
if ($hget(dy,dx) < 22) !kick # $nick clones from $wildsite
}