Tag Archives: eggdrop

Simple eggdrop script – random quotes

Simple eggdrop tcl script to return random movie quotes from a file. I haven’t fully tested this, it’s partially copied from a working script with some stuff removed that isn’t necessary.  Posted because someone was asking how it worked in the IRC channel.

#create the bind to allow the !movie (and aliases) to get a quote
bind pub - "!movie" myscript::quotes::movie
bind pub - "!film" myscript::quotes::movie
bind pub - "!quote" myscript::quotes::movie

namespace eval myscript {

variable version "0.4"

# file with the quotes, must be in the same directory as the script
variable quotefile "quotes.txt"

proc randline {file} {
  if {[catch {open scripts/$file r} fs]} {
    putlog "Failed to open scripts/$file"
    return ""
  } else {
    variable data [read -nonewline $fs]
    close $fs
    variable data [split $data \n]
    return [lindex $data [rand [llength $data]]]

namespace eval quotes {
  proc movie {nick uhost hand chan text} {
    variable aquote [myscript::randline $myscript::quotefile]
    puthelp "privmsg $chan :$myscript::quotes::aquote"
    return 0

putlog "Loaded: MyScript v$myscript::version"