| View previous topic :: View next topic |
| Author |
Message |
whittinghamj Op
Joined: 21 May 2006 Posts: 103
|
Posted: Tue Jun 20, 2006 1:34 am Post subject: random line from txt file |
|
|
Hey guys. I have a script request. I just looked over the forums but could not put my hands on a post that covers this already.
Anyways. I have a text file which is formatted like this.
| Code: |
Name: info URL: www.url.com
[quote]
What i need is someone to type say !sites and the script goes off and picks randomy a line from the txt file and pastes it to the channel.
No security needed and I am adding the sites already by trigger.
Any help would be great.
Thanks[/quote] |
|
|
| Back to top |
|
 |
SaPrOuZy Halfop

Joined: 24 Mar 2004 Posts: 75 Location: Lebanon
|
Posted: Wed Jun 21, 2006 2:49 pm Post subject: |
|
|
| Code: |
bind pub - !foo bar
proc bar {nick uhost hand chan rest} {
set file [open "txt_file_path" r]
set data [split [read $file] "\n"]
set line [lindex $data [rand [llength $data]]]
putserv "privmsg $chan : $line"
close $file
}
|
EDIT: Code fixed, thx Sir_Fz
Last edited by SaPrOuZy on Thu Jun 22, 2006 1:50 am; edited 1 time in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
|