The first column is serial number, next path to the file, third description and fourth the size.
I need a script which would read this file and privmsg it to the nick that requested it.
If somebody msg my channel with !cfg.et i want him to get the list of files with .ET on the end of the description. Similar with !cfg.q4 - Q4 and !cfg.q3 Q3 and others.
Hmmm it doesn't seems to work ok.
When i put !cfg on chan it gives me that its invalid - thats ok.
But when i put !cfg ET it gives nothing.
My file.db looks like this:
set text [split [string toupper $text]]
and
foreach line $cfgdata {
if {[lindex [split $line /] 3] == "$text"} {
puthelp "PRIVMSG $nick :CFG Match $line"
}
}
set text [string toupper $text]
set text [split $text]
and
foreach line $cfgdata {
set cfgtmp [split $line /];set cfgtmp [string toupper [lindex $cfgtmp 3]]
if {$cgftmp == "$text"} {
puthelp "PRIVMSG $nick :CFG Match $line"
}
}
foreach line $cfgdata {
set cfgtmp [split $line /];set cfgtmp [string toupper [lindex $cfgtmp 3]]
set cfgnametmp [split $line /];set cfgnametmp [lindex $cfgnametmp 4]]
then puthelp $cfgnametmp instead of $line.
If you want a linecount then before the foreach put 'set lineno 0' and inside the foreach after the "if" test to see if the filename matches, put 'incr lineno' and then in the puthelp output, use puthelp "PRIVMSG $nick :$lineno $cfgnametmp"
#USAGE: !cfg <cfgname> where <cfgname> is one of ET Q3 Q4, etc.
set mycfgfile "/home/zielik/shared/filesrv/xdcc/xdcc.pack"
# set this to the valid cfg names to make checking user's input easier
set validcfgnames "ET Q3 Q4 CS CSS WSW"
bind pub - !cfg cfgproc
proc cfgproc {nick uhost hand chan text} {
global mycfgfile validcfgnames
set text [string toupper $text]
set text [split $text]
if {[lsearch -exact $validcfgnames $text] == -1} {
puthelp "notice $nick :Invalid config filename. Valid names are $validcfgnames"
return
}
if {[file exists $mycfgfile]} {
set input [open $mycfgfile r]
set cfgdata "[split [read $input] \n]"
catch {close $mycfgfile}
foreach line $cfgdata {
set cfgtmp [split $line /];set cfgtmp [string toupper [lindex $cfgtmp 3]]
if {$cfgtmp == $text} {
puthelp "PRIVMSG $nick :CFG Match $line"
} else {
puthelp "notice $nick :no cfg file found!"
}
}
}
}
It's just not recognizing it because of the upper/lower case, so you can either use lowercase, it use the [string toupper] command seperately to uppercase the 'ET' part of the filename, eg: