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.

An addition to trivia.tcl case you don't like the HTML

Old posts that have not been replied to for several years.
Locked
C
CaliMonk

An addition to trivia.tcl case you don't like the HTML

Post by CaliMonk »

I took the liberty to edit the TCL script (trivia.tcl) by adding a somewhat nicer and more configurable HTML output as the old output its well, pretty basic. Anyway here it is:

At the top of the code

Code: Select all

# Table Colors
set tgbcolor "#000000"       ;#Border Color
set tgcellcolor "#EDE7E7"    ;#Cell color
set tgcellcolor_top "FFE1B5" ;# Table Head color

# Java chat available?
set tgjavachat "1" ;# 0 is no java chat, 1 is javachat
set tgjavaurl "http://axe4.axenet.org/index.php?page=chat&channel=trivia" ;# Url to point to
In stead of the old proc tghtml

Code: Select all

proc tghtml {} {
 global tgchan botnick tghtmlfile tghtmlrefresh server tgscoresbyname tgranksbyname
 global tgscorestotal tgranksbyname tgrealnames tgscoresbyrank tgranksbynum tgplaying
 global tgquestionstotal tghtmlrefreshtimer tghtmlfont 
 global tgbcolor tgcellcolor tgcellcolor_top tgjavachat tgjavaurl
 tggetscores
 tgreadqdb
 set _file [open $tghtmlfile~new w]
 puts $_file "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"
 puts $_file "<html>"
 puts $_file " <head>"
 puts $_file "  <title>$botnick's trivia channel: $tgchan on [lindex [split $server :] 0]</title>"
 puts $_file "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
 puts $_file "  <meta http-equiv=\"refresh\" content=\"$tghtmlrefresh\">"
 puts $_file "  <meta name=\"generator\" content=\"trivia.tcl script for eggdrop. http://www.eggdrop.za.net/\">"
 puts $_file " </head>"
 puts $_file " <body>"
 puts $_file "  <table cellspacing=4 cellpadding=4 border=0 align=center><tr><td>"
 puts $_file " <b><font face=\"Verdana\" size=\"3\">Trivia Statistics for $tgchan on [lindex [split $server :] 0]</font></b><br><font face=\"Verdana\" size=\"3\"><b>Generated on [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S]</b></font><br>"
 if {$tgjavachat>0} {
  puts $_file " <a href=\"$tgjavaurl\">Play Now!</a>"
 }
 puts $_file " <HR ALIGN=LEFT NOSHADE SIZE=1 WIDTH=480>"
 if {![onchan $botnick $tgchan]} {
  puts $_file "  <p>Hmmm... for some reason I'm not on $tgchan at the moment. Please try again later.</p>"
 } else {
  puts $_file "  <p>Trivia game is currently <b>[expr $tgplaying==1?"on":"off"]</b>. There are <b>$tgquestionstotal</b> questions in the database."
  puts $_file "  <p><b>People on $tgchan right now:</b><br><br>"
  puts $_file "  <table width=\"100%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" bgcolor=\"$tgbcolor\">"
  puts $_file "   <tr>"
  puts $_file "    <td bgcolor=\"$tgcellcolor_top\"><b>Nick</b></td>"
  puts $_file "    <td bgcolor=\"$tgcellcolor_top\"><b>Score</b></td>"
  puts $_file "    <td bgcolor=\"$tgcellcolor_top\"><b>Rank</b></td>"
  puts $_file "    <td bgcolor=\"$tgcellcolor_top\"><b>Idle</b></td>"
  puts $_file "   </tr>"
  foreach nick [lsort [chanlist $tgchan]] {
   puts $_file "   <tr>"
   puts $_file "    <td bgcolor=\"$tgcellcolor\">[expr [isop $nick $tgchan]?"@":""][expr [ishalfop $nick $tgchan]?"%":""][expr [isvoice $nick $tgchan]?"+":""]$nick[expr [string match $nick $botnick]?" (that's me!)":""]</td>"
   if {[info exists tgscoresbyname([strlwr $nick])]} {
    puts $_file "    <td bgcolor=\"$tgcellcolor\">$tgscoresbyname([strlwr $nick])</td>"
   } else {
    puts $_file "    <td bgcolor=\"$tgcellcolor\">-</td>"
   }
   if {[info exists tgranksbyname([strlwr $nick])]} {
    puts $_file "    <td bgcolor=\"$tgcellcolor\">$tgranksbyname([strlwr $nick])</td>"
   } else {
    puts $_file "    <td bgcolor=\"$tgcellcolor\">-</td>"
   }
   puts $_file "   <td bgcolor=\"$tgcellcolor\">[expr [getchanidle $nick $tgchan]>10?"[getchanidle $nick $tgchan]m":"-"]</td>"
   puts $_file "   </tr>"
  }
  puts $_file "  </table><br><br>"
 }
 if {$tgscorestotal>0} {
  puts $_file "  <center><small>There [expr $tgscorestotal==1?"is":"are"] currently <b>$tgscorestotal</b> [expr $tgscorestotal==1?"nick":"nicks"] in the score table:</small></center><br>"
  set _rank 1
  puts $_file " <table cellspacing=\"1\" cellpadding=\"3\" bgcolor=\"$tgbcolor\" align=center><tr><td bgcolor=\"$tgcellcolor_top\"><b>Rank</b></td><td bgcolor=\"$tgcellcolor_top\"><b>Nickname</b></td><td bgcolor=\"$tgcellcolor_top\"><b>Score</b></td></tr> "
  while {$_rank<=$tgscorestotal} {
   puts $_file "<tr><td bgcolor=\"$tgcellcolor\"><b>$_rank</b></td><td bgcolor=\"$tgcellcolor\">$tgrealnames($tgranksbynum($_rank))</td><td bgcolor=\"$tgcellcolor\">$tgscoresbyrank($_rank)</td></tr>"
   incr _rank
  }
  puts $_file " </table> "
 } else {
  puts $_file "<p><small>There are currently no nicks in the score table.</small></p><br>"
 }
 puts $_file "  <HR ALIGN=LEFT NOSHADE SIZE=1 WIDTH=480>"
 puts $_file "  <small>Generated on [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S] by <a href=\"http://www.eggdrop.za.net/\" target=_blank>trivia.tcl</a> for <a href=\"http://www.egghelp.org\">eggdrop</a>.<br>"
 puts $_file "  This page is automatically updated every [expr $tghtmlrefresh==1?"second":"$tghtmlrefresh seconds"].</small>"
 puts $_file " </td></tr></table></body>"
 puts $_file "</html>"
 close $_file
 file rename -force $tghtmlfile~new $tghtmlfile
 set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}
:)

----
CaliMonk
Network Administrator
Axenet IRC Network
C
CaliMonk

Post by CaliMonk »

Oh in case you want to see a preview check http://axe4.axenet.org/index.php?page=stats/trivia
User avatar
Souperman
Halfop
Posts: 69
Joined: Sat Feb 02, 2002 8:00 pm
Location: Cape Town, South Africa
Contact:

Post by Souperman »

Hey, it looks pretty good. :D Very nice for integrating into the rest of your site.
Locked