| View previous topic :: View next topic |
| Author |
Message |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sun Jun 17, 2007 12:43 am Post subject: Help with a command code (!day): |
|
|
Hello guys... I need some help again ...
I`m trying to make a little code that will work with a pub command...something like this:
| Quote: | -----
For Channel Managers:
<@Manager1> !day
-|Eggdrop- SYNTAX: !day <??> <nick|*!*@host> [reason]
-----
For :
<@Admin1> !day
-|Eggdrop- SYNTAX: !day <1-100> <nick|*!*@host> [reason]
-----
For Channel Senior OPs:
<@SOp1> !day
-|Eggdrop- SYNTAX: !day <1-60> <nick|*!*@host> [reason]
-----
......and so on
-----
For Channel OPs:
<@Op1> !day
-|Eggdrop- SYNTAX: !day <1-7> <nick|*!*@host> [reason]
----- |
and here is the code :
| Code: | set dj(br) "Banned!"
set dj(xp) 1
bind pub n|MASDTO !day s:ban
setudef flag djtools
proc s:ban {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!"
} elseif {[matchattr $hand n|- $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 !day <??> <nick|*!*@host> \[reason\] \002"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-99999\]" $item]} {
set days $item
}
s:day:ban
return 0
}
} elseif {![matchattr $hand -|O $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 !day <1-7> <nick|*!*@host> \[reason\] \002"
return 0
} else {
foreach not $target {
if {![regexp "\[^8-99999\]" $target} {
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
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" [expr $days * 1440]
return 0
}
}
} |
Well the errors are :
1.) Manager1
| Quote: | <Manager1> !day
-|Eggdrop- SYNTAX: !day <??> <nick|*!*@host> [reason]
<Manager1> !day 9999 *!*@test.ro lol |
NO reaction ..... and I`m getting this error in dcc-chat
| Quote: | | <|Eggdrop> [06:06] Tcl error [s:ban]: syntax error in expression "![matchattr $dtype n|MASDTOVU $chan] && ![isop $type $chan] ...": extra tokens at end of expression |
...and so on for every user who has specific flags and trys to use this command...
any suggestions in how to make this script work ?1  _________________ I am a man of few words, but many riddles
Last edited by Riddler on Mon Jun 18, 2007 6:45 am; edited 1 time in total |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Mon Jun 18, 2007 6:40 am Post subject: |
|
|
nobody has any suggestion/ideas in how to make this script work...
I only need to make it work for 2 diferent flag users...the rest of the script I`ll do it myself.  _________________ 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: Sat Jun 23, 2007 7:37 pm Post subject: |
|
|
...  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jun 23, 2007 8:06 pm Post subject: |
|
|
You can follow a patter like
| Code: | if {<is senior op>} {
# give senior op privileges
} elseif {<is bla op>} {
# give bla op privileges
} ...etc |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sat Jun 23, 2007 8:09 pm Post subject: |
|
|
| Sir_Fz wrote: | You can follow a patter like
| Code: | if {<is senior op>} {
# give senior op privileges
} elseif {<is bla op>} {
# give bla op privileges
} ...etc |
|
never heard of this type of command ...let`s see  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jun 23, 2007 8:15 pm Post subject: |
|
|
It's not a command, that was just an example (duh). In your case it's a [matchattr] check. For example
| Code: | | if {[matchattr $hand |+S $chan]} { |
This checks if $hand has +S (senior ops?) on $chan... and so on. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sat Jun 23, 2007 8:49 pm Post subject: |
|
|
ok, done the modifications, and here is the script..
| Code: | set dj(br) "Banned!"
set dj(xp) 1
bind pub n|MASDTO !day s:ban
setudef flag djtools
proc s:ban {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!"
} elseif {[matchattr $hand n|-]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 .d <??> <nick|*!*@host> \[reason\] \002"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-99999\]" $item]} {
set days $item
}
s:day:ban $nick $uhost $hand $chan $text
return 0
}
} elseif {[matchattr $hand -|+M $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 .d <??> <nick|*!*@host> \[reason\] \002"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-99999\]" $item]} {
set days $item
}
s:day:ban $nick $uhost $hand $chan $text
return 0
}
} elseif {[matchattr $hand -|+A $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 .d <1-100> <nick|*!*@host> \[reason\] \002"
return 0
} else {
foreach not $target {
if {![regexp "\[^101-99999\]" $target} {
puthelp "NOTICE $nick :Error max allowed 1-100 days for Administrator Access Users"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-100\]" $item]} {
set days $item
}
s:day:ban $nick $uhost $hand $chan $text
return 0
}
} elseif {[matchattr $hand -|+S $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 .d <1-60> <nick|*!*@host> \[reason\] \002"
return 0
} else {
foreach not $target {
if {![regexp "\[^61-99999\]" $target} {
puthelp "NOTICE $nick :Error max allowed 1-60 days for Senior OP Access Users"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-60\]" $item]} {
set days $item
}
s:day:ban $nick $uhost $hand $chan $text
return 0
}
} elseif {[matchattr $hand -|+D $chan]} {
if {$target == ""} {
puthelp "NOTICE $nick :SYNTAX:\002 .d <1-30> <nick|*!*@host> \[reason\] \002"
return 0
} else {
foreach not $target {
if {![regexp "\[^31-99999\]" $target} {
puthelp "NOTICE $nick :Error max allowed 1-30 days for DJ Access Users"
return 0
}
set options $target
foreach item $options {
if {![regexp "\[^0-30\]" $item]} {
set days $item
}
s:day:ban $nick $uhost $hand $chan $text
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 {![regexp "\[^15-99999\]" $target} {
puthelp "NOTICE $nick :Error max allowed 1-14 days for Test DJ 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 {![regexp "\[^8-99999\]" $target} {
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" [expr $days * 1440]
return 0
}
}
} |
..and I still get errors like this :
| Quote: | (03:48:13) <me> .load test.tcl
(03:48:13) <|EGG> [02:30] script: test.tcl -- loaded without error.
(03:48:17) <|EGG> [02:31] Tcl error [s:ban]: wrong # args: should be "foreach varList list ?varList list ...? command" |
I can`t understand why it`s giving me the error for the "foreach" command...because till now, that wasen`t the problem...  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sat Jun 23, 2007 9:04 pm Post subject: |
|
|
| Sir_Fz wrote: | | .set errorInfo? |
do you mean if I use this script ?!
| Code: | # .load scriptname.tcl
bind dcc n|- load script:load
proc script:load { handle idx text } {
if { [catch { uplevel #0 [list source scripts/$text] } error] } {
putlog "0,4Error while loading $text -- Errormsg: $error"
putlog "script: $text -- ::errorInfo: $::errorInfo"
return
}
putlog "script: $text -- loaded without errors."
return
} |
? _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sat Jun 23, 2007 9:34 pm Post subject: |
|
|
Try reading eggdrop.conf. Sir_Fz said to use '.set errorInfo' not run another script.
| Quote: | # Comment these two lines if you wish to enable the .tcl and .set commands.
# If you select your owners wisely, you should be okay enabling these.
unbind dcc n tcl *dcc:tcl
unbind dcc n set *dcc:set |
_________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Tue Jun 26, 2007 7:00 pm Post subject: |
|
|
ok, removed the "unbind`s".. now I`m getting this error..
| Code: | (01:57:38) <me> .set errorInfo
(01:57:38) <|EGG> [00:39] #me# set errorInfo
(01:57:38) <|EGG> Currently: wrong # args: should be "foreach varList list ?varList list ...? command"
(01:57:38) <|EGG> Currently: while compiling
(01:57:38) <|EGG> Currently: "foreach not $target {
(01:57:38) <|EGG> Currently: if {![regexp "\[^101-99999\]" $target} {
(01:57:38) <|EGG> Currently: puthelp "NOTICE $nick :Error max allowed 1-100 days for Administr..."
(01:57:38) <|EGG> Currently: ("if" else script line 2)
(01:57:38) <|EGG> Currently: while compiling
(01:57:38) <|EGG> Currently: "if {$target == ""} {
(01:57:38) <|EGG> Currently: puthelp "NOTICE $nick :SYNTAX:\002 .d <1-100> <nick|*!*@host> \[reason\] \002"
(01:57:38) <|EGG> Currently: return 0
(01:57:38) <|EGG> Currently: } else {
(01:57:38) <|EGG> Currently: ..."
(01:57:38) <|EGG> Currently: ("if" then script line 2)
(01:57:38) <|EGG> Currently: while compiling
(01:57:38) <|EGG> Currently: "if {![botisop $chan]} {
(01:57:38) <|EGG> Currently: puthelp "NOTICE $nick :Error I don't have OP!"
(01:57:38) <|EGG> Currently: } elseif {[matchattr $hand n|-]} {
(01:57:38) <|EGG> Currently: if {$target == ""} {..."
(01:57:38) <|EGG> Currently: ("if" then script line 3)
(01:57:38) <|EGG> Currently: while compiling
(01:57:38) <|EGG> Currently: "if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
(01:57:38) <|EGG> Currently: set target [lindex [split $text] 0]
(01:57:38) <|EGG> Currently: if {![botisop $chan]} {
(01:57:38) <|EGG> Currently: put..."
(01:57:38) <|EGG> Currently: ("if" then script line 2)
(01:57:38) <|EGG> Currently: while compiling
(01:57:38) <|EGG> Currently: "if {[channel get $chan djtools] && ![isbotnick $nick]} {
(01:57:38) <|EGG> Currently: if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
(01:57:38) <|EGG> Currently: set target [lindex ..."
(01:57:38) <|EGG> Currently: (compiling body of proc "s:ban", line 3)
(01:57:38) <|EGG> Currently: invoked from within
(01:57:38) <|EGG> Currently: "s:ban $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
(01:58:25) <|EGG> [00:40] @#นพ (+stn) : [m/8 o/8 h/0 v/0 n/0 b/0 e/- I/-] |
Suggestions ?!  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jun 26, 2007 7:07 pm Post subject: |
|
|
You've got a missing } after that foreach-loop, you only closed the if-conditional inside and not the foreach-loop itself.
It would also seem this is the case on several other locations. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Tue Jun 26, 2007 8:12 pm Post subject: |
|
|
UPDATE:
I`ve closed the missing " } " form the foreach-loop and simplifyed the script for only 1 access flags... to make it a little easy for the script to work...
so here is the code ( simplifyed ):
| Code: | set dj(br) "Banned!"
set dj(xp) 1
bind pub n|MASDTO !day s:ban
setudef flag djtools
proc s:ban {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 {![regexp "\[^15-99999\]" $target} {
puthelp "NOTICE $nick :Error max allowed 1-14 days for Test DJ Access Users"
return 0
}
}
}
set options $target
foreach item $options {
if {![regexp "\[^0-14\]" $item]} {
set days $item
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
}
}
}
}
}
} |
and I`m still getting this error on dcc ..
| Quote: | | <|EGG> [01:35] Tcl error [s:ban]: missing close-bracket |
and on the .set errorInfo I get this
| Quote: | <me> .set errorInfo
<|EGG> [01:35] #me# set errorInfo
<|EGG> Currently: missing close-bracket
<|EGG> Currently: ("if" test expression)
<|EGG> Currently: while compiling
<|EGG> Currently: "if {![regexp "\[^15-99999\]" $target} {
<|EGG> Currently: puthelp "NOTICE $nick :Error max allowed 1-14 days for Test DJ Access Users"
<|EGG> Currently: retur..."
<|EGG> Currently: ("foreach" body line 2)
<|EGG> Currently: while compiling
<|EGG> Currently: "foreach not $target {
<|EGG> Currently: if {![regexp "\[^15-99999\]" $target} {
<|EGG> Currently: puthelp "NOTICE $nick :Error max allowed 1-14 days for Test ..."
<|EGG> Currently: ("if" else script line 2)
<|EGG> Currently: while compiling
<|EGG> Currently: "if {![botisop $chan]} {
<|EGG> Currently: puthelp "NOTICE $nick :Error I don't have OP!"
<|EGG> Currently: return 0
<|EGG> Currently: } elseif {[matchattr $hand -|T $chan]} {
<|EGG> Currently: ..."
<|EGG> Currently: ("if" then script line 3)
<|EGG> Currently: while compiling
<|EGG> Currently: "if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
<|EGG> Currently: set target [lindex [split $text] 0]
<|EGG> Currently: if {![botisop $chan]} {
<|EGG> Currently: put..."
<|EGG> Currently: ("if" then script line 2)
<|EGG> Currently: while compiling
<|EGG> Currently: "if {[channel get $chan djtools] && ![isbotnick $nick]} {
<|EGG> Currently: if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
<|EGG> Currently: set target [lindex ..."
<|EGG> Currently: (compiling body of proc "s:ban", line 3)
<|EGG> Currently: invoked from within
<|EGG> Currently: "s:ban $_pub1 $_pub2 $_pub3 $_pub4 $_pub5" |
I`m suppose that my code is a little more complicated and has a lot of if-elseif-else commands in it and maybe that`s why it makes it hard to solve, and I`ll really appreciate is someone helps me to make this script a little more simple than... and also to make it work...
I`ve pointed that I want this script to do something like this:
| Quote: | For OP access user ( +O flag )
<OP> !day 7 *!*@*.test.ro
* |EGG sets mode: +b *!*@*.test.ro
How it works:
- sets a chan ban for 1 or 7 days on the banmask with a default ban reason;
- if the OP will type a number higher than 7, like 8 or 9 or 100, the BOT will NOT do the chan ban and will give the specific notice (puthelp "NOTICE $nick :Error max allowed 1-7 days for OP Access Users");
For Test OPs access user ( +T flag )
<TestOP> !day 14 *!*@*.test.ro
* |EGG sets mode: +b *!*@*.test.ro
How it works:
- sets a chan ban for 1 or 14 days on the banmask with a default ban reason;
- if the OP will type a number higher than 14, like 15 or 16 or 100, the BOT will NOT do the chan ban and will give the specific notice (puthelp "NOTICE $nick :Error max allowed 1-14 days for Test OP Access Users");
(...) |
and so on for the other flags... the higher the access flag, the more day's you can add to the banmask
It`s a complicated code I`m trying to make... at least I`m trying ( my tcl knowledge are at the beginning ) ...so any help will be appreciated. Thanks _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jun 27, 2007 8:09 am Post subject: |
|
|
This time you're lacking some brackets ([]), check this line again:
| Code: | | if {![regexp "\[^15-99999\]" $target} { |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Jun 27, 2007 10:06 am Post subject: |
|
|
Here's a huge bit of help: Properly TABINATE your scripts... Then you'd be able to see where missing junk is:
| Code: |
if {this is my first test} {
#tab
} else {
if {this is my 2nd test} {
# tab tab
} else {
if {this makes it much easier to figure things out} {
# tab tab tab
}
}
}
|
Yes I know tabs are a matter of style, but if you're having that much difficulty as a beginner, then learn good coding habits, which begin with TABS (and using small fonts/wider screens so you can read 300+ char length lines because of deeply nested if's/tabs And if your editor allows you to configure tab stops, set it to 4 spaces, not 2, which also makes it easier to read.. |
|
| Back to top |
|
 |
|