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 in chanlist with nick char

Old posts that have not been replied to for several years.
Locked
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

problem in chanlist with nick char

Post by Careto »

I have one problem with chanlist:

Code: Select all

bind join - "#canal *" topics
proc topics {nick uhost hand chan} {
if {[string equal -nocase $chan "$chan"]} {
set file [open pruebanick w]
set cuentame [chanlist $chan]
regsub -all "{" $cuentame "" cuentame
regsub -all "}" $cuentame "" cuentame
puts $file "$cuentame"
set op 0
set voice 0
set normal 0
putserv "notice $nick :Topic: [lrange [topic $chan] 0 end]"
putserv "notice $nick :Total de Usuarios: [llength [chanlist $chan]]"
putserv "notice $nick :Modos del canal: [lindex [getchanmode $chan] 0]"
foreach user [chanlist $chan] {
    if {[isop $user $chan]} {
      incr op
    } elseif {[isvoice $user $chan]} {
      incr voice
    } else { incr normal }
  }
putserv "notice $nick :Total de Op: $op - Total Voice: $voice - Total Normales: $normal"
}
close $file
}

bind part - "#canal *" partes
proc partes {nick uhost hand chan reason} {
if {$reason == ""} {
if {[string equal -nocase $chan "$chan"]} {
set file [open pruebanick w]
set cuentame [chanlist $chan]
regsub -all $nick $cuentame "" cuentame
set prueba [lsort -increasing -dictionary $cuentame]
puts $file "$prueba"
}
close $file
}
}
the problem is, in $file chanlist, if nick is [^__^] or |-XXX-|, when copying itself in the file it appears {[^__^]}, in the bind join this corrected with:

Code: Select all

regsub -all "{" $cuentame "" cuentame
regsub -all "}" $cuentame "" cuentame
But in the bind part, not remove $nick with char "[] {} | |".
thanks
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

There is no need to be using regsub..
Your problem is with trying to use lists as strings...

for example... you use "lrange" to return a LIST, which will escape/protect special character elements...
To convert to a string you must use the [join] command....

ie. Topic: [join [lrange yer-normal-stuff-here]]

And when writing your variable "prueba" and "cuentame" to file, they are lists,
if you want to write it as a string, you must again, use [join]...

ie. puts $file "[join $prueba]"
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

Post by Careto »

Thanks strikelight

The list of nick appears to me all good, with nicks correct with

Code: Select all

puts $file "[join $$prueba]"

But now not like doing, that in part it clears to nick that it leaves the channel, of the list and sees the others nicks.
IE. In Join: [^__^] atest axe
In part: (if list leaves the channel [^__^]): atest axe

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

Post by stdragon »

You can search the list with lsearch and remove the nick you want with lreplace, for part. For join, you can add the nick you want with lappend.
Locked