| View previous topic :: View next topic |
| Author |
Message |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jun 27, 2007 11:52 am Post subject: |
|
|
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:
| Code: | | if {![regexp "\[^15-99999\]" $target} { |
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. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Wed Jun 27, 2007 1:44 pm Post subject: |
|
|
| nml375 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:
| Code: | | if {![regexp "\[^15-99999\]" $target} { |
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. |
Ok, thanks for the ie, but if this code
| Code: | | if {![regexp "\[^15-99999\]" $target]} { |
doesn`t except the numbers between 1 to 14 ( that ar the numbers that a specifyed user level will use with the !day command ), what should I use to except numbers form 1 to 14 and for the rest of the numbers to give that notice to the user ( in hope that the user will type the correct number based on his access level ) _________________ I am a man of few words, but many riddles
Last edited by Riddler on Thu Jun 28, 2007 2:07 pm; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jun 27, 2007 4:04 pm Post subject: |
|
|
I would probably use something like this:
| Code: | | if {![string is -strict integer $target] || $target >= 15 || $target <= 0} { |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Thu Jun 28, 2007 7:30 pm Post subject: |
|
|
| nml375 wrote: | I would probably use something like this:
| Code: | | if {![string is -strict integer $target] || $target >= 15 || $target <= 0} { |
|
good idea, but... it didn`t work
I`ve used that code, and there is no reaction if the number is higher than 7 ( for user with OP Access) and 14 ( for user with Test OP Access) .... the user didn`t get the warning notice.
I`ve also tested the script with this ( the first pieces of codes):
| Code: | | if {![regexp "\[^8-99999\]" $target} { |
and
| Code: | | if {![regexp "\[^15-99999\]" $target} { |
...still no reaction from the bot ( no notice )
| Quote: | <@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 |
and the same thing happends for a nother user with a higher access flag to the bot
| Quote: | <@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 |
btw nm375, this piece of code:
| Code: | | if {![string is -strict integer $target] || $target >= 15 || $target <= 0} { |
doesn`t than mean number form 0 to 15 ?  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Thu Jun 28, 2007 8:03 pm Post subject: |
|
|
Later UPDATE:
| Code: | 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
}
}
} |
I`ve made some changes and reorder the script and I`m getting this error on dcc-chat:
| Quote: | | <|EGG> [01:01] Tcl error [s:day]: can't read "days": no such variable |
| Quote: | <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" |
How to I make the second proc to recognize a variable form the first proc ?!
In this case, this one :
| Code: | proc s:day {nick uhost hand chan text} {
(...)
set days $item
s:day:ban $nick $uhost $hand $chan $text
return 0
(...) |
_________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu Jun 28, 2007 8:25 pm Post subject: |
|
|
It's so obviously simple how to do this. Your missing minor logic first and need to look back..
| nml375 wrote: | | if {![string is -strict integer $target] || $target >= 15 || $target <= 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.
...and about your error, since the bind isn't calling your s:day:ban proc directly and your invoking it within an already bound proc, you can pass it added parameters easily, meaning.. you can just shove them into passing calls.. like below.. just modify your s:day proc like so: | Code: | # 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.. |
then, your s:day:ban proc needs to be changed like this: | Code: | proc s:day:ban {nick uhost hand chan days text} {
.. rest continues the same ... |
It's easier to understand code if your able to understand it's logic as well. You should follow nml375's advice, as your regexp's are not having their intended purpose in your script and are highly exploitable by lower level ops.
and finally, just as a ps.. heh, type .echo off on your partyline so you don't get those #echo# messages after everything..  |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Thu Jun 28, 2007 9:59 pm Post subject: |
|
|
ok, sorry for that I was just asking, didn`t know what that string will do.
so, I`ve made the changes like you suggested and now I`m getting this error wen I`m trying to load the script:
| Quote: | <me> .tcl source scripts/lol.tcl
<@|EGG> Error: missing close-brace: possible unbalanced brace in comment - 41.84 ms |
and on the dcc-chat:
| Quote: | <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" |
_________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu Jun 28, 2007 10:17 pm Post subject: |
|
|
| Riddler wrote: | | <|EGG> Currently: if {[channel get $chan djtools] && ![isbotnick $nick]} { |
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:
Indentation done to match position of your double stacked if statements that start the procedure.
| Riddler wrote: | | ok, sorry for that I was just asking, didn`t know what that string will do. |
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. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|