Snippets Project Page
Author: Dazuz
Added: 3y
Updated: 2y
mIRC: 7.62
Hits: 1,157
Downloads: 30
Review: entropy
Size: 11.28KB
1 0
Login to vote.
irc2html
v1.1
Converts a mIRC window, log file or clipboard into HTML.
/i2h -w ............ converts active window
/i2h -w [window] ... converts given window
/i2h -f ............ asks you to locate a file to be converted
/i2h -f c:\log.log . converts given file
/i2h -c ............ converts clipboard content
Download
JSON
▲ Review
▲ Log
▼ Source
/* irc2html for mIRC v7.62+ Version: 1.1 Coded by: Dazuz @ QuakeNet /i2h -w ............ converts active window /i2h -w [window] ... converts given window /i2h -f ............ asks you to locate a file to be converted /i2h -f c:\log.log . converts given file /i2h -c ............ converts clipboard content 1.1 - Cleans up properly after itself now. - Fixed a small colour processing bug. 1.0 - Initial release. */ on *:load: { if ($version < 7.62) { echo $color(info) -at * Unsupported mIRC version, please update to $v2 or newer. unload -rs $qt($script) } else echo $color(info) -at * irc2html loaded! Type /i2h [-wfc] [window/file] to convert something. } on *:unload: { unset %i2h.* %irc2html.* hfree -w i2h.* if ($fopen(i2h)) .fclose i2h } menu status,channel,query { irc2html .Convert $active:i2h -w $active .Convert file:i2h -f .Convert clipboard:i2h -c .- .Unload script:if ($input(Do you really want unload irc2html?,yqu,irc2html)) unload -rs $qt($script) } alias i2h { if ($1 == -w) { if ($2) tokenize 32 $2- else tokenize 32 $active if ($window($1-).type) { if ($istok(status channel query chat custom,$v1,32)) i2h.window $1- else echo $color(info) -at * irc2html: invalid window type. } else echo $color(info) -at * irc2html: $qt($1-) no such window. } elseif ($1 == -f) { if ($isfile($2-)) i2h.file $2- elseif (!$2) { if ($sfile($i2h.path $+ *.txt;*.log,Choose a file to convert,Select)) i2h.file $v1 } else echo $color(info) -at * irc2html: $qt($2-) no such file. } elseif ($1 == -c) { if ($cb(0).len) i2h.clipboard else echo $color(info) -at * irc2html: clipboard empty. } elseif ($window($1-).type) { if ($istok(status channel query chat custom,$v1,32)) i2h.window $1- else echo $color(info) -at * irc2html: invalid window type. } elseif ($isfile($1-)) i2h.file $1- else echo $color(info) -at * irc2html: syntax: /i2h [-wfc] [window/file] } alias -l i2h.path { if ($isdir(%irc2html.file)) return %irc2html.file else return $mircdirlogs\ } alias -l i2h.window { %i2h.window = $window($1-) if ($i2h.sfile(%i2h.window)) { %i2h.file = $v1 %i2h.lines = $line(%i2h.window,0) %i2h.title = %i2h.window i2h.start if (%i2h.window == status window) filter -sk i2h.processline else filter -wk %i2h.window i2h.processline i2h.end } unset %i2h.* } alias -l i2h.file { if ($isfile($1-)) && ($i2h.sfile($nopath($1-))) { %irc2html.file = $nofile($1-) %i2h.file = $v1 %i2h.lines = $lines($1-) %i2h.title = $nopath($1-) i2h.start filter -fk $qt($1-) i2h.processlinex i2h.end } unset %i2h.* } alias -l i2h.clipboard { if ($i2h.sfile(Clipboard $asctime(yyyy-mm-dd HH-nn-ss))) { %irc2html.file = $nofile($1-) %i2h.file = $v1 %i2h.lines = $cb(0) %i2h.title = Clipboard i2h.start while (%i2h.line <= %i2h.lines) i2h.processlinex $cb($v1,u) i2h.end } unset %i2h.* } alias i2h.sfile if ($sfile($+($mircdir,$1,.html),Save $1 as...,Save) != $null) return $+(",$nofile($v1),$replacex($nopath($v1),\,_,/,_,:,_,*,_,?,_,",_,<,_,>,_,|,_),$iif(!$istok(html htm,$gettok($v1,-1,46),32),.html),") alias -l i2h.font { tokenize 1 $window(%i2h.window).font if ($1 == Fixedsys) || (!$1) return Fixedsys,Tahoma else return $qt($1) $+ ,Fixedsys,Tahoma } alias -l i2h.start { if ($fopen(i2h)) .fclose i2h .fopen -o i2h %i2h.file .fwrite -n i2h <!DOCTYPE html> .fwrite -n i2h <html> .fwrite -n i2h <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> .fwrite -n i2h $+(<title>,%i2h.title - irc2html</title>) .fwrite -n i2h <style type="text/css"> tokenize 32 $i2h.rgb($color(nornal text)) $i2h.rgb($color(background)) .fwrite -n i2h $+(body{white-space:pre-wrap;font-family:,$i2h.font,;font-size:,$iif($window(%i2h.window).fontsize,$v1,12),px;color:#,$1,;background-color:#,$2,;tab-size:0,$chr(125)) .fwrite -n i2h .bold{font-weight:bold} .fwrite -n i2h $+(.reverse{color:#,$2,;background-color:#,$1,$chr(125)) .fwrite -n i2h .italic{font-style:italic} .fwrite -n i2h .underline{text-decoration:underline} hfree -w i2h.* hmake i2h.colour hmake i2h.backgroundcolour set -l %x 0 while (%x <= 98) { tokenize 32 $i2h.rgb(%x) .fwrite -n i2h $+(.color,%x,$chr(123),color:#,$1,$chr(125),.bgcolor,%x,$chr(123),background-color:#,$1,$chr(125)) hadd i2h.colour %x color $+ %x hadd i2h.colour $base(%x,10,10,2) color $+ %x hadd i2h.backgroundcolour %x bgcolor $+ %x hadd i2h.backgroundcolour $base(%x,10,10,2) bgcolor $+ %x inc %x } .fwrite -n i2h </style> .fwrite -n i2h <body> %i2h.line = 1 } alias -l i2h.rgb { tokenize 44 $rgb($color($1)) tokenize 32 $base($1,10,16,2) $base($2,10,16,2) $base($3,10,16,2) if ($left($1,1) == $right($1,1)) && ($left($2,1) == $right($2,1)) && ($left($3,1) == $right($3,1)) return $+($left($1,1),$left($2,1),$v1) else return $+($1,$2,$3) } alias -l i2h.end { .fwrite -n i2h </body> .fwrite -n i2h </html> .fclose i2h hfree -w i2h.* editbox -a url %i2h.file } alias -l i2h.processline { %i2h.safeline = $replacex($1,&,&,",",',',<,<,>,>,$chr(32),$chr(1)) %i2h.fixedline = $replacex(%i2h.safeline,$chr(3),$chr(2),$chr(15),$chr(2),$chr(22),$chr(2),$chr(29),$chr(2),$chr(31),$chr(2)) if ($strip(%i2h.safeline) != $null) { if ($pos(%i2h.fixedline,$chr(2),1)) i2h.colourfulline $v1 else i2h.normalline } else .fwrite -n i2h editbox -a %i2h.line of %i2h.lines inc %i2h.line } alias -l i2h.colourfulline { %i2h.linecolour = $line(%i2h.window,%i2h.line).color if (%i2h.linecolour != $color(normal text)) { bset -t & -1 $+(<span class=",$hget(i2h.colour,$v1),">) | %i2h.differentlinecolour = 1 } if ($1 > 1) bset -t & -1 $gettok(%i2h.fixedline,1,2) while ($pos(%i2h.fixedline,$chr(2),1)) { %i2h.position = $v1 while ($mid(%i2h.fixedline,%i2h.position,1) == $chr(2)) $asc($mid(%i2h.safeline,%i2h.position,1)) if ($mid(%i2h.fixedline,%i2h.position) != $null) { %i2h.fixedline = $v1 | i2h.part $gettok($v1,1,2) } else break } if (%i2h.classes) bset -t & -1 </span> if (%i2h.differentlinecolour) bset -t & -1 </span> breplace & 1 32 .fwrite -bn i2h & bunset & unset %i2h.bold %i2h.colour %i2h.reverse %i2h.italic %i2h.underline %i2h.oldclasses %i2h.differentlinecolour } alias -l i2h.part { %i2h.safeline = $mid(%i2h.safeline,%i2h.position) %i2h.classes = %i2h.bold %i2h.italic %i2h.underline $iif(%i2h.reverse,reverse,%i2h.colour) if (%i2h.classes == %i2h.oldclasses) bset -t & -1 $1- else bset -t & -1 $+($iif(%i2h.oldclasses,</span>),$iif(%i2h.classes,$+(<span class=",%i2h.classes,">)),$1-) %i2h.oldclasses = %i2h.classes } alias -l i2h.normalline { if ($line(%i2h.window,%i2h.line).color != $color(normal text)) bset -t & -1 $+(<span class=",$hget(i2h.colour,$v1),">,%i2h.safeline,</span>) else bset -t & -1 %i2h.safeline breplace & 1 32 .fwrite -bn i2h & bunset & } ;Bold alias -l 2 inc %i2h.position | if (%i2h.bold) unset %i2h.bold | else %i2h.bold = bold ;Colour alias -l 3 { inc %i2h.position tokenize 44 $mid(%i2h.safeline,%i2h.position,5) if ($len($1) isnum 1-2) && ($1 isnum) { if ($left($2,2) isnum) || ($left($2,1) isnum) { %i2h.colour = $hget(i2h.colour,$1) $hget(i2h.backgroundcolour,$v1) | inc %i2h.position $len($1 $v1) } else { %i2h.colour = $gettok(%i2h.colour,2,32) if (!%i2h.colour) && ($1 isnum %i2h.linecolour) unset %i2h.colour else { if (!%i2h.colour) && ($1 isnum $color(background)) %i2h.colour = $hget(i2h.colour,$color(normal text)) else %i2h.colour = $hget(i2h.colour,$1) %i2h.colour } inc %i2h.position $len($1) } } elseif ($left($1,2) isnum) || ($left($1,1) isnum) { inc %i2h.position $len($v1) set -l %c $v1 %i2h.colour = $gettok(%i2h.colour,2,32) if (!%i2h.colour) && (%c isnum %i2h.linecolour) unset %i2h.colour else { if (!%i2h.colour) && (%c isnum $color(background)) %i2h.colour = $hget(i2h.colour,$color(normal text)) else %i2h.colour = $hget(i2h.colour,%c) %i2h.colour } } else unset %i2h.colour } ;Plain alias -l 15 inc %i2h.position | unset %i2h.bold %i2h.colour %i2h.reverse %i2h.italic %i2h.underline ;Reverse alias -l 22 inc %i2h.position | if (%i2h.reverse) unset %i2h.reverse | else %i2h.reverse = reverse ;Italic alias -l 29 inc %i2h.position | if (%i2h.italic) unset %i2h.italic | else %i2h.italic = italic ;Underline alias -l 31 inc %i2h.position | if (%i2h.underline) unset %i2h.underline | else %i2h.underline = underline alias -l i2h.processlinex { %i2h.safeline = $replacex($1-,&,&,",",',',<,<,>,>,$chr(32),$chr(1)) %i2h.fixedline = $replacex(%i2h.safeline,$chr(3),$chr(2),$chr(15),$chr(2),$chr(22),$chr(2),$chr(29),$chr(2),$chr(31),$chr(2)) if ($strip(%i2h.safeline) != $null) { if ($pos(%i2h.fixedline,$chr(2),1)) i2h.colourfullinex $v1 else i2h.normallinex } else .fwrite -n i2h editbox -a %i2h.line of %i2h.lines inc %i2h.line } alias -l i2h.colourfullinex { if ($left(%i2h.safeline,1) == $chr(3)) && (($mid(%i2h.safeline,2,2) isnum) || ($left($v1,1) isnum)) %i2h.linecolour = $v1 else %i2h.linecolour = $color(normal text) if (%i2h.linecolour != $color(normal text)) { bset -t & -1 $+(<span class=",$hget(i2h.colour,$v1),">) | %i2h.differentlinecolour = </span> } if ($1 > 1) bset -t & -1 $gettok(%i2h.fixedline,1,2) while ($pos(%i2h.fixedline,$chr(2),1)) { %i2h.position = $v1 while ($mid(%i2h.fixedline,%i2h.position,1) == $chr(2)) $asc($mid(%i2h.safeline,%i2h.position,1)) if ($mid(%i2h.fixedline,%i2h.position) != $null) { %i2h.fixedline = $v1 | i2h.part $gettok($v1,1,2) } else break } if (%i2h.classes) bset -t & -1 </span> if (%i2h.differentlinecolour) bset -t & -1 </span> breplace & 1 32 .fwrite -bn i2h & bunset & unset %i2h.bold %i2h.colour %i2h.reverse %i2h.italic %i2h.underline %i2h.oldclasses %i2h.differentlinecolour } alias -l i2h.normallinex { bset -t & -1 %i2h.safeline breplace & 1 32 .fwrite -bn i2h & bunset & }
Changelog:
1.1
- Cleans up properly after itself now.
- Fixed a small colour processing bug.
1.0
- Initial release.
1.1
- Cleans up properly after itself now.
- Fixed a small colour processing bug.
1.0
- Initial release.
Comments (1)
Aug 7th, 2020 - By: entropy
Super Admin
It would be nice if there was a better description. Like, how to use it in the description!
Reply: