Link Detector / Get Link Info

By FordLawnmower on Feb 02, 2014

Detects links when typed in channels that have been activated and returns the title from

  • This is a bot script and should be loaded in a second mIRC client.
  • Type +linkinfo in each channel you want this script to run in. (Requires ops or higher)
  • There are settings at the top of the script for logo, text color and ignoring youtube links.
;GetLinkInfo Script by Ford_Lawnmower #Script-Help
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Change this to 0 to resolve youtube links
alias -l IgnoreYoutubeLinks return 1
;Change this to change the logo
alias -l GetLinkInfoLogo return $+($chr(3),12,LinkInfo:)
;Change this to change the text color
alias -l GetLinkInfoTextColor return $+($chr(15),$chr(2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu Channel,Status {
  .$iif($group(#GetLinkInfo) == On,$style(1)) GetLinkInfo
  ..$iif($group(#GetLinkInfo) == On,$style(2)) On: .enable #GetLinkInfo
  ..$iif($group(#GetLinkInfo) == Off,$style(2)) Off: .disable #GetLinkInfo
#GetLinkInfo on
On $*:Text:/(^[+-]LinkInfo|(https?|www\.)(www\.)?[\S]*)/Si:#: {
  var %action $strip($regml(1))
  if ($regex(action,%action,^[+-])) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (+* iswm %action) {
      if ($istok(%linkinfoChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the linkinfo script }
      else { 
        .enable #GetLinkInfo
        Set %linkinfoChanList $addtok(%linkinfoChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the linkinfo script for $chan .
    else {
      if (!$istok(%linkinfoChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the linkinfo script }
      else { 
        Set %linkinfoChanList $remtok(%linkinfoChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the linkinfo script for $chan . 
  elseif (!$timer($+(linkinfo,$network,$chan))) && ($istok(%linkinfoChanList,$+($network,$chan),32)) {
    .timer $+ $+(linkinfo,$network,$chan) 1 1 noop
    var %method msg #
    if ($IgnoreYoutubeLinks && $regex(%action,/(?:^https?:\/\/|www\.)(?:[\S]*youtube\.com|youtu\.be)/i)) {
    else {
      Getlinkinfo %method $gettok(%action,2-,47)
#GetLinkInfo end
alias linkinfo { Getlinkinfo echo -a $1- }
alias -l Getlinkinfo {
  var %sockname $+(LinkInfo,$network,$2,$ticks)
  sockopen %sockname 80
  svar %sockname method $1-2
  svar %sockname url $+(/info?link=,$urlencode($+(http://,$3)))
On *:sockopen:LinkInfo*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $svar($sockname,url) HTTP/1.1
    sockwrite -n $sockname Host: $sock($sockname).addr
    sockwrite -n $sockname $crlf
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
On *:sockread:LinkInfo*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %LinkInfo | sockread %LinkInfo
    if ($regex(%LinkInfo,/<dd><b>(.*?)<\/b><\/dd>/i)) {
      $svar($sockname,method) $GetLinkInfoLogo $+($GetLinkInfoTextColor,$Xchr($Xchr($regml(1))))
      sockclose $sockname
alias  Xchr { 
  var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2,4});/g,$utf8(\1)) 
  return $xXchr($replacecs(%return,&ndash;,$utf8(8211),&mdash;,$utf8(8212),&iexcl;,$utf8(161),&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,$&
alias -l xXchr {
  return $replacecs($1-,&eta;,$utf8(951),&theta;,$utf8(952),&iota;,$utf8(953),&kappa;,$utf8(954),&lambda;,$utf8(955),&mu;,$utf8(956),$&
  &Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),&aelig;,æ,&quot;,",&lt;,<,&gt;,>, &amp;,&,&quot;,")
alias -l urlencode { 
  return $regsubex($replace($1-,$chr(32),$+(%,2d),$+(%,20),$+(%,2d)),/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
alias -l Svar {
  var %sockname $1, %item $+($2,$1)
  if ($isid) {
    if ($regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01([^\x01]*)/i)) return $regml(svar,1)
  elseif ($3)  {
    var %value $3-
    if (!$regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01/i)) { sockmark %sockname $+($sock(%sockname).mark,$chr(1),%item,$UTF8(1),%value) }
    else { sockmark %sockname $regsubex(svar,$sock(%sockname).mark,/( $+ %item $+ \x01[^\x01]*)/i,$+(%item,$chr(1),%value)) }
alias -l UTF8 {
  if ($version >= 7) return $chr($1)
  elseif ($1 < 255) { return $chr($1) }
  elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 65536) && ($1 < 2097152) {
    return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
      $chr($calc(128 + $mod($1,64))))
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
  var %int $int($calc($1 / $2))
  return $calc($1 - (%int * $2))
alias -l H2U { return $utf8($base($1,16,10)) }


Sign in to comment.
dma   -  Apr 19, 2016

how can i change the text color in this??

dma   -  Feb 11, 2016

real good... thanks for it works great in my bot..... #irc

dma  -  Feb 12, 2016

ok my bad its wonderfull

Sign in to comment

damaks   -  Feb 19, 2014

Ford could you add link description and link thumb image to the script? It wold be nice, and it would be only script on hawkee that does all that! Thanks

rebel9   -  Feb 04, 2014

On alias Xchar in $replacecs at the end, add: ,',$chr(39)

&aelig;,æ,&quot;,",&lt;,<,&gt;,>, &amp;,&,&#039;,$chr(39))

@FordLawnmower: Personally I had to add all of this to my script also:


I still run into issues at times but I fix them as I see them at random. This is how mine would look if I were to start using your script (for those of you about to use it, also)

return $replacecs(%return,&ndash;,,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
&aelig;,æ,&quot;,",&lt;,<,&gt;,>, &amp;,&,&#039;,$chr(39),&#039;,',&raquo;,$chr(187),&#39;,$chr(39),$& &#x26;,$chr(38),&#0153;,,&#47;,$chr(47),&#40;,$chr(40),&#38;,$chr(38),&#41;,$chr(41),$&

Hope this helps at all.

FordLawnmower  -  Feb 04, 2014

I've posted a response here over and over and it doesn't take.
I'm tired of typing. This code is updated.
@rebel9 , If you have problems with any of my scripts, please just post the problem and not code.
If you feel the need to post code , then please put it in a code box so it is readable.

rebel9  -  Feb 06, 2014

&bot: Hollyanne "Set" Setola Twin Galaxies Trading Card Signed | eBay

&bot: BBC News - Afghan Taliban 'capture US military dog'

It doesn't end here. I would post the code to fix this now, but as posted above, I'm not supposed to.

FordLawnmower  -  Feb 06, 2014

@rebel9 I think that you are not using the updated code. I added " to the alias, but all &#; numeric characters are covered by the second regsubex.
In addition, there are no quotes in this link:
This is from the source at the top of the page.

<title>BBC News - Afghan Taliban capture British military dog</title>

Clearly you have edited the quotes in to the post.

The second regsubex, should catch all items starting with &# and ending with ; that have 2 to 4 numbers inbetween.
It will then send them to $utf8 for conversion. There is no need to have any of these in replaced.
The original code only caught &#; with 2 numbers, So ' . The code was updated 2 days ago to look for 2 to 4 numbers.

rebel9  -  Feb 06, 2014

I only tested this on a windows ec2 as I don't believe in running another mirc instance on my own box. I tried the updated code, when trying out your script, I get those errors along with others. Trust me I saw the ",", inside of your code, wondered the same thing myself. I'll leave you to it though.

But don't say I edited shit when I clearly didn't, the site must have very recently.

(07:10:35) A_Cow:
(07:10:37) @b0t: BBC News - Afghan Taliban 'capture US military dog&#039

I'll quit trying to help other people make their scripts and just go back to using my own now. Enjoy m8.

FordLawnmower  -  Feb 06, 2014

@rebel9 I never said that you didn't see "
As I stated; "I added " to the alias"
If you have problems with other links, pls post the links and I will test them and make adjustments if necessary.

You must keep in mind, that I do not use any of these scripts. I only write them.
I have very little use for irc , but I still make scripts as people request them.
My testing is limited to common links off the top of my head, so this script will be refined based on user response.

rebel9  -  Feb 06, 2014

(14:04:15) ~me:
(14:04:17) @b0t: 10 1" Google Android 4 03 Tablet PC 8GB 1GB DDR3 HDMI Bundle 10" Keyboard | eBay

FordLawnmower  -  Feb 06, 2014

That one is working fine with the updated code rebel9 :

[15:15:32] <~Ford_Lawnmower>
[15:15:34] LinkInfo: 10 1" Google Android 4 03 Tablet PC 8GB 1GB DDR3 HDMI Bundle 10" Keyboard | eBay

j0nas  -  Mar 21, 2014

Is there anyway we can update this to catch www. aswell as http://

Sign in to comment

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.