bind pub Caomn|Caomn !flood pub:flood
proc pub:flood {nick uhost hand chan text} {
global limit
set limit(number) [expr [llength [chanlist $chan]] -1]
putlog $limit(number)
if {[nick2hand $nick] == "*"} {
putmsg $nick "Sorry, you must be logged in for this command"
return 0 }
if {[botisop $chan] == 0} {
putmsg $chan "Ops are required to enact preventative measures"
return 0 }
#Sets the limit command where the number is derived in the main execution
set limit(cmd) "l $limit(number)"
#Sets the operator flood modes
set limit(modeop) "i"
#Sets the halfop flood modes
set limit(modehalfop) "R$limit(cmd)"
if {[matchattr $hand +aomn $chan] == 1 } {
putquick "MODE +$limit(modeop) $chan" -next
utimer 10 [putserv "MODE -$limit(modeop)"] }
elseif {[matchattr $hand +Cly $chan] == 1 } {
putquick "MODE +$limit(modehalfop) $chan" -next
utimer 10 [putserv "MODE -$limit(modehalfop)"] }
else { putmsg $chan "It hasnt worked cause summin is wrong. Sod off you silly bastard"
return 0 }
}
I am trying to make a script that will automatically set a strict limit and then set modes to prevent a part/join flood attack.
Problem is, i am getting this
[14:02] Tcl error [pub:flood]: invalid command name "elseif"
I know Elseif is a command, so is Else, but i have been getting errors for both commands. The bot has been compiled using TCL 8.4.1. I am guessing its syntax, but i am quite stumped. Any help?
else and elseif aren't commands, they're arguments to the "if" command. The problem is you have your } and your "elseif" and "else" on separate lines. It should be like this:
bind pub Caomn|Caomn !flood pub:flood
proc pub:flood {nick uhost hand chan text} {
global limit
set limit(number) [expr [llength [chanlist $chan]] -1]
putlog $limit(number)
if {[nick2hand $nick] == "*"} {
putmsg $nick "Sorry, you must be logged in for this command"
return 0 }
if {[botisop $chan] == 0} {
putmsg $chan "Ops are required to enact preventative measures"
return 0 }
#Sets the limit command where the number is derived in the main execution
set limit(cmd) "l $limit(number)"
#Sets the operator flood modes
set limit(modeop) "i"
#Sets the halfop flood modes
set limit(modehalfop) "R$limit(cmd)"
if {[matchattr $hand +aomn $chan] == 1 } {
putquick "MODE +$limit(modeop) $chan" -next
utimer 10 [putserv "MODE -$limit(modeop)"]
} elseif {[matchattr $hand +Cly $chan] == 1 } {
putquick "MODE +$limit(modehalfop) $chan" -next
utimer 10 [putserv "MODE -$limit(modehalfop)"]
} else {
putmsg $chan "It hasnt worked cause summin is wrong. Sod off you silly bastard"
return 0
}
}