Also, I'm not sure those regular expressions you're using actually does what you intended, ie:
Code: Select all
if {![regexp "\[^15-99999\]" $target} {
Code: Select all
if {![regexp "\[^15-99999\]" $target} {
Ok, thanks for the ie, but if this codenml375 wrote:In my opinion, the number of spaces/tabs per level is'nt that important, what is however, is using the same fashion all through the script, ie. add one space/tab for each level you descend, as illustrated by rosc.
Also, I'm not sure those regular expressions you're using actually does what you intended, ie:This will match anything starting with the number 1, 5, 6, 7, 8, 9 (such as 1, 10, 19, 91, but not 20). Probably not what you intended.Code: Select all
if {![regexp "\[^15-99999\]" $target} {
Code: Select all
if {![regexp "\[^15-99999\]" $target]} {
Code: Select all
if {![string is -strict integer $target] || $target >= 15 || $target <= 0} {
good idea, but... it didn`t worknml375 wrote:I would probably use something like this:Code: Select all
if {![string is -strict integer $target] || $target >= 15 || $target <= 0} {
Code: Select all
if {![regexp "\[^8-99999\]" $target} {
Code: Select all
if {![regexp "\[^15-99999\]" $target} {
and the same thing happends for a nother user with a higher access flag to the bot<@OP> !d
-|EGG- SYNTAX: !d <1-7> <nick|*!*@host> [reason]
<@OP> !d 8 *!*@*.test.ro
<@OP> !d 7 *!*@*.test.ro
* |EGG sets mode: +b *!*@*.test.ro
<me> .tcl killchanban #chan *!*@*.test.ro
<@|EGG> OK: 1 - 0.246 ms
* |EGG sets mode: -b *!*@*.test.ro
btw nm375, this piece of code:<@TestOP> !d
-|EGG- SYNTAX: !d <1-14> <nick|*!*@host> [reason]
<@TestOP> !d 15 *!*@*.test.ro
<@TestOP> !d 100 *!*@*.test.ro
<@TestOP> !d 14 *!*@*.test.ro
* |EGG sets mode: +b *!*@*.test.ro
<me> .tcl killchanban #chan *!*@*.test.ro
<@|EGG> OK: 1 - 0.246 ms
* |EGG sets mode: -b *!*@*.test.ro
Code: Select all
if {![string is -strict integer $target] || $target >= 15 || $target <= 0} {
Code: Select all
set dj(br) "Banned!"
set dj(xb) 1
bind pub n|MASDTO !d s:day
setudef flag djtools
proc s:day {nick uhost hand chan text} {
global botnick dj
if {[channel get $chan djtools] && ![isbotnick $nick]} {
if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
set target [lindex [split $text] 0]
if {![botisop $chan]} {
puthelp "NOTICE $nick :Error I don't have OP!"
return 0
} elseif {[matchattr $hand -|T $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 !d <1-14> <nick|*!*@host> \[reason\] \002"
return 0
}
} else {
foreach not $target {
if {![string is -strict integer $target] || $target >= 15 || $target <= 0} {
puthelp "NOTICE $nick :Error max allowed 1-14 days for Test OP Access Users"
return 0
}
}
}
set options $target
foreach item $options {
if {![regexp "\[^0-14\]" $item]} {
set days $item
s:day:ban $nick $uhost $hand $chan $text
return 0
}
}
} elseif {[matchattr $hand -|O $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 !d <1-7> <nick|*!*@host> \[reason\] \002"
return 0
}
} else {
foreach not $target {
if {![string is -strict integer $target] || $target >= 8 || $target <= 0} {
puthelp "NOTICE $nick :Error max allowed 1-7 days for OP Access Users"
return 0
}
}
}
set options $target
foreach item $options {
if {![regexp "\[^0-7\]" $item]} {
set days $item
s:day:ban $nick $uhost $hand $chan $text
return 0
}
}
}
}
proc s:day:ban {nick uhost hand chan text} {
global botnick dj
if {[channel get $chan djtools] && ![isbotnick $nick]} {
set type [lindex [split $text] 1]
set dtype [nick2hand $type]
set reason [join [lrange [split $text] 3 end]]
if {$reason == ""} {
set reason $dj(br)
}
if {[string match *!*@* $type]} {
set dhost $type
} else {
set dhost "*!*@[lindex [split [getchanhost $type] @] 2]"
}
if {![matchattr $dtype n|MASDTOVU $chan] && ![isop $type $chan] && ![isvoice $type $chan] && ![matchattr $dtype b]} {
newchanban $chan $dhost days "($hand) $reason" [expr $days * 1440]
putquick "MODE $chan +b $dhost"
putquick "KICK $chan $type :($hand) $reason"
if {$dj(xb) == 1} {
putquick "PRIVMSG X :ban $chan $dhost 1 100 ($hand) $reason" -next
}
newignore $dhost days "($hand) $reason"
return 0
}
}
}
<|EGG> [01:01] Tcl error [s:day]: can't read "days": no such variable
How to I make the second proc to recognize a variable form the first proc ?!<me> .set errorInfo
<|EGG> [01:02] #me# set errorInfo
<|EGG> Currently: can't read "days": no such variable
<|EGG> Currently: while executing
<|EGG> Currently: "expr $days * 1440"
<|EGG> Currently: (procedure "s:day:ban" line 16)
<|EGG> Currently: invoked from within
<|EGG> Currently: "s:day:ban $nick $uhost $hand $chan $text"
<|EGG> Currently: (procedure "s:day" line 26)
<|EGG> Currently: invoked from within
<|EGG> Currently: "s:day $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
Code: Select all
proc s:day {nick uhost hand chan text} {
(...)
set days $item
s:day:ban $nick $uhost $hand $chan $text
return 0
(...)
You said, "doesn`t than mean number form 0 to 15 ?" Quite the opposite, it means string not an integer -or- the value is less than or equal to 0 -or- the value is larger than or equal to 15. This is where you would write your standard error message checks to explain to that user what they did wrong, too long, too short, not a number, etc.. it's simple input sanitizing, and in this situation simple is best.nml375 wrote:if {![string is -strict integer $target] || $target >= 15 || $target <= 0} {
Code: Select all
# the line below should replace the regexp line presently used
# if {[string is -strict integer $item] || $item <= 14 || $item >= 1} {
# if you insist on using that dirty regexp, remove the line above or you will get unbalanced brace error
if {![regexp "\[^0-14\]" $item]} {
# the set line below can be removed, and change $days to $item in the s:day:ban call
set days $item
s:day:ban $nick $uhost $hand $chan $days $text
.. rest is here..
Code: Select all
proc s:day:ban {nick uhost hand chan days text} {
.. rest continues the same ...
and on the dcc-chat:<me> .tcl source scripts/lol.tcl
<@|EGG> Error: missing close-brace: possible unbalanced brace in comment - 41.84 ms
<me> .set errorInfo
<|EGG> Currently: missing close-brace: possible unbalanced brace in comment
<|EGG> Currently: while executing
<|EGG> Currently: "proc s:day {nick uhost hand chan text} {
<|EGG> Currently: global botnick dj
<|EGG> Currently: if {[channel get $chan djtools] && ![isbotnick $nick]} {
<|EGG> Currently: if {[matchattr $hand n|MASD..."
<|EGG> Currently: (file "scripts/lol.tcl" line
<|EGG> Currently: invoked from within
<|EGG> Currently: "source scripts/lol.tcl"
<|EGG> Currently: ("eval" body line 1)
<|EGG> Currently: invoked from within
<|EGG> Currently: "eval $args"
The eggdrop is telling you the offending line here, you haven't closed this conditional before closing the procedure. Just change the last part of the s:day proc like this:Riddler wrote:<|EGG> Currently: if {[channel get $chan djtools] && ![isbotnick $nick]} {
Code: Select all
return 0
}
}
}
}
}
Sorry for what? That the advice I gave you was in a tone that led you to believe your question upset me?...hahah.. It's just that remedial questions (questions easily solved just by reading tcl commands docs) usually get sterner answers than something truly complex. So figured I would chime in to explain that you were incorrect in your interpretation of the logic behind that code nml375 gave you, before I explained your other issues.Riddler wrote:ok, sorry for that I was just asking, didn`t know what that string will do.