Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc toastertxt {nick uhost handle chan text} {
- # File name to read.
- set fname "scripts/myscripts/iliketoast.txt"
- # Open file for read access (note we're not catching errors, you might
- # want to use catch {} if the file might not exist.
- set fp [open $fname "r"]
- # Here we read in all of the data.
- set data [read -nonewline $fp]
- # Close the file, since we're done reading.
- close $fp
- # Now we split the data into lines.
- set lines [split $data "\n"]
- # Use the code from above (1.) to read in all the lines from the file.
- # We continue right after: set lines [split $data "\n"]
- # Get the number of lines.
- set numlines [llength $lines]
- # Choose a random line with eggdrop's rand function.
- set num [rand $numlines]
- # Get the line from the list!
- set randline [lindex $lines $num]
- putserv "privmsg #Dangerbot : $randline "
- }
Add Comment
Please, Sign In to add comment