http preview

By xero_art on May 22, 2009

Ok, so this just gives a hint as to what a url someone posts does. You can make it personal use or have it msg the chan. I'm working on getting it to work on tinyurls and other compressed addresses....not sure why it doesn't so any help in that department would be much appreciated. I'm thinking to use a separate socket for specific tinyurls

I used Gummo's $between...

eventual update will hopefully work for redirects like tinyurl and other url compression sites...this was more about learning socket and is my first "finished" socket script

on *:text:*http*:#: { 
    var %x $1-
    var %z 1
    while (%z <= $numtok(%x,32)) {
      if (http:// isin $gettok(%x,%z,32)) { /urlcheck $chan $gettok(%x,%z,32) | BREAK }
      /inc %z 1
    }
  }

alias urlcheck {
  unset %url.*
  set %I $ticks
  set $+(%,url.chan.,%I) $1
  set $+(%,url.check.,%I) $replace($2,http://,$null)
  set $+(%,url.host.,%I) $gettok($eval($+(%,url.check.,%I),2),1,47)
  set $+(%,url.get.,%I) $replace($eval($+(%,url.check.,%I),2),$eval($+(%,url.host.,%I),2),$null)
  sockopen $+(remoteurl.,%I) $eval($+(%,url.host.,%I),2) 80
}

on *:SOCKOPEN:remoteurl.*: {
  sockwrite -n $sockname GET $+($chr(47),$($eval($+(%,url.get.,%I),2)))
  sockwrite -n $sockname Host: $($eval($+(%,url.host.,%I),2))
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 $+ $crlf $+ $crlf
}

on *:SOCKREAD:remoteurl.*: {
  var %r
  sockread %r
  if ($regex(%r,<title>)) {
    ;msg $eval($+(%,url.chan.,%I),2) ' $+ $between(%r,<title>,</title>,1) $+ ' (at ' $+ $eval($+(%,url.host.,%I),2) $+ ') 
    .echo $eval($+(%,url.chan.,%I),2) ' $+ $between(%r,<title>,</title>,1) $+ ' (at ' $+ $eval($+(%,url.host.,%I),2) $+ ') 
  }
}

; Gummo's
alias between { 
  noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) 
  return $regml($4) 
}

Comments

Sign in to comment.
Xaric   -  Jul 30, 2009
  • /sockopen: insufficient parameters

Get this when I say a url.

 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.