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.

Kicking nicknames with brackets in them

Old posts that have not been replied to for several years.
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Kicking nicknames with brackets in them

Post by Aron »

My bot seems to be having problems kicking nicknames that start with {}. It the brackets are at the end of the nickname, there is no problem , though.

I have already read the guide to write scripts that dont choke on characters, but i really don't see what i am doing wrong.

This is the error:

Code: Select all

[08:08] Tcl error [academy:kick]: list element in braces followed by "test" instead of space
I used a nickname "{}test", so that is what the error is talking about.

This is the variable that holds the nickname:

Code: Select all

set nickhost [join [lindex [split $text] 0]]
...and this is the kick command:

Code: Select all

putkick $chan $nickhost $reason
What am i doing wrong here?

Thanks in advance.
The best way to start learning is to start helping.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i am not sur what u mean by braces what is it example i is it " or [] {}

bind to join then check if $nick matches \[ \] \{ \} \" ...


if {[string match "\[" "$nick"] || [string match ..]} {
...
}
XplaiN but think of me as stupid
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Kicking nicknames with brackets in them

Post by user »

AsoAron wrote:

Code: Select all

set nickhost [join [lindex [split $text] 0]]
Don't 'join' the string returned by 'lindex' and everything should be fine :)
Have you ever read "The Manual"?
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

i already tried that, but it gives the same error.

Im now auto-kicking everyone who has brackets at the start of their nickname, but there must be another way :(
The best way to start learning is to start helping.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

AsoAron wrote:i already tried that, but it gives the same error.
Then the error must be some where else in your proc (or a proc called from within it)
Have you ever read "The Manual"?
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

here is my kick procedure:

Code: Select all

## The kick command ##

proc academy:kick {nick host handle chan text} { 
  global botnick guardmethod 

 if {(![authed $handle])} {return 0}
  if {$chan != "#jedi-academy"} {return 0}

  set userlevel [level $handle]
  set reason [lrange $text 1 end]

  if {$reason == ""} {
    set reason "requested by $nick"
  }
  
  set nickhost [lindex [split $text] 0]

  if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { return 0 } 

  if {$nickhost == "me"} {
    set nickhost $nick
    set reason "$nick is a poopoohead!"
  }
    
  if {[botisop $chan]} {
    if {[string tolower $botnick] != [string tolower $nickhost]} {  
      putkick $chan $nickhost $reason
    } else {
        putserv "NOTICE $nick :Stop messing around..."
    }
  } else {
      putserv "NOTICE $nick :I'm not opped in $chan!"
  }
}
The best way to start learning is to start helping.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You should split the $reason variable in the first place like:

Code: Select all

set reason [lrange [split $text] 1 end]
Instead of:

Code: Select all

if {$chan != "#jedi-academy"} {return 0 }
with:

Code: Select all

if {![string equal -nocase $chan "#jedi-academy"]} { return 0 }
instead of:

Code: Select all

if {$nickhost == "me"} { 
change to:

Code: Select all

if {[string equal -nocase $nickhost "me"]} {
and:

Code: Select all

if {[string tolower $botnick] != [string tolower $nickhost]} {
to:

Code: Select all

if {![string equal -nocase $botnick $nickhost]} {
Also, you can *join* this two checks:

Code: Select all

if {(![authed $handle])} {return 0} 
  if {$chan != "#jedi-academy"} {return 0} 
to something like:

Code: Select all

if {(![authed $handle]) || ![string equal -nocase $chan "#jedi-academy"]} { return 0 }
Once the game is over, the king and the pawn go back in the same box.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

lrange returns a (sub)list, and from my understanding, $reason is supposed to be a string... as such you need to apply the join tcl command to the result to make it into a proper string.
User avatar
Souperman
Halfop
Posts: 69
Joined: Sat Feb 02, 2002 8:00 pm
Location: Cape Town, South Africa
Contact:

Post by Souperman »

strikelight wrote:lrange returns a (sub)list, and from my understanding, $reason is supposed to be a string... as such you need to apply the join tcl command to the result to make it into a proper string.
Yup, you also have to [split] it before using [lrange] on it, like caesar says.
Quick! Somebody get me a new ink cartridge
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Souperman wrote:
strikelight wrote:lrange returns a (sub)list, and from my understanding, $reason is supposed to be a string... as such you need to apply the join tcl command to the result to make it into a proper string.
Yup, you also have to [split] it before using [lrange] on it, like caesar says.
Right, however my response was in fact a reply to caesar's post.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Umm.. actualy no, it's an string.. umm. To be honest I haven't understood completly your response..
Once the game is over, the king and the pawn go back in the same box.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

caesar wrote:Umm.. actualy no, it's an string.. umm. To be honest I haven't understood completly your response..
No caesar... lrange returns a list....

from the TCL Manpages for lrange:
This command will return a new list consisting of elements first through last, inclusive.
Hence, the need for "join".
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

After a lil discution on irc with strikelight and Souperman and thinked a lil bit at that thing I've realised that strikelight was right, so the correct and best solution is [join [lrange [split $text] 1 end]]. Thanks for clearing that out strikelight, ow you one :P

/me dose 20 hail mary's to be forgiven :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

Code: Select all

proc academy:kick {nick host handle chan text} { 
  global botnick guardmethod 

  if {(![authed $handle]) || ![string equal -nocase $chan "#jedi-academy"]} { return 0 }
  set userlevel [level $handle]
  set reason [join [lrange [split $text] 1 end]]

  if {$reason == ""} {
    set reason "requested by $nick"
  }
  
  set nickhost [join [lindex [split $text] 0]]

  if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { return 0 } 

if {[string equal -nocase $nickhost "me"]} { 
    set nickhost $nick
    set reason "$nick is a poopoohead!"
  }
    
  if {[botisop $chan]} {
  if {![string equal -nocase $botnick $nickhost]} { 
      putkick $chan $nickhost $reason
    } else {
        putserv "NOTICE $nick :Stop messing around..."
    }
  } else {
      putserv "NOTICE $nick :I'm not opped in $chan!"
  }
}

proc lastban_check {nick uhost hand chan mode victim } {
 global lastbanned
  if {[lindex $mode 0] == "+b"} {
   set lastbanned($chan) $victim
   }  
}
changed the code. Still the same error.

"[16:57] Tcl error [academy:kick]: list element in braces followed by "testing" instead of space"

The nick i tried to kick was {}testing
The best way to start learning is to start helping.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

read my first post
Have you ever read "The Manual"?
Locked