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.

very simple random script

Old posts that have not been replied to for several years.
Locked
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

very simple random script

Post by Pitchat »

Hi ,

I`ve look at the tutorial on how to work with files but i still can`t get my simple script to work ( maybe it is too simple and i do something wrong)

here`s what i want to do

and a trigger like !random i want my eggdrop to read a random line in a file call random.txt and say it on channel

that`s all

thank for any help like always
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

if ![catch {set f [open file.txt]}] {
  while {![eof $f]} {lappend t [gets $f]}
  bind pub - !random foo; close $f
}
proc foo {n u h c t} {
  puthelp "privmsg $c :[lindex $::t [rand [llength $::t]]]"
}
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

Post by Pitchat »

works perfectly thanks a lot !
Locked