;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTOLIMIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;info: ; ; by wiebe @ QuakeNet ; version 2.0 (written and tested on mIRC 6.15) ; ; ; last edit: Fri Jul 02 2004 ; ; ;What does this script do? ; ; auto sets a channel limit, helps to stop flood joins ; ; - supports hidden users (chanmode D/d) on asuka (quakenet's ircd based on ircu) and beware ircd (bircd) ; this way a limit will be set based on the total number of users in the channel ; hidden users are counted using 'names -d' or 'list' command ; ; ;How to use this script? ; ; general help ; ;   /autolimit -a [delay] [buffer] [overhead] [underhead] [minimum] [maximum] [hidden] [status] ;       to add a channel with the given parameters ; ;   /autolimit -ah ;       to show help for /autolimit -a ; ;   /autolimit -r ;       to remove a channel ; ;   /autolimit -d ;       to disable a channel ; ;   /autolimit -e ;       to enable a channel ; ;   /autolimit -l [network] ;       to list channels for all networks or for a specific network ; ;   /autolimit -s ;       to change a setting ; ;   /autolimit -sl ;       to list current settings ; ;   /autolimit -sh ;       to show help for /autolimit -s ; ;   /autolimit -i ;       to list active channels ; ;   /autolimit reload ;       to reload settings from the ini (only needed when the file was manually changed) ; ;   /autolimit -h ;       to show help ; ; ; help for adding ; ;   usage: /autolimit -a [delay] [buffer] [overhead] [underhead] [minimum] [maximum] [hidden] [status] ; ;   ;       network and channel to add ;       use servername when no NETWORK= token is present (no $network) ;       use global for network to add a channel for all networks ;       network specific settings overwrite a global entry ; ;   [delay] ;       delay in seconds between limit checks/changes ; ;   [buffer] ;       limit is changed if current limit is higher than " + " ; ;   [overhead] ;       limit is set to " + - " ;       users can part before a limit change is needed ; ;   [underhead] ;       limit is changed if current limit is lower than " + - - " ;       users can join before a limit change is needed ; ;   [minimum] ;       limit is never set lower ; ;   [maximum] ;       limit is never set higher ; ;   [hidden] ;       setting for hidden users (chanmode D/d) ;       0=off ;       1=use "names -d " to get the hidden users ;       2=use "list " to get the hidden users ; ;   [status] ;       on|off to enable or disable auto limit for the channel ; ;   - or 0 ;       use - or ommit a setting to use default value ;       use 0 to disable a setting ; ; ; help for settings ; ;   delay buffer overhead underhead minimum maximum hidden status ;       default settings, used when adding new channels and a - is used or a setting is ommitted ; ;   target ;       0=echo in @autolimit window ;       1=echo in active window ;       2=echo in Status Window ; ;   color1 color2 ;       colors to use, possible to use an identifier, $color(info) for example ; ;   serverlimit ;       on|off, corrects limit set by server (netsplit remerge) ; ;   script ;       on|off, sets this script on or off ; ; ; other things ; ; info/result is returned with 'return' (handy on bots) ; this means you can use '$autolimit()' or ; '/autolimit ' with $result afterwards ; ; no need to seperate params with a , when calling autolimit as identifier ; like '$autolimit(,,[param3],...)' ; instead '$autolimit()' will also work ; ; . silence prefix ; when .autolimit is used, no output is shown ; ; multiline editbox ; reads multiline editbox setting from mirc's ini when creating the window ; ; @autolimit window ; you can change its name in the settings below (together with some other things) ; double clicking in the window shows the channels where the script is active at the moment ; ; network ; 'network' refers to what $network returns, so for example QuakeNet and not irc.quakenet.org ; if an irc server has no NETWORK= token ($network is $null), use the servername instead (ONLY THEN!) ; 'settings' is reserved for script settings, i doubt any irc server has 'settings' as network name ; network 'global' means it will work on ALL servers, a network/server specific entry overwrites a global entry ; ; pushmode ; script can use 'pushmode' snippet if loaded, else it uses 'quote MODE ' to set a limit ; ; chanmode n ; script auto sets chanmode n (no external messages), setting +l without +n does not make much sense ; ; list ; it is not possible to halt the raws and to stop the 'Channels List' from opening ; when the script uses list the window is closed ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; todo: ; improve /list when a future mIRC version allows halting those raws ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.INI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.ini { ; ini file the script uses to store settings return autolimit.ini } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.WINDOW ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.window { ; window name the script uses (in case of conflicts, change and close window) return @autolimit } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.HASH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.hash { ; hash table the script uses (in case of conflicts, change and restart mirc) return autolimit } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.VERSION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.version { ; script version return 2.0 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias autolimit { tokenize 32 $1- var %window = $iif($hget($autolimit.hash,$+(settings,$chr(160),target)) == 0,$autolimit.window) var %target = $replace($hget($autolimit.hash,$+(settings,$chr(160),target)),0,target0,1,target1,2,target2) var %target = $replace(%target,target0,-mqgi2 $autolimit.window,target1,-amqgi2,target2,-smqgi2) var %cmd = $+($readini($mircini,n,text,commandchar),autolimit) var %color1 = $eval($hget($autolimit.hash,$+(settings,$chr(160),color1)),2) var %color2 = $eval($hget($autolimit.hash,$+(settings,$chr(160),color2)),2) if (!$window(%window)) && (%window) && ($show) { ; window is opened here, changes things here if you want window -xn $+ $iif($gettok($readini($mircini,n,options,n1),8,44),E,e) $autolimit.window font %window 10 Fixedsys titlebar %window autolimit version $autolimit.version - by wiebe @ QuakeNet editbox -p %window %cmd } if (!$editbox(%window)) && (%window) { editbox -p %window %cmd } if ($1- == $null) { echo %color2 %target * Not enough parameters, %cmd -h for help var %result = * Not enough parameters $+ $chr(44) %cmd -h for help } ; list elseif ($1 == -l) { if ($2 == settings) { var %x = 1 echo %color2 %target * List ( $+ $2 $+ ) while ($ini($autolimit.ini,$2,0) != 0) && ($ini($autolimit.ini,$2,%x) != $null) { var %i = $readini($autolimit.ini,n,$2,$ifmatch) echo %color1 %target   $ifmatch = %i inc %x } echo %color2 -i2 * End of list ( $+ $2 $+ ) var %result = * End of list ( $+ $2 $+ ) } elseif ($2) { if ($ini($autolimit.ini,$2,0) == 0) { echo %color2 %target * Nothing to list ( $+ $2 $+ ) var %result = * Nothing to list ( $+ $2 $+ ) } else { var %x = 1 echo %color2 %target * List ( $+ $2 $+ ) echo %color2 %target   Delay Buffer Overhead Underhead Minimum Maximum Hidden Status Channel while ($ini($autolimit.ini,$2,0) != 0) && ($ini($autolimit.ini,$2,%x) != $null) { var %i = $readini($autolimit.ini,n,$2,$ifmatch) var %i = $gettok(%i,1-7,32) $replace($gettok(%i,8,32),0,off,1,names,2,list) $gettok(%i,9,32) echo %color1 %target   $& $gettok(%i,2,32) $+ $str($chr(32) $+ ,$calc(4 - $len($gettok(%i,2,32)) +1)) $& $gettok(%i,3,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,3,32)) +1)) $& $gettok(%i,4,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,4,32)) +3)) $& $gettok(%i,5,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,5,32)) +4)) $& $gettok(%i,6,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,6,32)) +2)) $& $gettok(%i,7,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,7,32)) +2)) $& $gettok(%i,8,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,8,32)) +1)) $& $gettok(%i,9,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,9,32)) +1)) $& $gettok(%i,1,32) inc %x } echo %color2 %target * End of list ( $+ $2 $+ ) var %result = * End of list ( $+ $2 $+ ) } } else { var %y = 1 echo %color2 %target * List echo %color2 %target   Delay Buffer Overhead Underhead Minimum Maximum Hidden Status Channel echo %color2 %target   $ini($autolimit.ini,%y) while ($ini($autolimit.ini,0) != 0) && ($ini($autolimit.ini,%y) != $null) { var %x = 1, %s = $ifmatch if (%s != settings) && ($ini($autolimit.ini,%s,0) != 0) { while ($ini($autolimit.ini,%s,0) != 0) && ($ini($autolimit.ini,%s,%x) != $null) { var %i = $readini($autolimit.ini,n,%s,$ifmatch) var %i = $gettok(%i,1-7,32) $replace($gettok(%i,8,32),0,off,1,names,2,list) $gettok(%i,9,32) echo %color1 %target   $& $gettok(%i,2,32) $+ $str($chr(32) $+ ,$calc(4 - $len($gettok(%i,2,32)) +1)) $& $gettok(%i,3,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,3,32)) +1)) $& $gettok(%i,4,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,4,32)) +3)) $& $gettok(%i,5,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,5,32)) +4)) $& $gettok(%i,6,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,6,32)) +2)) $& $gettok(%i,7,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,7,32)) +2)) $& $gettok(%i,8,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,8,32)) +1)) $& $gettok(%i,9,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,9,32)) +1)) $& $gettok(%i,1,32) inc %x } } inc %y if ($ini($autolimit.ini,%y) != $null) && ($ifmatch != settings) { echo %color1 %target   echo %color2 %target   $ifmatch } } echo %color2 %target * End of list var %result = * End of list } } ; help elseif ($1 == -h) { echo %color2 %target * Help echo %target   %cmd -a [delay] [buffer] [overhead] [underhead] [minimum] [maximum] [hidden] [status] echo %target       to add a channel with the given parameters echo %target   %cmd -ah echo %target       to show help for %cmd -a echo %target   %cmd -r echo %target       to remove a channel echo %target   %cmd -d echo %target       to disable a channel echo %target   %cmd -e echo %target       to enable a channel echo %target   %cmd -l [network] echo %target       to list channels for all networks or for a specific network echo %target   %cmd -s echo %target       to change a setting echo %target   %cmd -sl echo %target       to list current settings echo %target   %cmd -sh echo %target       to show help for %cmd -s echo %target   %cmd -i echo %target       to list active channels echo %target   %cmd reload echo %target       to reload settings from the ini file (only needed when the file was manually changed) echo %target   %cmd -h echo %target       to show this help echo %color2 %target * End of help var %result = * End of help } ; add help elseif ($1 == -ha) || ($1 == -ah) { echo %color2 %target * Help echo %target   usage: %cmd -a [delay] [buffer] [overhead] [underhead] [minimum] [maximum] [hidden] [status] echo %target   echo %target       network and channel to add echo %target       use servername when no NETWORK= token is present (no $!network) echo %target       use global for network to add a channel for all networks echo %target       network specific settings overwrite a global entry echo %target   [delay] echo %target       delay in seconds between limit checks/changes echo %target   [buffer] echo %target       limit is changed if current limit is higher than " + " echo %target   [overhead] echo %target       limit is set to " + - " echo %target       users can part before a limit change is needed echo %target   [underhead] echo %target       limit is changed if current limit is lower than " + - - " echo %target       users can join before a limit change is needed echo %target   [minimum] echo %target       limit is never set lower echo %target   [maximum] echo %target       limit is never set higher echo %target   [hidden] echo %target       setting for hidden users (chanmode D/d) echo %target       0=off echo %target       1=use "names -d " to get the hidden users echo %target       2=use "list " to get the hidden users echo %target   [status] echo %target       on|off to enable or disable auto limit for the channel echo %target   - or 0 echo %target       use - or ommit a setting to use default value echo %target       use 0 to disable a setting echo %color2 %target * End of help var %result = * End of help } ; help settings elseif ($1 == -sh) || ($1 == -hs) { echo %color2 %target * Help echo %target   delay buffer overhead underhead minimum maximum hidden status echo %target       default settings, used when adding new channels and a - is used or a setting is ommitted echo %target   target echo %target       0=echo in @autolimit window echo %target       1=echo in active window echo %target       2=echo in Status Window echo %target   color1 color2 echo %target       colors to use 0-15 echo %target       possible to use an identifier, $!color(info) for example echo %target   serverlimit echo %target       on|off, corrects limit set by server (netsplit remerge) echo %target   script echo %target       on|off, sets this script on or off echo %color2 %target * End of help var %result = * End of help } ; add elseif ($1 == -a) { ; network channel if ($2 == $null) || ($3 == $null) { echo %color2 %target * Not enough parameters, %cmd -ha for help var %result = * Not enough parameters $+ $chr(44) %cmd -ha for help } ; settings elseif ($2 == settings) { echo %color2 %target * Topic 'settings' is reserved var %result = * Topic 'settings' is reserved } ; control codes elseif ($strip($2-3) != $2-3) { echo %color2 %target * Error, control codes can not be used var %result = * Error $+ $chr(44) control codes can not be used } ; delay elseif ($4 !isnum 0-9999) && ($4 != -) && ($4 != $null) { echo %color2 %target * Invalid value for delay, valid value 0-9999, for default setting use - or ommit var %result = * Invalid value for delay $+ $chr(44) valid value 0-9999, for default setting use - or ommit } ; buffer elseif ($5 !isnum 0-99999) && ($5 != -) && ($5 != $null) { echo %color2 %target * Invalid value for buffer, valid value 0-99999, for default setting use - or ommit var %result = * Invalid value for buffer $+ $chr(44) valid value 0-99999, for default setting use - or ommit } ; overhead elseif ($6 !isnum 0-99999) && ($6 != -) && ($6 != $null) { echo %color2 %target * Invalid value for overhead, valid value 0-99999, for default setting use - or ommit var %result = * Invalid value for overhead $+ $chr(44) valid value 0-99999, for default setting use - or ommit } ; underhead elseif ($7 !isnum 0-99999) && ($7 != -) && ($7 != $null) { echo %color2 %target * Invalid value for underhead, valid value 0-99999, for default setting use - or ommit var %result = * Invalid value for underhead $+ $chr(44) valid value 0-99999, for default setting use - or ommit } ; minimum elseif ($8 !isnum 0-99999) && ($8 != -) && ($8 != $null) { echo %color2 %target * Invalid value for minimum, valid value 0-99999, for default setting use - or ommit var %result = * Invalid value for minimum $+ $chr(44) valid value 0-99999, for default setting use - or ommit } ; maximum elseif ($9 !isnum 0-99999) && ($9 != -) && ($9 != $null) { echo %color2 %target * Invalid value for maximum, valid value 0-99999, for default setting use - or ommit var %result = * Invalid value for maximum $+ $chr(44) valid value 0-99999, for default setting use - or ommit } ; hidden elseif ($10 !isnum 0-2) && ($10 != -) && ($10 != $null) { echo %color2 %target * Invalid value for hidden, valid values are: 0=off, 1=names, 2=list, for default setting use - or ommit var %result = * Invalid value for hidden $+ $chr(44) valid values are: 0=off, 1=names, 2=list, for default setting use - or ommit } ; status elseif (!$istok(on off -,$11,32)) && ($11 != $null) { echo %color2 %target * Invalid value for status, valid values are on and off, for default setting use - or ommit var %result = * Invalid value for status $+ $chr(44) valid values are on and off, for default setting use - or ommit } ; add else { if (!$hget($autolimit.hash)) { autolimit.load } ; delay if ($4 == -) || ($4 == $null) { tokenize 32 $1-3 $hget($autolimit.hash,$+(settings,$chr(160),delay)) $5- } ; buffer if ($5 == -) || ($5 == $null) { tokenize 32 $1-4 $hget($autolimit.hash,$+(settings,$chr(160),buffer)) $6- } ; overhead if ($6 == -) || ($6 == $null) { tokenize 32 $1-5 $hget($autolimit.hash,$+(settings,$chr(160),overhead)) $7- } ; underhead if ($7 == -) || ($7 == $null) { tokenize 32 $1-6 $hget($autolimit.hash,$+(settings,$chr(160),underhead)) $8- } ; minimum if ($8 == -) || ($8 == $null) { tokenize 32 $1-7 $hget($autolimit.hash,$+(settings,$chr(160),minimum)) $9- } ; maximum if ($9 == -) || ($9 == $null) { tokenize 32 $1-8 $hget($autolimit.hash,$+(settings,$chr(160),maximum)) $10- } ; hidden if ($10 == -) || ($10 == $null) { tokenize 32 $1-9 $hget($autolimit.hash,$+(settings,$chr(160),hidden)) $11- } ; status if ($11 == -) || ($11 == $null) { tokenize 32 $1-10 $hget($autolimit.hash,$+(settings,$chr(160),status)) } if ($autolimit.add($2-11) == 2) { echo %color2 %target * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 var %result = * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 } else { echo %color2 %target * Added network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 var %result = * Added network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 } autolimit.load scon -am1 autolimit.find $2-3 start } } ; remove elseif ($1 == -r) { if ($2 == $null) || ($3 == $null) { echo %color2 %target * Not enough parameters, usage: %cmd $1 var %result = * Not enough parameters $+ $chr(44) usage: %cmd $1 } elseif ($autolimit.remove($2,$3) == 1) { scon -am1 autolimit.find $2-3 stop echo %color2 %target * Removed $3 ( $+ $2 $+ ) from autolimit list var %result = * Removed $3 ( $+ $2 $+ ) from autolimit list autolimit.load } else { echo %color2 %target * $3 ( $+ $2 $+ ) not in autolimit list var %result = * $3 ( $+ $2 $+ ) not in autolimit list } } ; list settings elseif ($1 == -ls) || ($1 == -sl) { echo %color2 %target * List (settings) var %x = 1 while ($ini($autolimit.ini,settings,0) != 0) && ($ini($autolimit.ini,settings,%x) != $null) { echo %color1 %target   $ifmatch = $readini($autolimit.ini,n,settings,$ifmatch) inc %x } echo %color2 %target * End of list (settings) var %result = * End of list (settings) } ; settings elseif ($1 == -s) { if ($2 == delay) && ($3 isnum 0-9999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 seconds var %result = * Updated setting $2 to $3 seconds } elseif ($2 == buffer) && ($3 isnum 0-99999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == overhead) && ($3 isnum 0-99999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == underhead) && ($3 isnum 0-99999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == minimum) && ($3 isnum 0-99999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == maximum) && ($3 isnum 0-99999) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == hidden) && ($3 isnum 0-2) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 ( $+ $replace($3,0,disabled,1,names,2,list) $+ ) var %result = * Updated setting $2 to $3 ( $+ $replace($3,0,disabled,1,names,2,list) $+ ) } elseif ($2 == status) && ($istok(on off,$3,32)) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == target) && ($3 isnum 0-2) { writeini $autolimit.ini settings $2-3 autolimit.load var %target = $replacex($hget($autolimit.hash,$+(settings,$chr(160),target)),0,-i2 %window,1,-ai2,2,-si2) echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == color1) && ($eval($3,2) isnum 0-15) { writeini $autolimit.ini settings $2-3 autolimit.load var %color1 = $eval($hget($autolimit.hash,$+(settings,$chr(160),color1)),2) echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == color2) && ($eval($3,2) isnum 0-15) { writeini $autolimit.ini settings $2-3 autolimit.load var %color1 = $eval($hget($autolimit.hash,$+(settings,$chr(160),color1)),2) echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == serverlimit) && ($istok(on off,$3,32)) { writeini $autolimit.ini settings $2-3 autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 } elseif ($2 == script) && ($istok(on off,$3,32)) { writeini $autolimit.ini settings $2-3 var %old = $hget($autolimit.hash,$+(settings,$chr(160),$2)) autolimit.load echo %color1 %target * Updated setting $2 to $3 var %result = * Updated setting $2 to $3 if (%old != $3) { scon -am1 autolimit.all $iif($3 == off,stop,start) echo %color2 %target * $iif($3 == off,Stoping,Starting) all var %result = * $iif($3 == off,Stoping,Starting) all } } elseif ($2 == $null) { echo %color2 %target * Not enough parameters, usage: %cmd $1 var %result = * Not enough parameters $+ $chr(44) usage: %cmd $1 } elseif (!$istok(delay buffer overhead underhead minimum maximum hidden status target color1 color2 serverlimit script,$2,32)) || ($3 == $null) { echo %color2 %target * Invalid setting, valid settings are: delay buffer overhead underhead minimum maximum hidden status target color1 color2 serverlimit script var %result = * Invalid setting $+ $chr(44) valid settings are: delay buffer overhead underhead minimum maximum hidden status target color1 color2 serverlimit script } else { echo %color2 %target * Invalid value for $2 var %result = * Invalid value for $2 } } ; disable elseif ($1 == -d) { if ($2 == $null) || ($3 == $null) { echo %color2 %target * Not enough parameters, usage: %cmd $1 var %result = * Not enough parameters $+ $chr(44) usage: %cmd $1 } elseif ($hget($autolimit.hash,$autolimit.lower($+($2,$chr(160),$3)))) { tokenize 32 $1-3 $gettok($ifmatch,1-7,32) off scon -am1 autolimit.find $2-3 stop autolimit.add $2- echo %color2 %target * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 var %result = * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 } else { echo %color2 %target * $3 ( $+ $2 $+ ) not in autolimit list var %result = * $3 ( $+ $2 $+ ) not in autolimit list } } ; enable elseif ($1 == -e) { if ($2 == $null) || ($3 == $null) { echo %color2 %target * Not enough parameters, usage: %cmd $1 var %result = * Not enough parameters $+ $chr(44) usage: %cmd $1 } elseif ($hget($autolimit.hash,$autolimit.lower($+($2,$chr(160),$3)))) { tokenize 32 $1-3 $gettok($ifmatch,1-7,32) on scon -am1 autolimit.find $2-3 start autolimit.add $2- echo %color2 %target * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 var %result = * Updated switches network= $+ $2 channel= $+ $3 delay= $+ $4 buffer= $+ $5 overhead= $+ $6 underhead= $+ $7 minimum= $+ $8 maximum= $+ $9 hidden= $+ $10 status= $+ $11 } else { echo %color2 %target * $3 ( $+ $2 $+ ) not in autolimit list var %result = * $3 ( $+ $2 $+ ) not in autolimit list } } ; reload elseif ($1 == reload) { autolimit.load echo %color2 %target * Settings reloaded from $nopath($autolimit.ini) var %result = * Settings reloaded from $nopath($autolimit.ini) } ; info elseif ($1 == -i) { var %x = 1 echo %color2 %target * Listing running timers echo %color2 %target   Delay Buffer Overhead Underhead Minimum Maximum Hidden Status Channel Network while ($timer(%x) != $null) { var %timer = $ifmatch if ($+($scid($gettok(%timer,1,46)),.,$gettok(%timer,2,46),.,$hash($autolimit.lower($gettok($timer(%timer).com,2,32)),32)) == %timer) { var %i = $gettok($timer(%timer).com,2,32) $timer(%timer).delay $gettok($timer(%timer).com,3-,32) var %i = $gettok(%i,1-7,32) $replace($gettok(%i,8,32),0,off,1,names,2,list) $gettok(%i,9,32) echo %color1 %target   $& $gettok(%i,2,32) $+ $str($chr(32) $+ ,$calc(4 - $len($gettok(%i,2,32)) +1)) $& $gettok(%i,3,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,3,32)) +1)) $& $gettok(%i,4,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,4,32)) +3)) $& $gettok(%i,5,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,5,32)) +4)) $& $gettok(%i,6,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,6,32)) +2)) $& $gettok(%i,7,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,7,32)) +2)) $& $gettok(%i,8,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,8,32)) +1)) $& $gettok(%i,9,32) $+ $str($chr(32) $+ ,$calc(5 - $len($gettok(%i,9,32)) +1)) $& $gettok(%i,1,32) ( $+ $iif($scid($timer(%timer).cid).network,$ifmatch,$scid($timer(%timer).cid).server) $+ ) } inc %x } echo %color2 %target * End of list var %result = * End of list } else { echo %color2 %target * Unknown option, see %cmd -h for help var %result = * Unknown option $+ $chr(44) see %cmd -h for help } return %result } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.LIMIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = users (+hidden) $2 = limit $3 = buffer $4 = overhead $5 = underhead $6 = minimum $7 = maximum alias -l autolimit.limit { var %users = $1, %limit = $2, %buffer = $3, %overhead = $4, %underhead = $5 if (%buffer <= 0) { return } if (%overhead >= %buffer) { var %overhead = 0 } if (%underhead >= %underhead) { var %underhead = 0 } if ($calc(%buffer - %overhead - %underhead) <= 0) { var %overhead = 0, %underhead = 0 } var %minimum = $6, %maximum = $7 if (%maximum < %minimum) { var %maximum = 0 } var %newlimit = $calc(%users + %buffer - %overhead), %upper = $calc(%users + %buffer) var %lower = $calc(%newlimit - %overhead - %underhead) if (%newlimit < %minimum) { return %minimum } if (%newlimit > %maximum) && (0 < %maximum) { return %maximum } if (%limit !isnum %lower $+ - $+ %upper) { return %newlimit } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JOIN EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on me:*:join:#:{ autolimit.start $chan } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PART EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on me:*:part:#:{ autolimit.stop $chan } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KICK EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:kick:#:{ if ($knick == $me) { autolimit.stop $chan } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.LOWER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.lower { ; these chars are upper(lower) case of eachother: { = [, } = ], | = \, ~ = ^ (rfc1459) ; so here we replace them to make sure we compare the right things right return $lower($replace($1-,$chr(123),$chr(91),$chr(125),$chr(93),$chr(124),$chr(92),$chr(126),$chr(94))) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; START EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:start:{ if ($readini($autolimit.ini,n,settings,delay) == $null) { writeini $autolimit.ini settings delay 180 } if ($readini($autolimit.ini,n,settings,buffer) == $null) { writeini $autolimit.ini settings buffer 8 } if ($readini($autolimit.ini,n,settings,overhead) == $null) { writeini $autolimit.ini settings overhead 2 } if ($readini($autolimit.ini,n,settings,underhead) == $null) { writeini $autolimit.ini settings underhead 2 } if ($readini($autolimit.ini,n,settings,minimum) == $null) { writeini $autolimit.ini settings minimum 15 } if ($readini($autolimit.ini,n,settings,maxmimum) == $null) { writeini $autolimit.ini settings maximum 0 } if ($readini($autolimit.ini,n,settings,hidden) == $null) { writeini $autolimit.ini settings hidden 0 } if ($readini($autolimit.ini,n,settings,status) == $null) { writeini $autolimit.ini settings status on } if ($readini($autolimit.ini,n,settings,target) == $null) { writeini $autolimit.ini settings target 0 } if ($readini($autolimit.ini,n,settings,color1) == $null) { writeini $autolimit.ini settings color1 $!color(info) } if ($readini($autolimit.ini,n,settings,color2) == $null) { writeini $autolimit.ini settings color2 $!color(info2) } if ($readini($autolimit.ini,n,settings,serverlimit) == $null) { writeini $autolimit.ini settings serverlimit off } if ($readini($autolimit.ini,n,settings,script) == $null) { writeini $autolimit.ini settings script on } autolimit.load autolimit.all start } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.LOAD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.load { if ($hget($autolimit.hash)) { hfree $autolimit.hash } var %s = 1 while ($ini($autolimit.ini,0) != 0) && ($ini($autolimit.ini,%s) != $null) { var %section = $ifmatch, %i = 1 while ($ini($autolimit.ini,%s,0) != 0) && ($ini($autolimit.ini,%s,%i) != $null) { var %item = $ifmatch, %value = $readini($autolimit.ini,n,%section,%item) if (%section != settings) { hadd -m $autolimit.hash $+(%section,$chr(160)) $+ %value } else { hadd -m $autolimit.hash $+(%section,$chr(160),%item) %value } inc %i } inc %s } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.FIND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = network, $2 = channel, $3 = start|stop alias -l autolimit.find { tokenize 32 $autolimit.lower($1-2) $3 if ($1 == $autolimit.lower($network)) || ($1 == $autolimit.lower($server)) || ($1 == global) { var %x = $comchan($me,0) while (%x) { if ($2 == $autolimit.lower($comchan($me,%x))) { if ($3 == start) { autolimit.start $2 } elseif ($3 == stop) { autolimit.stop $2 } } dec %x } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.START ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = channel alias -l autolimit.start { tokenize 32 $1 $autolimit.lower($1) $autolimit.lower($iif($network,$ifmatch,$server)) if ($me ison $1) && ($hget($autolimit.hash,$+(settings,$chr(160),script)) == on) { if (!$hget($autolimit.hash,$+($3,$chr(160),$2))) && ($hget($autolimit.hash,$+(global,$chr(160),$2))) { tokenize 32 $1-2 $ifmatch if ($10 == on) { .timer $+ $cid $+ .autolimit. $+ $hash($2,32) 0 $3 autolimit.set $1 $4- autolimit.set $1 $4- } } elseif ($hget($autolimit.hash,$+($3,$chr(160),$2))) { tokenize 32 $1-2 $ifmatch if ($10 == on) { .timer $+ $cid $+ .autolimit. $+ $hash($2,32) 0 $3 autolimit.set $1 $4- autolimit.set $1 $4- } } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.STOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.stop { .timer $+ $cid $+ .autolimit. $+ $hash($autolimit.lower($1),32) off } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.SET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = channel alias -l autolimit.set { var %hidden, %mode if ($1 == -d) { var %hidden = $ [ $+ [ $0 ] ] tokenize 32 $2- [ $+ [ $calc($0 -1) ] ] } if ($me isop $1) || ($me ishop $1) { if ($7) && (d isin $gettok($chan($1).mode,1,32)) && (%hidden == $null) { if ($7 == 1) { hadd -m $+($autolimit.hash,.temp.,$cid) $+(setting,$chr(160),$1) $2- autolimit.namesexec $1 autolimit.hidden.1 } elseif ($7 == 2) { hadd -m $+($autolimit.hash,.temp.,$cid) $+(setting,$chr(160),$1) $2- .list $1 } } else { var %users = $calc($nick($1,0) + %hidden) var %l = $autolimit.limit(%users,$iif($chan($1).limit,$ifmatch,0),$2,$3,$4,$5,$6) if (%l) { if ($isalias(pushmode)) { pushmode $1 +l %l } else { var %mode = +l %l } } if (n !isincs $gettok($chan($1).mode,1,32)) { if ($isalias(pushmode)) { pushmode $1 +n } else { var %mode = +n $+ %mode } } } if (%mode) { .quote MODE $1 %mode } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INPUT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:input:$($autolimit.window):{ editbox -p $autolimit.window $+($readini($mircini,n,text,commandchar),autolimit) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.ADD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1- = network chan settings... alias -l autolimit.add { tokenize 32 $1- tokenize 32 $autolimit.lower($1-2) $3- var %x = 1, %y while ($ini($autolimit.ini,$1,0) != 0) && ($ini($autolimit.ini,$1,%x)) { var %y = $addtok(%y,$ifmatch,32), %item = $ifmatch, %value = $readini($autolimit.ini,n,$1,%item) if ($gettok(%value,1,32) == $2) { writeini $autolimit.ini $1 %item $2- return 2 } inc %x } var %x = 1 while ($istok(%y,%x,32)) { inc %x } writeini $autolimit.ini $1 %x $2- return 1 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.REMOVE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1- = network chan alias -l autolimit.remove { tokenize 32 $autolimit.lower($1-2) var %x = 1 while ($ini($autolimit.ini,$1,0) != 0) && ($ini($autolimit.ini,$1,%x)) { var %item = $ifmatch, %value = $readini($autolimit.ini,n,$1,%item) if ($gettok(%value,1,32) == $2) { remini $autolimit.ini $1 %item if ($ini($autolimit.ini,$1,0) == 0) { remini $autolimit.ini $1 } return 1 } inc %x } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SERVERMODE EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:servermode:#:{ if (l isincs $1) && ($chan($chan).limit != $null) && ($hget($autolimit.hash,$+(settings,$chr(160),serverlimit)) == on) { if (($me isop $chan) || ($me ishop $chan)) && ($timer($+($cid,.autolimit.,$hash($autolimit.lower($chan),32))).com) { var %cmd = $ifmatch if (autolimit.set $chan * iswm %cmd) { %cmd } } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.ALL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = start|stop alias -l autolimit.all { if ($1 == start) { var %x = 1 while ($comchan($me,%x)) { autolimit.start $ifmatch inc %x } } elseif ($1 == stop) { var %x = 1 while ($comchan($me,%x)) { autolimit.stop $ifmatch inc %x } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LOAD EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:load:{ echo -a loaded autolimit ( $+ $autolimit.version $+ ), writing default settings to $mircdir $+ $autolimit.ini echo -a $readini($mircini,n,text,commandchar) $+ autolimit -h for help } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; UNLOAD EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:unload:{ scon -am1 autolimit.all stop if ($hget($autolimit.hash)) { hfree $autolimit.hash } if ($window($autolimit.window)) { window -c $autolimit.window } echo -a autolimit: unloaded } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.NAMESEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; /namesexec [params..] alias -l autolimit.namesexec { if ($status == connected) && ($2) && ($left($1,1) isin $chantypes) { hadd -m $+(autolimit.namesexec.,$cid) $autolimit.lower($1) $1 $2- .quote names -d $1 } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 355 NAMES HIDDEN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 355 me =|*|@ channel :nicks raw 355:& & & *: { if ($hget($+(autolimit.namesexec.,$cid),$autolimit.lower($3))) { var %t = $hget($+(autolimit.namesexec.,$cid),$autolimit.lower($3)) $gettok(%t,2-,32) 355 $gettok(%t,1,32) $4- haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 366 NAMES END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; raw 366 me channel :End of /NAMES list. raw 366:& & End of /NAMES list*: { if ($hget($+(autolimit.namesexec.,$cid),$autolimit.lower($2))) { var %t = $hget($+(autolimit.namesexec.,$cid),$autolimit.lower($2)) $gettok(%t,2-,32) 366 $gettok(%t,1,32) End of /NAMES list hdel $+(autolimit.namesexec.,$cid) $autolimit.lower($2) if ($hget($+(autolimit.namesexec.,$cid),0).item == 0) { hfree $+(autolimit.namesexec.,$cid) } haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:disconnect:{ hfree -w $+(autolimit.namesexec.,$cid) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS AUTOLIMIT.HIDDEN.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l autolimit.hidden.1 { if ($1 == 355) { hinc -m $+($autolimit.hash,.temp.,$cid) $+(count,$chr(160),$2) $calc($0 - 2) } elseif ($1 == 366) { autolimit.set -d $2 $hget($+($autolimit.hash,.temp.,$cid),$+(setting,$chr(160),$2)) $hget($+($autolimit.hash,.temp.,$cid),$+(count,$chr(160),$2)) hdel $+($autolimit.hash,.temp.,$cid) $+(count,$chr(160),$2) hdel $+($autolimit.hash,.temp.,$cid) $+(setting,$chr(160),$2) if ($hget($+($autolimit.hash,.temp.,$cid),0).item == 0) { hfree $+($autolimit.hash,.temp.,$cid) } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 321 LIST START ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 321 me Channel :Users Name raw 321:*:{ if ($hget($+($autolimit.hash,.temp.,$cid))) { window -n "Channels List" halt } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 322 LIST ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 322 me chan users :topic raw 322:& & & *:{ if ($hget($+($autolimit.hash,.temp.,$cid),$+(setting,$chr(160),$2))) { autolimit.set -d $2 $hget($+($autolimit.hash,.temp.,$cid),$+(setting,$chr(160),$2)) $calc($nick($2,0) - $3) hdel $+($autolimit.hash,.temp.,$cid) $+(setting,$chr(160),$2) hadd $+($autolimit.hash,.temp.,$cid) close 1 halt } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 322 LIST END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 323 me :End of /LIST raw 323:*:{ if ($hget($+($autolimit.hash,.temp.,$cid),close)) { window -c "Channels List" if ($hget($+($autolimit.hash,.temp.,$cid),0).item == 0) { hfree $+($autolimit.hash,.temp.,$cid) } halt } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MENU @autolimit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; menu * { dclick:$iif($active == $autolimit.window,autolimit -i) }