mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2017
Posts: 2
Wirls Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
Joined: Jun 2017
Posts: 2
I have searched high and low and can't seem to find a way to save the logs in a different external format (such as .docx or HTML) while keeping the color formatting.
I use IRC for roleplaying and would like to display the logs online for our members to see (current idea is using Google Docs), but I would like it to keep the color formatting so that it doesn't become confusing to read. These logs can get really long.
Does anybody know how to do this without having to go through a manual process?

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
It really depends on what you mean by manual. Would a command that parsers the IRC to HTML be fine?


I am SReject
My Stuff
Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Don't believe mirc has a feature for doing this, but it can be scripted. You can try the script below, it is not mine and I haven't tried it in years. So it may or may not work any more.

If this does what you want, it should be simple enough to make a script that runs this on the log files at some time period.

Code:
--------------------------------------------------------------------------------
 irc2html [2004.04.18] by Andy Dufilie
--------------------------------------------------------------------------------
 Website: http://pages.cthome.net/pdufilie/
--------------------------------------------------------------------------------
   This script will create .html files using buffers, logs, clipboard contents,
 or any text you specify containing IRC control codes.  It will use your current
 mIRC RGB color settings (alt+k).

   Note that if you use this to convert a .log, the colors will not show up if
 you strip color codes in mIRC logging options (alt+o/irc/logging).
--------------------------------------------------------------------------------

 ==========
  Commands
 ==========
   Buffer conversion
     /buf2html [window]

   File conversion
     /log2html [file]

   Clipboard conversion
     /cb2html
     - Copy text to the clipboard before using.

   Single line conversion (output to window)
     /irc2html <text>
     - Use several /irc2html commands to output them to the same window.

--------------------------------------------------------------------------------

 =================
  Version history
 =================
   2001.07.29
   - First release.

   2002.02.12
   - Rewrote control code parsing algorithm (fixed bugs, optimized output).

   2002.08.22
   - Font size is now kept.

   2004.02.22
   - /buf2html now uses mIRC 6.14's new $line().color and filter -z features.

   2004.04.18
   - Modified /buf2html line color handling.
   - Fixed a CSS error that was making output files incompatible with Mozilla
     browsers.  Thanks go to |TREMOR| for pointing out the problem.
   - The script generates smaller output files now.
   - The parsing code is now cleaner & easier to understand.
   - I made a separate alias for modifying the output filename so it's easy to
     edit.

--------------------------------------------------------------------------------



Code:
;--------------------------------------------
; irc2html [2004.04.18] by Andy Dufilie
;--------------------------------------------
; Website: http://pages.cthome.net/pdufilie/
;--------------------------------------------


; Change this alias if you want output files to go to a different directory or have different filenames.
alias -l modify_output_filename {
  var %directory = $nofile($1-)
  var %file = $nopath($1-)

  ; replace invalid characters
  %file = $mkfn(%file)

  ; remove "#"
  %file = $remove(%file,$chr(35))

  ; make sure there's a character before the "."
  if (.* iswm %file) %file = _ $+ %file

  ; replace char 160 (non-breaking space)
  %file = $replace(%file,$chr(160),_)

  return %directory $+ %file
}


; buffer conversion
; /buf2html [window]
alias buf2html {
  reset
  if ($window($1-)) var %@ = $1-
  else var %@ = $active
  %i2h.buffermode = 1
  if (%@ == status window) filter -swz @i2h
  elseif (=* iswm %@) {
    %i2h.buffermode = 0
    savebuf %@ irc2html.tmp
    loadbuf @i2h irc2html.tmp
    .remove irc2html.tmp
  }
  else filter -wwz %@ @i2h
  var %x = $line(@i2h,0)
  while (%x) {
    if ($line(@i2h,%x) == $chr(32)) dline @i2h %x
    dec %x
  }
  var %t = %@ buffer
  var %f = $mkfn(%@) $+ .html
  var %outputfile = $i2h(%t,%f)
  echo $colour(i) -q *** Done making %outputfile
  ;run $shortfn(%outputfile)
}

