It doesn't screw the list. Very likely, it is the way you retrieve the nicks from the list which is screwed up. If you use the correct list functions on your list, the nicks will be retrieved correctly.caesar wrote:I'm using an lappend next(list) $nick to add them in the list. With the normal nick works smoothly, when a nick has an }, - or other like this this screws the list. What can I do?
Code: Select all
# next list
set next(list) {}
# flag
set next(flag) "n"
# messages
set next(welcome) "Hi! Welcome to \002!chan!\002 channel. Please wait for your turn as we are busy right now. You will be voiced automaticly when we finish with the current guests."
# binds
bind join - * next:add
bind pub $next(flag) .list next:list
# join
proc next:add {nick uhost handle chan} {
global botnick next
if {$nick == $botnick || $chan != $next(chan)} { return }
if {[botisop $chan] && [validuser [nick2hand $nick $chan]]} { putserv "MODE $chan +v $nick" ; return }
lappend next(list) $nick; set num [lsearch -exact $next(list) $nick]; incr num
regsub -all {!chan!} $next(welcome) "$chan" next(welcome)
putserv "NOTICE $nick :$next(welcome) You are number \002$num\002 in line. Thank you!" }
# list
proc next:list {nick uhost handle chan arg} {
global next
if {$chan != $next(chan)} { return }
if {$next(list) == ""} { putserv "NOTICE $nick :List is curently empty."; return }
putserv "NOTICE $nick :\002List\002: $next(list)"; return }
In return, I've put an example below to see with your own eyes. Save it to a file and run it through the "tclsh file.tcl".caesar wrote: [snip]... I'll put under this the join part to see with your own eyes this ... [snip]
Code: Select all
# Prepare a string containing a "}"
set string bar}
# Convert the string to a list:
set nicklist [split $string]
# After the split we now have a list. Print the list.
puts $nicklist
# Print each nick in the list.
# Note that foreach is a list function, it operates on a list.
foreach nick $nicklist {
puts $nick
}
Code: Select all
# list
proc next:list {nick uhost handle chan arg} {
global next
if {$chan != $next(chan)} { return }
if {$next(list) == ""} { putserv "NOTICE $nick :List is curently empty."; return }
# HINT HINT HINT HINT HINT HINT HINT
putserv "NOTICE $nick :\002List\002: $next(list)"; return }
Caesar, take a close look at the following and reflect it on the script and what ppslim said.caesar wrote:ppslim : Excuse me? What you meen with that regsub that isn't beeng used in the welcome notice? Take a closer look, it's used when a user joins the channel.
Code: Select all
set variable hello
puts "BEFORE: $variable"
proc dosomething { } {
global variable
regsub {hello} $variable world variable
puts "Regsub done!"
}
dosomething
puts "AFTER: $variable"
ppslim has stated explicitely and exactly the problem. Actually you will not notice the problem, because your script only works for one channel.caesar wrote:I still havent got the point. What you meen? Please be more specific cos I really don't understand what you two are tryng to explain to me about that regsub. I've used it in the next(welcome) !chan! and I've regsub it to put instead the !chan! to put $chan. What is the mistake and please point me the real problem with the nick. Thanks for your time and support.
Code: Select all
set next(welcome) "Hi! Welcome to \002!chan!\002 channel. Please wait for your turn as we are busy right now. You will be voiced automaticly when we finish with the current guests."
Code: Select all
global botnick next
Code: Select all
regsub -all {!chan!} $next(welcome) "$chan" next(welcome)
Code: Select all
regsub -all -- {!chan} $var $chan var
putserv "PRIVMSG BLAH :$var rest of message"
Code: Select all
regsub -all -- {!chan} $var $chan var2
putserv "PRIVMSG BLAH :$var2 rest of message"