Paste code in color with -mIRC alias-

By rebel9 on Jun 02, 2017

Pastes what you have in your clipboard (ctrl+c) with color for various chars, mainly for posting code in IRC for readability purposes.

Usage: /code /codepaste
Add this to Aliases tab, not Remotes.

code {
  var %r1 = /(\$[^\s\(\),\x03]+)/g | var %r2 = /([\(\)\[\]])/g | var %r3 = /([,\:><=&|!])/g | var %r4 = /(%[^\s\(\),\x03]+)/g
  var %r5 = /([\{\}])/g | var %r6 = /(?:^|\G)(\s)/g | var %r7 = /(#[^\s\(\),\x03]*)/g
  var %loop = 1, %end = $cb(0)
  while (%loop <= %end) {
    say $regsubex($regsubex($regsubex($regsubex($regsubex($regsubex($regsubex($cb(%loop),%r1,09\1),%r2,12\1),%r3,07\1),%r4,14\1),%r5,13\1),%r6,\1),%r7,04\1)
    inc %loop 1
  }
}

 ; #Alternate Method

codepaste {
  var %totl = $cb(0)
  var %c = 1
  while (%c <= %totl) {
    var %clip = $iif($cb(%c),$replace($cb(%c),$chr(2),$chr(25),$chr(3),$chr(25),$chr(15),$chr(25),$chr(22),$chr(25),$chr(29),$chr(25),$chr(31),$chr(25)),$chr(160))
    var %rsub1 = $regsubex(%clip,/(\$[^(),  ]*)/g,  12\1  )
    var %rsub2 = $regsubex(%rsub1,/(\%[^(),  ]*)/g,  09\1  )
    var %rsub3 = $regsubex(%rsub2,/(\(|\)|\{|\}|\[|\])/g,  04\1  )
    var %rsub4 = $regsubex(%rsub3,/(\=|\<|\>|\!|\/|\\|\||\&|\,|\.)/g,  07\1  )
    var %rsub5 = $regsubex(%rsub4,/(if|elseif|else|while|isin|isincs|iswm|iswmcs|isnum|return) /g,  14\1   )
    var %rsub6 = $regsubex(%rsub5,/(isletter|isalnum|isalpha|islower|isupper|ison|echo|alias|unset) /g,  14\1   )
    var %rsub7 = $regsubex(%rsub6,/(isop|ishop|isvoice|isreg|ischan|isban|isaop|isavoice|say|scon) /g,  14\1   )
    var %rsub8 = $regsubex(%rsub7,/(isignore|isprotect|isnotify|var|set|inc|dec|msg|describe) /g,  14\1   )
    ;var %output = $regsubex(%rsub5,/ ( *) /g,\1 )
    $iif($1 == e,echo -a,msg $active) $replace(%rsub8,$chr(32),$chr(160))
    inc %c
  }
}

Comments

Sign in to comment.
dma   -  Oct 16, 2017

when i use /code it comes up with blank and a error ( UNKOWN COMMAND)
when I use ./codepaste that all that come up no url just /codepaste in orange

any ideas?

rebel9  -  Nov 04, 2017

Sounds like you put it in remotes tab and not Alias.

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.