; file conversion
; /log2html [file]
alias log2html {
  var %dll = 0
  if ($1 == -dll) {
    %dll = 1
    tokenize 32 $2-
  }
  elseif ($1 == -mrc) {
    %dll = 0
    tokenize 32 $2-
  }

  if ($isfile($1-)) var %log = $1-
  elseif ($version < 5.8) var %log = $dir="Pick a .log" $shortfn($logdir*.log)
  else var %log = $sfile($logdir*.log,Pick a .log)
  if ($isfile(%log) == $false) {
    if (%log) echo $colour(info) * /log2html: File doesn't exist: %log
    return
  }
  if (*.log iswm %log) var %html = $left(%log,-3) $+ html
  else var %html = %log $+ .html

  if (%dll) {
    var %irc2html.dll = $findfile($scriptdir,irc2html.dll,1)
    if ($isfile(%irc2html.dll) != $true) { 
      %irc2html.dll = $findfile($mircdir,irc2html.dll,1)
      if ($isfile(%irc2html.dll) != $true) {
        echo $colour(i) *** irc2html.dll is missing.
        return
      }
    }

    ;filename $+ $cr $+ outfile?fontname?defaultfore?defaultback?rgb0?rgb1?rgb2?rgb3?rgb4?rgb5?rgb6?rgb7?rgb8?rgb9?rgb10?rgb11?rgb12?rgb13?rgb14?rgb15

    var %size = $window(@i2h).fontsize
    if (%size < 0) %size = $right(%size,-1) $+ pt
    else %size = %size $+ px

    window -h @irc2html
    var %n = 0, %params = %log $+ $cr $+ %html $+ ? $+ $window(@i2h).font $+ ;font-size: $+ %size $+ ? $+ $colour(normal) $+ ? $+ $colour(background)
    close -@ @irc2html
    while (%n < 16) {
      %params = %params $+ ? $+ $colour(%n)
      inc %n
    }
    var %outputfile = $dll(%irc2html.dll,irc2html,%params)
  }
  else {
    reset
    loadbuf @i2h $shortfn(%log)
    var %title = $nopath(%log)
    if (*.log iswm %title) %title = $left(%title,-4) log
    var %outputfile = $i2h(%title,%html)
    echo $colour(i) -q *** Done making %outputfile
  }

  ;run $shortfn(%outputfile)
}

; clipboard conversion
; /cb2html
alias cb2html {
  reset
  var %x = 1, %f = clipboard.html
  while (%x <= $cb(0)) {
    aline @i2h $iif(* iswm $cb(%x),$cb(%x),)
    inc %x
  }
  var %outputfile = $i2h(Clipboard,%f)
  echo $colour(i) -q *** Done making %outputfile
  ;run %outputfile
}

; single line conversion (output to window)
; /irc2html <text>
alias irc2html {
  if (* !iswm $1-) return
  if (* !iswm $window(@irc2html)) reset
  close -@ @i2h
  window -h @i2h
  aline @i2h $1-
  window -h @irc2html
  var %x = $line(@irc2html,0)
  if (</html> isin $line(@irc2html,%x)) dline @irc2html %x
  i2h
  window -aw @irc2html
}

