Guest User

Untitled

a guest
Aug 23rd, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.87 KB | None | 0 0
  1. proc toastertxt {nick uhost handle chan text} {
  2.  
  3.  
  4.  
  5. # File name to read.
  6. set fname "scripts/myscripts/iliketoast.txt"
  7.  
  8. # Open file for read access (note we're not catching errors, you might
  9. # want to use catch {} if the file might not exist.
  10. set fp [open $fname "r"]
  11.  
  12. # Here we read in all of the data.
  13. set data [read -nonewline $fp]
  14.  
  15. # Close the file, since we're done reading.
  16. close $fp
  17.  
  18. # Now we split the data into lines.
  19. set lines [split $data "\n"]
  20.  
  21.  
  22. # Use the code from above (1.) to read in all the lines from the file.
  23. # We continue right after: set lines [split $data "\n"]
  24.  
  25. # Get the number of lines.
  26. set numlines [llength $lines]
  27.  
  28. # Choose a random line with eggdrop's rand function.
  29. set num [rand $numlines]
  30.  
  31. # Get the line from the list!
  32. set randline [lindex $lines $num]
  33.  
  34.  
  35. putserv "privmsg #Dangerbot : $randline "
  36.  
  37.  
  38.    }
Add Comment
Please, Sign In to add comment