hello, looking for a script then when typing !count filename it will count the number of lines of the filename (the file will be in scripts/ folder)
i.e.
!count Work.txt
<Bot> there are 14 lines in scripts\work.txt
Code: Select all
bind pub -|- !count count:numoflines
proc count:numoflines {nick host hand chan text} {
set fname [lindex [split $text] 0]
set loc "scripts"
#check file exists
if {![file exists $loc/$fname]} {
puthelp "PRIVMSG $chan :$loc/$fname does not exist.";return
}
#open file and count the lines
set file [open $loc/$fname "r"]
set nol 0
while {[gets $file line] >= 0} {
incr nol
}
close $file
#msg the channel
putserv "privmsg $chan :there are $nol lines in $loc/$fname"
}