I made this following script, it works in coherance with another script kicking clones and locking the channel, this is the channel locking procedure.
Code: Select all
set clone_mlock "mR"
set clone_mlockswitch "1"
set clone_noticeswitch "1"
set clone_notice "Testing channel locking script"
set clone_mlocktime "3"
bind pub m !checklock check:lock
proc check:lock {nick uhost hand chan text} {
global botnick clone_mlock clone_mlockswitch clone_noticeswitch clone_notice clone_mlocktime clone_mlocked
set checkmode [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]; set allmodes [split $clone_mlock ""]; putlog "Allmodes = $allmodes"
if {($clone_mlocktime == "") || ($clone_mlocktime == 0) || ($clone_mlocktime < 1)} { set $clone_mlocktime 10 }
if {(![info exists clone_mlocked($chan)]) && ($clone_mlockswitch == 1) && ($allmodes != "")} {; set newmodes [list]
foreach modelock $allmodes { if {(![string match *$modelock* $checkmode])} { lappend modelock $newmodes } }; putlog "New modes = $newmodes"
putquick "MODE $chan +[string trim $newmodes]" -next; set clone_mlocked([join [split $chan]]) 1; putlog "Locked channel to +[string trim $newmodes]"
if {([info exists clone_mlocked($chan)]) && ($clone_noticeswitch == 1) && ($clone_notice != "")} {
putquick "NOTICE $chan :$clone_notice" -next; putlog "Notice = $clone_notice" } }
utimer $clone_mlocktime [list remove:flood:mlock $chan]
putlog "Removing lock in $clone_mlocktime secs"
}
proc remove:flood:mlock {chan} {
global botnick clone_mlock clone_mlockswitch clone_mlocked
set checknewmode [split [string trim [lindex [split [getchanmode $chan]] 0] "+"] ""]; set newmodes [list]; set allmodes [split $clone_mlock ""]; putlog "New allmodes = $allmodes"
foreach modelock $allmodes {; if {([string match *$modelock* $checknewmode])} { lappend modelock $newmodes } }; putlog "New unlock modes = $newmodes"
if {([info exists clone_mlocked($chan)]) && ($clone_mlockswitch == 1) && ($allmodes != "")} {
putquick "MODE $chan -[string trim $newmodes]" -next
utimer [expr $clone_mlocktime + 5] "unset clone_mlocked($chan)"
putlog "Removed mlock -[string trim $newmodes]"
}
}
I get the value "", null for $newmodes when I try to string match, foreach modelock from the list $allmodes. Don't know what is wrong. I have tried lsearch too.<bot> Allmodes = m R
<bot> New modes =
<bot> Locked channel to +
<bot> Notice = Testing channel locking script
<bot> Removing lock in 3 secs
<bot> New modes = m R
<bot> New unlock modes =
<bot> Removed mlock -
Can anyone please help me? I have made this script a little complicated so that, the bot doesn't do a mode flood and also it doesn't lock the modes which are already placed in the channel if they are given in its defined settings!
I get a null value for $newmodes, if I can get it with a value from the check:mlock procedure, then everything would be okay and would work!
