egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

random line from txt file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
whittinghamj
Op


Joined: 21 May 2006
Posts: 103

PostPosted: Tue Jun 20, 2006 1:34 am    Post subject: random line from txt file Reply with quote

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
View user's profile Send private message
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Wed Jun 21, 2006 2:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Jun 21, 2006 7:15 pm    Post subject: Reply with quote

And don't forget to close the file.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber