Alias putmode {
if (!$isid) {
var %echo = !echo -acq $+ $iif($active == Status Window,e) info *
var %strict = $true
if ($left($1,1) == -) {
if (f isincs $1) %strict = $false
if (t isincs $1) !.echo -q $regex(putmode,$1,/t(\d*)/)
tokenize 32 $2-
}
if ($2 == $null) %echo /putmode: insufficient parameters
elseif (!$nick($1,$me,~&@%) && o !isin $usermode) { %echo /putmode: you need to need to be at least half-opped or have ircops access }
else {
var %name = putmode. $+ $cid $+ . $+ $1
if (!$timer(%name)) {
hadd -m %name index -1
hadd -m %name current 0
hadd -m %name strict $iif(%strict,$true,$false)
!.timer $+ %name -m 0 $iif($regml(putmode,1) isnum,$ifmatch,1400) putmode.exec $cid $1
!.echo -q $regex(putmode,reset,/reset/)
}
hinc -m %name index
hadd -m %name $hget(%name,index) $2-
}
}
}
alias putmode.exec {
var %name = putmode. $+ $1 $+ . $+ $2, %parameter, %parameters, %tmp, $&
%index = $hget(%name,current), %subindex, %modestring, %prefix, $&
%parmrequired = $remove($gettok($chanmodes,1-2,44),44) $+ $nickmode, $&
%parmrequiredset = $gettok($chanmodes,3,44), %string, %substring, %operator
while ($hget(%name,%index) <= $hget(%name,index)) {
%string = $ifmatch
%subindex = 1
while (%subindex <= $len($gettok(%string,1,32))) {
%substring = $mid(%string,%subindex,1)
%parameter = $gettok(%string,2,32)
if (%substring isin +-) {
%tmp = %prefix
%prefix = $ifmatch
if (%prefix == %tmp) goto loopend
}
elseif (%substring isincs %parmrequired || (%substring isincs %parmrequiredset && %prefix == +)) {
if (%substring isincs $nickmode && $gettok(%string,2,32) !ison $2) goto loopend
elseif (%substring isincs bhov && $hget(%name,strict)) {
if (%substring === b) && ($chr(33) !isin %parameter) && (@ !isin %parameter) {
if (%parameter == $null) !.echo -q .
elseif (. !isin %parameter) %parameter = %parameter $+ !*@*
else %parameter = *!*@ $+ %parameter
}
%operator = $iif(%prefix == -,!) $+ is $+ $replacex(%substring,b,ban,q,owner,o,op,h,hop,v,voice)
if (%parameter %operator $2) goto loopend
}
%parameters = %parameters %parameter
%string = $gettok(%string,1,32) $gettok(%string,3-,32)
}
%modestring = %modestring $+ %substring
if ($numtok(%parameters,32) == $modespl) {
if ($me ison $2) || ($me ison $2) !mode $2 %modestring %parameters
; $iif(o isin $usermode || !$nick($2,$me,@&~%) ,cs mode $2 set %modestring %parameters,!mode $2 %modestring %parameters)
%string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok($hget(%name,%index),$calc(10 + 2) $+ -,32)
hadd -m %name %index $iif($left(%string,1) !isin +-,%prefix) $+ %string
goto end
}
:loopend
inc %subindex
}
hdel %name %index
hinc %name current
inc %index
}
if (($me ison $2 || $me ison $2) && $len(%modestring) > 1) {
!mode $2 %modestring %parameters
hdel %name %index
}
:end
if ($hget(%name,0).item == 3) putmode.cleanup $1 $2
}
alias putmode.cleanup {
var %name = putmode. $+ $1 $+ . $+ $2
!.timer $+ %name off
hfree -w %name
}
ON *:KICK:#:if ($knick == $me) putmode.cleanup $cid $chan
ON *:PART:#:if ($nick == $me) putmode.cleanup $cid $chan
ON *:DISCONNECT:{ putmode.cleanup $cid * | echo -at 0,4 *!*...Disconnected...*!* 00,03 $network }