egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unmatched open brace in list
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Fri Jun 22, 2007 5:33 am    Post subject: unmatched open brace in list Reply with quote

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

Code:

putserv "KICK $chan $nick :$reason"


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

Many thanks before. Smile
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri Jun 22, 2007 9:11 am    Post subject: Reply with quote

How to write eggdrop scripts that won't choke on special characters
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Fri Jun 22, 2007 8:36 pm    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jun 22, 2007 8:49 pm    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Fri Jun 22, 2007 11:23 pm    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jun 23, 2007 5:00 am    Post subject: Reply with quote

That's because you're passing a string instead of a list to [timer]. Replace:
Code:
timer 3 "unset jn_msg_done($nick:$chan)"

with
Code:
timer 3 [list unset jn_msg_done($nick:$chan)]

And remove the [filt $nick] line it's not necessary.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Sat Jun 23, 2007 5:51 am    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jun 23, 2007 5:08 pm    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Sat Jun 23, 2007 10:13 pm    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Jun 24, 2007 8:10 am    Post subject: Reply with quote

[string tolower $badwords] is not a list, what is $badwords?
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Mon Jun 25, 2007 8:43 pm    Post subject: Reply with quote

badwords - [censored] fukker asshole
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jun 26, 2007 12:39 am    Post subject: Reply with quote

I mean it's a list right?
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Tue Jun 26, 2007 12:56 am    Post subject: Reply with quote

Yes, it's alist of badwords for nick and swearing text
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jun 26, 2007 6:35 am    Post subject: Reply with quote

Code:
foreach x $badwords {
 if {[string match -nocase *$x* $nick]} {
  set bannick($nick) "$nick!*@*"
  putserv "KICK $chan $nick :Badword detected"
  break
 }
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Tue Jun 26, 2007 10:16 pm    Post subject: Reply with quote

this's proc for ban/kick badnick
Code:

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:

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 Sad

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

i think with that code will return like this:

if {[matchattr $cflag B]} { badnick_chk {asshole $uhost $hand $chan }
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber