proc quote:pub:quote {nick uhost hand chan arg} {
global quotefile quotevianotice
set quotes ""
if { [file exists $quotefile] } { set file [open $quotefile r]
} else {
if { $quotevianotice == 0 } { putmsg $chan "$quotefile does not exist. You'll need to add quotes to the database first by typing \002!addquote <a quote>\002" }
if { $quotevianotice == 1 } { putnotc $nick "$quotefile does not exist. You'll need to add quotes to the database first by typing \002!addquote <a quote>\002" }
return 0
}
while { ![eof $file] } {
set quote [gets $file]
if { $quote != "" } {
set quotes [linsert $quotes end $quote]
}
}
close $file
if { $arg != "" } {
set pattern [string tolower $arg]
set aquotes ""
set quote ""
foreach quote $quotes {
set lowquote [string tolower $quote]
if { [string match $pattern $lowquote] } {
set aquotes [linsert $aquotes end $quote]
}
set quotes ""
set quotes $aquotes
}
}
set row [rand [llength $quotes]]
if { [expr $row >= 0] && [expr $row < [llength $quotes]] } {
set quote [lindex $quotes $row]
}
if { $quote != "" } {
if { $quotevianotice == 0 } {
putmsg $chan " Quote: $quote"
}
if { $quotevianotice == 1 } {
putnotc $nick "$quote"
}
}
return 1
}
simply add this proc to read quote.txt file...
proc Quote_Read {file} {
if {[file exists $file] && [file readable $file]} then {
set FILE [open $file r]
set READ [read -nonewline $FILE]
close $FILE
return $READ
}
return 0
}
#Now to read it in your code
#use this:
#set path of the file:
set quotes [Quote_Read /home/path/Quotes.txt]
#Now get the quotes using foreach loop.
foreach myquote [split $quotes \n] {