Tell you that I have solved the problem.
Very grateful to willyw and Spike ^^.
The idea of
willyw, I invested because if the
set modes2 [getchanmode $chan] command is executed before the timer,was not the result that I wanted, to wait 5sec and refresh the list and then take its value.
Regarding the comment
Spike^^ related to chan, I had changed my code before and everything was the same.
The problem was discovered by testing the code in parts, to the point where the BoT froze.
The error was in the While, had 2 errors, one was a brace:
if {[string index $modes2 $x] in $modes1} == 0 {
The other most important mistake why the bot froze, was that the x variable is not increased in value.
Thus x always worth 0 (zero) and became infinite loop.
I managed to fix the increase in x variable, placing it at the beginning of the loop.
You may wonder but that makes x starts with a value of 1 instead of 0.
That's right, but that's no problem because the mode list always starts with the sign ''+" (i.e +mCc ) and this symbol would be index 0 which does not interest me to compare because it is always constant even changing modes.
Conclusion here is finished and fixed script:
Code: Select all
proc pub:addinvite {nick uhost hand chan text} {
if {$text == ""} { putmsg $chan "Please enter \002nick\002 to add."; return 0 }
set t [lindex [split $text] 0]
set modos [getchanmode $chan]
set modes1 [split "$modos" {}]
set ti "$t[join !*@*]"
if {![isinvite $ti $chan]} {
newchaninvite $chan $ti invite 0 sticky
utimer 5 [list rest_of_commands $modes1 $chan $t]
proc rest_of_commands {modes1 chan t} {
set modes2 [getchanmode $chan]
set largo [string length $modes2]
set x 0
while {$x < $largo} {
set x [expr {$x + 1}]
if {[string index $modes2 $x] in $modes1 == 0} {
set modchange [string index $modes2 $x]
pushmode $chan "-[join $modchange]"
unset modchange
}}}
putmsg $chan "$t has been added to the autoinvite database $chan"
} else { putmsg $chan "$t is already in the autoinvite database $chan" }
}