set spamnicks [split [read -nonewline [open $spnfile]] "\n"]
close [open $spnfile]
foreach spamnick $spamnicks {
if {[string match -nocase $spamnick $nick]} {
## action
}
}
to see if the joined nick matches any of the nicks in the file, but it gave an error, my guess is that the spamnicks are not in a list like { "nick1" "nick2" "..." }, so can anyone give me a better method ?
set f [open "search.txt" r]
while {[gets $f spamnick]>-1} {
if {[string match -nocase $nick $spamnick]} {
# we have a match here
}
}
close $f
# search complete.. nothing found
Once the game is over, the king and the pawn go back in the same box.
set spamnicks [split [read -nonewline [open $spnfile]] "\n"]
close [open $spnfile]
foreach spamnick $spamnicks {
if {[string match -nocase $spamnick $nick]} {
## action
}
}
to see if the joined nick matches any of the nicks in the file, but it gave an error, my guess is that the spamnicks are not in a list like { "nick1" "nick2" "..." }, so can anyone give me a better method ?
The main problem I see with this, is that you are not closing the file you opened when you read in the data from file.... What you did is open another instance of the file just to be closed.
yeah, I realized that anyway caesar's way worked and looks better.
as for adding nicks into the file by a dcc command, I did open file r to read and open file a to write into it, isn't there a way to add both a and r into the same var like set f [open $file ar] (but this didn't work)
may I also ask for, how can I remove the nick from a file ? what's the command for removing the specified arg from the file if it exists ?
Last edited by Sir_Fz on Thu Nov 06, 2003 5:16 pm, edited 1 time in total.
As for your second question, just read and save all the stuff in an variable then by using the lsearch and lreplace just remove them from there and then save the contenst of the variable in to the file.
Once the game is over, the king and the pawn go back in the same box.
proc add:spamnick {hand idx arg} {
global spnfile
set af [open "$spnfile" a+]
while {[gets $af spnick]>-1} {
if {![string match -nocase $spnick $arg]} {
puts $af [split $arg]
putlog "Added [split $arg] into $spnfile"
return 0
}
}
close $af
putlog "\002[split $arg]\002 already exists in SPNICKS-list"
}
this adds the nick several times in the script, and when I remove the nicks from the script and try to add them again using the dcc coomand, it tells me that the nick already exists.
strange, when I do set af [open $spnfile a+] the bot always says that the nick already exists... but when I put 2 sets (a and r) on separate lines it works with the adding.
But I'm not able to remove using a command... anyone ?
proc add:spamnick {hand idx arg} {
global spnfile
# opening with a+ will set the initial access position to the end of the file...
set af [open "$spnfile" a+]
# ...meaning the body of this while loop will never get executed
# but if you'd add "seek $af 0" before the loop things would be different :)
while {[gets $af spnick]>-1} {
# now 'spnick' contains one line read from the file...
# Are you sure 'string match' is what you want? Does your file contain masks?
if {![string match -nocase $spnick $arg]} {
# when you reach this point you have no idea about the rest of the file
# ...just the last line read from it...then you proceed to overwrite the
# existing data at the next line (if any) because you forget to move the
# access position to the end...
puts $af [split $arg]
putlog "Added [split $arg] into $spnfile"
# you sure did :P
return 0
# oops..forgot to close the file :)
}
}
close $af
putlog "\002[split $arg]\002 already exists in SPNICKS-list"
}
set f [open "search.txt" r]
while {[gets $f spamnick]>-1} {
if {[string match -nocase $nick $spamnick]} {
# we have a match here
}
}
close $f
# search complete.. nothing found
how if i want in search.txt i put the host ex *!*@*.net