usually you use split, in your case probably you need after definition.
set cv_bannednicks [split cv_bannednicks \n]
however, this will retain all white spaces, so maybe you should make your list like:
set cv_bannednicks {firsttag
[tag2]
{tag3}
$tag4$
lasttag}
btw. you dont need to use "", if you use split on \n.
ps: you should use [string match -nocase *$s* $nick] instead of lsearch, because $nick isnt supposed to be a list... however it is a string as it is, if you used [split $nick], you would change it into a 1 element list.
set tcl_precision 2
set percent [expr $cv_banned/$cv_count*100.00]
putserv "PRIVMSG $chan :Banned $cv_banned hosts out of $cv_count clients ($percent%).
That snippet is showing the following text in channel:
Banned 40 hosts out of 457 clients (0.0%).
set mylist {
"element1"
"element2"
"element3"
"element4"
"element5"
}
#and then do the matching:
foreach element $mylist {
if {[string match -nocase *$element* $nick]} {
#do your stuff
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee) PS: Guys, I don't accept script helps or requests personally anymore.
==================================
that worked fine. So I'm concerned after reading: http://www.peterre.com/characters.html that my script may fail with some nicks. Using nicks like "[die]" could be real problematic without using list to escape the special characters.
its not brainsurgery, store everything in lists (split), so you wont get any problems with special chars or [commands], then when doing matches or server outputs, convert it back to a string (join).
Solarin wrote:that worked fine. So I'm concerned after reading: http://www.peterre.com/characters.html that my script may fail with some nicks. Using nicks like "[die]" could be real problematic without using list to escape the special characters.
after 'set cv_bannednicks [split $cv_bannednicks \n]' a 'foreach s $cv_bannednicks' won't break on special characters, because split already did everything you have to worry about (the only 2 commands you would have worry would be "eval" and "expr", but you use neither of them )
remember, in your usage $s and $nick are strings, so its best you compare them via string match.
set percent 0
set tcl_precision 2
set percent [expr $cv_banned / $cv_count * 100.00]
putserv "PRIVMSG $chan :Banned $cv_banned hosts out of $cv_count clients ($percent%).
That snippet is showing the following text in channel:
Banned 40 hosts out of 457 clients (0.0%).
Sorry... that was meant to be cv_banned instead of cv_klined for consistency sake.
with a version of XDCC Catcher Basic, $tempversionnumber is 8 not 7 (which is "xdcc" not "xdcc catcher basic"). This indicates that spaces in the element of $cv_bannedversions are making it choke up.
Furthermore, De Kus, the nick SeXy_BeBuLs_16 was banned with this code instead of nicks with [xxx] in them (so any nick with x in it will be banned):
the list is proccessed smoothly here using your code (with putdcc 7 "$tempversionnumber: $s" after the incr invoaction).
for the nick thing... strange. from the code you posted it doesnt make sense at all. *[xxx]* cant match SeXy_BeBuLs_16. you accidently used join on a string while setting the nick (lindex returns a string, lrange returns a list ^^), but i doubt that was the problem.
same goes with my intention of using split \n
.loadtcl test
firsttag
[tag2]
{tag3}
$tag4$
lasttag