|
Joined: Nov 2021
Posts: 135
Vogon poet
|
OP
Vogon poet
Joined: Nov 2021
Posts: 135 |
greetings folks, ive been using this fine code for a while now i forgot who the author is but its an excellent code to compress modes in 1 mode line as much as the ircd allows , i was wondering if anyone could edit it to use to stack kicks in the case of nicks getting adding 1 by one to stack in stacks of 4 and send away to server as much as the ircd allows , Thanks in advance.
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 }
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
This 'fine' code as you put it is not fine, it has two main issues if (%substring isincs $nickmode && $gettok(%string,2,32) !ison $2) goto loopend
When this if is true and it skips this current mode because the nickname you want to set a mode on/with is not on the channel, you're not updating %string (you're not updating the next parameter for the next mode taking a parameter) which would break the next mode with a parameter. Granted you were never in this situation so it works fine for you but then: 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
} When you reach a number of modes (or number of parameters for modes, same thing) that is equal to the maximum number of modes the server allows per /mode command, you sends the current /mode and then /goto end, which exits the two nested loop and basically stop the processing of the modes for now and it will wait for the timer to retrigger to continue processing. For this to work it must update the next mode and next parameter and save to the hash table, the next mode is correctly updated with the $mid, but the parameters of the modes are not updated properly with $gettok($hget(%name,%index),$calc(10 + 2) $+ -,32) aka $gettok($hget(%name,%index),12-,32), it should probably be $gettok(%string,2-,32) instead so %string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok(%string,2-,32). Another improvement is to use $unsafe on the parameter passed to /timer in order to not double evaluate the unknown content passed to it, avoiding exploits: !.timer $+ %name -m 0 $iif($regml(putmode,1) isnum,$ifmatch,1400) putmode.exec $cid $unsafe($1) Now kick are unrelated to /mode completely and therefore to $modespl, the maximum number of kicks in a single /kick command can be found in raw 005's KICK: token. You probably don't want to mix kicks and /putmodes as they are probably unrelated server wise as well, so it's probably best to write a seperate function for it. That being said, and it was requested many times, mIRC does not offer a way to access the various token of the raw 005, you'll have to write a script for it and then write a /putkick alias: Alias putkick {
if (!$isid) {
var %echo = !echo -acq $+ $iif($active == Status Window,e) info *
if ($regex(putkick,$1,/^-t(\d+)/)) tokenize 32 $2-
if ($2 == $null) %echo /putkick: insufficient parameters
elseif (!$nick($1,$me,~&@%) && o !isin $usermode) { %echo /putkick: you need to need to be at least half-opped or have ircops access }
else {
var %name = putkick. $+ $cid $+ . $+ $1
hadd -m kick %name $hget(kick,%name) $2-
if (!$timer(%name)) {
!.timer $+ %name -m 0 $iif($regml(putkick,1) isnum,$ifmatch,1400) putkick.exec $cid $unsafe($1)
!.echo -q $regex(putkick,reset,/reset/)
}
}
}
}
alias putkick.exec {
var %name = putmode. $+ $1 $+ . $+ $2,%nicks $hget(kick,%name)
var %maxkick 4,%a 1,%tmp
while ($gettok(%nicks,%a,32) {
%tmp = %tmp $+ , $+ $ifmatch
if ($numtok(%tmp,44) == %maxkick) {
if ($me ison $2) kick $2 %tmp
hadd kick %name $gettok(%nicks,$calc(%a + 1),32)
if (!$hget(kick,%name)) {
hdel kick %name
.timer $+ %name off
}
return
}
hdel %name %index
hinc %name current
inc %index
}
if ($me ison $2) && (%tmp) {
kick $2 %tmp
hdel kick %name
.timer $+ %name off
}
} This is untested.. I used 4 for the maximum kick per /kick, just use /putkick <channel> <nick nick1 nickN>
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2021
Posts: 135
Vogon poet
|
OP
Vogon poet
Joined: Nov 2021
Posts: 135 |
Thanks for your response Wims
i have tested the code you coded and kept gettin this error :
* /while: invalid format (line 558, clone-kicker.mrc)
for this line :
while ($gettok(%nicks,%a,32) {
i tested with an example such as :
/putkick #test Billy,Braden,Bryana,Eurydice,Giffer,Herold,Hueneke,Martinic,Paymar,Pelage,Sammy,Spracklen,Veronike,Waller custom kick reason here
|
|
|
|
|