This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

irc2html (Color Version)

Old posts that have not been replied to for several years.
Locked
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

irc2html (Color Version)

Post by blood_x »

Dear All,

Anyone can help me on how to modified irc2html originally written by Natrak to be more interactive (using color) such as seen on default mIRC color. For example, I want to change 'Join Event' to be in GREEN color when this script display it on web html.

Modified and Patched Version for irc2html script as below;

###############################################################
# __ __ _ #
# ___ ____ __ _ ___ ___ / /_ \ \/ / #
# / _ \' __/ _ `/ / -_)/ __/ _/ ) ( #
# / .__/_/ \___/ /\___/\__/\__/ /_/\_\ #
# /_/ -------- /__/ --------------------- #
# #
###############################################################
# Filename.....: irc2html.tcl #
# Description..: ProjectX irc2html v1.00 #
# Author.......: Natrak <natrak@projectx.mx.dk> #
# Website......: http://www.projectx.mx.dk/ #
###############################################################

### -----------------------------------------------------------
### Description
### -----------------------------------------------------------
### This script logs what goes on in an IRC channel, converts
### it to HTML and make it visible to user on the web. To see
### irc2html in action visit:
### http://www.projectx.mx.dk/contact/spycam.html

### -----------------------------------------------------------
### User-defined settings
### -----------------------------------------------------------

### Path and name of html file to create:
set i2h_htmlfile "../public_html/mychannel.php"

### IRC channel to log:
set i2h_chan "#mychannel"

### Text that start with this character will not be included on
### the web page that is generated:
set i2h_secret "*"

### What sort of output should the script mimic:
### 0 = BitchX
### 1 = mIRC
set i2h_style 1

### Most browsers support page refreshing using meta tags. This
### value determins how long the browser should wait before
### checking if the page has been change:
set i2h_refresh 6

### This value is the maximum number of lines the script will
### keep 'logged' at once and display on the web page:
set i2h_maxlines 18

### All the settings below determin what the generated page
### should look like. Topic, colors of the text, background,
### heading, and the font to use:
set i2h_title "$i2h_chan Live! Chat"
set i2h_text "#666666"
set i2h_joincolor "#006600"
set i2h_bgcolor "#FFFFFF"
set i2h_heading "#666666"
set i2h_font "Fixedsys"

### -----------------------------------------------------------
### About ProjectX
### -----------------------------------------------------------
###
### We are an organised group of scripters determined to help
### each other create, develop and refine scripts. We bundle our
### knowledge, so that the inexperienced scripters may benefit
### from our experienced crew-members and our experienced
### members benefit from the enthousiasm and fresh insights
### from our less-experienced members. We are not trying to
### create the 'ULTIMATE' script, there is no such thing. We
### concentrate on creating good, reliable, compatible and
### useful scripts for eggdrops.
### You can contact ProjectX in the following ways:
### - Visit our homepage..: http://www.projectx.mx.dk/
### - Vist us on IRC......: #ProjectX (GalaxyNet)
### - Drop us an e-mail...: info@projectx.mx.dk

###############################################################
########### Don't change anything below this line! ############
###############################################################

