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.

Reading from .txt file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
Burke-1
Voice
Posts: 1
Joined: Wed Mar 28, 2012 2:22 pm

Reading from .txt file

Post by Burke-1 »

Code: Select all

set sex "./sex.txt"

bind pub - !sex sex:msg

proc sex:msg {nick uhost hand chan arg} {
  global sex
  set sexmsg [string range [randomline $sex] 0 end]
  puthelp "privmsg $chan :$sexmsg"
}

proc randomline f {
 set data [split [read [set file [open $f]]][close $file] \n]
 set position [rand [llength $data]]
 lindex $data $position
}
is there a way this can be modified, so it will keep track of which lines from the sex.txt have been used, and not repeat those until all lines have been used ?
Post Reply