URL color w/out same line color issues.

By rebel9 on Feb 04, 2014

Colors URL with the color of your choosing, just change the '12' in urlcolor alias to what color number you want (ctrl+k). This isn't perfected, but works for me. Special thanks to ex0a for help making it less buggy.

The difference with this URL color script than most is that it doesn't effect the rest of your text line's color.

You will have to slightly modify this script so it matches your script color/style.

alias urlcolor return $+($chr(3), 12, $1-, $chr(3))
on ^&*:text:*:*:{
  var %pnick = $null

;;;;-----------Beginning of nick color change, where you see color 07 right below this line,-----------;;;
;;;;-----------change to the color of how you have it in your script, and add a char if needed.--------;;;
;;;;-------------------------------This is the starting point------------------------------------------;;;

if ($chan) && ($remove($nick($chan,$nick).pnick,$nick)) var %pnick = $+(07,$left($remove($nick($chan,$nick).pnick,$nick),1))
  var %nick = $+(00,$nick)
  var %urlreg = /((?:(?:(?:http|https|ftp|gopher)\72\/\/)|(?:www|ftp)\.)\S+)/Sig
  if ($regex($1-,%urlreg)) {
    var %regml = $regml(1)
    var %ntok = $findtok($1-,%regml,32)
    var %getcontrolstr = $gettok($1-,1- $+ $calc(%ntok - 1), 32)
    var %nbold = $calc($numtok(%getcontrolstr,2)-1)
    var %nitalics = $calc($numtok(%getcontrolstr,29)-1)
    var %nunderline = $calc($numtok(%getcontrolstr,31)-1)
    var %ccode = $color(normal)
    if ($regex($gettok(%getcontrolstr,$numtok(%getcontrolstr,3),3),/^(\d{1,2})?.*/)) var %ccode = $iif($regml(1),$v1,%ccode)
    var %ccode = %ccode $+ $iif($calc(%nbold % 2) == 1,$chr(2),$null) $+ $iif($calc(%nitalics % 2) == 1,$chr(29),$null) $+ $iif($calc(%nunderline % 2) == 1,$chr(31),$null)
    var %ccodepre = $iif($calc(%nbold % 2) == 1,$chr(2),$null) $+ $iif($calc(%nitalics % 2) == 1,$chr(29),$null) $+ $iif($calc(%nunderline % 2) == 1,$chr(31),$null)
    var %msg = $puttok($1-,%ccodepre $+ $urlcolor($strip(%regml)) $+ %ccode,%ntok,32)

;;;-----------------Last color change for the way your script looks, this is the closing point---------;;;

  echo -tcrl normal $iif($chan,$chan,$nick) $+(%pnick,%nick,7:) $iif(%msg,%msg,$1-)
  }
  else {
    echo -tcrl normal $iif($chan,$chan,$nick) $+(%pnick,%nick,7:) $1-
  }
  haltdef
}

Comments

Sign in to comment.
^WeSt   -  Feb 08, 2014

good but make it work with more links per one text.

e.g: hey join us www.google.com or www.youtube.com

 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.