This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
neoclust
Halfop
Posts: 55 Joined: Fri Aug 14, 2009 11:03 am
Post
by neoclust » Sun Apr 11, 2010 10:52 am
I have a file called bd.dat containing "x" lines, how to read a one line of randomly thanks
raider2k
Op
Posts: 140 Joined: Tue Jan 01, 2008 10:42 am
Post
by raider2k » Sun Apr 11, 2010 12:41 pm
after you read all of a files content into a list:
Code: Select all
set output [lindex $filecontent [rand [llength $filecontent]]]
putserv "PRIVMSG $channel :$output"
should do the trick, at least did it for me
neoclust
Halfop
Posts: 55 Joined: Fri Aug 14, 2009 11:03 am
Post
by neoclust » Sun Apr 11, 2010 4:15 pm
i'm using this proc
Code: Select all
proc readfile {min hour day month year} {
global filenews
foreach chan [channels] {
if {[channel get $chan randnews]} {
set file [open $filenews r]
set data [read $file]
close $file
set lines [split $data \n]
set randline [lindex $lines [rand [llength $lines]]]
putserv "PRIVMSG $chan :$randline"
}
}
}
Thanks