This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[TCL ERROR] wrong # args {{Solved}}

Help for those learning Tcl or writing their own scripts.
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

[TCL ERROR] wrong # args {{Solved}}

Post by Branden »

Error:

Code: Select all

[23:24] Tcl error [CoreBan]: wrong # args: should be "stricthost host chan"

Snippit:

Code: Select all

bind pub l|l !Ban CoreBan



proc stricthost {host chan} {
	if {![string match "*@*" $host]} {
		return [maskhost "[string trimleft $host "!"]![getchanhost $host $chan]"]
	}
	return [maskhost $host]
}



proc CoreBan { nick host hand chan text } {
	set who [lindex [split $text] 0]
	set why [lrange [split $text] 1 end]
	set whohost [stricthost [lindex [split $text] 0]]
	putquick "MODE $chan +b $whohost"
	putquick "KICK $chan $who $why"
}

Just wondering, what does "wrong # args" generally mean, so I don't have to waste anyone time with opening a new thread?




Thank you!
Branden
Last edited by Branden on Thu Jul 16, 2009 3:31 pm, edited 3 times in total.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

set whohost [stricthost [lindex [split $text] 0] $chan]
You've tied chan as an argument in your procedure. This is why you can't invoke it without specifying the chan parameter as well as the host.
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

Thank you!
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

ERROR:


Code: Select all

[00:27] Tcl error [CorePermBan]: wrong # args: should be "stick ban ?channel?"


SCRIPT:

Code: Select all

proc CorePermBan { nick host hand chan text } {
   set who [lindex [split $text] 0]
   set why [lrange [split $text] 1 end]
   set whohost [stricthost [lindex [split $text] 0] $chan]
   putquick "MODE $chan +b $whohost"
   putquick "KICK $chan $who $why"
   stick ban $whohost
}


Sorry to be a pain!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

How do you supoose to stick the ban thats never been set correctly? Your using putquick'd mode changes, not eggdrops internal bans to catch this. Perhaps you should use:

Code: Select all

proc CorePermBan { nick host hand chan text } {
   set who [lindex [split $text] 0]
   set why [lrange [split $text] 1 end]
   set whohost [stricthost [lindex [split $text] 0] $chan]
   putquick "MODE $chan +b $whohost"
   putquick "KICK $chan $who :$why"
   newchanban $chan $whohost "$nick-PUB" $why 0
   stick ban $whohost $chan
}
As you can see, you forgot the $chan parameter of the stick command. You also forgot to put the colon between $who and $why in your putquick'd kick, meaning the ircd would always kick users without giving your entire $why reason. It would've only given the first word used, not the entire sentence. This is what the colon is for.
Last edited by speechles on Wed Jul 15, 2009 8:12 pm, edited 1 time in total.
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

speechles wrote:How do you supoose to stick the ban thats never been set correctly? Your using putquick'd mode changes, not eggdrops internal bans to catch this. Perhaps you should use:

Code: Select all

proc CorePermBan { nick host hand chan text } {
   set who [lindex [split $text] 0]
   set why [lrange [split $text] 1 end]
   set whohost [stricthost [lindex [split $text] 0] $chan]
   putquick "MODE $chan +b $whohost"
   putquick "KICK $chan $who :$why"
   newchanban $chan $whohost "$nick-PUB" $why 0
   stick ban $whohost $chan
}
As you can see, you forgot the $chan parameter of the stick command. You also forgot to put the colon between $who and $why in your putquick'd kick, meaning the ircd would always kick users without giving your $why reason.

Yeah, I was trying to do that instead, but the bot isn't setting the ban at all with newchanban, and it's not outputting any errors.
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Code: Select all

proc CorePermBan { nick host hand chan text } { 
   set who [lindex [split $text] 0] 
   set why [lrange [split $text] 1 end] 
   set whohost [stricthost [lindex [split $text] 0] $chan] 
   putquick "MODE $chan +b $whohost" 
   putquick "KICK $chan $who :$why" 
   newchanban $chan $whohost $nick-PUB "$why" 0 sticky
   if {![isbansticky $whohost $chan]} {
    stick $whohost $chan
   }
}
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

"newchanban" is still not working nor outputting any errors. :S
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The variable why should be converted back to a string rather than left as a list

Code: Select all

set why [join [lrange [split $text] 1 end]] 
I don't see $nick-PUB defined anywhere within the scope of the proc CorePermBan, did you mean $nick?

"$why" is in quotes in the newchanban and doesn't need to be

The following code seems superfluous, since the newchanban is set as sticky explicitly

Code: Select all

if {![isbansticky $whohost $chan]} { 
    stick $whohost $chan 
}
I must have had nothing to do
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

The use of $nick-PUB was to set the owner of the ban to the person's nickname that issued the command plus the tag "-PUB" :) and Yes, its superfluous :P but i prefer to include it ;)

As for newchanban not working, you could trying removing the putquick' and stuff, since added a ban via newchanban will already result in a ban and kick of any/all users matching the given address.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The Tcl interpreter will look for a variable named nick-PUB since there is nothing to suggest that -PUB is tagged onto the value of the variable nick.

Use $nick\-PUB

Though I accept it does work
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Code: Select all

bind PUB l|l !ban pCoreBan 

proc pCoreBan {nick uhost hand chan text} {
    set who [lindex [split $text] 0]
    set why [join [lrange [split $text] 1 end]]
    switch -- [regexp -- {\.} $who] {
        0 {
            if {[onchan $who]} {
                set host [maskhost [getchanhost $who]]
            }
        }
        1 {set host [maskhost $who]}
        default {}
    }
    if {[info exists host]} {newchanban $chan $host $nick\-PUB $why 0 sticky}
    return 0
} 
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

arfer:
Regarding $nick-PUB, due to various mechanics in tcl, if you intend to have a dash (-) in the name of a variable, you'll have to enclose it using {} when reading it. Ie: ${nick-PUB}. Otherwise, the dash is taken as the end of the variable name. As such, speechles' and TCL_no_TK's approach is fully valid, although perhaps not the best of practice in demonstration. The proper way to "tag" in the case of other characters than dash, once again you would use the {}; Ie: ${nick}-PUB.

So far, I've seen several different approaches to use newchanban, and all seem perfectly valid. Perhaps focus on figuring out why newchanban does not set the ban on the channel instead?

Branden:
Think you could post your channel settings (use .chaninfo from the dcc chat partyline)? Especially the dynamicbans and enforcebans (shouldn't matter since we've got it sticky though).
Could you check whether the new bans are added to your eggdrop's internal banlist (use .bans all from the dcc chat partyline)?
Also, have you verified that the generated banmask isn't blocked by the server (numerous ircd's these days bounce bans that match already active bans on the channel).
Other things to check, that the ban/invite/exempt-list isn't full, and that your eggdrop's setting match the ircd's capabilities..
NML_375
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

Ah, really sorry, the error was on my end...

I had the bot opered up, and it wasn't +o in the room, therefore it wasn't setting the modes.


I'll never make that mistake again. :]



Thank you all for your help!
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

OK nml375, I see that now. Thanks. It did look rather strange at first sight
I must have had nothing to do
Post Reply