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 Errors - Quotation Marks

Old posts that have not been replied to for several years.
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Tcl Errors - Quotation Marks

Post by mike-c »

Hi,

I have asked about this in many places, but so far nobody has provided an answer.

I'm running a modified version of lamer.tcl by cmouse ( http://help.quakenet.org/files/lamer.tar.gz ), and I get this error (yes, it happens in the original as well, not just my version).

Code: Select all

Tcl error [handle_lamer]: list element in quotes followed by "," instead of space
I have also had this one:

Code: Select all

Tcl error [handle_lamer]: unmatched open quote in list
I know what the problem is, but I have no idea now to fix it. I've played a little but nothing worked.

The error is only shown in newer tcl versions from what I can gather, and it happens when they type a line containing a " mark.

If their line contains a quotation mark,

Code: Select all

proc handle_lamer {nick keyword text}
reads something like:

Code: Select all

YourNick!something something #chan this is a quote "quotes", with a comma afterwards
I'm not quite sure what the $nick and $keyword variables are for this proc, but i know the quotes are messing up the 'lindex' operation on $text.

so do I need to replace " with \" ? If so how?

If you have any ideas, I'd appreciate them.

Cheers,

Mike
T
TomSommer

Post by TomSommer »

the function subst might work in this case
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is due to using list commands on string (IE, not converting the string to a list first).

I don't have any of my normal tools on this system (like winzip, or unix files editors), so I can't produce a fix for you yet.

I will look into it on monday.
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

Hi,

Just wondering if there are any further thoughts on this...

Due the increasing number of lame mIRC scripts being used in the channels I 'patrol', I'm getting tougher with the scripts I use.

Unfortunately, it seems these new scripts people are using feature a lot of quotation, and of course, if this error occurs, then the anti-spam functions that follow do not happen.

This script is great, apart from this 1 problem.

Cheers,

Mike
T
TomSommer

Post by TomSommer »

Tell me about it

This might help http://forum.egghelp.org/viewtopic.php?t=2445

use [split $text] when using list functions on strings
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Find places that say lindex $text 1, and change it to lindex [split $text] 1
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

Hi,

Thanks for your replies... I think the method suggested (split) is already in place...

Code: Select all

