Code: Select all
########################################################################
### __ __ __ ###
### ___ ____ __ _ ___ ___ / /_ \ \/ / ###
### / _ \' __/ _ `/ / -_)/ __/ _/ ) ( ###
### / .__/_/ \___/ /\___/\__/\__/ /_/\_\ ###
### /_/ -------- /__/ --------------------- ###
### ###
########################################################################
### ProjectX IRC 2 HTML v2.00 by Natrak <natrak@projectx.mx.dk> ###
########################################################################
### 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 pxi2h in ###
### action visit: ###
### http://www.projectx.mx.dk/contact/spycam.html ###
########################################################################
### Goto http://www.projectx.mx.dk/contact/bugreport.shtml to send ###
### bug reports, or http://www.projectx.mx.dk/contact/feedback.shtml ###
### to tell us what you think of this script. ###
########################################################################
### Configuration:
#
# The channel set to show online:
set pxi2h_chan(#EPL) "/home/xabriel/eggdrop/public_html/EPL.html"
#
# The prefix to prevent stuff from being shown on the web:
set pxi2h(secret) "."
#
# Maximum number of lines shown on the web:
set pxi2h(maxlines) 50
#
# The page is set to refes every X seconds:
set pxi2h(refresh) 5
#
# The title of the page:
set pxi2h(title) "#EPL - Latest Activity"
#
# Text color:
set pxi2h(text) ""
#
# Background color:
set pxi2h(bgcolor) "#ffffff"
#
# Heading color:
set pxi2h(heading) "#ff6a6a"
#
# Font type:
set pxi2h(font) "monospace"
#
### End of config.
########################################################################
proc pxi2h:style {event chan nick host arg} {
global pxi2h_history
set chan [pxi2h:findchan $chan]
if {$chan == ""} { return }
switch -- $event {
actn { set text "* $nick $arg" }
join { set text "*** $nick ($host) has joined $chan" }
kick { set text "*** [lindex $arg 0] was kicked by $nick ([lrange $arg 1 end])" }
mode { set text "*** $nick sets mode: $arg" }
nick { set text "*** $nick is now known as $arg" }
part { set text "*** $nick ($host) has left $chan" }
pubm { set text "<$nick> $arg" }
sign { set text "*** $nick ($host) #has quit irc ($arg)" }
topc { set text "*** $nick changes topic to '$arg'" }
}
set pxi2h_history($chan) [lappend pxi2h_history($chan) [pxi2h:control [pxi2h:convert $text]]]
utimer 1 "pxi2h:make $chan"
}
proc pxi2h:dcc {hand idx arg} {
global pxi2h
if {[string tolower [lindex $arg 0]] == "on"} {
set pxi2h(status) "on"
} elseif {[string tolower [lindex $arg 0]] == "off"} {
set pxi2h(status) "off"
}
putdcc $idx "ProjectX irc2html is $pxi2h(status)"
return 1
}
proc pxi2h:html {text} {
return [pxi2h:unconvert [pxi2h:convert $text]]
}
proc pxi2h:control {text} {
set temp $text
set text ""
set bold "0"
set undr "0"
set color ""
for {set i 0} {$i < [string length $temp]} {incr i} {
set c [string index $temp $i]
switch -- $c {
{ if {$bold == "1"} { set text "$text</B>"; set bold "0" } else { set text "$text<B>"; set bold "1" } }
{ if {$undr == "1"} { set text "$text</U>"; set undr "0" } else { set text "$text<U>"; set undr "1" } }
{ }
{ }
default { set text "$text$c" }
}
}
if {$bold == "1"} { set text "$text</B>" }
if {$undr == "1"} { set text "$text</U>" }
return $text
}
proc pxi2h:convert {text} {
regsub -all , $text "" text
regsub -all 0 $text "" text
regsub -all 1 $text "" text
regsub -all 2 $text "" text
regsub -all 3 $text "" text
regsub -all 4 $text "" text
regsub -all 5 $text "" text
regsub -all 6 $text "" text
regsub -all 7 $text "" text
regsub -all 8 $text "" text
regsub -all 9 $text "" text
regsub -all {\]} $text "p!c1" text
regsub -all {\[} $text "p!c2" text
regsub -all {\}} $text "p!c3" text
regsub -all {\{} $text "p!c4" text
regsub -all {\$} $text "p!c5" text
regsub -all {\"} $text "p!c6" text
regsub -all {\;} $text "p!c7" text
regsub -all {\\} $text "p!c8" text
regsub -all {\/} $text "p!c9" text
regsub -all & $text "\\&" text
regsub -all < $text "\\<" text
regsub -all > $text "\\>" text
regsub -all \" $text "\\"" text
regsub -all " " $text "\\ " text
return $text
}
proc pxi2h:unconvert {text} {
regsub -all {p!c1} $text "\]" text
regsub -all {p!c2} $text "\[" text
regsub -all {p!c3} $text "\}" text
regsub -all {p!c4} $text "\{" text
regsub -all {p!c5} $text "\$" text
regsub -all {p!c6} $text "\"" text
regsub -all {p!c7} $text "\;" text
regsub -all {p!c8} $text "\\" text
regsub -all {p!c9} $text "\/" text
return $text
}
proc pxi2h:make {chan} {
global pxi2h_history pxi2h pxi2h_chan server
if {[llength $pxi2h_history($chan)] > $pxi2h(maxlines)} { set pxi2h_history($chan) [lrange $pxi2h_history($chan) 1 end] }
set nicks ""
foreach nick [chanlist $chan] {
if {[isop $nick $chan]} {
set nicks "$nicks @[pxi2h:convert $nick]"
} elseif {[isvoice $nick $chan]} {
set nicks "$nicks +[pxi2h:convert $nick]"
} else {
set nicks "$nicks [pxi2h:convert $nick]"
}
}
set nicks [lsort -increasing $nicks]
set html [open $pxi2h_chan($chan) w]
puts $html "<HTML>\n<HEAD>\n <TITLE>$pxi2h(title)</TITLE>\n <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$pxi2h(refresh)\">\n</HEAD>"
puts $html "BGCOLOR=\"$pxi2h(bgcolor)\" LINK=\"$pxi2h(heading)\" VLINK=\"$pxi2h(heading)\">"
puts $html " <FONT COLOR=\"$pxi2h(heading)\"><FONT SIZE=\"+0\" FACE=\"sans-serif\">$chan</FONT> <FONT SIZE=\"+1\" FACE=\"monospace\">: '[pxi2h:html [topic $chan]]'</FONT></FONT><P>"
puts $html " <FONT SIZE=\"-1\" FACE=\"$pxi2h(font)\">"
puts $html " <B>Server</B>: [string range $server 0 [expr [string last ":" $server] - 1]]<BR>"
puts $html " <B>Users</B>: [pxi2h:unconvert $nicks]<BR>\n <HR SIZE=\"1\">"
close $html
set html [open $pxi2h_chan($chan) a]
if {$pxi2h(status) == "on"} {
for {set i 0} {$i < [llength $pxi2h_history($chan)]} { incr i } {
puts $html " \[[strftime "%H:%M"]\][pxi2h:unconvert [lindex $pxi2h_history($chan) $i]]<BR>"
}
} else {
puts $html " <BR><CENTER><B>O F F L I N E !</B></CENTER><P>"
}
puts $html " </FONT>\n <HR SIZE=\"1\">\n <CENTER><FONT SIZE=\"-1\" FACE=\"sans-serif\"><I>Powered by <A HREF=\"http://www.eplonline.co.uk/viewpage.php?page_id=4/\">#EPL Quakenet</A></I></FONT></CENTER>\n</BODY>\n</HTML>"
close $html
}
proc pxi2h:findchan {chan} {
global pxi2h_chan
foreach ele [array names pxi2h_chan] {
if {[string tolower $ele] == [string tolower $chan]} { return $ele }
}
}
proc pxi2h:ctcp {nick host handle dest keyword arg} {
if {![string compare $keyword "ACTION"]} { pxi2h:style "actn" $dest $nick $host $arg }
}
proc pxi2h:join {nick host handle chan} {
pxi2h:style "join" $chan $nick $host ""
}
proc pxi2h:kick {nick host handle chan knick arg} {
pxi2h:style "kick" $chan $nick $host "$knick $arg"
}
proc pxi2h:mode11x {nick host handle chan arg} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode [lrange $arg 0 end] }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:mode13x {nick host handle chan arg mnick} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode "[lrange $arg 0 end] $mnick" }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:nick {nick host handle chan newnick} {
pxi2h:style "nick" $chan $nick $host $newnick
}
proc pxi2h:part {nick host handle chan rest} {
pxi2h:style "part" $chan $nick $host ""
}
proc pxi2h:pubm {nick host handle chan arg} {
global pxi2h
if {[string range $arg 0 0] != $pxi2h(secret)} { pxi2h:style "pubm" $chan $nick $host $arg }
}
proc pxi2h:sign {nick host handle chan arg} {
pxi2h:style "sign" $chan $nick $host $arg
}
proc pxi2h:topc {nick host handle chan topic} {
if {$nick != "*"} { pxi2h:style "topc" $chan $nick $host $topic }
}
bind dcc +m irc2html pxi2h:dcc
bind ctcp - ACTION pxi2h:ctcp
bind join - * pxi2h:join
bind kick - * pxi2h:kick
if {[lindex $version 1] < "01030000"} {
bind mode - * pxi2h:mode11x
} else {
bind mode - * pxi2h:mode13x
}
bind nick - * pxi2h:nick
bind part - * pxi2h:part
bind pubm - * pxi2h:pubm
bind sign - * pxi2h:sign
bind topc - * pxi2h:topc
set pxi2h(ver) "2.00"
if {![info exists pxi2h(status)]} { set pxi2h(status) "on" }
foreach ele [array names pxi2h_chan] {
if {![info exists pxi2h_history($ele)]} { set pxi2h_history($ele) "" }
pxi2h:make $ele
}
putlog "\[ProjectX\] irc2html v$pxi2h(ver) loaded."
Code: Select all
regsub -all 0 $text "" text
regsub -all 1 $text "" text
regsub -all 2 $text "" text
regsub -all 3 $text "" text
regsub -all 4 $text "" text
regsub -all 5 $text "" text
regsub -all 6 $text "" text
regsub -all 7 $text "" text
regsub -all 8 $text "" text
regsub -all 9 $text "" text
Code: Select all
puts $html "BGCOLOR=\"$pxi2h(bgcolor)\" LINK=\"$pxi2h(heading)\" VLINK=\"$pxi2h(heading)\">"
Code: Select all
puts $html "<BODY BGCOLOR=\"$pxi2h(bgcolor)\" LINK=\"$pxi2h(heading)\" VLINK=\"$pxi2h(heading)\">"
Code: Select all
########################################################################
### __ __ __ ###
### ___ ____ __ _ ___ ___ / /_ \ \/ / ###
### / _ \' __/ _ `/ / -_)/ __/ _/ ) ( ###
### / .__/_/ \___/ /\___/\__/\__/ /_/\_\ ###
### /_/ -------- /__/ --------------------- ###
### ###
########################################################################
### ProjectX IRC 2 HTML v2.1 by Trixar_za <trixarian@gmail.com> ###
### based on original script by Natrak <natrak@projectx.mx.dk> ###
########################################################################
### This script logs what goes on in an IRC channel, converts it to ###
### HTML and make it visible to user on the web. ###
########################################################################
### I mainly just fixed the bugs in this and added in a crapload ###
### more user configuration options, better way to handel font ###
### types, sizes and color. I also added in a way to show mirc ###
### control codes (even colours). So Enjoy! ###
### -- Trixar_za ###
########################################################################
### Configuration:
#
# The channel set to show online & path to output to:
set pxi2h_chan(#Zen) "/home/brenton/eggdrop/EPL.html"
#
# The prefix to prevent stuff from being shown on the web:
set pxi2h(secret) "."
#
# Maximum number of lines shown on the web:
set pxi2h(maxlines) 50
#
# The page is set to refes every X seconds:
set pxi2h(refresh) 5
#
# The title of the page:
set pxi2h(title) "#EPL - Latest Activity"
#
# The powered by of the page:
set pxi2h(powered) "<A HREF=\"http://www.eplonline.co.uk/viewpage.php?page_id=4/\">#EPL Quakenet</A>"
#
# Background color:
set pxi2h(bgcolor) "white"
#
# Default Font:
set pxi2h(font) "monospace"
#
# Default Text color:
set pxi2h(text) "black"
#
# Font type, color & size (in standard pixel format) for the heading:
set pxi2h(hfont) "sans-serif"
set pxi2h(heading) "#ff6a6a"
set pxi2h(hfontsize) "18"
#
# Font type, color & size (in standard pixel format) for the server address:
set pxi2h(sfont) "monospace"
set pxi2h(sfontcol) "black"
set pxi2h(sfontsize) "10"
#
# Font type, color & size (in standard pixel format) for the user list:
set pxi2h(ufont) "monospace"
set pxi2h(ufontcol) "black"
set pxi2h(ufontsize) "10"
#
# Font type, color & size (in standard pixel format) for the channel text:
set pxi2h(mfont) "monospace"
set pxi2h(mfontcol) "black"
set pxi2h(mfontsize) "11"
#
# Font type, color & size (in standard pixel format) for the powered by message:
set pxi2h(pfont) "sans-serif"
set pxi2h(pfontcol) "black"
set pxi2h(pfontsize) "12"
#
### End of config.
########################################################################
proc pxi2h:style {event chan nick host arg} {
global pxi2h_history
set chan [pxi2h:findchan $chan]
if {$chan == ""} { return }
switch -- $event {
actn { set text "* $nick $arg" }
join { set text "\00304*** $nick ($host) has joined $chan" }
kick { set text "*** [lindex $arg 0] was kicked by $nick ([lrange $arg 1 end])" }
mode { set text "*** $nick sets mode: $arg" }
nick { set text "*** $nick is now known as $arg" }
part { set text "*** $nick ($host) has left $chan" }
pubm { set text "<$nick> $arg" }
sign { set text "*** $nick ($host) #has quit irc ($arg)" }
topc { set text "*** $nick changes topic to '$arg'" }
}
set pxi2h_history($chan) [lappend pxi2h_history($chan) [pxi2h:control [pxi2h:convert $text]]]
utimer 1 "pxi2h:make $chan"
}
proc pxi2h:dcc {hand idx arg} {
global pxi2h
if {[string tolower [lindex $arg 0]] == "on"} {
set pxi2h(status) "on"
} elseif {[string tolower [lindex $arg 0]] == "off"} {
set pxi2h(status) "off"
}
putdcc $idx "ProjectX irc2html is $pxi2h(status)"
return 1
}
proc pxi2h:html {text} {
return [pxi2h:unconvert [pxi2h:convert $text]]
}
# mirc to html code by stdragon
proc pxi2h:control {text} {
set mirc_color(00) "white"
set mirc_color(01) "black"
set mirc_color(02) "blue"
set mirc_color(03) "green"
set mirc_color(04) "red"
set mirc_color(05) "brown"
set mirc_color(06) "purple"
set mirc_color(07) "orange"
set mirc_color(08) "yellow"
set mirc_color(09) "lightgreen"
set mirc_color(10) "cyan"
set mirc_color(11) "lightcyan"
set mirc_color(12) "lightblue"
set mirc_color(13) "pink"
set mirc_color(14) "grey"
set mirc_color(15) "lightgrey"
set chars [split $text ""]
set len [llength $chars]
set output ""
set in_bold 0
set in_color 0
set in_uline 0
for {set i 0} {$i < $len} {incr i} {
switch [lindex $chars $i] {
"" {
if {$in_bold} {
append output "</b>"
set in_bold 0
} else {
append output "<b>"
set in_bold 1
}
}
"" {
incr i
set c [lindex $chars $i]
if {$i < $len && [string is integer $c]} {
incr i
set d [lindex $chars $i]
if {$i < $len && [string is integer $d]} {
incr i
set num "$c$d"
} else {
set num "0$c"
}
if {$in_color} { append output "</font>" }
append output "<font color="
if {[info exists mirc_color($num)]} {
append output $mirc_color($num)
} else {
append output $pxi2h(text)
}
append output ">"
set in_color 1
# Skip past background color if it's there.
set c [lindex $chars $i]
if {$i < $len && $c == ","} {
incr i
set c [lindex $chars $i]
if {$i < $len && [string is integer $c]} {
incr i
set c [lindex $chars $i]
if {![string is integer $c]} { incr i -1 }
} else { incr i -2 }
} else { incr i -1 }
} else {
if {$in_color} { append output "</font>" }
set in_color 0
incr i -1
}
}
"" {
if {$in_uline} {
append output "</u>"
set in_uline 0
} else {
append output "<u>"
set in_uline 1
}
}
default {
append output [lindex $chars $i]
}
}
}
if {$in_bold} { append output "</b>" }
if {$in_color} { append output "</font>" }
if {$in_uline} { append output "</u>" }
return $output
}
proc pxi2h:clean {text} {
regsub -all {} $text "" text
regsub -all {[0-9]*} $text "" text
regsub -all {} $text "" text
return $text
}
proc pxi2h:convert {text} {
regsub -all , $text "" text
regsub -all {\]} $text "p!c1" text
regsub -all {\[} $text "p!c2" text
regsub -all {\}} $text "p!c3" text
regsub -all {\{} $text "p!c4" text
regsub -all {\$} $text "p!c5" text
regsub -all {\"} $text "p!c6" text
regsub -all {\;} $text "p!c7" text
regsub -all {\\} $text "p!c8" text
regsub -all {\/} $text "p!c9" text
regsub -all & $text "\\&" text
regsub -all < $text "\\<" text
regsub -all > $text "\\>" text
regsub -all \" $text "\\"" text
regsub -all " " $text "\\ " text
return $text
}
proc pxi2h:unconvert {text} {
regsub -all {p!c1} $text "\]" text
regsub -all {p!c2} $text "\[" text
regsub -all {p!c3} $text "\}" text
regsub -all {p!c4} $text "\{" text
regsub -all {p!c5} $text "\$" text
regsub -all {p!c6} $text "\"" text
regsub -all {p!c7} $text "\;" text
regsub -all {p!c8} $text "\\" text
regsub -all {p!c9} $text "\/" text
return $text
}
proc pxi2h:make {chan} {
global pxi2h_history pxi2h pxi2h_chan server
if {[llength $pxi2h_history($chan)] > $pxi2h(maxlines)} { set pxi2h_history($chan) [lrange $pxi2h_history($chan) 1 end] }
set nicks ""
foreach nick [chanlist $chan] {
if {[isop $nick $chan]} {
set nicks "$nicks @[pxi2h:convert $nick]"
} elseif {[isvoice $nick $chan]} {
set nicks "$nicks +[pxi2h:convert $nick]"
} else {
set nicks "$nicks [pxi2h:convert $nick]"
}
}
set nicks [lsort -increasing $nicks]
set html [open $pxi2h_chan($chan) w]
puts $html "<HTML>\n<HEAD>\n <TITLE>$pxi2h(title)</TITLE>\n <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$pxi2h(refresh)\">\n</HEAD>"
puts $html "<BODY TEXT=\"$pxi2h(text)\" BGCOLOR=\"$pxi2h(bgcolor)\" LINK=\"$pxi2h(heading)\" VLINK=\"$pxi2h(heading)\">"
puts $html "<FONT COLOR=\"$pxi2h(heading)\" FACE=\"$pxi2h(hfont)\"><DIV style=\"font-size:$pxi2h(hfontsize)px\">$chan: '[pxi2h:clean [pxi2h:html [topic $chan]]]'</DIV></FONT><P>"
puts $html "<FONT COLOR=\"$pxi2h(sfontcol)\" FACE=\"$pxi2h(sfont)\"><DIV style=\"font-size:$pxi2h(sfontsize)px\"><B>Server</B>: [string range $server 0 [expr [string last ":" $server] - 1]]<DIV></FONT>"
puts $html "<FONT COLOR=\"$pxi2h(ufontcol)\" FACE=\"$pxi2h(ufont)\"><DIV style=\"font-size:$pxi2h(ufontsize)px\"><B>Users</B>: [pxi2h:unconvert $nicks]</DIV></FONT>\n <HR SIZE=\"1\">"
close $html
set html [open $pxi2h_chan($chan) a]
if {$pxi2h(status) == "on"} {
for {set i 0} {$i < [llength $pxi2h_history($chan)]} { incr i } {
puts $html "<FONT COLOR=\"$pxi2h(mfontcol)\" FACE=\"$pxi2h(mfont)\"><DIV style=\"font-size:$pxi2h(mfontsize)px\">\[[strftime "%H:%M"]\] [pxi2h:unconvert [lindex $pxi2h_history($chan) $i]]</DIV></FONT>"
}
} else {
puts $html "<BR><CENTER><B>O F F L I N E !</B></CENTER><P>"
}
puts $html "<HR SIZE=\"1\">\n <CENTER><FONT COLOR=\"$pxi2h(pfontcol)\" FACE=\"$pxi2h(pfont)\"><DIV style=\"font-size:$pxi2h(pfontsize)px\"><I>Powered by $pxi2h(powered)</I></DIV></FONT></CENTER>\n</BODY>\n</HTML>"
close $html
}
proc pxi2h:findchan {chan} {
global pxi2h_chan
foreach ele [array names pxi2h_chan] {
if {[string tolower $ele] == [string tolower $chan]} { return $ele }
}
}
proc pxi2h:ctcp {nick host handle dest keyword arg} {
if {![string compare $keyword "ACTION"]} { pxi2h:style "actn" $dest $nick $host $arg }
}
proc pxi2h:join {nick host handle chan} {
pxi2h:style "join" $chan $nick $host ""
}
proc pxi2h:kick {nick host handle chan knick arg} {
pxi2h:style "kick" $chan $nick $host "$knick $arg"
}
proc pxi2h:mode11x {nick host handle chan arg} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode [lrange $arg 0 end] }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:mode13x {nick host handle chan arg mnick} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode "[lrange $arg 0 end] $mnick" }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:nick {nick host handle chan newnick} {
pxi2h:style "nick" $chan $nick $host $newnick
}
proc pxi2h:part {nick host handle chan rest} {
pxi2h:style "part" $chan $nick $host ""
}
proc pxi2h:pubm {nick host handle chan arg} {
global pxi2h
if {[string range $arg 0 0] != $pxi2h(secret)} { pxi2h:style "pubm" $chan $nick $host $arg }
}
proc pxi2h:sign {nick host handle chan arg} {
pxi2h:style "sign" $chan $nick $host $arg
}
proc pxi2h:topc {nick host handle chan topic} {
if {$nick != "*"} { pxi2h:style "topc" $chan $nick $host $topic }
}
bind dcc +m irc2html pxi2h:dcc
bind ctcp - ACTION pxi2h:ctcp
bind join - * pxi2h:join
bind kick - * pxi2h:kick
if {[lindex $version 1] < "01030000"} {
bind mode - * pxi2h:mode11x
} else {
bind mode - * pxi2h:mode13x
}
bind nick - * pxi2h:nick
bind part - * pxi2h:part
bind pubm - * pxi2h:pubm
bind sign - * pxi2h:sign
bind topc - * pxi2h:topc
set pxi2h(ver) "2.00"
if {![info exists pxi2h(status)]} { set pxi2h(status) "on" }
if {[info exists pxi2h(status)] && [validchan pxi2h_chan]} {
foreach ele [array names pxi2h_chan] {
if {![info exists pxi2h_history($ele)]} { set pxi2h_history($ele) "" }
pxi2h:make $ele
}
}
putlog "\[ProjectX\] irc2html v$pxi2h(ver) loaded."
Code: Select all
########################################################################
### __ __ __ ###
### ___ ____ __ _ ___ ___ / /_ \ \/ / ###
### / _ \' __/ _ `/ / -_)/ __/ _/ ) ( ###
### / .__/_/ \___/ /\___/\__/\__/ /_/\_\ ###
### /_/ -------- /__/ --------------------- ###
### ###
########################################################################
### ProjectX IRC 2 HTML v3.0 by Trixar_za <trixarian@gmail.com> ###
### based on original script by Natrak <natrak@projectx.mx.dk> ###
########################################################################
### This script logs what goes on in an IRC channel, converts it to ###
### HTML and make it visible to user on the web. ###
########################################################################
### The Configuration madness continues and this script is even more ###
### configurable to the point that you can alter most of the ###
### elements without alterning a single line of code. ###
### I also fixed some of my lingering bugs and added utf-8 support, ###
### which to me warrented another release and version number. ###
### So enjoy and have fun with it ;) ###
### -- Trixar_za ###
########################################################################
### Configuration:
#
# The channel set to show online & path to output to:
set pxi2h_chan(#Chatz) "/home/irc/eggdrop/index.html"
#
# The prefix to prevent stuff from being shown on the web:
set pxi2h(secret) "."
#
# Maximum number of lines shown on the web:
set pxi2h(maxlines) 50
#
# The page is set to refes every X seconds:
set pxi2h(refresh) 5
#
# HTML MANAGEMENT:
# Change these to alter the text, font, colour and size of the html elements
#
# The title of the page:
set pxi2h(title) "#Chatz - Latest Activity"
#
# Default Font & text colour:
set pxi2h(font) "monospace"
set pxi2h(text) "white"
#
# Background colour:
set pxi2h(bgcolor) "black"
#
# Links colour:
set pxi2h(links) "#FF6A6A"
#
# Topic Heading:
set pxi2h(htxt) "Topic for #Chatz: "
set pxi2h(hfont) "sans-serif"
set pxi2h(heading) "#FF6A6A"
set pxi2h(hfontsize) "18"
# Strip colours and other codes from the topic and only use the above colour?
# Remember more colours equal bigger file equals slower refresh times in a browser!
# Set this as 1 to enable and as 0 to disable
set pxi2h(tstrip) 1
#
# The user list:
set pxi2h(ufont) "monospace"
set pxi2h(ufontcol) "white"
set pxi2h(ufontsize) "10"
#
# Channel text:
set pxi2h(mfont) "monospace"
set pxi2h(mfontcol) "lightgrey"
set pxi2h(mfontsize) "11"
#
# Powered by footer:
set pxi2h(powered) "Powered by <A HREF=\"http://chat.gigirc.com/?channel=#chatz\">#Chatz on GigIRC</A>"
set pxi2h(pfont) "sans-serif"
set pxi2h(pfontcol) "white"
set pxi2h(pfontsize) "12"
#
# EVENTS MANAGEMENT:
#
# Change these to alter the text, colours and symbols used for events:
# The symbol gets used with actions (one) and events (three)
# Colour Key: white(00), black(01), blue(02), green(03), red(04), brown(05), purple(06), orange(07),
# yellow(08), light green(09), cyan(10), light cyan(11), light blue(12), pink(13), grey(14),
# light grey(15)
# Leave as "" to use default font colour. Remember more colours equal bigger file equals slower
# refresh times in a browser!
#
# Timestamp configuration:
set pxi2h(tstamp) "%H:%M:%S"
set pxi2h(tstampcol) "14"
set pxi2h(tleft) "\("
set pxi2h(tright) "\)"
# Nick wrapper (The <> or [] around nicknames - remember to prefix [ or ] with \ to use),
# and colours:
set pxi2h(left) "\["
set pxi2h(right) "\]"
# The Rest:
set pxi2h(symbol) "*"
set pxi2h(actioncol) "08"
set pxi2h(jointxt) "has joined"
set pxi2h(joincol) "03"
set pxi2h(kicktxt) "was kicked by"
set pxi2h(kickcol) "14"
set pxi2h(modetxt) "sets mode:"
set pxi2h(modecol) "07"
set pxi2h(nickchangetxt) "is now known as"
set pxi2h(nickchangecol) "07"
set pxi2h(parttxt) "has left"
set pxi2h(partcol) "14"
set pxi2h(quittxt) "has quit"
set pxi2h(quitcol) "04"
set pxi2h(topichangetxt) "changes the topic to"
set pxi2h(topichangecol) "07"
#
# STRIP FUNCTIONS:
#
# Use this to strip colour or formatting codes from users
# enable it by setting it as 1 and set as 0 to disable
set pxi2h(ustrip) 1
# This is the master strip function - it even strips the above colours you
# just set and uses the html elements colours only. Use this is your in
# serious need of smaller files and don't want to do all the effort of
# setting all the above colours to ""
# Set to 1 to enable and set to 0 to disable.
set pxi2h(mstrip) 0
#
########################################################################
### End of config. ###
########################################################################
proc pxi2h:style {event chan nick host arg} {
global pxi2h_history pxi2h
set chan [pxi2h:findchan $chan]
if {$chan == ""} { return }
set arg [encoding convertto utf-8 $arg]
if {$pxi2h(ustrip) == 1} {
set arg [pxi2h:clean $arg]
}
switch -- $event {
actn { set text "\003$pxi2h(actioncol)$pxi2h(symbol) $nick $arg" }
join { set text "\003$pxi2h(joincol)[string repeat $pxi2h(symbol) 3] $nick ($host) $pxi2h(jointxt) $chan" }
kick { set text "\003$pxi2h(kickcol)[string repeat $pxi2h(symbol) 3] [lindex $arg 0] $pxi2h(kicktxt) $nick ([lrange $arg 1 end])" }
mode { set text "\003$pxi2h(modecol)[string repeat $pxi2h(symbol) 3] $nick $pxi2h(modetxt) $arg" }
nick { set text "\003$pxi2h(nickchangecol)[string repeat $pxi2h(symbol) 3] $nick $pxi2h(nickchangetxt) $arg" }
part { set text "\003$pxi2h(partcol)[string repeat $pxi2h(symbol) 3] $nick ($host) $pxi2h(parttxt) $chan" }
pubm {
if {[ishalfop $nick $chan]} {
set text "$pxi2h(left)%$nick$pxi2h(right) $arg"
} elseif {[isop $nick $chan]} {
set text "$pxi2h(left)@$nick$pxi2h(right) $arg"
} elseif {[isvoice $nick $chan]} {
set text "$pxi2h(left)+$nick$pxi2h(right) $arg"
} else {
set text "$pxi2h(left)$nick$pxi2h(right) $arg"
}
}
sign { set text "\003$pxi2h(quitcol)[string repeat $pxi2h(symbol) 3] $nick ($host) $pxi2h(quittxt) ($arg)" }
topc { set text "\003$pxi2h(topichangecol)[string repeat $pxi2h(symbol) 3] $nick $pxi2h(topichangetxt) \"$arg\"" }
}
set text "[strftime "\003$pxi2h(tstampcol)$pxi2h(tleft)$pxi2h(tstamp)$pxi2h(tright)\003"] $text"
set pxi2h_history($chan) [lappend pxi2h_history($chan) [pxi2h:control [pxi2h:convert $text]]]
utimer 1 "pxi2h:make $chan"
}
proc pxi2h:dcc {hand idx arg} {
global pxi2h
if {[string tolower [lindex $arg 0]] == "on"} {
set pxi2h(status) "on"
} elseif {[string tolower [lindex $arg 0]] == "off"} {
set pxi2h(status) "off"
}
putdcc $idx "ProjectX irc2html is $pxi2h(status)"
return 1
}
proc pxi2h:html {text} {
return [pxi2h:unconvert [pxi2h:convert $text]]
}
# mirc to html code by stdragon
proc pxi2h:control {text} {
set mirc_color(00) "white"
set mirc_color(01) "black"
set mirc_color(02) "blue"
set mirc_color(03) "green"
set mirc_color(04) "red"
set mirc_color(05) "brown"
set mirc_color(06) "purple"
set mirc_color(07) "orange"
set mirc_color(08) "yellow"
set mirc_color(09) "lightgreen"
set mirc_color(10) "cyan"
set mirc_color(11) "lightcyan"
set mirc_color(12) "lightblue"
set mirc_color(13) "pink"
set mirc_color(14) "grey"
set mirc_color(15) "lightgrey"
set chars [split $text ""]
set len [llength $chars]
set output ""
set in_bold 0
set in_color 0
set in_uline 0
for {set i 0} {$i < $len} {incr i} {
switch -- [lindex $chars $i] {
"\002" {
if {$in_bold} {
append output "</b>"
set in_bold 0
} else {
append output "<b>"
set in_bold 1
}
}
"\003" {
incr i
set c [lindex $chars $i]
if {$i < $len && [string is integer $c]} {
incr i
set d [lindex $chars $i]
if {$i < $len && [string is integer $d]} {
incr i
set num "$c$d"
} else {
set num "0$c"
}
if {$in_color} { append output "</font>" }
append output "<font color="
if {[info exists mirc_color($num)]} {
append output $mirc_color($num)
} else {
append output $pxi2h(text)
}
append output ">"
set in_color 1
# Skip past background color if it's there.
set c [lindex $chars $i]
if {$i < $len && $c == ","} {
incr i
set c [lindex $chars $i]
if {$i < $len && [string is integer $c]} {
incr i
set c [lindex $chars $i]
if {![string is integer $c]} { incr i -1 }
} else { incr i -2 }
} else { incr i -1 }
} else {
if {$in_color} { append output "</font>" }
set in_color 0
incr i -1
}
}
"\x1F" {
if {$in_uline} {
append output "</u>"
set in_uline 0
} else {
append output "<u>"
set in_uline 1
}
}
default {
append output [lindex $chars $i]
}
}
}
if {$in_bold} { append output "</b>" }
if {$in_color} { append output "</font>" }
if {$in_uline} { append output "</u>" }
return $output
}
proc pxi2h:clean {text} {
regsub -all {\002} $text "" text
regsub -all {\003[0-9]*} $text "" text
regsub -all {\x1F} $text "" text
return $text
}
proc pxi2h:convert {text} {
global pxi2h
regsub -all {\]} $text {p!c1} text
regsub -all {\[} $text {p!c2} text
regsub -all {\}} $text {p!c3} text
regsub -all {\{} $text {p!c4} text
regsub -all {\$} $text {p!c5} text
regsub -all {\"} $text {p!c6} text
regsub -all {\;} $text {p!c7} text
regsub -all {\\} $text {p!c8} text
regsub -all {\/} $text {p!c9} text
regsub -all {\&} $text {\&} text
regsub -all {\<} $text {\<} text
regsub -all {\>} $text {\>} text
regsub -all {\"} $text {\"} text
regsub -all { } $text {\ } text
if {$pxi2h(mstrip) == 1} {
set text [pxi2h:clean $text]
}
return $text
}
proc pxi2h:unconvert {text} {
regsub -all {p!c1} $text "\]" text
regsub -all {p!c2} $text "\[" text
regsub -all {p!c3} $text "\}" text
regsub -all {p!c4} $text "\{" text
regsub -all {p!c5} $text "\$" text
regsub -all {p!c6} $text "\"" text
regsub -all {p!c7} $text "\;" text
regsub -all {p!c8} $text "\\" text
regsub -all {p!c9} $text "\/" text
return $text
}
proc pxi2h:make {chan} {
global pxi2h_history pxi2h pxi2h_chan server
if {[llength $pxi2h_history($chan)] > $pxi2h(maxlines)} { set pxi2h_history($chan) [lrange $pxi2h_history($chan) 1 end] }
set ops ""
set halfops ""
set voice ""
set other ""
foreach nick [chanlist $chan] {
if {[ishalfop $nick $chan]} {
set halfops "$halfops %[pxi2h:convert $nick]"
} elseif {[isop $nick $chan]} {
set ops "$ops @[pxi2h:convert $nick]"
} elseif {[isvoice $nick $chan]} {
set voice "$voice +[pxi2h:convert $nick]"
} else {
set other "$other [pxi2h:convert $nick]"
}
}
set ops [lsort -increasing $ops]
set halfops [lsort -increasing $halfops]
set voice [lsort -increasing $voice]
set other [lsort -increasing $other]
set ops "$ops $halfops"
set other "$voice $other"
set html [open $pxi2h_chan($chan) w]
puts $html "<HTML>\n<HEAD>\n <TITLE>$pxi2h(title)</TITLE>\n <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$pxi2h(refresh)\">\n <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n </HEAD>"
puts $html "<BODY TEXT=\"$pxi2h(text)\" BGCOLOR=\"$pxi2h(bgcolor)\" LINK=\"$pxi2h(links)\" VLINK=\"$pxi2h(links)\">"
if {$pxi2h(tstrip) == 0} {
puts $html "<FONT COLOR=\"$pxi2h(heading)\" FACE=\"$pxi2h(hfont)\"><DIV style=\"font-size:$pxi2h(hfontsize)px\">$pxi2h(htxt)\"[pxi2h:control [pxi2h:html [topic $chan]]]\"</DIV></FONT><BR />"
} else {
puts $html "<FONT COLOR=\"$pxi2h(heading)\" FACE=\"$pxi2h(hfont)\"><DIV style=\"font-size:$pxi2h(hfontsize)px\">$pxi2h(htxt)\"[pxi2h:clean [pxi2h:html [topic $chan]]]\"</DIV></FONT><BR />"
}
puts $html "<FONT COLOR=\"$pxi2h(ufontcol)\" FACE=\"$pxi2h(ufont)\"><DIV style=\"font-size:$pxi2h(ufontsize)px\"><B>Ops</B>: [pxi2h:unconvert $ops]</DIV></FONT>\n"
puts $html "<FONT COLOR=\"$pxi2h(ufontcol)\" FACE=\"$pxi2h(ufont)\"><DIV style=\"font-size:$pxi2h(ufontsize)px\"><B>Users</B>: [pxi2h:unconvert $other]</DIV></FONT>\n <HR SIZE=\"1\">"
close $html
set html [open $pxi2h_chan($chan) a]
if {$pxi2h(status) == "on"} {
for {set i 0} {$i < [llength $pxi2h_history($chan)]} { incr i } {
puts $html "<FONT COLOR=\"$pxi2h(mfontcol)\" FACE=\"$pxi2h(mfont)\"><DIV style=\"font-size:$pxi2h(mfontsize)px\">[pxi2h:unconvert [lindex $pxi2h_history($chan) $i]]</DIV></FONT>"
}
} else {
puts $html "<BR><CENTER><B>O F F L I N E !</B></CENTER><P>"
}
puts $html "<HR SIZE=\"1\">\n <CENTER><FONT COLOR=\"$pxi2h(pfontcol)\" FACE=\"$pxi2h(pfont)\"><DIV style=\"font-size:$pxi2h(pfontsize)px\"><I>$pxi2h(powered)</I></DIV></FONT></CENTER>\n</BODY>\n</HTML>"
close $html
}
proc pxi2h:findchan {chan} {
global pxi2h_chan
foreach ele [array names pxi2h_chan] {
if {[string tolower $ele] == [string tolower $chan]} { return $ele }
}
}
proc pxi2h:ctcp {nick host handle dest keyword arg} {
if {![string compare $keyword "ACTION"]} { pxi2h:style "actn" $dest $nick $host $arg }
}
proc pxi2h:join {nick host handle chan} {
pxi2h:style "join" $chan $nick $host ""
}
proc pxi2h:kick {nick host handle chan knick arg} {
pxi2h:style "kick" $chan $nick $host "$knick $arg"
}
proc pxi2h:mode11x {nick host handle chan arg} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode [lrange $arg 0 end] }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:mode13x {nick host handle chan arg mnick} {
if {[lindex $arg 0] == "+k"} { set mode [lindex $arg 0] } else { set mode "[lrange $arg 0 end] $mnick" }
pxi2h:style "mode" $chan $nick $host $mode
}
proc pxi2h:nick {nick host handle chan newnick} {
pxi2h:style "nick" $chan $nick $host $newnick
}
proc pxi2h:part {nick host handle chan rest} {
pxi2h:style "part" $chan $nick $host ""
}
proc pxi2h:pubm {nick host handle chan arg} {
global pxi2h
if {[string range $arg 0 0] != $pxi2h(secret)} { pxi2h:style "pubm" $chan $nick $host $arg }
}
proc pxi2h:sign {nick host handle chan arg} {
pxi2h:style "sign" $chan $nick $host $arg
}
proc pxi2h:topc {nick host handle chan topic} {
if {$nick != "*"} { pxi2h:style "topc" $chan $nick $host $topic }
}
bind dcc +m irc2html pxi2h:dcc
bind ctcp - ACTION pxi2h:ctcp
bind join - * pxi2h:join
bind kick - * pxi2h:kick
if {[lindex $version 1] < "01030000"} {
bind mode - * pxi2h:mode11x
} else {
bind mode - * pxi2h:mode13x
}
bind nick - * pxi2h:nick
bind part - * pxi2h:part
bind pubm - * pxi2h:pubm
bind sign - * pxi2h:sign
bind topc - * pxi2h:topc
set pxi2h(ver) "3.0"
if {![info exists pxi2h(status)]} { set pxi2h(status) "on" }
if {[info exists pxi2h(status)] && [validchan pxi2h_chan]} {
foreach ele [array names pxi2h_chan] {
if {![info exists pxi2h_history($ele)]} { set pxi2h_history($ele) "" }
pxi2h:make $ele
}
}
putlog "\[ProjectX\] irc2html v$pxi2h(ver) loaded."