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 [joinproc]: invalid command name "}"

Old posts that have not been replied to for several years.
Locked
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Tcl error [joinproc]: invalid command name "}"

Post by Buffy_25 »

Hi,
I have a problem with my code below. I have two bots in my channel. When Blacky joins, this bot1 sends the current uptime of the online users in #channel to Blacky. But before that those times are being sent to Blacky, Blacky needs to reset it's times. So this bot1 sends (putbot) "clear" to Blacky so that Blacky unset his parameters. After this the uptimes are being sent from bot1 to Blacky and Blacky confirms this by putting a copy of this into #controlchan.

Find below the code for this bot1:

Code: Select all

bind join - * joinproc
proc joinproc {nick uhost hand chan} { 
  if {![string match -nocase "$chan" "#channel"]} { return 0 }
  global joined
#if {[isbotnick $nick]} {return} i removed this temporary
  set ::joined($nick) [clock seconds]
#if {[string equal -nocase [nick2hand $nick] "Blacky"]} { i removed this temporary
  if {[string equal -nocase $nick "Blacky"] || [string match -nocase "*@testing.com" $uhost]} {
	puthelp "PRIVMSG #controlchan :Blacky, i'm clearing your uptime-database so you can update your uptimes with mine" 
	putbot Blacky "clear"
	puthelp "PRIVMSG #controlchan :Blacky, I'm sending the info..." 
	foreach nick [chanlist "#channel"] { 
		if {![info exists ::joined($nick)]} { 
		 set ::joined($nick) [getchanjoin $nick #channel]
		}
  	putbot Blacky "join $nick [expr {[clock seconds] - $::joined($nick)}]"
  	puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration [expr {[clock seconds] - $::joined($nick)}]] ago" 
    }
  } else { 
     putbot Blacky "join $nick 0"
  }
}
Find below the code for Blacky (with this info he clears first his times and then adds in his parameters the uptimes of the users (info passed from bot1):

Code: Select all

bind bot - "clear" procbot_clear
proc procbot_clear {from-bot command arg} {
catch {unset ::joined}
}

bind bot - "join" procbot_join
proc procbot_join {from-bot command arg} {
puthelp "PRIVMSG #controlchan :Bot1 has sent me the following information:" 
foreach {nick ago} $arg break
set ::joined($nick) [expr { [clock seconds] - $ago } ]
puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration { $::joined($nick) } ] ago" 
}
But i'm having the following problems:
1/ When Blacky joins #channel, i get the following error in telnet:
Tcl error [joinproc]: invalid command name "}"
What could be the problem? i checked all the }, but didn't find any too much.
2/ Additionally, once all the times are sent from bot1 to Blacky, i don't see the msg in #controlchan sent by Blacky:
$nick has already joined as of [duration { $::joined($nick) } ] ago
Does this mean that it's not triggered with the word "join" coming from bot1 ? Is the structure for putbot not correct? Or is the trigger script from Blacky not correct?

Thanks in advance.

Buffy
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

have you tried using ".set errorInfo" on partyline to get a more detailed error? it should tell you the construct within the error occured. The message sounds like a bracet error, but script highlighting doesnt find any open or to many closed, either.
really strange. You dont need to use :: when the variable is already "global ..." and you can use [unixtime] instead of [clock seconds], but I cannot imaging one of these would cause such an error ;).

On the other bot you have used foreach a bit strange, id rather use something like this:

Code: Select all

foreach "nick ago" $arg {
  set ::joined($nick) [expr { [unixtime] - $ago } ]
  puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration  $::joined($nick)] ago"
}
this might at least fix your problem regarding the control channel.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Most of the time what this basically means is:

Code: Select all

Tcl error [joinproc]: invalid command name "}"
You have an extra closing curly bracket "}" some where in your procedure. Count the total number of opening and closing braces make sure they are equal.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi,

I tried to check with '.set errorInfo' in partyline but without luck. When i typed in the partyline: '.set errorInfo' i got : What? You need '.help'
After this i tried to put in my bot1 script after 'global joined' :
set errorInfo
and made my bot Blacky rejoin and then typed in partyline .set errorInfo but still same : What? You need '.help'

Am i doing something wrong to be able to check the error? (to get more structured details about this error)

Additionally,
I tried with the new "foreach" part in Blacky's script, but couldn't see the msg's in #controlchan.
I suppose that when bot1 sends with 'putbot Blacky "join $nick [expr {[clock seconds] - $::joined($nick)}]" i should engage a trigger at Blacky and so he can confirm his info in #controlchan, right?
Is there a way to see if this trigger "join" is good reciept by Blacky? Maybe there is already an error?

Thanks.

Buffy
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

awyeah,

I counted those brackets several times, and always i got the same openings as same closings.
I even tried to remove some parts of the script to be sure, but even with that i'm still getting this error :(

I don't understand and kind of lost.

Buffy
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For the .tcl set errorInfo you should read some posts in this thread.

http://forum.egghelp.org/viewtopic.php?t=9096
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Buffy_25 wrote:When i typed in the partyline: '.set errorInfo' i got : What? You need '.help'
#unbind dcc n tcl *dcc:tcl
#unbind dcc n set *dcc:set
.. then .rehash your bot.

As for your error, try reconstructing your first foreach loop; it appears that is where your error is.
Last edited by Alchera on Mon Feb 07, 2005 8:59 am, edited 1 time in total.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Code: Select all

foreach {nick ago} $arg {
  set ::joined($nick) [expr ([unixtime] - $ago)]
  puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration  $::joined($nick)] ago"
}
Hmmm... interesting... don't find any logical error in here whatsoever.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

The first foreach loop looks to be the problem, not the second.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You mean this one?

Code: Select all

   foreach nick [chanlist #channel] {
      if {![info exists ::joined($nick)]} {
       set ::joined($nick) [getchanjoin $nick #channel]
      }
This also looks fine.
Just dont use these curly braces for anything other than opening closing new statements and conditions in a procedure.

This should be:

Code: Select all

putbot Blacky "join $nick [expr {[clock seconds] - $::joined($nick)}]" 
Like this:

Code: Select all

putbot Blacky "join $nick [expr ([clock seconds] - $::joined($nick))]"
You should remove all of these and fix them throughout your procedure.

As Alchera said maybe you had to put a "}" after this line

Code: Select all

putbot Blacky "join $nick [expr {[clock seconds] - $::joined($nick)}]"
Because otherwise your foreach loop 2 in the end would be embedded in your foreach loop 1. Meaning a loop running within a loop and somewhere causing a problem.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Try changing:

Code: Select all

set ::joined($nick) [getchanjoin $nick #channel]
to

Code: Select all

set ::joined($nick) [getchanjoin $nick "#channel"]
I just noticed it.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

just as note, I don't have problems with {} within an [expr ] command. I use this line really fine:

Code: Select all

[expr {$kataschaden - pow(1.20, $i)}]
in a for loop.

But triiing will make wise :).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hey your comments are messing things up... delete those lines instead of just adding a #. At least, that worked for me.
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

stdragon,
Thnx so much ! It's working great (no fault anymore) :D

Thnx for all the help guys!

Buffy
Locked