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!)
Enjoy! :D
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | 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 } } } }
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.