on *:close:@irc2html:unset %i2h.*
alias -l reset {
  close -@ @i2h @irc2html
  unset %i2h.*
  window -h @i2h
}
alias -l _rgb {
  tokenize 44 $rgb($colour($1))
  return $base($1,10,16,2) $+ $base($2,10,16,2) $+ $base($3,10,16,2)
}
; $i2h(title,outfile) returns output file w/ quotes
; /i2h with no parameters is used for /irc2html single-line conversion
alias -l i2h {
  var %title = $1
  var %outputfile = $modify_output_filename($2)
  window -h @irc2html
  var %ctime = $ctime, %x = 16
  while (%x) {
    dec %x
    %i2h. [ $+ [ %x ] ] = $_rgb(%x)
  }
  if (* iswm %outputfile) || ($line(@irc2html,0) !isnum 1-) {
    if (* iswm %outputfile) aline @irc2html <html><head><title> $+ %title $+ </title><style type="text/css"><!--
    else aline @irc2html <html><head><title>irc2html</title><style type="text/css"><!--
    var %size = $window(@i2h).fontsize
    if (%size < 0) %size = $right(%size,-1) $+ pt
    else %size = %size $+ px
    aline @irc2html body{font-family: $+ $window(@i2h).font $+ ;font-size: $+ %size $+ ;color: $+ %i2h. [ $+ [ $colour(no) ] ] $+ ;background-color: $+ %i2h. [ $+ [ $colour(b) ] ] $+ ;}
    aline @irc2html --></style></head><body>
  }
  %x = $line(@i2h,0)
  while (%x) {
    %i2h.ecolor = $line(@i2h,1).color
    convert $line(@i2h,1)
    dline @i2h 1
    editbox -a %x
    dec %x
  }
  editbox -a
  if (* iswm %outputfile) {
    aline @irc2html </body></html><!-- $duration($calc($ctime -%ctime)) -->
    unset %i2h.*
    savebuf @irc2html " $+ %outputfile $+ "
    close -@ @irc2html
  }
  else aline @irc2html </body></html>
  close -@ @i2h
  return %outputfile
}
alias -l classname {
  var %bold = $1, %underline = $2, %fcolor = $3, %bcolor = $4, %reverse = $5, %bg = $6
  var %class = $iif(%underline,$iif(%bold,W,X),$iif(%bold,Y,Z))
  if (%reverse != 1) {
    if (%class == Z) %class =
    %class = %class $+ $chr($calc($asc(A) + %fcolor))
    if (%bcolor != %bg) %class = %class $+ $chr($calc($asc(A) + %bcolor))
  }
  return %class
}
alias -l classdef {
  var %class = $1, %bold = $2, %underline = $3, %fcolor = $4, %bcolor = $5, %reverse = $6, %ncolor = $7, %bg = $8
  var %def = . $+ %class $+ {font-weight: $+ $iif(%bold,bold,normal)
  %def = %def $+ ;text-decoration: $+ $iif(%underline,underline,none)
  %def = %def $+ ;color: $+ %i2h. [ $+ [ $iif(%reverse,%bg,%fcolor) ] ]
  %def = %def $+ ;background-color: $+ %i2h. [ $+ [ $iif(%reverse,%ncolor,%bcolor) ] ]
  %def = %def $+ ;}
  return %def
}
; convert one line of text
alias -l convert {
  if (* !iswm $1-) return
  var %nbsp = $chr(160), %b = , %r = , %u = , %k = , %o = , %text = $replace($1-,&,&amp;,<,&lt;,>,&gt;) $+ %o, %ncolor = $colour(no), %ecolor = %ncolor, %bg = $colour(b), %etag = 0
  if ($version >= 6.14) && (%i2h.buffermode) %ecolor = %i2h.ecolor
  elseif ($1 == *) {
    if (/*: iswm $2) || ($2-3 == Invalid format:) || ($2-4 == Too many parameters:) || ($2-3 == Invalid parameters:) %ecolor = $colour(i)
    elseif (Break: iswm $2) %ecolor = $colour(c)
    else %ecolor = $colour(a)
  }
  elseif (-?*- iswm $1) var %ecolor = $colour(not)
  elseif (-> [*] iswm $1-2) var %ecolor = $colour(c)
  elseif ($1 == ***) var %ecolor = $colour(i)
  if (%ecolor !isnum) %ecolor = %ncolor
  if (%ecolor != %ncolor) %etag = 1
  var %btext = $replace(%text,%k,%b,%r,%b,%u,%b,%o,%b), %codenum = 1, %numcodes = $count(%btext,%b), %nextcodepos, %codepos = 1, %prevcodepos, %nocomma, %class, %baseclass, %prevclass
  var %char, %bold = 0, %underline = 0, %reverse = 0, %fcolor = %ecolor, %bcolor = %bg, %aline, %length = $len(%text), %tcolor, %inside_span = 0
  %baseclass = $classname(%bold,%underline,%ecolor,%bcolor,%reverse,%bg)
  %class = %baseclass
  if (%etag) {
    %aline = <span class= $+ %class $+ >
    ; define class if not already defined
    if (%i2h.c [ $+ [ %class ] ] != 1) {
      iline @irc2html 2 $classdef(%class,%bold,%underline,%fcolor,%bcolor,%reverse,%ncolor,%bg)
      %i2h.c [ $+ [ %class ] ] = 1
    }
  }
  while (%codenum <= %numcodes) {
    %prevcodepos = %codepos
    %nextcodepos = $pos(%btext,%b,%codenum)
    %codepos = %nextcodepos

    ; read control codes
    while ($mid(%btext,%codepos,1) == %b) {
      inc %codenum
      %char = $mid(%text,%codepos,1)
      if (%char == %k) {
        inc %codepos
        %nocomma = 1
        %tcolor =
        while ($mid(%text,%codepos,1) isnum) {
          %tcolor = $ifmatch
          inc %codepos
          if ($mid(%text,%codepos,1) isnum) {
            %tcolor = %tcolor $+ $ifmatch
            inc %codepos
          }
          if (%tcolor == 99) %tcolor = %ecolor
          if (%fcolor == 99) %fcolor = %bcolor
          %tcolor = $calc(%tcolor % 16)
          %fcolor = $calc(%fcolor % 16)
          if (%nocomma) %fcolor = %tcolor
          else %bcolor = %tcolor
          if (%nocomma) && ($mid(%text,%codepos,1) == ,) {
            %nocomma = 0
            inc %codepos
          }
          else break
        }
        if (* !iswm %tcolor) {
          %fcolor = %ecolor
          %bcolor = %bg
        }
      }
      else {
        if (%char == %b) %bold = 1 - %bold
        elseif (%char == %u) %underline = 1 - %underline
        elseif (%char == %r) %reverse = 1 - %reverse
        elseif (%char == %o) {
          %fcolor = %ecolor
          %bcolor = %bg
          %bold = 0
          %underline = 0
          %reverse = 0
        }
        inc %codepos
      }
    }
    ; done reading control codes

    %prevclass = %class
    %class = $classname(%bold,%underline,%fcolor,%bcolor,%reverse,%bg)

    ; append text since last control code
    if (%prevcodepos < %nextcodepos) {
      var %" = " $+ $mid(%text,%prevcodepos,$calc(%nextcodepos -%prevcodepos)) $+ "
      if (" * " iswm %") %aline = %aline $+ %nbsp $+ $right($left(%",-2),-2) $+ %nbsp
      elseif (" * iswm %") %aline = %aline $+ %nbsp $+ $right($left(%",-1),-2)
      elseif (* " iswm %") %aline = %aline $+ $right($left(%",-2),-1) $+ %nbsp
      else %aline = %aline $+ $right($left(%",-1),-1)
    }

    ; break out of loop if this the end of the line
    if (%codepos > %length) break

    ; check if span class needs changing
    if (%class != %prevclass) {
      ; close off previous tag if needed
      if (%inside_span) {
        %aline = %aline $+ </span>
        %inside_span = 0
      }
      ; begin new tag if needed
      if (%class != %baseclass) {
        ; define class if not already defined
        if (%i2h.c [ $+ [ %class ] ] != 1) {
          iline @irc2html 2 $classdef(%class,%bold,%underline,%fcolor,%bcolor,%reverse,%ncolor,%bg)
          %i2h.c [ $+ [ %class ] ] = 1
        }
        ; output text & new span tag
        aline @irc2html %aline $+ <span
        %aline = class= $+ %class $+ >
        ; remember that we're inside a span tag
        %inside_span = 1
      }
    }
  }

  ; close previous span tag if needed
  if (%inside_span) {
    %aline = %aline $+ </span>
    %inside_span = 0
  }
  ; add remaining text if needed
  if (%codepos <= %length) %aline $+ $mid(%text,%codepos)
  ; close outer span tag if needed
  if (%etag) %aline = %aline $+ </span>
  ; output with line break
  aline @irc2html %aline $+ <br>
}



http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
That script requires a dll


I am SReject
My Stuff
Joined: Jan 2005
Posts: 192
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
It does not require dll.

If the dll is present it will utilize it... otherwise it will proceed without it.

Have been using this script for ages and never had the dll to accompany it.


echo -a $signature
Joined: Jun 2017
Posts: 2
Wirls Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
Joined: Jun 2017
Posts: 2
I just checked this and it works exactly as I need it to! Thanks so much for the help! grin


Link Copied to Clipboard