egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

covert codes to html

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Savage_Garden
Voice


Joined: 23 Aug 2006
Posts: 1

PostPosted: Wed Aug 23, 2006 4:02 pm    Post subject: covert codes to html Reply with quote

Hello, sorry if this has been asked before but i didnt meet such a topic. My problem is that i am writing a tcl for online stats and i am logging whats going on in the channel in chat.txt. Next i write a html using that file, but the problem is in the .txt file where there are lines with bold, reverse, underline or color, such as:
1156356695 quit LaM3r43t0 admin@84.238.171.248 Quit: 4? 9Club Xtazy ? 11Script ? 4Download ? w15ww.15styni.HiT.9bG ?
on the .html file they dont appear colored, underlined, etc.
I hope you understand what my problem is and you can help me. I need a procedure that would fix that effect.

Thanks in advantage.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Aug 23, 2006 5:41 pm    Post subject: Reply with quote

Try regsub.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Aug 23, 2006 10:16 pm    Post subject: Reply with quote

I already wrote mirc-colors-to-html converter for some guy a while ago, you could have found it with a simple forum search for "color html"

anyway, here it is again:

Code:

proc mirc2html str {
   set re {([\002\017\026\037]|[\003]{1}[0-9]{0,2}[\,]{0,1}[0-9]{0,2})}
array   set colors { 0 white   1 black    2 navy    3 green
                4 red     5 maroon   6 purple  7 olive
                8 yellow  9 lime    10 teal   11 aqua
               12 blue   13 fuchsia 14 gray   15 silver}
   set numtags 0; set bold 0
   while {[regexp -indices $re $str -> idxs]} {
      set b [lindex $idxs 0]
      set e [lindex $idxs 1]
      set sub [string range $str $b $e]
      switch [string index $sub 0] {
         "\002" {
            if !$bold {
               set tag "<span style=\"font-weight:bold\">"
               set bold 1
            } {
               set tag "<span style=\"font-weight:normal\">"
               set bold 0
            }
            incr numtags
         }
         "\017" {
            set tag [string repeat "</span>" $numtags]
            set numtags 0
         }
         "\026" {
            set tag [string repeat "</span>" $numtags]           
            append tag "<span style=\"color:white;background-color:black\">"
            set numtags 1
         }
         "\037" {
            set tag "<span style=\"text-decoration:underline\">"
            incr numtags
         }
         "\003" {
            set fg [lindex [split [string range $sub 1 e] ,] 0]
            set bg [lindex [split [string range $sub 1 e] ,] 1]
            if {$fg != "" || $bg != ""} {
               if {$fg > 15 || $bg > 15} {
                  set tag "<span>"
               } elseif {$fg != "" && $bg != ""} {
                  set tag "<span style=\"color:$colors($fg);background-color:$colors($bg)\">"
               } elseif {$fg != "" && $bg == ""} {
                  set tag "<span style=\"color:$colors($fg)\">"
               } else {
                  set tag "<span style=\"background-color:$colors($bg)\">"
               }
               incr numtags
            } {
               set tag [string repeat "</span>" $numtags]
               set numtags 0
            }
         }
      }
      set str [string replace $str $b $e $tag]
   }
   append str [string repeat "</span>" $numtags]
   return $str
}

_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber