View previous topic :: View next topic |
Author |
Message |
Careto Voice
Joined: 02 Mar 2004 Posts: 11
|
Posted: Tue Mar 02, 2004 1:56 pm Post subject: problem in chanlist with nick char |
|
|
I have one problem with chanlist:
Code: | 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: |
regsub -all "{" $cuentame "" cuentame
regsub -all "}" $cuentame "" cuentame
|
But in the bind part, not remove $nick with char "[] {} | |".
thanks |
|
Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Tue Mar 02, 2004 2:01 pm Post subject: |
|
|
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]" |
|
Back to top |
|
 |
Careto Voice
Joined: 02 Mar 2004 Posts: 11
|
Posted: Tue Mar 02, 2004 6:04 pm Post subject: |
|
|
Thanks strikelight
The list of nick appears to me all good, with nicks correct with
Code: | 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. |
|
Back to top |
|
 |
stdragon Owner

Joined: 23 Sep 2001 Posts: 959
|
Posted: Tue Mar 02, 2004 6:28 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
|