mIRC Homepage

link checker help

Posted By: D00M

link checker help - 29/04/11 09:24 AM

Hey guys ,iv been using this link checker snippet I got from over at hawkees with a few adjustments but for some reason its not picking up urls like tinyurl/somelink or bit.ly/somelink or t.co/somelink.

Code:
<@D00M> http://www.fukung.net/v/10945/cabd1b785ffb889b68a107dcc2bd156a.gif
<+Bot> cabd1b785ffb889b68a107dcc2bd156a.gif &raquo; fukung.net : I eat people like you ( http://www.fukung.net/v/10945/cabd1b785ffb889b68a107dcc2bd156a.gif )   (EDIT: Seems to have messed up the title on this one and puts &raquo; into the chan from the snippet)
<@D00M> http://t.co  (EDIT: This one works for main site)
<+Bot> t.co / Twitter ( http://t.co )
<@D00M> http://t.co/Rdy6riw  (EDIT: But with a link from the site it doesn't,just ignored)
<@D00M> http://tinyurl.com   
<+Bot> TinyURL.com - shorten that long URL into a tiny URL ( http://tinyurl.com )   (EDIT: Again works from homepage)
<@D00M> http://tinyurl.com/1c2  (EDIT: but no reply at all for a link)
<@D00M> http://bit.ly/2V6CFi
<+Bot> bit.ly ( http://bit.ly/2V6CFi )  (EDIT: This one doesnt give the titlename properly ,just names the bit.ly site)
<@D00M> http://bit.ly
<+Bot> bitly | Basic | a simple URL shortener ( http://bit.ly )
<@D00M> www.youtube.com
<+Bot> YouTube - Broadcast Yourself. ( www.youtube.com )
<@D00M> www.google.com
<+Bot> 302 Moved ( www.google.com )  (EDIT: title isnt right ,says 302 moved)
<@D00M> http://74.125.237.40
<+bot> Google ( http://74.125.237.40 )   (IP got it right with title though)
<@D00M> www.psx-scene.com
<+bot> 301 Moved Permanently ( www.psx-scene.com )   (EDIT: Again with the moved error in the title)
<@D00M> http://i.imgur.com/7FjWf.jpg   (EDIT: ignores this completely) 
<@D00M> http://i.imgur.com
<+Bot> 302 Found ( http://i.imgur.com )   (EDIT: 302 error)


As you can see it picks up on it if the link from tinyurl/t.co/bit.ly as the main homepage but it fails to catch the link itself. Also with the fukung.net link it messed up the title name and put part of the code in the chan instead,any help would be great,

TIA D00M.

Code:
on *:text:*:#MYCHAN: {
  if (http:// isin $1-) {
    sockclose linkchecker
    set %link $remove($matchtok($1-,http://,1,32),http://)
    set %linkchan $chan
    set %actlink $matchtok($1-,http://,1,32)
    if (/ !isin %link) { set %link %link $+ / }
    sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
    halt
  }
  if (www. isin $1-) {
    sockclose linkchecker
    set %link $matchtok($1-,www.,1,32)
    set %linkchan $chan
    set %actlink $matchtok($1-,www.,1,32)
    if (/ !isin %link) { set %link %link $+ / }
    sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
    halt
  }
}
on *:sockopen:linkchecker: {
  if $sockerr > 0 { sockclose $sockname | halt }
  sockwrite -n $sockname GET / $+ $right(%link,$calc($len(%link)- $pos(%link,/,1))) HTTP/1.1
  sockwrite -n $sockname Host: $remove($left(%link,$pos(%link,/,1)),/)
  sockwrite -n $sockname $crlf
}
on *:sockread:linkchecker: {
  if $sockerr > 0 { sockclose $sockname | halt }
  sockread %linkh
  if (%delbug != $null) && ($len(%linkch) <= 150) && (</title> !isin %linkh) { set %linkch %linkch %linkh }
  if (%delbug != $null) && (</title> isin %linkh) {
    msg %linkchan $replace(%linkch,&quot;,",&apos;,',&amp;,&,&lt;,<,&gt;,>,&copy;,,&reg;,,&trade;,,&euro;,,&pound;,,&yen;,) (3 %actlink )
    unset %delbug
    sockclose $sockname
    halt
  }
  if (<title> isin %linkh) {
    set %linkch $remove($left(%linkh,$pos(%linkh,</title>,1)),</title>)
    set %linkch $right(%linkch,$calc($len(%linkch)- $pos(%linkch,<title>,1) -6))
    set %linkch $left(%linkch,$calc($len(%linkch)-1))
    set %delbug 1
    if (%linkch != $null) {
      msg %linkchan  $replace(%linkch,&quot;,",&apos;,',&amp;,&,&lt;,<,&gt;,>,&copy;,,&reg;,,&trade;,,&euro;,,&pound;,,&yen;,) (3 %actlink ) 
      sockclose $sockname
      unset %delbug
      halt
    }
  }
}
if (*HTTP*302* iswm %x) set -e %web.tmp 1
if (Location: isin %x) {
  if ($mtc(%x)) {
    tokenize 32 %e
    sockclose %z
    soc $regml(web,1) $iif($regml(web,2),$v1,/) $iif($3,$3,1) %z $iif(%web.tmp,Redirected)
    unset %web.tmp
  }
}
on *:sockclose:website.*: unset $+(%,$sockname)
alias -l soc {
  var %x = $iif($4,$4,$+(website.,$r(a,z),$r(a,z),$r(a,z),$r(0,9),$r(0,9),$r(0,9)))
  set -e $+(%,%x) $1-2 $iif($3 ischan && $me ison $3,$3) $iif($5,$ntc($5))
  sockopen %x $1 80
}
alias -l mtc return $regex(web,$1,/(?:https?:\/\/)?((?:www\.)?[\w-.]+\.(?>[a-z]{2,4})(?![a-z]))([\w-_#?=%.\/&?]+)?/ig)
alias -l ptc return $replacecs($1,&mdash;,-,&quot;,",&amp;,&,&lt;,<,&gt;,>,?,$chr(233),?,$chr(231),&ccedil;,$chr(231),&ntilde;,$chr(241),?,$chr(209),?,$chr(220),?,$chr(244))
alias -l btc return $+($chr(2),$1,$chr(2))
alias -l ntc return $+($chr(40),$1,$chr(41))
alias rtc {
  if ($mtc($2-)) && (!%website.flood [ $+ [ $regml(web,1) ] ]) {
    var %x = 1, %v
    while ($regml(web,%x)) {
      var %z = $iif(/ isin $regml(web,$calc(%x +1)),$v2,/), %i = $regml(web,%x)
      if (/ !isin %i) && (!$istok(%v,%i,32)) {
        soc %i %z $1
        %v = %v %i
      }
      inc %x 1
    }
    set -eu5 %website.flood $+ $regml(web,1) 1
  }
}
© 2020 mIRC Discussion Forums