; --- Multi-Channel Dynamic Limit & Auto-Voice --- ; Purpose: +vl (+1 to limit and voice) after 45s on join. ; Immediate -l (limit reduction) on Part/Kick/Quit. ; On Join: Start a unique 45s timer for the user and channel on *:JOIN:#: { .timer $+ $+(limit_,$chan,_,$nick) 1 45 set_limit_and_voice $chan $nick } ; Combined Delay: Voices the user and increments the limit simultaneously alias set_limit_and_voice { var %chan = $1, %nick = $2 if (%nick ison %chan) && ($me isop %chan) { ; Calculate: current users + 1 var %new_limit = $calc($nick(%chan, 0) + 1) mode %chan +vl %nick %new_limit } } ; Immediate cleanup on Part on *:PART:#: { update_limit $chan } ; Immediate cleanup on Kick (with hardened math for race conditions) on *:KICK:#: { if ($me isop $chan) { ; Subtract the kicked user if they are still counted in the nicklist var %count = $nick($chan, 0) if ($knick ison $chan) { var %count = $calc(%count - 1) } var %new_limit = $calc(%count + 1) if ($chan($chan).limit != %new_limit) { mode $chan +l %new_limit } } } ; Immediate cleanup on Quit (checks all shared channels) on *:QUIT: { var %i = 1 while ($comchan($nick, %i)) { update_limit $v1 inc %i } } ; Global alias to handle the limit math alias update_limit { if ($1 && $me isop $1) { var %new_limit = $calc($nick($1, 0) + 1) if ($chan($1).limit != %new_limit) { mode $1 +l %new_limit } } }