What The Fuck Should I Make For Dinner?

By hxck
Platform:  mIRC
Published  Oct 28, 2011
Updated  Oct 31, 2011
This is a quick socket snippet to the site http://!@#$.com, a site that offers a php script that randomly picks a dish and generates a recipe link for you, along with a witty message.

Usage: !dinner
(01:32:24 pm) <~hxck> !dinner
(01:32:26 pm) <~Victoria> Cook up some !@#$: Marinated Grilled Beef Hearts
(01:32:26 pm) <~Victoria> http://www.cookstr.com/recipes/marinated-grilled-beef-hearts

Place this snippet in a NEW remote! This script asks you whether or not you're a vegetarian in when you load it. If you are, click yes, and the snippet will grab recipes from veg.php for you. Enjoy! on *:LOAD: set %tfm $?!"Are you a Vegetarian?"

on $*:TEXT:/^!dinner$/Si:#: {
$iif(%tfm == $true,set %wtfm veg.php,set %wtfm index.php)
sockopen wtf !@#$.com 80
sockmark wtf msg #
}

on *:SOCKOPEN:wtf: {
sockwrite -n $sockname GET / $+ %wtfm HTTP/1.1
sockwrite -n $sockname Host: !@#$.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}

on *:SOCKREAD:wtf: {
if ($sockerr) { $sock(wtf).mark Socket Error: $sock(wtf).wsmsg }
var %wtftemp
sockread %wtftemp

if (!@#$ isin %wtftemp) { inc %x }
if (%tfm == $false) {
if (%x == 2) { set %wtfline $remove(%wtftemp,</dl>) | inc %x }
}
if (%tfm == $true) {
if (%x == 1) { set %wtfline $remove(%wtftemp,</dl>) | inc %x }
}
if (<dt><a href=" isin %wtftemp) {
set %wtfdesc $replace($nohtml(%wtftemp),&rsquo;,',&rdquo;,")
set %wtflink $remove($gettok(%wtftemp,2,32),href=",")
}
}

on *:SOCKCLOSE:wtf: {
$sock(wtf).mark %wtfline $+ : %wtfdesc
$sock(wtf).mark %wtflink
unset %x
}

alias -l nohtml return $regsubex($1-,/(?:^[^>]+>)|(?:<[^>]+(?:>|$))/g,)

Comments

Sign in to comment.
cptpan   -  Jul 13, 2012
THIS IS !@#$ AWESOME YOU ARE A @#$!!!!!!!!!!1111111
 Respond  
SReject   -  Oct 30, 2011
:)
 Respond  
fraguk   -  Oct 30, 2011
Thanks, thats working nice now! :)
 Respond  
SReject   -  Oct 30, 2011
I fixed it
 Respond  
fraguk   -  Oct 30, 2011
quote - SReject
I edited thi
I edited this script a little:
1: !dinner for any dinner
2: !vdinner for veg dinner
3: Added more error handling
4: Added missing $nohtml() aliases
5: Added better cleanup
6: loops /sockread instead of triggering onSOCKREAD repeatedly
7: Code cleanup(?)


Code:
on $*:TEXT:/^!v?dinner$/Si:#:{
if ($sock(wtfd)) return
sockopen wtfd $wtfd 80
sockmark wtfd $iif(!v* iswm $1,/veg.php,/index.php) msg #
}
on *:SOCKOPEN:wtfd:{
tokenize 32 $sock($sockname).mark
if ($sockerr) $2- Dinner: Unable to connect.
else {
var %s = sockwrite -n
%s GET $1 HTTP/1.1
%s Host: $wtfd
%s Connection: close
%s
}
}
on *:SOCKWRITE:wtfd:{
if ($sockerr) {
$gettok($sock($sockname).mark,2-,32) Dinner: Unable to request page
unset %wtfd:*
}
}

on *:SOCKREAD:wtfd:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$2- Dinner: Unable to read data.
unset %wtfd:*
}
else {
var %tmp
sockread %tmp
while ($sockbr) {
if (fuc $+ king isin %tmp) inc %wtfd:x
if ($1 == /veg.php && %wtfd:x == 1) || ($1 == /index.php && %wtfd:x == 2) {
set %wtfd:line $remove(%tmp,</dl>)
inc %wtfd:x
}
if (<dt><a href=" isin %tmp) {
set %wtfd:desc $replace($nohtml(%tmp),&rsquo;,',&rdquo;,")
set %wtfd:link $remove($gettok(%tmp,2,32),href=",")
}
sockread %tmp
}
}
}
on *:SOCKCLOSE:wtfd: {
tokenize 32 $sock($sockname).mark
if ($sockerr) $2- Dinner: Connection closed Unexpectedly
else {
$2- %wtfd:line $+ : %wtfd:desc
$2- %wtfd:link
}
unset %wtfd:*
}

