i need a script that read every 3 mins line from a file and send it to me in a privmsg.
something like this:
timer 3 "privmsg jag :line 1"
and after 3 mins it will do:
timer 3 "privmsg jag :line 2"
and after 3 mins it will do:
timer 3 "privmsg jag :line 3"
and after 3 mins it will do:
timer 3 "privmsg jag :line 4"
somebody can help me with that please?
Where are you stuck and what happens when you reach the end of the file?
EDIT: I was bored...
Usage is pretty much explained by the variable names except for 'pos' which is the byte position when we last read from the file (not used when you start a new "slowmsg")
This proc doesn't care about nick changes, quitting etc., so if you need that, you've got some coding to do It doesn't care if you call it multiple times with the same nick/file as arguments either ...which might become annoying if you .rehash alot and have a call to this proc that is executed every time
Jag wrote:Thanks a lot, but.... how can i do that when it get to the end of the file, it will go back to the start?
Start a new timer with 0 as the last parameter or call the proc from within itself (make sure your file is not empty if you do this ) instead of doing that putlog.
Jag wrote:EDIT: can you build it in "bind time" please?
10x
I _can_ but you don't provide enough info and I'm not always bored. Do you need it to work with multiple users/files? How are you planning to use this? Why did you change your mind about using 'timer'? Here's something to get you started:
proc slowmsg {file {pos 0}} {
set f [open $file]
seek $f $pos
if {[gets $f line]>-1} {
putserv "privmsg #Jag $line"
timer 3 [list slowmsg $file [tell $f]]
} {
}
close $f
}
slowmsg "news.txt"
And it's works fine.
But, how can i do that when it get to the end of the file, it will go back to the start (go again from the first line to the end of the file) ?
And when i do a lot of '.rehash' it starts a lot of timers because the:
Jag wrote:
But, how can i do that when it get to the end of the file, it will go back to the start (go again from the first line to the end of the file) ?