proc handle_lamer {nick keyword text} {

    set text [join $text]
    set nick [split $nick !]
    set nick [lindex $nick 0]
    set text [split $text]
    set chan [lindex $text 0]
    set text [lrange $text 1 end]
I'll have a read through that other thread, and see if I can find a solution there.

Cheers,

Mike
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Just delete the line that says [join $text]
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

Hi,

I removed the line

Code: Select all

set text [join $text]
and now the script doesn't do anything... it's as though it's not even loaded :cry:

Thanks for your ideas.

Cheers,

Mike
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Eh who knows, it's hard to say without all the code involved. You shouldn't do [join $text] unless $text has already been split in the past. I'm sure you would have included that if it had been, so removing that line was the correct thing to do. If it makes the script break, the error ie elsewhere.
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Still no solution...

Post by mike-c »

Ok, I've been playing with this for months now, and the TCL FAQ entry on the main forum page reminded me of it... Here is the full code I have. I would really appreciate it if someone could offer a solution.

Code: Select all

bind raw -|- "NOTICE" handle_lamer
bind raw -|- "PRIVMSG" handle_lamer

# Ban time for kickban
set flood_time 60

# Percentage of CAPS allowed in string (0 - 1)
set capsp 0.8

# Percentage of !?!?! characters allowed in string (0 - 1)
set screamp 0.5

# Allowed color/control code count (0=not allowed at all)
set numcolor 0

global lamers

proc del_floodvars {key} {
    global lamers
    array get lamers
    catch {unset lamers($key!wt)}
    catch {unset lamers($key!w2)}
    catch {unset lamers($key!w3)}
    return 0
}


proc handle_lamer {nick keyword text} {
    set text [join $text]
    global lamers flood_time capsp screamp numcolor
    set nick [split $nick !]
    set nick [lindex $nick 0]
    set text [split $text]
    set chan [lindex $text 0]
    if {![validchan $chan]} { return 0 }
    if {([isop $nick $chan])||([nick2hand $nick]!="*")} { return 0 }
    set text [lrange $text 1 end]
    set n [md5 $nick]
    set screams [regexp -all -- {[!,?]} $text]
    set caps [regexp -all -- {[A-Z,Å,Ä,Ö]} $text] 
    set colors [regexp -all -- "\003" $text]
    incr colors [regexp -all -- "\026" $text]
    incr colors [regexp -all -- "\033" $text]
    set strlen [string length $text]
    set retval 0
    if {![info exists lamers($n!wt)]} {
	set lamers($n!wt) [md5 $text]
	set lamers($n!w2) 1
	utimer $flood_time "del_floodvars $n"
	if {($colors>$numcolor)||(([expr $caps/$strlen.0]>$capsp)||([expr $screams/$strlen.0]>$screamp)&&($strlen>3))} {
	    set lamers($n!w3) 1
	    putserv "NOTICE $nick :Colours, control codes, and excess CAPS are forbidden" -next
	} else {
	    set lamers($n!w3) 0
	}
    } else {
        if {[utimerexists "del_floodvars $n"]==""} { utimer $flood_time "del_floodvars $n" }
	if {$lamers($n!wt)==[md5 $text]} {
	    set lc $lamers($n!w2)
	    incr lc
	    set lamers($n!w2) $lc
	    if {$lc==2} {
		putserv "NOTICE $nick :Please do not repeat" -next
	    } elseif {$lc==3} {
		putserv "KICK $chan $nick :Do not repeat - Final Warning" -next
		set retval 1
	    } elseif {$lc>3} {
		newchanban $chan [maskhost [getchanhost $nick $chan]] "Sentinel" "Repetition warnings ignored, banned."
		putserv "KICK $chan $nick :Repeating is not allowed" -next
		putserv "MODE $chan +b [maskhost [getchanhost $nick $chan]]" -next
		set retval 1
	    }
	} else {
	    set lamers($n!wt) [md5 $text]
	    set lamers($n!w2) 1
	}
	if {($colors>$numcolor)||(([expr $caps/$strlen.0]>$capsp)||([expr $screams/$strlen.0]>$screamp)&&($strlen>3))} {
            set lc $lamers($n!w3)
            incr lc
            set lamers($n!w3) $lc
            if {$lc==2} {
                putserv "KICK $chan $nick :Colours, control codes, and excess CAPS are forbidden - Final Warning" -next
		set retval 1
            } elseif {$lc>2} {
                newchanban $chan [maskhost [getchanhost $nick $chan]] "Sentinel" "Colours, control codes, and excess CAPS are forbidden"
                putserv "KICK $chan $nick :Colours/control codes/CAPS warning ignored, banned." -next
                putserv "MODE $chan +b [maskhost [getchanhost $nick $chan]]" -next
		set retval 1
	    }
	}
    }
    return $retval
}

Thanks,

Mike
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

Umm, just try to escape unnececery quotes by removing the first line in handle_lamer that goes [join $text] blah.. and replace it with

regsub -all \" $text \\" text

I haven't tried putting it in the script myself but it should help.
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

Nope, I still get the same error......

Code: Select all

foo "bar", foobar
causes

Code: Select all

Tcl error [handle_lamer]: list element in quotes followed by "," instead of space
This is really annoying me :cry:

Cheers,

Mike
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Ok delete the first line (set text [join $text]) and change "set text [lrange $text 1 end]" to "set text [join [lrange $text 1 end]]"

Also, when you're looking at errors, it's helpful if you type ".tcl putlog $errorInfo" right after the error. Then include that output in your post.
m
mike-c
Voice
Posts: 20
Joined: Thu Jul 25, 2002 3:40 pm

Post by mike-c »

Ok, I replaced that line, and it still errors. Here is the output of '.tcl putlog $errorInfo'...

Code: Select all

list element in quotes followed by "," instead of space
    while executing
"join $text"
    (procedure "handle_lamer" line 2)
    invoked from within
"handle_lamer $_raw1 $_raw2 $_raw3"
Tcl: 
I hope this is of some use.

Cheers,

Mike
Locked