URL title finder

By Jagfire on Jul 29, 2008

When somebody posts a link in a channel, this will echo the title of the page to you, so you know what you're clicking on. Only detects links that begin the line, not in the middle (95% of links are posted as their own line)

on *:text:http*:#:{
  var %a = $iif(*www.* iswm $1- || $count($gettok($1-,2,47),$chr(46)) == 1,$iif(*www.* iswm $1-,$gettok($gettok($1-,2,47),2-,46),$gettok($1-,2,47)),$gettok($1-,2,47))
  set %title.site %a
  set %title.chan #
  if ($chr(47) isin $gettok($1-,2-,46)) && ($gettok($1-,3,47)) set %title.site2 $+($chr(47),$gettok($1-,3-,47))
  sockopen findtitle %a 80
}
on *:sockread:findtitle:{
  if ($sockerr) {
    echo %title.chan Error finding title.
    sockclose findtitle
    unset %title.*
    halt
  }
  else {
    var %', %hee
    sockread %'
    %hee = $z(%')
    if (*<*title>* iswm %') {
      echo %title.chan Title: $remove($strip(%hee),$chr(9))
      unset %title.*
      sockclose findtitle
      halt
    }
  }
}
alias -l z {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
on *:sockopen:findtitle:{
  sockwrite -n $sockname GET $iif(%title.site2,%title.site2,$chr(47)) HTTP/1.1
  sockwrite -n $sockname Host: %title.site $+ $crlf $+ $crlf
}

Comments

Sign in to comment.
k0ji   -  Aug 01, 2009

hu uh. not working to me

 Respond  
DaNzO   -  Jul 31, 2008
  • /sockwrite: \'findtitle\' not connected (line 32, script1.mrc)
 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.