Random pun

By zak123 on Jun 15, 2009

My final socket... Geez, these things are fun to play with once you learn how to use them correctly...

Usage: `pun

on *:text:`pun*:#: {
if ($sock(pun)) .sockclose pun
set %chan $chan
sockopen pun www.punoftheday.com 80
}
on *:SOCKOPEN:pun: {
sockwrite -nt $sockname GET /cgi-bin/randompun.pl HTTP/1.1
sockwrite -nt $sockname Host: www.punoftheday.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:pun: {
if ($sockerr) {
msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
halt
}
else {
var %sockreader
sockread %sockreader
if (*<div class="dropshadow1">* iswm %sockreader-1) {
noop $regex(%sockreader,/<p>(.*?)<\/p>/Si)
set %pun $regml(1)
msg %chan %pun
unset %sockreader*
unset %chan
sockclose $sockname
}
if ($len($remove(%sockreader,$chr(9),$chr(32))) > 0) {
var %x = 0
while (%x > -1) {
if ($len(%sockreader [ $+ [ $iif(%x != 0,$+(-,%x)) ] ]) <= 850) set %sockreader [ $+ [ $+(-,$calc(%x + 1)) ] ] %sockreader [ $+ [ $iif(%x != 0,$+(-,%x)) ] ]
dec %x
}
}
}
}

Comments

Sign in to comment.
napa182   -  Jun 15, 2009

you can just do somthing like this

on $*:text:/^@pun$/iS:#: {
  if (!%f) { 
    inc -u3 %f 
    if ($sock(pun)) sockclose pun 
    sockopen pun www.punoftheday.com 80 
    sockmark pun msg # 
  } 
}
on *:sockopen:pun: {
  sockwrite -nt $sockname GET /cgi-bin/randompun.pl HTTP/1.1 
  sockwrite -nt $sockname Host: $+($sock(pun).addr,$str($crlf,2)) 
}
on *:sockread:pun: {
  var %pun | sockread %pun
  if ($regex(%pun,/<p>(.+)<\/p>/)) { 
    $sock(pun).mark $regml(1) 
    sockclose pun 
  }
}
 Respond  
blitzz   -  Jun 15, 2009

I can see you edit it a little. ....snippet/6304/ and ....snippet/6303/

Looks like you want to add your snippet as much as you can.

:-)

 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.