set ver "1.00"
set i2h_history
  • bind ctcp - ACTION ctcp:i2h
    bind join - * join:i2h
    bind kick - * kick:i2h
    if {$numversion < 1030000} {
    bind mode - * mode11x:i2h
    } else {
    bind mode - * mode13x:i2h
    }
    bind nick - * nick:i2h
    bind part - * part:i2h
    bind pubm - * pubm:i2h
    bind sign - * sign:i2h
    bind topc - * topc:i2h

    proc i2h:make {} {
    global i2h_history i2h_htmlfile i2h_maxlines i2h_chan i2h_text i2h_bgcolor i2h_heading i2h_refresh i2h_font i2h_title server
    if {[llength $i2h_history] > $i2h_maxlines} { set i2h_history [lrange $i2h_history 1 end] }
    set i2h_file [open $i2h_htmlfile w]
    puts $i2h_file "<HTML>\n<HEAD>\n <TITLE>$i2h_title</TITLE>\n <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$i2h_refresh\">\n</HEAD>"
    puts $i2h_file "<BODY TEXT=\"$i2h_text\" BGCOLOR=\"$i2h_bgcolor\" LINK=\"$i2h_heading\" VLINK=\"$i2h_heading\">"
    puts $i2h_file " <FONT SIZE=\"+1\" COLOR=\"$i2h_heading\" FACE=\"Tahoma, Sans-serif\">$i2h_chan<FONT SIZE=\"-1\" FACE=\"Fixedsys\"> \[[lindex [getchanmode $i2h_chan] 0]\]: '[i2h:convert [topic $i2h_chan]]'</FONT></FONT><P>"
    puts $i2h_file " <FONT SIZE=\"-1\" FACE=\"$i2h_font\">"
    puts $i2h_file " <B>Server</B>: underworld.undernet.org<BR>"
    puts $i2h_file " <B>Users</B>: [lrange [chanlist $i2h_chan] 0 end] \[[llength [chanlist $i2h_chan]]\]<BR>\n <HR SIZE=\"1\">"
    close $i2h_file
    set i2h_file [open $i2h_htmlfile a]
    for {set i 0} {$i < [llength $i2h_history]} { incr i } {
    puts $i2h_file " [lindex $i2h_history $i]<BR>"
    }
    puts $i2h_file " </FONT>\n <HR SIZE=\"1\">\n <CENTER><FONT SIZE=\"-1\" FACE=\"Sans-serif\"></FONT></CENTER>\n</BODY>\n</HTML>"
    close $i2h_file
    return 1
    }

    proc i2h:convert {i2h_text} {
    #Strip control codes.. sorta
    regsub -all $i2h_text "" i2h_text
    regsub -all $i2h_text "" i2h_text
    regsub -all $i2h_text "" i2h_text
    regsub -all $i2h_text "" i2h_text
    regsub -all $i2h_text "" i2h_text
    #Convert special chars
    regsub -all & $i2h_text "\\&" i2h_text
    regsub -all \" $i2h_text "\\&" i2h_text
    regsub -all < $i2h_text "\\&" i2h_text
    regsub -all > $i2h_text "\\&" i2h_text
    regsub -all " " $i2h_text " \\&" i2h_text
    return $i2h_text
    }

    proc ctcp:i2h {nick host handle dest keyword arg} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $dest] [string tolower $i2h_chan]] && ![string compare $keyword "ACTION"]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] * $nick [i2h:convert $arg]"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] ð $nick [i2h:convert $arg]"]
    }
    }
    utimer 1 i2h:make
    }

    proc join:i2h {nick host handle chan} {
    global i2h_history i2h_chan i2h_style i2h_joincolor
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick ($host) has joined $chan"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- $nick \[$host\] has joined $chan"]
    }
    }
    i2h:make
    }

    proc kick:i2h {nick host handle chan knick arg} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $knick was kicked by $nick ([i2h:convert $arg])"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- $knick was kicked off $chan by $nick ([i2h:convert $arg])"]
    }
    }
    utimer 1 i2h:make
    }

    proc mode11x:i2h {nick host handle chan arg} {
    global i2h_history i2h_chan i2h_style
    if {[lindex $arg 0] == "+k"} {
    set mode [lindex $arg 0]
    } else {
    set mode [lrange $arg 0 end]
    }
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick sets mode: $mode"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- mode/$chan \[$mode\] by user $nick"]
    }
    }
    utimer 1 i2h:make
    }

    proc mode13x:i2h {nick host handle chan arg mnick} {
    global i2h_history i2h_chan i2h_style
    set mode "$arg $mnick"
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick sets mode: $mode"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- mode/$chan \[$mode\] by user $nick"]
    }
    }
    utimer 1 i2h:make
    }

    proc nick:i2h {nick host handle chan newnick} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick is now known as $newnick"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- $nick is now known as $newnick"]
    }
    }
    utimer 1 i2h:make
    }

    proc part:i2h {nick host handle chan {arg ""}} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick ($host) has left $chan"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- $nick has left $chan"]
    }
    }
    utimer 1 i2h:make
    }

    proc pubm:i2h {nick host handle chan arg} {
    global i2h_history i2h_chan i2h_secret
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]] && [string range $arg 0 0] != $i2h_secret} {
    set i2h_history [lappend i2h_history "\[[time]\] &$nick&&[i2h:convert $arg]"]
    }
    i2h:make
    }

    proc sign:i2h {nick host handle chan arg} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick ($host) has quit irc ([i2h:convert $arg])"]
    } else {s
    set i2h_history [lappend i2h_history "\[[time]\] -o- $nick \[$host\] quit ([i2h:convert $arg])"]
    }
    }
    utimer 1 i2h:make
    }

    proc topc:i2h {nick host handle chan topic} {
    global i2h_history i2h_chan i2h_style
    if {![string compare [string tolower $chan] [string tolower $i2h_chan]] && $nick != "*"} {
    if {$i2h_style} {
    set i2h_history [lappend i2h_history "\[[time]\] *** $nick changes topic to '[i2h:convert $topic]'"]
    } else {
    set i2h_history [lappend i2h_history "\[[time]\] -o- $nick changes topic on $chan to '[i2h:convert $topic]'"]
    }
    }
    utimer 1 i2h:make
    }

    set i2h_file [open $i2h_htmlfile w]
    puts $i2h_file "<HTML>\n<HEAD>\n <TITLE>$i2h_title</TITLE>\n <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$i2h_refresh\">\n</HEAD>"
    puts $i2h_file "<BODY TEXT=\"$i2h_text\" BGCOLOR=\"$i2h_bgcolor\" LINK=\"$i2h_heading\" VLINK=\"$i2h_heading\">"
    puts $i2h_file " <FONT SIZE=\"+1\" COLOR=\"$i2h_heading\" FACE=\"Tahoma, Sans-serif\">$i2h_chan<FONT SIZE=\"-1\" FACE=\"Fixedsys\"> \[\]: ''</FONT></FONT><P>"
    puts $i2h_file " <FONT SIZE=\"-1\" FACE=\"${i2h_font}\">"
    puts $i2h_file " <B>Server.</B>: unknown<BR>"
    puts $i2h_file " <B>Users..</B>: unknown<BR>\n <HR SIZE=\"1\">"
    puts $i2h_file " </FONT>\n <HR SIZE=\"1\">\n <CENTER><FONT SIZE=\"-1\" FACE=\"Sans-serif\"></FONT></CENTER>\n</BODY>\n</HTML>"
    close $i2h_file

    utimer 2 i2h:make

    putlog "\[ProjectX\] irc2html v$ver by Natrak <natrak@projectx.mx.dk> loaded."

    Thanks for your help :)
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You can contact the author and ask for this or locate the lines that you want to colour and see this page for instructions on how to use them.
Once the game is over, the king and the pawn go back in the same box.
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

