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.

unmatched open brace in list

Help for those learning Tcl or writing their own scripts.
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

unmatched open brace in list

Post by Reynaldo »

any idea how to kick the nick with special character like {,},[,],\

Code: Select all

putserv "KICK $chan $nick :$reason"

will return error: Tcl error procname: unmatched open brace in list.

Many thanks before. :)
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Code: Select all

proc filt {data} {
regsub -all -- \\\\ $data \\\\\\\\ data
regsub -all -- \\\[ $data \\\\\[ data
regsub -all -- \\\] $data \\\\\] data
regsub -all -- \\\} $data \\\\\} data
regsub -all -- \\\{ $data \\\\\{ data
regsub -all -- \\\" $data \\\\\" data
return $data
}
Thanks bro.

Here's another one:
Can we replace "putquick" command with "pushmode" command ?
because i worry if it will make it slower.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

pushmode is for modes and not for kicks. Your problem is with using lists and strings, it's not recommended to solve it using regexp filtering.
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Code: Select all

bind join - * do_jn_msg
proc do_jn_msg {nick uhost hand chan} {
  global botnick jn_msg_done
  set nick [filt $nick]
  if {$nick == "X" || $nick == $botnick} {
    return 0
  }
  if {[info exists jn_msg_done($nick:$chan)]} {
    return 0
  }
  set jn_msg_done($nick:$chan) 1
  timer 3 "unset jn_msg_done($nick:$chan)"
  puthelp "NOTICE $nick :Welcome to $chan"
  return 0
}
Tcl error [do_jn_msg]: unmatched open brace in list

$nick join with special character will return that error.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That's because you're passing a string instead of a list to [timer]. Replace:

Code: Select all

timer 3 "unset jn_msg_done($nick:$chan)"
with

Code: Select all

timer 3 [list unset jn_msg_done($nick:$chan)]
And remove the [filt $nick] line it's not necessary.
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Code: Select all

bind join - * do_jn_msg 
proc do_jn_msg {nick uhost hand chan} { 
  global botnick jn_msg_done 
    if {$nick == "X" || $nick == $botnick} { 
    return 0 
  } 
  if {[info exists jn_msg_done($nick:$chan)]} { 
    return 0 
  } 
  set jn_msg_done($nick:$chan) 1 
  timer 3 [list unset jn_msg_done($nick:$chan)]
  puthelp "NOTICE $nick :Welcome to $chan" 
  return 0 
} 

Tcl error [do_jn_msg]: unmatched open brace in list

still error, it happen when user with special character joined. like {user or }user or \user.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The code I gave you must not give such an error. Did you rehash after loading it? Also, a full errorInfo (.set errorInfo) is much more helpful.
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Code: Select all

foreach x [string tolower $badwords] {
if {[string match "*$x*" [string tolower $nick]]} {
set bannick($nick) "$nick!*@*"
putserv "KICK $chan $nick :Badword detected"
}
added that lines, will return the error. when user with special character joining channel.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

[string tolower $badwords] is not a list, what is $badwords?
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

badwords - [censored] fukker asshole
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I mean it's a list right?
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Yes, it's alist of badwords for nick and swearing text
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

foreach x $badwords {
 if {[string match -nocase *$x* $nick]} {
  set bannick($nick) "$nick!*@*"
  putserv "KICK $chan $nick :Badword detected"
  break
 }
}
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

this's proc for ban/kick badnick

Code: Select all

proc badnick_chk {nick uhost hand chan} {
global bannick notc botnick badwords
foreach x $badwords {
if {[string match -nocase *$x* $nick]} {
set bannick($nick) "$nick!*@*"
putsrv "KICK $chan $nick :Badnick match from [string toupper $x]"
return 1
}
}
return 0
}

i'm using channel flag: here's the code if badnick is enabled on specific channel

Code: Select all

if {[matchattr $cflag B]} { badnick_chk $nick $uhost $hand $chan }
then return tcl error: unmatched open brace in list

if $nick with special character joined :(

* {asshole (~user@host) has joined #

i think with that code will return like this:

if {[matchattr $cflag B]} { badnick_chk {asshole $uhost $hand $chan }
Post Reply