Code: Select all
# Set the path and filename of text file to read
set file2read "you/need/to/edit/this/path/file_to_read.txt"
bind pub - "!readfile" readfile
proc readfile {nick uhost handle chan text} {
global file2read
if {![file exists $file2read]} {
putserv "privmsg $chan :Sorry, $file2read does not exist"
} else {
set fname "$file2read"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
if {[lsearch -exact -nocase -inline -all -index 0 $lines $text] != ""} {
putserv "privmsg $chan :[join [lsearch -exact -nocase -inline -all -index 0 $lines $text]]"
} else {
putserv "privmsg $chan :Sorry, $text not found"
}
}
}
putlog "Please see: http://forum.egghelp.org/viewtopic.php?t=18428"
# ref: http://forum.egghelp.org/viewtopic.php?t=6885
# http://www.tcl.tk/man/tcl8.5/TclCmd/lsearch.htm
In channel with bot, do:
!readfile Ted
for example, and bot will reply in the channel.
Tested briefly. It worked.
Am not saying that I thought of every possibility when testing.
There are probably lots of things that could be done, to improve it.
So it will be interesting to see what else gets posted here.
I hope this helps. You seemed like you just wanted a rough idea, to get you started. That's all this is.