caesar wrote:You can contact the author and ask for this or locate the lines that you want to colour and see this page for instructions on how to use them.
Dear Caesar,

Do you now how to get Natrak? I have tried to check his domain email, but seems to be offline.. Hum, can you teach me step by step on how to add color event in irc2html.. I have read ppslim article, but failed to understand.. Eventhough, I have try put it in irc2html, and it doesn't work.. crash color! :)
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Your issue seems to be with html, not tcl or mirc colors...check www.w3.org :P
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

user wrote:Your issue seems to be with html, not tcl or mirc colors...check www.w3.org :P
Argh, is it true? Hum, what I mean, as below;

proc join:i2h {nick host handle chan} {
global i2h_history i2h_chan i2h_style i2h_joincolor
if {![string compare [string tolower $chan] [string tolower $i2h_chan]]} {
if {$i2h_style} {
set i2h_history [lappend i2h_history "\[[time]\] *** $nick ($host) has joined $chan"] <--||- TO BE IN GREEN COLOR, we can add i2h_joincolor etc etc...
} else {
set i2h_history [lappend i2h_history "\[[time]\] -o- $nick \[$host\] has joined $chan"]
}
}
i2h:make
}

When TCL script wrote a color, is it possible for HTML to be in color too right? or neither?.. Argh.. Little confusing :(
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The best thing would probably be to rewrite the entire script. Keeping the entire log in memory (like this one seems to do) makes no sense.

Or else you'd have to:
a) include the html color formatting in the logged messages
b) parse the messages before output

Both alternatives seem rather unattractive to me...
But if all you need is the html output, the easiest thing would be to add a couple of <FONT> or <SPAN style=..> or whatever -tags around the messages that are to be colored, when they're stored in the history array.
T
TLM
Voice
Posts: 11
Joined: Thu Apr 10, 2003 7:35 pm
Location: Asheville, NC, USA
Contact:

Post by TLM »

That is what I have done, but in the v2 script where doing so is much easier. But once I get some time, I will most likly rewrite this. Right now on the v2 script it has a timestamp problem, which I would like to fix. Also make it a multi channel script.
Locked