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.

Problem on switch of strings

Old posts that have not been replied to for several years.
Locked
H
HecKel
Voice
Posts: 23
Joined: Wed Jan 19, 2005 3:50 pm
Location: Lisbon, Portugal

Problem on switch of strings

Post by HecKel »

I have a code similar this one:

Code: Select all

proc add_new {n u h c args} {
  set args [lindex $args 0]
  set args [split $args " "]  
  switch [lindex $args 0] {
	"friend" {
			adduser [lindex $args 1] "[lindex $args 1]!*@*"
			chattr [finduser "[lindex $args 1]!*@*"] "+f" $c
		}
	"op" {
			adduser [lindex $args 1] "[lindex $args 1]!*@*"
			chattr [finduser "[lindex $args 1]!*@*"] "+o" $c
		}
	"voice" {
			adduser [lindex $args 1] "[lindex $args 1]!*@*"
			chattr [finduser "[lindex $args 1]!*@*"] "+v" $c
		}
(...)
  }
I already try to view the [lindex $args 0] by notice and the value is correct, but nothing happens on the switch..., btw, the egg return this error
[02:32] Tcl error [add_new]: extra characters after close-quote
tnks, HecKel
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

type

Code: Select all

.tcl errorInfo
after you get that error on the bot for more specific information.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

You have a misplaced quotation mark, change

Code: Select all

[finduser "[lindex $args 1]!*@*"]
to

Code: Select all

[finduser "[lindex $args 1]!*@*]"
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Re: Problem on switch of strings

Post by Sir_Fz »

try

Code: Select all

proc add_new {n u h c arg} {
  set arg [split $arg]
  set cmd [lindex $arg 0]
  switch -- $cmd {
	"friend" {
			adduser [lindex $arg 1] "[lindex $arg 1]!*@*"
			chattr "[finduser [lindex $arg 1]!*@*]" "+f" $c
		}
	"op" {
			adduser [lindex $arg 1] "[lindex $args 1]!*@*"
			chattr "[finduser [lindex $arg 1]!*@*]" "+o" $c
		}
	"voice" {
			adduser [lindex $arg 1] "[lindex $arg 1]!*@*"
			chattr "[finduser [lindex $args 1]!*@*]" "+v" $c
		}
(...)
 }
all quotes seem correct here, the error might be from another switch in the proc.
H
HecKel
Voice
Posts: 23
Joined: Wed Jan 19, 2005 3:50 pm
Location: Lisbon, Portugal

Post by HecKel »

this is the full code, the same error, the same results....

Code: Select all

proc add_new {n u h c args} {
  set found 0
  set args [split [lindex $args 0]]
  set cmd [lindex $args 0]  
  set user [lindex $args 1]
  set c [string tolower $c]
  set chans [string tolower $::chans]
  if {[lsearch -exact $chans $c] != -1} {
	makelog $n ".addnew"
	global newflags
	set h "$n!*@*"
	set exflags $newflags
	if { [matchattr [finduser $h] "X" $c] } {
		switch -- $cmd {
		"friend" {
			if{$user == ""} {
				puthelp "NOTICE $n :Command: .addnew friend <nick>"
			} else {
				set found 1
				set newop $user
				set newhost "$newop!*@*"
				set utype "friend"
				set exflags "-jmnptxAGX+fo|-mnACGNVX+foF"
			}
		}
		"little" {
			if {[[matchattr [finduser $h] "V" $c] || [matchattr [finduser $h] "A" $c]]} {
				if{$user == ""} {
					puthelp "NOTICE $n :Command: .addnew little <nick>"
				} else {
					set found 2
					set newop $user
					set newhost "$newop!*@*"
					set utype "little"
					set exflags "-jmnptxAGX+fo|-mnACGNVX+foCX"
					set acclevel 5
				}
			} { puthelp "NOTICE $n :You can't do this command"}
		}
		"medium" {
			if { [matchattr [finduser $h] "A" $c] } {
				if{$user == ""} {
					puthelp "NOTICE $n :Command: .addnew medium <nick>"
				} else {
					set found 2
					set newop $user
					set newhost "$newop!*@*"
					set utype "medium"
					set exflags "-jmnptxAGX+fo|-mnACGNVX+foVX"
					set acclevel 10
				}
			} { puthelp "NOTICE $n :You can't do this command"}
		}	
		"admin" {
			if {[matchattr [finduser $h] "G" $c]} {
				if{$user == ""} {
					puthelp "NOTICE $n :Command: .addnew admin <nick>"
				} else {
					set found 2
					set newop $user
					set newhost "$newop!*@*"
					set utype "admin"
					set exflags "-jmnptxAGX+fo|-nACGNVX+fmoANVX"
					set acclevel 12
				}
			} { puthelp "NOTICE $n :You can't do this command"}
		}
		"gadmin" {
			if {[matchattr [finduser $h] "G" $c]} {
				if{$user == ""} {
					puthelp "NOTICE $n :Command: .addnew admin <nick>"
				} else {
					set found 1
					set newop $user
					set newhost "$newop!*@*"
					set utype "gadmin"
					set exflags "+fhjmnoptxAGX|+flmnoAGNVX"
					putserv "NOTICE $n :REMEMBER: I can't add user to access list!"
				}
			} { puthelp "NOTICE $n :You can't do this command"}
		}
		default { puthelp "NOTICE $n :Command: \002.addnew <friend|little|medium|admin|gadmin>"}
		}
	} { puthelp "NOTICE $n :You can't do this command"}
	if {$found > 0} {
		if {[validuser $newop] == 1} {
			if {[lsearch [getuser $newop hosts] $newhost] == "-1"} {
				putserv "NOTICE $n :$newop isn't on bd, adding..."
				if{$found == 2} {
					putserv "CHANSERV ACCESS $c ADD $newop $acclevel"
				}
				chattr $newop $exflags $c
				setuser $newop hosts $newhost
				return 1
			} {
				putserv "NOTICE $n :$newop is on bd, changing flags..."
				if{$found == 2} {
					putserv "CHANSERV ACCESS $c ADD $newop $acclevel"
				}
				chattr $newop $exflags $c
				return 1 
			}
		}  
		if {[finduser $newhost] != "*"} { 
			putserv "NOTICE $n :$newop\[$newhost\] is [finduser $newhost]"
			if{$found == 2} {
				putserv "CHANSERV ACCESS $c ADD $newop $acclevel"
			}
			chattr [finduser $newhost] $exflags $c
			return 1
		} {
			if{$found == 2} {
				putserv "CHANSERV ACCESS $c ADD $newop $acclevel"
			}
			adduser $newop $newhost
			chattr [finduser $newhost] $exflags $c
			return 1
		}
		if {[chattr $newop $exflags $c] == "*"} {
			putserv "NOTICE $n :Error adding flags to $newop."
			return 1
		}
		save
	}
  }
}
tnks, Heckel
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

^DooM^ wrote:type

Code: Select all

.tcl errorInfo
after you get that error on the bot for more specific information.
try

Code: Select all

.set errorInfo
instead cause errorInfo is a variable not a command
XplaiN but think of me as stupid
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

or .tcl set errorInfo
Locked