mIRC Format Code Converter

By FordLawnmower on Jul 06, 2009

This is a odd little script but it serves a very useful function. This script will convert mIRC's text/color codes to html for website posting or PHPBB for forum posting.
Here is a quick example;
mIRC:

[20:16:38] <04Demonoid> 8,4 HELLO 4,8 HELLO 8,4 HELLO 4,8 HELLO 0,12 Sm00ch_Operator 4,8 HELLO 8,4 HELLO 4,8 HELLO 8,4 HELLO

Converted to PHPBB:

20:16:38 <Demonoid>  HELLO  HELLO  HELLO  HELLO  Sm00ch_Operator  HELLO  HELLO  HELLO  HELLO

RESULTS:
20:16:38 <Demonoid> HELLO HELLO HELLO HELLO Sm00ch_Operator HELLO HELLO HELLO HELLO

As you can see I removed the background colors. This will only work for foreground colors, bold and underline.

To use this script.
[list=1]
[]Copy some mIRC text to the clipboard(Hold down ctrl to copy the color codes)
[
]Right Click the channel,query or Status screen and scroll to Convert Clipboard Contents.
[*]Select PHPBB or HTML and choose Clipboard or file. (Clipboard will do the conversion within the clipboard and you can just click ctrl+v to paste the results. File will send the results to the filename you select.)[/list]

Suggestions will be welcomed, as I am only scratching the surface of what can be done with some of these routines.

One thing to note If you are trying to copy long lines of really colorful text, you will need mIRC 6.32 or higher. Each color adds about 20 characters to the text, so if you have a full line of 430+ characters, 27 color changes will push you over the old variable limit.

