mIRC Control Codes to HTML

By Spoofing on Nov 29, 2010

$mirccc2html(string), also can use $mirccc2html($rawmsg) for messages from IRC server.

Example:

on *:TEXT:*:#: {
  write $+($mkfn(#),.,htm) $timestamp $+(<,$nick,>) $+($mirccc2html($rawmsg),<,br,>)
}
  • bold, reverse, italic, underline, plain text
  • text color, background
  • multispace, every second space replaces to  

CSS for colors here: http://www.hawkee.com/snippet/8163/

Enjoy!

alias mirccc2html {
  var %stdin = $+($replace($mid($1,$calc($pos($1,:,2) + 1)),$chr(32),$lf),$chr(15)), %stdout, %LF = 0, %i = 1, %len = $len(%stdin)
  while (%i <= %len) {
    var %char = $mid(%stdin,%i,1), %i = %i + 1
    if (%char == $lf) var %LF = %LF + 1, %stdout = $+(%stdout,$iif(2 // %LF,&nbsp;,$lf))
    elseif (%char == $chr(2)) var %^B = $iif(%^B,$false,$true), %stdout = $+(%stdout,$iif(%^B,<b>,</b>))
    elseif (%char == $chr(29)) var %^I = $iif(%^I,$false,$true), %stdout = $+(%stdout,$iif(%^I,<i>,</i>))
    elseif (%char == $chr(31)) var %^U = $iif(%^U,$false,$true), %stdout = $+(%stdout,$iif(%^U,<u>,</u>))
    elseif (%char == $chr(22)) var %^R = $iif(%^R,$false,$true), %stdout = $+(%stdout,$iif(%^R,<span class="R">,</span>))
    elseif (%char == $chr(3)) {
      if (%^K) var %^K = $false, %stdout = $+(%stdout,</span>), %color, %background-color
      if ($mid(%stdin,%i,1) isnum) var %color = $base($v1,10,10,2), %i = %i + 1
      if ($mid(%stdin,%i,1) isnum) var %color = $base($+(%color,$v1),10,10,2), %i = %i + 1
      if ($mid(%stdin,%i,1) == ,) {
        var %i = %i + 1
        if ($mid(%stdin,%i,1) isnum) var %background-color = $base($v1,10,10,2), %i = %i + 1
        if ($mid(%stdin,%i,1) isnum) var %background-color = $base($+(%background-color,$v1),10,10,2), %i = %i + 1
      }
      if (%color) var %^K = $true, %stdout = $+(%stdout,<span class=" $+ $+(K,%color,%background-color) $+ ">)
    }
    elseif (%char == $chr(15)) {
      if (%^B) var %^B = $false, %stdout = $+(%stdout,</b>)
      if (%^I) var %^I = $false, %stdout = $+(%stdout,</i>)
      if (%^U) var %^U = $false, %stdout = $+(%stdout,</u>)
      if (%^R) var %^R = $false, %stdout = $+(%stdout,</span>)
      if (%^K) var %^K = $false, %stdout = $+(%stdout,</span>), %color, %background-color
    }
    else {
      var %LF = 0
      if (%char == &) var %stdout = $+(%stdout,&amp;)
      elseif (%char == <) var %stdout = $+(%stdout,&lt;)
      elseif (%char == >) var %stdout = $+(%stdout,&gt;)
      else var %stdout = $+(%stdout,%char)
    }
  }
  return $replace(%stdout,$lf,$chr(32))
}
Sign in to comment.
Spoofing   -  Dec 01, 2010

eg.

var %i = 1 | while (%i <= 10) var %i = %i + 1
  • script have no problem. ;)
 Respond  
Spoofing   -  Dec 01, 2010

see code, I use "var %i = %i + 1" (first line after while), not "inc %i"

but thanks =)

 Respond  
dlsocool   -  Dec 01, 2010

If you are used while loop you needed to input inc %i see this code fallowing:

alias mirccc2html {
  var %stdin = $+($replace($mid($1,$calc($pos($1,:,2) + 1)),$chr(32),$lf),$chr(15)), %stdout, %LF = 0, %i = 1, %len = $len(%stdin)
  while (%i <= %len) {
    var %char = $mid(%stdin,%i,1), %i = %i + 1
    if (%char == $lf) var %LF = %LF + 1, %stdout = $+(%stdout,$iif(2 // %LF,&nbsp;,$lf))
    elseif (%char == $chr(2)) var %^B = $iif(%^B,$false,$true), %stdout = $+(%stdout,$iif(%^B,<b>,</b>))
    elseif (%char == $chr(29)) var %^I = $iif(%^I,$false,$true), %stdout = $+(%stdout,$iif(%^I,<i>,</i>))
    elseif (%char == $chr(31)) var %^U = $iif(%^U,$false,$true), %stdout = $+(%stdout,$iif(%^U,<u>,</u>))
    elseif (%char == $chr(22)) var %^R = $iif(%^R,$false,$true), %stdout = $+(%stdout,$iif(%^R,<span class="R">,</span>))
    elseif (%char == $chr(3)) {
      if (%^K) var %^K = $false, %stdout = $+(%stdout,</span>), %color, %background-color
      if ($mid(%stdin,%i,1) isnum) var %color = $base($v1,10,10,2), %i = %i + 1
      if ($mid(%stdin,%i,1) isnum) var %color = $base($+(%color,$v1),10,10,2), %i = %i + 1
      if ($mid(%stdin,%i,1) == ,) {
        var %i = %i + 1
        if ($mid(%stdin,%i,1) isnum) var %background-color = $base($v1,10,10,2), %i = %i + 1
        if ($mid(%stdin,%i,1) isnum) var %background-color = $base($+(%background-color,$v1),10,10,2), %i = %i + 1
      }
      if (%color) var %^K = $true, %stdout = $+(%stdout,<span class=" $+ $+(K,%color,%background-color) $+ ">)
    }
    elseif (%char == $chr(15)) {
      if (%^B) var %^B = $false, %stdout = $+(%stdout,</b>)
      if (%^I) var %^I = $false, %stdout = $+(%stdout,</i>)
      if (%^U) var %^U = $false, %stdout = $+(%stdout,</u>)
      if (%^R) var %^R = $false, %stdout = $+(%stdout,</span>)
      if (%^K) var %^K = $false, %stdout = $+(%stdout,</span>), %color, %background-color
    }
    else {
      var %LF = 0
      if (%char == &) var %stdout = $+(%stdout,&amp;)
      elseif (%char == <) var %stdout = $+(%stdout,&lt;)
      elseif (%char == >) var %stdout = $+(%stdout,&gt;)
      else var %stdout = $+(%stdout,%char)
    }
    inc %i
  }
  return $replace(%stdout,$lf,$chr(32))
}

if you forget this (inc %i) this script will have problem.

 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.