Random Quote Eggdrop Script

By FordLawnmower on Dec 01, 2009

Requested script.
Script gets a random quote from www.quotedb.com and returns it to the channel. Trigger is !quote.
You can change the command char to what ever you want on line 2. -->> set quote_cmdchar "!"

Example Output:
20:18:32 !quote
20:18:33 A truly great book should be read in youth again in maturity and once more in old age as a fine building should be seen by morning light at noon and by moonlight. by Robertson Davies

#Random Quote Script by Ford_Lawnmower irc.mindforge.org #USA-Chat
set quote_cmdchar "!"
bind pub - [string trimleft $quote_cmdchar]quote randomquote
proc randomquote {nick host hand chan args} {
  set site "www.quotedb.com"
  set url "/quote/quote.php?action=random_quote&=&=&"
  set QuoteResult ""
  if {[catch {set QuoteSock [socket -async $site 80]} sockerr]} {
    putserv "PRIVMSG $chan :$site $url $sockerr error"
    return 0
    } else {
    puts $QuoteSock "GET $url HTTP/1.0"
    puts $QuoteSock "Host: $site"
    puts $QuoteSock ""
    flush $QuoteSock
    while {![eof $QuoteSock]} {
      set QuoteVar " [gets $QuoteSock] "
      if {[regexp {document\.write\('(.*)'} $QuoteVar match QuoteResult]} {
        regsub -all {\<.*\>} $QuoteResult "" QuoteResult
      } 
      if {[regexp {authors\/.*">(.*)<\/a><\/i>'\);} $QuoteVar match QuoteAuthor]} {
        putserv "PRIVMSG $chan :\0037$QuoteResult - \0034by $QuoteAuthor"
        break
      }
    }
    close $QuoteSock
    return 0 
  }
}

Comments

Sign in to comment.
play4free2   -  Sep 17, 2013

Nice work Ford, I added a chanset to it and it works good. One of these days I will learn to write tcl LOL. About all I have ever written was mirc code.

 Respond  
Get_A_Fix   -  May 01, 2010

nice ;)

I did mine a little different though - here

 Respond  
FordLawnmower   -  Jan 06, 2010

Thanks GuitarMasterx7 :)

Junga  -  Aug 19, 2013

MR. Ford I get a error cannot found varialble $QuoteResult

FordLawnmower  -  Aug 20, 2013

@Junga Updated and working now

Sign in to comment

GuitarMasterx7   -  Jan 06, 2010

its a FORD lawnmower =D.
very nice work i like it alot o.O

 Respond  
SnoooP   -  Dec 20, 2009

You move fast for a Lawnmower lol...

 Respond  
FordLawnmower   -  Dec 20, 2009

mIRC version is here -->> http://www.hawkee.com/snippet/7043/

 Respond  
FordLawnmower   -  Dec 20, 2009

@yna I'll post a mIRC version a little later today.

 Respond  
SnoooP   -  Dec 20, 2009

yna: search the mirc snippet section, there are quite a few random quote snippets about.

 Respond  
yna   -  Dec 20, 2009

is it possible to get this script in mirc code please? :P

 Respond  
FordLawnmower   -  Dec 07, 2009

Thanks SnoooP :)

 Respond  
SnoooP   -  Dec 07, 2009

Thanks FordLawnmower, I needed one of these.. :D works nice, does it's job :)

 Respond  
FordLawnmower   -  Dec 02, 2009

No worries JDavis. Thanks for the comments :)

 Respond  
JDavis   -  Dec 02, 2009

kk. my bad.. i meant as a random posting bot i guess.. thx for the come back Ford.. much respect to you..

 Respond  
FordLawnmower   -  Dec 02, 2009

@JDavis An eggdrop is already a bot. This is just a Script that you load for the Bot to use.

 Respond  
JDavis   -  Dec 02, 2009

could it be made as random quotes bot?? i'd change my avatar, but it is actually the way i look.. rofl

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.