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.

{}'s in nick cause tcl error...

Help for those learning Tcl or writing their own scripts.
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

{}'s in nick cause tcl error...

Post by WulfMan72 »

I'm having an issue with nicks that have {}'s in them

an example of the problem comes from nicks like "{nick}X"

I used:

Code: Select all

set who [lindex [split $args] 0]
but whenever the nick follows the format listed above, I get the error:
Tcl error [kick]: list element in braces followed by "X" instead of space

is there a way to set the nick as a variable and not get this error?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

use arg instead of args because args has a special use in Tcl.
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

hmmmm tried that Fz, same results, still getting the tcl error.

I'm using a winegg "eggdrop1.6.17"

dunno if that makes a difference, but it also doesn't seem to like the "read" command :?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Show us the code.
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

Code: Select all

bind pub f kick, kick
proc kick {nick host hand chan arg} {
  set who [lindex [split $arg] 0]
  set reason [lrange $arg 1 end]
    if {![onchan $who $chan]} {
      putchan $chan "$who is not in the channel" 
    } else {
   if {[botisop $chan]} {putkick $chan $who $reason}
  }
return 0
}
this code is working for all nicks accept ones with the {}'s in them
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Although this shouldn't happen (I tested it with a dcc command), try

Code: Select all

set who [string map {\{ \\\{ \} \\\}} $who]
after setting who [lindex [split $arg] 0].
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

tried that, same error :(

here's the revised code just to make sure I did it right:

Code: Select all

bind pub f kick, kick
proc kick {nick host hand chan arg} {
  set who [lindex [split $arg] 0]
  set who [string map {\{ \\\{ \} \\\}} $who]
  set reason [lrange $arg 1 end]
    if {![onchan $who $chan]} {
      putchan $chan "$who is not in the channel" 
    } else {
   if {[botisop $chan]} {putkick $chan $who $reason}
  }
return 0
}
and error message again:
[17:55] Tcl error [kick]: list element in braces followed by "B" instead of space
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Just noticed

Code: Select all

set reason [lrange $arg 1 end]
should be

Code: Select all

set reason [join [lrange [split $arg] 1 end]]
Also, show us what .set errorInfo returns to know exactly where the error occurs.
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

ok, updated the line for setting the reason variable, and tried to do the .set errorinfo, this is what I got:

#Wulf# set errorinfo
Error: can't read "errorinfo": no such variable
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Capital I, errorInfo.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

From eggdrop.conf:
# 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
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

ok, I shut the bot down completely and restarted it, went to test it again, and now I'm not getting a tcl error, but I'm getting this in the channel as the bots output:

\{nickname\}X is not in the channel

here's the code as it stands now:

Code: Select all

bind pub f kick, kick
proc kick {nick host hand chan arg} {
  set who [lindex [split $arg] 0]
  set who [string map {\{ \\\{ \} \\\}} $who]
  set reason [join [lrange [split $arg] 1 end]]
    if {![onchan $who $chan]} {
      putchan $chan "$who is not in the channel" 
    } else {
   if {[botisop $chan]} {putkick $chan $who $reason}
  }
return 0
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You can remove the 2nd 'set who...'
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

ahhhhhh perfect, that worked!!!
ty much Fz, I really appreciate the help :)
User avatar
BarkerJr
Op
Posts: 104
Joined: Sun Mar 30, 2003 1:25 am
Contact:

Post by BarkerJr »

So, it was all due to forgetting to convert a list to a string before using it as a string?
Post Reply