Doing [llength [lindex [split $arg] 2]] just to see if there is a third element, is a bit complicated.ProXy wrote:Okay I fixed the bug with the ban, and the script works fine now, but i still have some questions:
This line should check if: The user entered a parameter , the user entered a number, the user typed a third (wrong) argument.Code: Select all
if {([llength $arg]==0) || (![string is digit [lindex [split $arg] 1]]) || ([llength [lindex [split $arg] 2]])} {
A right input would be: !lamer NICK 10, but not !lamer NICK 10 BLA.
I hope you understand my thinking. Now, what should be fxied in this short source to make it work better?
Why not do it like:
Code: Select all
set arglist [split $arg]
set listlen [llength $arglist]
switch -- $listlen {
0 { # no nick, no bantime }
1 { # no bantime }
2 { # 2 parameters }
default { # more than 2 parameters }
}
One interesting question is: if someone types !lamer nick 10 (i.e. !lamer<space><space>nick<space>10).