Something explained me SpiKe^^ in another post, but it was referred to a list, which added nicks.
Now is another case, I store every nick on a separate line of a file.
I don't know fix it for this particular case a file.
example:
!notiadd {juan}
Returns first line of file (prohibidos.txt) {juan}
!notiadd pedro
Returns second line of file (prohibidos.txt) pedro
Code: Select all
bind pub at|n !notiadd notiadd
proc notiadd {nick uhost handle chan text} {
set nickpro [lindex $text 0]
if {![file exist prohibidos.txt]} {
set fs [open prohibidos.txt "w"]
puts $fs ""
close $fs
} else {
set fname "prohibidos.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
set first [lindex $lines 0]
if {$first == ""} {
set lines [lreplace $lines 0 0]
set fp [open $fname "w"]
puts $fp [join $lines "\n"]
close $fp
}
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines1 [split $data "\n"]
if {([lsearch -exact [string tolower $lines1] [string tolower $nickpro]] == -1)} {
set fp [open $fname "a"]
puts $fp $nickpro
close $fp
putmsg $canal_admin [encoding convertfrom utf-8 "\002$nickpro\002 has been added to the list of banned nicks."]
} else {
putmsg $canal_admin [encoding convertfrom utf-8 "$nickpro was already added!"]
return
}
}}