I have a script that reads a txt file and displays the results in my channel on efnet.
The script is a !bnc script, that gets current bnc ip's from that txt file.
The script works fine now, except I need 2 things added to it. ;O)
1) I need it to only work in 1 channel
2) it needs to read lines till the end of file, now its just setup to read 6 lines
...and the file length will vary depending on how many bncs are up at any given time.
If you could PLEASE help me add this bit, I would appreciate it very much !!!
Here is the tcl now:
# Set this to the filename
set dvs_ccbnc_filename "/glftpd/ftp-data/misc/bnclist.msg"
bind pub -|- !ccbnc dvs_ccbnc_pub:spitlines
proc dvs_ccbnc_pub:spitlines {nick uhost hand chan text} {
global dvs_ccbnc_filename
set fileid [dvs_func:openfile $dvs_ccbnc_filename]
if {$fileid == ""} then {
puthelp "NOTICE $nick :Unable to open file for reading."
return 0
}
while {![eof $fileid]} {
gets $fileid line
puthelp "NOTICE $nick :$line"
}
close $fileid
switch -- $mode
read - r {
set m r
} write - w {
set m w
} append - a {
set m a
}
if {$m == "r" && (![file exists $file] || ![file readable $file]) || ($m == "w" || $m == "a") && ![file writable $file] || [catch {set fileid [open $file $m]}]} then {
catch {
# I don't know how the hell it would be possible for $fileid to exist at this point..
if {[info exists fileid]} then {
# But I'm still insane enough to check if it does
close $fileid
}
}
return ""
}
if {$binary} then {
fconfigure $fileid -encoding binary -translation binary
}
return $fileid
}
As for reading only 6 lines, I don't see why. The code sugests that it shoudl read till the end, but you claim it only reads 6 lines. You could paste the exact (with secuity changes, but keep it as original as possible) file, as it may montain some nasty suprises.
[00:58] can't read "chan": no such variable
while executing
"string tolower $chan"
(file "scripts/ccbnc.tcl" line 6)
invoked from within
"source scripts/ccbnc.tcl"
(file "aiplan9" line 1088)
[00:58] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
I will get you the txt file (edited) later today, but what would cause this error above ??