This is an idea I had to create a quote bot that pulls a random quote from the site quotationspage.com. I started out using a txt file, then thought about using sockets to pull from the site as an unlimited quote resource. Or, moreso than a txt file. It's pretty cool.
Usage:
Make sure you're using the lastest version of mIRC.
Load the script into your bot.
Use !quote to trigger a random quote.
<%MaxEvans> !quote
<@[Jack]> "The reward of one duty is the power to fulfill another. " - George Eliot (1819 - 1880)
<%MaxEvans> !quote
<@[Jack]> "Honesty may be the best policy, but it's important to remember that apparently, by elimination, dishonesty is the second-best policy. " - George Carlin (1937 - 2008)
Thanks to Scakk for helping with the code.
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return %x }
alias quotation {
if (!$sock(quotationspage)) {
sockopen quotationspage www.quotationspage.com 80
set %quotechan $chan
}
}
on *:sockopen:quotationspage: {
sockwrite -n $sockname GET /random.php3 HTTP/2.0
sockwrite -n $sockname Host: www.quotationspage.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:quotationspage: {
sockread %quotationspage
if (<dt class="quote"> isin %quotationspage) {
set %quote %quotationspage
}
}
on *:sockclose:quotationspage: {
set %author $htmlfree($gettok(%quote,19-,62))
.msg %quotechan $qt($remove($htmlfree(%quote),%author)) - %author
unset %quot* %author
}
on *:TEXT:!quote:#: {
quotation
}
Ah, you've finally got it working. :)
Nice to see that you've changed /quote to /quotation instead.
<@null> "You ask me why I do not write something....I think one's feelings waste themselves in words, they ought all to be distilled into actions and into actions which bring results. " - Florence Nightingale (1820 - 1910), in Cecil Woodham-Smith, Florence Nightingale, 1951 - More quotations on: [Writing] [Actions]
For some of the quotes, I get > More quotations on: [Writing] [Actions] [Passion]. etc. Do you want to keep those in? (I think they were originally hyperlinks, on the site.)
Should be /unset %quot than /unset %quote. :X
Otherwise, good work MaxEvans.
/me rates 7.0