;mIRC format code converter by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu status,query,channel {
  $iif(!$cb,$style(2)) Convert Clipboard Contents
  .PHPBB
  ..Clipboard to Clipboard:cliptoHTML -cPHPBB
  ..Clipboard to File:cliptoHTML -fPHPBB
  .HTML
  ..Clipboard to Clipboard:cliptoHTML -cHTML
  ..Clipboard to File:cliptoHTML -fHTML
}
alias -l cliptoHTML {
  var %cbtotal $cb(0), %cbline 1
  if (-c isin $1) {
    var %type $remove($1,-c)
    if ($isfile($+(cliptemp.,%type))) { .remove $+(cliptemp.,%type) }
    while (%cbline <= %cbtotal) {
      write $+(cliptemp.,%type) $+($,mircto,%type,( [ $rembackcol($cb(%cbline)) ] ))
      inc %cbline
    }
    %cbtotal = $lines($+(cliptemp.,%type))
    %cbline = 1
    clipboard
    while (%cbline <= %cbtotal) {
      clipboard -an $read($+(cliptemp.,%type),%cbline)
      inc %cbline
    }
    echo -a Clipboard Conversion to %type Completed Successfully.
    .remove $+(cliptemp.,%type)
  }
  if (-f isin $1) {
    if ($sfile($scriptdir,Navigate to the desired location and enter a filename,Save to File)) { 
      var %savename $qt($ifmatch), %type $remove($1,-f)
      if ($isfile(%savename)) {
        $iif($input(File Exists -- Do you want to Overwrite?,yn),.remove %savename,return)
      }
      while (%cbline <= %cbtotal) {
        write %savename $($+($,mircto,%type,( [ $remove($rembackcol($cb(%cbline)),$chr(91),$chr(93),$chr(40),$chr(41),$chr(47),$chr(124)) ] )),2)
        inc %cbline
      }
      echo -at Conversion to %type was successfully written to %savename 
    }
  }
}
alias -l mIRCtoHTML {
  var %r, %rrr $1-
  while ($regex(%rrr,/([0-9]{1,2})/)) {
    noop = $regsub(%rrr,/([0-9]{1,2})/,$getHTMLcolor($calc($remove($regml($regml(0)),))),%r)
    %rrr = %r
  }
  return $boldHTML($underHTML($iif(%r,$+($replace(%r,,</font>),</font>),$1-))) $+ <br />
}
alias -l mIRCtoPHPBB {
  var %r, %rrr $remove($1-,$chr(91),$chr(93)), %rr 0, %ron 0
  while ($regex(%rrr,/([0-9]{1,2})/)) {
    noop = $regsub(%rrr,/([0-9]{1,2})/,$+($iif(%rr,),$getPHPBBcolor($calc($remove($regml($regml(0)),)))),%r)
    %rrr = %r | %rr = 1 | %ron = $iif(%ron,0,1) 
  }
  while ($regex(%rrr,/()[^\d]/)) {
    noop = $regsub(%rrr,/()[^\d]/,$iif(%rr, $+) ,%r)
    %rrr = %r | %rr = 1 | %ron = $iif(%ron,0,1) 
  }
  return $boldPHPBB($underPHPBB($iif(%r,$+($remove(%r,,),),$1-)))
}
alias -l GetPHPBBColor {
  return $+([color=,$replacex($1-,15,darkgray,14,dimgray,13,pink,12,blue,11,aqua,10,darkcyan,9,lime,8,yellow,7,orange,6,purple,5,maroon$&
    ,4,red,3,green,2,darkblue,1,black,0,black),])
}
alias -l GetHTMLColor {
  return $+(<font color=,$qt($replacex($1-,15,darkgray,14,dimgray,13,pink,12,blue,11,aqua,10,darkcyan,9,lime,8,yellow,7,orange,6,purple,5,maroon$&
    ,4,red,3,green,2,darkblue,1,black,0,black)),>)
}
alias -l RemBackCol {
  var %bc, %bcc $1-
  while ($regex(%bcc,/([0-9]{1,2},[0-9]{1,2})/)) {
    noop = $regsub(%bcc,/([0-9]{1,2},[0-9]{1,2})/,$gettok($regml($regml(0)),1,44),%bc)
    %bcc = %bc
  }
  return $iif(%bc,%bc,$1-)
}
alias -l underPHPBB {
  var %u, %uu $1-, %uon 0
  while ($regex(%uu,/()/)) {
    noop = $regsub(%uu,/()/,$iif(%uon,[/u],[u]),%u)
    %uu = %u
    %uon = $iif(%uon,0,1) 
  }
  return $+($iif(%u,%u,$1-),$iif(%uon,[/u])) 
}
alias -l underHTML {
  var %u, %uu $1-, %uon 0
  while ($regex(%uu,/()/)) {
    noop = $regsub(%uu,/()/,$iif(%uon,</u>,<u>),%u)
    %uu = %u
    %uon = $iif(%uon,0,1) 
  }
  return $+($iif(%u,%u,$1-),$iif(%uon,</u>)) 
}
alias -l boldPHPBB {
  var %b, %bb $1-, %bon 0
  while ($regex(%bb,/()/)) {
    noop = $regsub(%bb,/()/,$iif(%bon,[/b],[b]),%b)
    %bb = %b
    %bon = $iif(%bon,0,1) 
  }
  return $+($iif(%b,%b,$1-),$iif(%bon,[/b])) 
}
alias -l boldHTML {
  var %b, %bb $1-, %bon 0
  while ($regex(%bb,/()/)) {
    noop = $regsub(%bb,/()/,$iif(%bon,</b>,<b>),%b)
    %bb = %b
    %bon = $iif(%bon,0,1) 
  }
  return $+($iif(%b,%b,$1-),$iif(%bon,</b>)) 
}

Comments

Sign in to comment.
FordLawnmower   -  Jul 07, 2009

Thanks TheImrac but the script is already working exactly the way it was intended to.

 Respond  
TheImrac   -  Jul 07, 2009
alias clr {
  var %c = black black darkblue darkgreen red maroon purple orange yellow lightgreen teal lightblue blue pink darkgray lightgray
  var %m = $1-
  %m = $regsubex(%m,/(\d?\d)(?:,\d?\d)?(.*?)(?=|||$)/gi, $+ \2 $+ )
  %m = $regsubex(%m,/(.*?)(?:|(?=|$))/gi,<u> $+ \1 $+ </u>)
  %m = $regsubex(%m,/(.*?)(?:|(?=|$))/gi,** $+ \1 $+ **)
  echo -b %m
}

Should work I haven't tested it thoroughly, but seems to be working properly.