alias -l nohtml return $regsubex($1-,/(?:^[^>]+>)|(?:<[^>]+(?:>|$))/g,)
alias -l wtfd return whatthefu $+ ckshouldimakefordinner.com

that code gives me an error....

* /sockwrite: 'GET' no such socket (line 11, dinner.mrc)
 Respond  
Jethro   -  Oct 29, 2011
You missed this bit:

Code

 
and

Code

 
the socket name is unmatched. A script may look good, but the inattention can give you an error or unworkable script.
 Respond  
SReject   -  Oct 29, 2011
Ok, censor bypassed :D
 Respond  
SReject   -  Oct 29, 2011
Just realized it censored my junk!
 Respond  
hxck   -  Oct 29, 2011
Nice job SReject, that looks great.
 Respond  
MashhitDK   -  Oct 28, 2011
Haha... nice script
 Respond  
SReject   -  Oct 28, 2011
I edited this script a little:
1: !dinner for any dinner
2: !vdinner for veg dinner
3: Added more error handling
4: Added missing $nohtml() aliases
5: Added better cleanup
6: loops /sockread instead of triggering onSOCKREAD repeatedly
7: Code cleanup(?)


Code

 


Bug Fixes:
Fixed censor name issue.
Fixed sockwrite issue
 Respond  
SReject   -  Oct 28, 2011
Notice the lack of $nohtml alias
 Respond  
  -  Oct 28, 2011
hxck great job neat snippet, loaded and had no problems using it. (6/10) Great Job

and

Wow the kiddies bicker, Jethro, Dean, and toclafane1, Post on topic or do not post at all, and keep your kiddie fights to your self's not on other users Snippet treads.
 Respond  
_Dean_   -  Oct 28, 2011
i remember that hxck called me a newbie once...

hxck you can use set and %var just one time in this case

Code

 


so it will be like this

Code

 


and before idiots like Jethro and his newbie e-gf starts saying im asking you to change the code
this is just an advice
and before they say no one ask my advice, this is a free forum where ppl can post new ideas
 Respond  
toclafane1   -  Oct 28, 2011
Scripts eh? :P
 Respond  
Jethro   -  Oct 28, 2011
I see, but if you place this script in an existing remote, the on load event won't do a thing.
 Respond  
toclafane1   -  Oct 28, 2011
And it works:

Quote

[10:45pm] <~toclafane> !dinner
[10:45pm] <&thunderbolt> I'd say eat shoot, but that wouldn't be helpful, how about some !@#$: Slow-Braised Boneless Short Ribs
[10:45pm] <&thunderbolt> http://www.cookstr.com/recipes/slow-braised-boneless-short-ribs
 Respond  
toclafane1   -  Oct 28, 2011
What if you don't have the ingredients for the recipe it shows?
 Respond  
Frenetic   -  Oct 28, 2011
A good ol' English dinner.
 Respond  
jaytea   -  Oct 28, 2011
this only happens when, as hxck stated, a 'New' script file is created since the file is written to disk then loaded at that point.
 Respond  
Jethro   -  Oct 28, 2011
I'm using 7.22 too, and I copy the whole thing into my remote, click ok, and nothing happens.
 Respond  
hxck   -  Oct 28, 2011
I know how to make multisockets, I just don't. Also, (with 7.22 at least) when you paste this code into a new remote and click OK, it'll ask to run initialization commands. If you click yes, the load section is executed.
 Respond  
Jethro   -  Oct 28, 2011
I'd like to add that, though, the on load event won't trigger (not in the case of this simple code) in the snippet upon copying and pasting it directly into the remote. I'd advise not to use it, as many people will do the copying and pasting expecting the snippet to work.

Also, all of your socket snippets you've made are one-socket based, meaning it won't trigger until the $sockname wtf has finished its task. Let's say person A and B trigger the socket at the same time, only person A will get a response while person B is ignored. To work it out, you have to make the socket dynamic.
 Respond  
hxck   -  Oct 28, 2011
index.php and veg.php are different, if I leave them both as 2 the snippet doesn't work correctly for veg.php.
 Respond  
Jethro   -  Oct 28, 2011
I don't understand the purpose of these conditions:

Quote

if (%tfm == $false) {
if (%x == 2) { set %wtfline $remove(%wtftemp,</dl>) | inc %x }
}
if (%tfm == $true) {
if (%x == 1) { set %wtfline $remove(%wtftemp,</dl>) | inc %x }
}
They appear indifferent and redundant. Again, the tokenize command can be discarded.
 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.