I have a problem in a script that matches nicks joining channels with nicks in a file, if 1 is returned the bot will kick the nick. I'm using string match -nocase $nick-from-file $nick but if the nick contains [ or ] in it, tcl considers it a command. Is there any way to fix this ?
thanks user for pointing that out. you said "Use 'string equal'" in your post there but it does the same thing on nicks containing such characters. I would use ==, but I want to use wildcards such as * and ? in matching.
Sir_Fz wrote:thanks user for pointing that out. you said "Use 'string equal'" in your post there but it does the same thing on nicks containing such characters. I would use ==, but I want to use wildcards such as * and ? in matching.
The brackets doesn't trigger command substitution when used in a mask passed to 'string match' or as one of the strings being compared using 'string equal'. What exactly are you doing? You might also want to check the manual page for string match (to know what chars are special so you know what to escape in your masks)
I've tested string qual using .tcl command in partyline, for example .tcl string equal -nocase [nick1] [Nick1] it returns "Tcl error: invalid command name "nick1"". the pattern here would be the nick from the file (I use foreach to get each nick from the file) and the string would be the nick joining the channel, would string equal be the solution ?
Last edited by Sir_Fz on Wed Dec 03, 2003 4:18 pm, edited 1 time in total.
Sir_Fz wrote:I've tested string qual using .tcl command in partyline, for example .tcl string equal -nocase [nick1] [Nick1] it returns "Tcl error: invalid command name "nick1"". the pattern here would be the nick from the file (I use foreach to get each nick from the file) and the string would be the nick joining the channel, would string equal be the solution ?
The line you run using .tcl in your eggdrop is evaluated and variable/command/backslash substitution is done. (escaping is needed if you don't want this to happen)
Text recieved from irc/read from a file and put in a variable is not evaluated. (no escaping needed)
'string equal' is just a simple char by char comparison of the strings (optional -nocase), so if you want the match chars * and ? to work you better use 'string match' and escape the special chars you don't want to work using 'regsub' or 'string map'.