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 

help me @ ProjectX IRC 2 HTML TCL

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
sotengboy
Voice


Joined: 03 Jan 2010
Posts: 14

PostPosted: Thu Dec 16, 2010 9:55 am    Post subject: help me @ ProjectX IRC 2 HTML TCL Reply with quote

i try to run my bot, but i got a warning like this:
Code:
[16:51:57] invalid channel: #ndhesso
    while executing
"chanlist $chan"
    (procedure "pxi2h:make" line 5)
    invoked from within
"pxi2h:make $ele"
    ("foreach" body line 3)
    invoked from within
"foreach ele [array names pxi2h_chan] {
  if {![info exists pxi2h_history($ele)]} { set pxi2h_history($ele) "" }
  pxi2h:make $ele
}"
    (file "scripts/log.tcl" line 247)
    invoked from within
"source scripts/log.tcl"
    (file "g.conf" line 380)
[16:51:57] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


can anyone help me? thanks before Smile
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Thu Dec 16, 2010 2:32 pm    Post subject: Reply with quote

Is it that script that generates html files based on what's being said in the channel? I once created a modified copy of it to fix that bug and add in serveral features, so here you go:

Code:
########################################################################
###                                         __  __  __               ###
###               ___  ____ __  _ ___  ___ / /_ \ \/ /               ###
###              / _ \' __/ _ `/ / -_)/ __/  _/  )  (                ###
###             / .__/_/  \___/ /\___/\__/\__/  /_/\_\               ###
###            /_/ -------- /__/ ---------------------               ###
###                                                                  ###
########################################################################
### 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 "\\&amp;" text
  regsub -all < $text "\\&lt;" text
  regsub -all > $text "\\&gt;" text
  regsub -all \" $text "\\&quot;" text
  regsub -all "  " $text "\\&nbsp; " 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."

_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
sotengboy
Voice


Joined: 03 Jan 2010
Posts: 14

PostPosted: Sat Dec 18, 2010 11:25 am    Post subject: Reply with quote

ok thanks sir. i'll try it
Back to top
View user's profile Send private message
sotengboy
Voice


Joined: 03 Jan 2010
Posts: 14

PostPosted: Sat Dec 18, 2010 11:41 am    Post subject: Reply with quote

sotengboy wrote:
ok thanks sir. i'll try it


I've tried, and succeeded. thank you very much sir
Back to top
View user's profile Send private message
sotengboy
Voice


Joined: 03 Jan 2010
Posts: 14

PostPosted: Sat Dec 18, 2010 11:45 am    Post subject: Reply with quote

wow, but there is one small mistake

Code:
<gseen> [18:41:38] Tcl error [pxi2h:join]: ambiguous option "-": must be -exact, -glob, -regexp, or --


what is it sir? help me, I am a newbie
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Sat Dec 18, 2010 1:34 pm    Post subject: Reply with quote

sotengboy wrote:
wow, but there is one small mistake

Code:
<gseen> [18:41:38] Tcl error [pxi2h:join]: ambiguous option "-": must be -exact, -glob, -regexp, or --


what is it sir? help me, I am a newbie

No clue, because it's refering to the switch statement found here:
Code:
proc pxi2h:style {event chan nick host arg} {
  global pxi2h_history
  set chan [pxi2h:findchan $chan]
  if {$chan == ""} { return }
  switch -- $event {
Like you can see, switch DOES have -- written there which makes this pretty weird. Maybe replacing it with --exact or --glob will fix it?
_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Dec 19, 2010 9:47 pm    Post subject: Reply with quote

Trixar_za, you're good. But you missed one tiny, small, easily over-looked detail. The fellows error itself:
Code:
<gseen> [18:41:38] Tcl error [pxi2h:join]: ambiguous option "-": must be -exact, -glob, -regexp, or --

It is a single hyphen causing this. Investigating the invocation trail leading from the original bind yields the offender easily, since we know what we are looking for. With the code left as is, no line with hyphens will work.
Code:
switch [lindex $chars $i] {

Bingo, replace that.. with

Code:
switch -- "[lindex $chars $i]" {

Solved... Single hyphens should no longer cause a problem.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Mon Mar 21, 2011 5:08 pm    Post subject: Reply with quote

Code:
[18:06] <tester_bot> [14:06] Tcl error [pxi2h:ctcp]: can't read "pxi2h(text)": no such variable
[18:06] <tester_bot> [14:06] Tcl error [pxi2h:pubm]: can't read "pxi2h(text)": no such variable


I don't know what is this.
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Tue Mar 22, 2011 9:24 am    Post subject: Reply with quote

Exedore wrote:
Code:
[18:06] <tester_bot> [14:06] Tcl error [pxi2h:ctcp]: can't read "pxi2h(text)": no such variable
[18:06] <tester_bot> [14:06] Tcl error [pxi2h:pubm]: can't read "pxi2h(text)": no such variable


I don't know what is this.
You're missing this variable:
Code:
# Default Text color:
set pxi2h(text) "black"

_________________
http://www.trixarian.net/Projects
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 -> Script Support & Releases 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