Edit: it seems mine breaks =(

 Respond  
FordLawnmower   -  Jul 07, 2009

Actually you are wrong WorldDMT. If you read and understand the whole script you will see that I have taken careful steps to make sure that the PHPBB code is in perfect order.

If you have an extra without a coinciding match The PHPBB parser will treat it as normal text. The same goes for extra markers.

This is wrong ---->> hello  <<--- from your code.

In addition, the bold and underlined are done the same way for the similar reasons.

**<u>hello**</u> <--- This will also fail. 
**<u>hello</u>**<-- Should be this 

I also made separate aliases because I might decide to add another output format to this script.

I'm not at all trying to argue with you WorldDMT. It is obvious to everyone here that you have exceptional mSL scripting skills and a great mind. The problem that I have is that you only see the code and you never acknowledge the work that has went into making it.
In fact, you go from post to post discrediting the actual scripter by reposting an edited version of someones hard work. Editing a working script to make it more efficient or smaller is much easier than actually writing a script from scratch. So even though you might end up with a better script by editing other peoples posts, you had to stand on the real scripters shoulders to do so.

A lot goes into making a script from scratch. The code is the easy part.

  • The Original Idea - The main component of every script.
  • Planning - Endless hours can be spent just trying to decide how you want the script to act and respond.
  • Design - Designing dialogs and menu's so they are easy to read and self explanatory.
  • Flowcharts - I still use these :P Scripters who don't still have to map out the flow in their mind.
  • Scripting - Writing the actual code to put it all together.
  • Testing & Debugging - All code has to be tested clean before posting.
  • Bug Fixes and error trapping - Code that is added as a result of testing results.
  • Screen Shots - Taking screen shots to be placed in your post.
  • Writing a description/instructions - Description to be placed in your post.
  • Posting - Putting it all together and posting it to your favorite sites.
    Sure we are posting scripts here and it's all about the script, but it's not really ALL about the script :P

Something to consider :)

 Respond  
WorldDMT   -  Jul 07, 2009

ok i see but u can do it with $regsubex u dont need to do much aliases

E.G for color only an E.G ok??

alias t {
  var %x $regsubex($1-,/(\d+)( $+ $chr(44) $+ \d+)?\s?/g,\1),%c black darkblue green red maroon purple orange yellow lime darkcyan aqua blue pink dimgray darkgray
  echo -a $regsubex(%x,/(\d+)\s?(\S+)(\s+|$)/g,\2\3)
}

so if u type

/t [20:16:38] <04Demonoid> 8,4 HELLO 4,8 HELLO 8,4 HELLO 4,8 HELLO 0,12 Sm00ch_Operator 4,8 HELLO 8,4 HELLO 4,8 HELLO 8,4 HELLO

u'll get include the spaces

[20:16:38] HELLO HELLO HELLO HELLO Sm00ch_Operator HELLO HELLO HELLO HELLO

 Respond  
FordLawnmower   -  Jul 07, 2009

As you can see I removed the background colors. This will only work for foreground colors, bold and underline.
PHPBB forums don't allow the users to define background colors. I removed them on purpose with this routine.

alias -l RemBackCol {
  var %bc, %bcc $1-
  while ($regex(%bcc,/([0-9]{1,2},[0-9]{1,2})/)) {
    noop = $regsub(%bcc,/([0-9]{1,2},[0-9]{1,2})/,$gettok($regml($regml(0)),1,44),%bc)
    %bcc = %bc
  }
  return $iif(%bc,%bc,$1-)
}

I also removed them for html because I think it would be ridiculous to change the background of a form each time there is a background change in irc. I also changed white to black and color stops to black.

MuaHahAhaHahAhaHaaAaaAaaAaaaaa!!!!!!!

 Respond  
knoeki   -  Jul 07, 2009

i dont now much in html or phpBB but i didnt saw the background color here

the description mentions that background colours will not work.

 Respond  
WorldDMT   -  Jul 07, 2009

hi

i see 8,4 HELLO <= that mean color of text yellow and background red

i dont now much in html or phpBB but i didnt saw the background color here

 HELLO 
 Respond  
FordLawnmower   -  Jul 07, 2009

Thanks Aucun50 :)

 Respond  
Aucun50   -  Jul 07, 2009

Looks nice, good job.

 Respond  
Adamon   -  Jul 06, 2009

:D Ownage.

 Respond  
FordLawnmower   -  Jul 06, 2009

MuaHahAhaHahAhaHaaAaaAaaAaaaaa!!!!!!!

 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.