Random Quote Generator

By Kirby on Dec 08, 2008

My first snippet using sockets! :D
Thanks to ^Neptune who taught me how.
This snippet allows you to msg your active channel a random quote from http://smacie.com/, from four popular characters, Homer and Bart Simpson, Borat, and Cartman from South Park.

Syntax: /quote <homer,bart,borat,cartman> (choose only one person without <>'s!)

Here's a picture:
Image

Enjoy! :D

alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) | return %x }
alias smacie { if (!$sock($1)) && ($istok(Homer Bart Borat Cartman,$1,32)) { sockopen $1 www.smacie.com 80 } | else { echo -a $+(,$me,,:,) You must supply a valid parameter of whose quote you want. (Choose from Homer, Bart, Borat, or Cartman). Syntax: /smacie <person> } }
on *:sockopen:*: { if ($istok(Homer Bart Borat Cartman,$sockname,32)) { sockwrite -n $sockname GET /randomizer/ $+ $iif($sockname == homer,simpsons/homer.html,$iif($sockname == bart,simpsons/bart.html,$iif($sockname == cartman,southpark/cartman.html,borat.html))) HTTP/1.0 | sockwrite -n $sockname Host: www.smacie.com $+ $crlf $+ $crlf } }
on *:sockread:*: { if ($istok(Homer Bart Borat Cartman,$sockname,32)) { if ($sockerr) { echo -a * There was a problem retrieving data from the website. Please try again. } | else { sockread %smacie | if (<title> isin %smacie) { sockmark $sockname $htmlfree($remove(%smacie,random,quote)) } | if (<td valign="top"><big><big><big><font face="Comic Sans MS"> isin %smacie) { msg $active $+($chr(34),$htmlfree(%smacie),$chr(34)) - $sock($sockname).mark | unset %smacie } } } }

Comments

Sign in to comment.
Kirby   -  Feb 26, 2009

Updated. There is only one variable used now (for sockread).

 Respond  
Kirby   -  Feb 12, 2009

shouldnt the variable already be set in the snippet itself. and why do WE have to set it, when the writer of the snippet should of done it him/her self, and i also got the same messege as well

I changed it so that you don't have to do a single thing but just do:

/smacie <person>

.
I just realized /quote is a separate command.

As for the > i also got the same messege as well, you have to choose one person from the four possible people:

/smacie homer
/smacie bart
/smacie borat
/smacie cartman

I don't see how you get "error" messages.

 Respond  
Blitzjager   -  Feb 12, 2009

It does get set fire. :P

 Respond  
fire_wizard1   -  Feb 12, 2009

shouldnt the variable already be set in the snippet itself. and why do WE have to set it, when the writer of the snippet should of done it him/her self, and i also got the same messege as well

 Respond  
Kirby   -  Dec 30, 2008

This was just my first test with sockets. Don't know why I posted this. :P

 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.