· 4 years ago · Dec 24, 2020, 03:10 PM
1######################################################################
2#PLEASE customise the settings before rehashing your bot! #
3######################################################################
4
5# The full path to the file containing the questions and answers.
6# The account the bot runs on must have read access to this file.
7set tgqdb "/home/kaka/lidy/eggdrop/scripts/triv.questions.txt"
8
9# The character that seperates the question and the answer in the
10# question/answer file.
11set tgqdbsep "|"
12
13# What you set here defines how the bot expects the question/answer
14# pairs to be arranged.
15# If set to 1, bot expects lines in the format:
16# question<seperator>answer
17# If set to 0, bot expects lines in the format:
18# answer<seperator>question
19set tgqdbquestionfirst 0
20
21# The full path to the file which tracks the scores. The account
22# the bot runs on must have read & write access to this file. If
23# the file does not exist, it will be created when needed.
24set tgscf "/home/kaka/lidy/eggdrop/scripts/trivia.scores"
25
26# How to send error reports. Set to 1 to send error report to an
27# e-mail address of your choice, or 0 to record errors in a file.
28# Sending via e-mail requires that the bot have access to the "mail"
29# program. If the bot doesn't have access to this program (e.g. if
30# you're running the bot on the Windows platform), then set this to
31# 0 to have errors recorded in a file.
32set tgerrmethod 1
33
34# The full path to the file which records error reports. The
35# account the bot runs on must have read & write access to this
36# file. If the file does not exist, it will be created when needed.
37set tgerrfil "/home/kaka/lidy/eggdrop/scripts/trivia.errors"
38
39# The e-mail address to send error reports to.
40set tgerremail "email@gmail.com"
41
42# If error reports are sent via e-mail, where will the bot create
43# a temp file? /tmp is usually a good idea.
44set tgerrmailtmp "/tmp"
45
46# The full path to the file which the bot will use to generate
47# an HTML info page. The account the bot runs on must have read
48# & write access to this file. If the file does not exist, it will
49# be created when needed.
50set tghtmlfile "/home/personal/personal/BpSa/eggdrop/mychan.html"
51
52# How often (in seconds) does the html file get updated. Set to 0
53# to disable HTML page.
54set tghtmlrefresh 0
55
56# The font to use on the html page.
57set tghtmlfont "verdana,helvetica,arial"
58
59# The name of the channel where the game will be played. The game
60# can only be played on one channel.
61set tgchan "#Trivia-Qui"
62
63# How many points to give a person for a correctly answered
64# question.
65set tgpointsperanswer 10
66
67# The maximum number of hints to give before the question 'expires'
68# and the bot goes on to another one. This EXCLUDES the first hint
69# given as the question is asked (i.e. the hint which shows no letters,
70# only placeholders).
71set tgmaxhint 3
72
73# Should the bot show the question on each hint (1) or only on the first (0)?
74set tgalwaysshowq 1
75
76# Show questions in all CAPS (1) or not (0)?
77set tgcapsquestion 0
78
79# Show answers in all CAPS (1) or not (0)?
80set tgcapsanswer 0
81
82# Show hints in all CAPS (1) or not (0)?
83set tgcapshint 0
84
85# The minimum number of correct answers in a row by one person which
86# puts them on a winning streak. Setting this to 0 will disable the
87# winning streak feature.
88set tgstreakmin 3
89
90# The number of missed (i.e. unanswered, not skipped) questions to allow
91# before automatically stopping the game. Setting this to 0 will cause the
92# game to run until somebody uses the stop command, or the bot dies, gets
93# killed, pings out, or whatever.
94set tgmaxmissed 0
95
96# The character to use as a placeholder in hints.
97set tghintchar "*"
98
99# The time in seconds between hints.
100set tgtimehint 15
101
102# The time in seconds between a correct answer, 'expired' or skipped question
103# and the next question being asked.
104set tgtimenext 10
105
106# Phrases to use at random when someone answers a question correctly. This must
107# be a TCL list. If you don't know what that means, stick to the defaults.
108set tgcongrats [list "Congratulations" "Well done" "Nice going" "Way to go" "You got it" "That's the way" "Show 'em how it's done" "Check out the big brain on"]
109
110# Phrases to use when the question has 'expired'. Must also be a TCL list.
111set tgnobodygotit [list "Nobody got it right." "Hello? Anybody home?" "You're going to have to try harder!" "Are these too tough for you?" "Am I alone here or what?" "You're not going to score any points this way!"]
112
113# Phrases to use when the question expired and there's another one coming up.
114# Yep, you guessed it... another TCL list.
115set tgtrythenextone [list "Let's see if you can get the next one..." "Get ready for the next one..." "Maybe you'll get the next one..." "Try and get the next one..." "Here comes the next one..."]
116
117# Will the bot calculate the time it took to get the correct
118# answer (1) or not (0)? (requires TCL 8.3 or higher).
119set tgtimeanswer 1
120
121# Will the bot show the correct answer if nobody gets it (1) or not (0)?
122set tgshowanswer 1
123
124# When someone answers a question, will the bot show just that person's score (0)
125# or will it show all players' scores (1) (default). This is useful in channels with
126# a large number (>20) players.
127set tgshowallscores 1
128
129# Use bold codes in messages (1) or not (0)?
130set tgusebold 0
131
132# Send private messages using /msg (1) or not (0)?
133# If set to 0, private messages will be sent using /notice
134set tgpriv2msg 0
135
136# Word to use as /msg command to give help.
137# e.g. set tgcmdhelp "helpme" will make the bot give help when someone
138# does "/msg <botnick> helpme"
139set tgcmdhelp "?"
140
141# Channel command used to start the game.
142set tgcmdstart "!start"
143
144# Flags required to be able to use the start command.
145set tgflagsstart "-|-"
146
147# Channel command used to stop the game.
148set tgcmdstop "!stop"
149
150# Flags required to be able to use the stop command.
151set tgflagsstop "o|o"
152
153# Channel command used to give a hint.
154set tgcmdhint "!hint"
155
156# Flags required to be able to use the hint command.
157set tgflagshint "-|-"
158
159# Disable the !hint command x seconds after someone uses it. This
160# prevents accidental double hints if two people use the command in
161# quick succession.
162set tgtempnohint 10
163
164# Channel command used to skip the question.
165set tgcmdskip "!skip"
166
167# Flags required to be able to use the skip command.
168set tgflagsskip "-|-"
169
170# Channel command for showing the top 10 scores.
171set tgcmdtop10 "!top10"
172
173# Flags required to use the top 10 command.
174set tgflagstop10 "-|-"
175
176# /msg command used to reset scores.
177set tgcmdreset "reset"
178
179# Flags required to be able to use the reset command.
180set tgflagsreset "m|m"
181
182# Require password for resetting scores?
183# If enabled, you must use /msg bot reset <password> to reset scores.
184# The password is the one set by a user using '/msg bot pass'.
185set tgresetreqpw 1
186
187# /msg command for looking up somebody's score.
188set tgcmdlookup "score"
189
190# /msg command for looking up your target.
191# (i.e. the person ranked one higher than you).
192set tgcmdtarget "target"
193
194# /msg command for reporting errors in questions and/or answers.
195set tgcmderror "error"
196
197# /msg command to show channel's rules.
198set tgcmdrules "rules"
199
200# Channel's rules.
201set tgrules "No advertising, no profanity, no harassing of users, no active scripts and no flooding. Break the rules and expect to be banned. Have fun. :-)"
202
203# Number of minutes between reminders of how to report errors.
204set tgerrremindtime 15
205
206# COLOURS
207# The colour codes used are the same as those used by mIRC:
208# 00:white 01:black 02:dark blue 03:dark green
209# 04:red 05:brown 06:purple 07:orange
210# 08:yellow 09:light green 10:turquoise 11:cyan
211# 12:light blue 13:magenta 14:dark grey 15:light grey
212#
213# Always specify colour codes as two digits, i.e. use "01" for
214# black, not "1".
215# You can specify a background colour using "00,04" (white text
216# on red background).
217# To disable a colour, use "".
218# Note that disabling some colours but not others may yield
219# unexpected results.
220
221set tgcolourstart "03" ;#Game has started.
222set tgcolourstop "04" ;#Game has stopped.
223set tgcolourskip "10" ;#Question has been skipped.
224set tgcolourerr "04" ;#How to report errors.
225set tgcolourmiss "10" ;#Nobody answered the question.
226set tgcolourqhead "04" ;#Question heading.
227set tgcolourqbody "12" ;#Question text
228set tgcolourhint "03" ;#Hint.
229set tgcolourstrk "12" ;#Person is on a winning streak.
230set tgcolourscr1 "04" ;#Score of person in first place.
231set tgcolourscr2 "12" ;#Score of person in second place.
232set tgcolourscr3 "03" ;#Score of person in third place.
233set tgcolourrset "04" ;#Scores have been reset.
234set tgcolourstend "12" ;#Winning streak ended.
235set tgcolourmisc1 "06" ;#Miscellaneous colour #1.
236set tgcolourmisc2 "04" ;#Miscellaneous colour #2.
237
238
239# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
240# #
241# Any editing done beyond this point is done at your own risk! #
242# #
243# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
244#Misc checks & var initialisations
245set tgver "1.3.4"
246set tgrel "release"
247if {[info tclversion]<8.2} {
248 putlog "\002[file tail [info script]]\002 failed to load: in order to use this script, eggdrop needs to be compiled to use tcl 8.2 or higher (recommended: latest stable version)."
249 return
250}
251if {$tgtimeanswer==1&&[info tclversion]<8.3} {
252 putlog "\002[file tail [info script]]\002 warning: timing of answers has been automatically disabled. this feature requires tcl 8.3 or higher."
253 set tgtimeanswer 0
254}
255if {![info exists alltools_loaded]||$allt_version<205} {
256 putlog "\002[file tail [info script]]\002 failed to load: please load alltools.tcl v1.14 or higher (available with eggdrop 1.6.13 or higher) before attempting to load this script."
257 return
258}
259if {[utimerexists tghtml]!=""} {killutimer $tghtmlrefreshtimer}
260if {$tghtmlrefresh>0} {
261 set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
262}
263if {![file exists $tgqdb]} {
264 putlog "\002[file tail [info script]]\002 failed to load: $tgqdb does not exist."
265 return
266}
267if {[llength [split $tgchan]]!=1} {
268 putlog "\002[file tail [info script]]\002 failed to load: too many channels specified."
269 return
270}
271if {![info exists tgplaying]} {
272 set ctcp-version "${ctcp-version} (with trivia.tcl $tgver ($tgrel) from www.eggdrop.za.net)"
273 set tgplaying 0
274}
275if {![info exists tghintnum]} {set tghintnum 0}
276if {![info exists tgmissed]} {set tgmissed 0}
277
278#Binds
279bind pubm $tgflagsstart "$tgchan %$tgcmdstart" tgstart
280bind pubm $tgflagsstop "$tgchan %$tgcmdstop" tgstop
281proc tgbindhintcmd {} {
282 global tgflagshint tgcmdhint
283 bind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
284}
285proc tgunbindhintcmd {} {
286 global tgflagshint tgcmdhint
287 unbind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
288}
289tgbindhintcmd
290bind pubm $tgflagsskip "$tgchan %$tgcmdskip" tgskip
291bind pubm $tgflagstop10 "$tgchan %$tgcmdtop10" tgshowtop10
292bind join -|- "$tgchan *" tgjoinmsg
293bind msg - $tgcmdhelp tggivehelp
294bind msg - $tgcmdlookup tgscorelookup
295bind msg - $tgcmdtarget tgtargetlookup
296bind msg - $tgcmderror tgerror
297bind msg - $tgcmdrules tgrulesmsg
298bind msg $tgflagsreset "$tgcmdreset" tgresetscores
299bind kick - "$tgchan $botnick" tgbotgotkicked
300bind evnt - disconnect-server tgbotgotdisconnected
301
302#starts the game if it isn't running.
303proc tgstart {nick host hand chan text} {
304 global tgplaying tgstreak tgchan tgerrremindtime tgerrremindtimer tgmissed
305 if {[strlwr $tgchan]==[strlwr $chan]} {
306 if {$tgplaying==0} {
307 tggamemsg "[tgcolstart]Trivia game started by $nick!"
308 tgnextq
309 set tgplaying 1
310 set tgstreak 0
311 set tgmissed 0
312 set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
313 }
314 }
315}
316
317#stops the game if it's running.
318proc tgstop {nick host hand chan text} {
319 global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
320 global tgerrremindtimer tgrebindhinttimer
321 if {[strlwr $tgchan]==[strlwr $chan]} {
322 if {$tgplaying==1} {
323 tggamemsg "[tgcolstop]Trivia game stopped by $nick!"
324 if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
325 set tgstreak 0
326 set tgplaying 0
327 catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
328 if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
329 if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
330 if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
331 if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
332 }
333 }
334}
335
336#gives a hint if there is currently a question to answer.
337proc tgforcehint {nick host hand chan text} {
338 global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
339 global tgtempnohint tgmaxhintcurrent tghintnum tgrebindhinttimer tgtempnohint
340 if {[strlwr $tgchan]==[strlwr $chan]} {
341 if {$tgplaying==1&&[utimerexists tghint]!=""} {
342 killutimer $tghinttimer
343 tghint
344 tgunbindhintcmd
345 if {$tghintnum<$tgmaxhintcurrent} {
346 set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
347 }
348 }
349 }
350}
351
352#skips the current question if one has been asked.
353proc tgskip {nick host hand chan text} {
354 global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak
355 global tgstreakmin tgtimenext tgrebindhinttimer
356 if {[strlwr $tgchan]==[strlwr $chan]} {
357 if {$tgplaying==1&&[utimerexists tghint]!=""} {
358 tggamemsg "[tgcolskip]Skipping to next question by [tgcolmisc2]$nick's[tgcolskip] request..."
359 if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin&&[strlwr [lindex [split $tgstreak ,] 0]]==[strlwr $nick]} {
360 tgstreakend
361 set tgstreak 0
362 }
363 catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
364 killutimer $tghinttimer
365 if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
366 set tgnextqtimer [utimer $tgtimenext tgnextq]
367 }
368 }
369}
370
371#reminds channel how to report errors in questions/answers
372proc tgerrremind {} {
373 global tgerrremindtimer tgerrremindtime botnick tgcmderror
374 tggamemsg "[tgcolerr]Remember: to report errors in questions/answers, type /msg $botnick $tgcmderror <number> \[description\] or contact #Trivia-Quiz Admin"
375 set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
376}
377
378#bot got kicked. stop the game.
379proc tgbotgotkicked {nick host hand chan targ text} {
380 tgquietstop
381}
382
383#bot got disconnected. stop the game.
384proc tgbotgotdisconnected {disconnect-server} {
385 tgquietstop
386}
387
388#stops the game without telling the channel.
389proc tgquietstop {} {
390 global tgplaying tgstreak tgchan tgcurrentanswer tghinttimer tgnextqtimer tgerrremindtimer
391 global tgrebindhinttimer
392 if {$tgplaying==1} {
393 set tgstreak 0
394 set tgplaying 0
395 catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
396 if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
397 if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
398 if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
399 if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
400 }
401}
402
403#reads the question database.
404proc tgreadqdb {} {
405 global tgqdb tgquestionstotal tgquestionslist
406 set tgquestionstotal 0
407 set tgquestionslist ""
408 set qfile [open $tgqdb r]
409 set tgquestionslist [split [read -nonewline $qfile] "\n"]
410 set tgquestionstotal [llength $tgquestionslist]
411 close $qfile
412}
413
414#selects the next question.
415proc tgnextq {} {
416 global tgqdb tgcurrentquestion tgcurrentanswer tgquestionnumber
417 global tgquestionstotal tghintnum tgchan tgquestionslist tgqdbsep tgqdbquestionfirst
418 global tgcapsquestion tgcapsanswer
419 tgreadqdb
420 set tgcurrentquestion ""
421 set tgcurrentanswer ""
422 while {$tgcurrentquestion == ""} {
423 set tgquestionnumber [rand [llength $tgquestionslist]]
424 set tgquestionselected [lindex $tgquestionslist $tgquestionnumber]
425 set tgcurrentquestion [lindex [split $tgquestionselected $tgqdbsep] [expr $tgqdbquestionfirst^1]]
426 if {$tgcapsquestion==1} {
427 set tgcurrentquestion [strupr $tgcurrentquestion]
428 }
429 set tgcurrentanswer [string trim [lindex [split $tgquestionselected $tgqdbsep] $tgqdbquestionfirst]]
430 if {$tgcapsanswer==1} {
431 set tgcurrentanswer [strupr $tgcurrentanswer]
432 }
433 }
434 unset tghintnum
435 tghint
436 bind pubm -|- "$tgchan *" tgcheckanswer
437 return
438}
439
440#shows timed hints.
441proc tghint {} {
442 global tgmaxhint tghintnum tgcurrentanswer tghinttimer tgchan
443 global tgtimehint tghintchar tgquestionnumber tgquestionstotal
444 global tgcurrentquestion tghintcharsused tgnextqtimer tgtimenext tgstreak tgstreakmin
445 global tgnobodygotit tgtrythenextone tgmissed tgmaxmissed tgcmdstart tgshowanswer
446 global tgtimestart tgtimeanswer tgalwaysshowq tgmaxhintcurrent tgtempnohint tgcapshint
447if {![info exists tghintnum]} {
448 set tghintnum 0
449 regsub -all -- "\[^A-Za-z0-9\]" $tgcurrentanswer "" _hintchars
450 set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
451 catch {tgunbindhintcmd}
452 if {$tgmaxhintcurrent>0} {
453 set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
454 }
455 } else { incr tghintnum }
456 if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
457 incr tgmissed
458 set _msg ""
459 append _msg "[tgcolmiss][lindex $tgnobodygotit [rand [llength $tgnobodygotit]]]"
460 if {$tgshowanswer==1} {
461 append _msg " The answer was [tgcolmisc2]$tgcurrentanswer[tgcolmiss]."
462 }
463 if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} {
464 append _msg " That's $tgmissed questions gone by unanswered! The game is now automatically disabled. To start the game again, type $tgcmdstart"
465 tgquietstop
466 } else {
467 append _msg " [lindex $tgtrythenextone [rand [llength $tgtrythenextone]]]"
468 }
469 tggamemsg "[tgcolmiss]$_msg"
470 if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
471 set tgstreak 0
472 catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
473 if {$tgmaxmissed==0||$tgmissed<$tgmaxmissed} {
474 set tgnextqtimer [utimer $tgtimenext tgnextq]
475 }
476 return
477 } elseif {$tghintnum == 0} {
478 set i 0
479 set _hint {}
480 set tghintcharsused {}
481 foreach word [split $tgcurrentanswer] {
482 regsub -all -- "\[A-Za-z0-9\]" $word $tghintchar _current
483 lappend _hint $_current
484 }
485 if {$tgtimeanswer==1} {
486 set tgtimestart [clock clicks -milliseconds]
487 }
488 } elseif {$tghintnum == 1} {
489 set i 0
490 set _hint {}
491 while {$i<[llength [split $tgcurrentanswer]]} {
492 set _word [lindex [split $tgcurrentanswer] $i]
493 set j 0
494 set _newword {}
495 while {$j<[strlen $_word]} {
496 if {$j==0} {
497 append _newword [stridx $_word $j]
498 lappend tghintcharsused $i,$j
499 } else {
500 if {[string is alnum [stridx $_word $j]]} {
501 append _newword $tghintchar
502 } else {
503 append _newword [stridx $_word $j]
504 lappend tghintcharsused $i,$j
505 }
506 }
507 incr j
508 }
509 lappend _hint $_newword
510 incr i
511 }
512 } else {
513 set i 0
514 set _hint {}
515 while {$i<[llength [split $tgcurrentanswer]]} {
516 set _word [lindex [split $tgcurrentanswer] $i]
517 set j 0
518 set _newword {}
519 set _selected [rand [strlen $_word]]
520 regsub -all -- "\[^A-Za-z0-9\]" $_word "" _wordalnum
521 if {[strlen $_wordalnum]>=$tghintnum} {
522 while {[lsearch $tghintcharsused $i,$_selected]!=-1||[string is alnum [stridx $_word $_selected]]==0} {
523 set _selected [rand [strlen $_word]]
524 }
525 }
526 lappend tghintcharsused $i,$_selected
527 while {$j<[strlen $_word]} {
528 if {[lsearch $tghintcharsused $i,$j]!=-1||[string is alnum [stridx $_word $j]]==0} {
529 append _newword [stridx $_word $j]
530 } else {
531 if {[string is alnum [stridx $_word $j]]} {
532 append _newword $tghintchar
533 }
534 }
535 incr j
536 }
537 lappend _hint $_newword
538 incr i
539 }
540 }
541 if {$tgcapshint==1} {
542 set _hint [strupr $_hint]
543 }
544 tggamemsg "[tgcolqhead]»» Trivia-Quiz Question «« [expr $tghintnum?"(Hint $tghintnum/$tgmaxhintcurrent)":""]"
545 if {$tgalwaysshowq==1||$tghintnum==0} {
546 tggamemsg "[tgcolqbody]$tgcurrentquestion"
547 }
548 tggamemsg "[tgcolhint]Hint: [join $_hint]"
549 set tghinttimer [utimer $tgtimehint tghint]
550}
551
552#triggered when someone uses !top10 command
553proc tgshowtop10 {nick host hand chan text} {
554 global tgscores tgchan tgscorestotal
555 if {[strlwr $chan]==[strlwr $tgchan]} {
556 tggetscores
557 if {$tgscorestotal>0} {
558 if {$tgscorestotal>9} {
559 set _max 9
560 } else {
561 set _max [expr $tgscorestotal-1]
562 }
563 set i 0
564 while {$i<=$_max} {
565 set _item [lindex $tgscores $i]
566 set _nick [join [lindex [split $_item ,] 2]]
567 set _score [join [lindex [split $_item ,] 0]]
568 if {$i==0} {
569 append _scores "[tgcolscr1]$_nick $_score"
570 } elseif {$i==1} {
571 append _scores ", [tgcolscr2]$_nick $_score"
572 } elseif {$i==2} {
573 append _scores ", [tgcolscr3]$_nick $_score"
574 } else {
575 append _scores ", [tgcolmisc1]$_nick $_score"
576 }
577 incr i
578 }
579 tggamemsg "[tgcolmisc1]Top 10: $_scores"
580 } else {
581 tggamemsg "[tgcolmisc1]Score table is empty."
582 }
583 }
584}
585
586#checks if anyone has said the correct answer on channel.
587proc tgcheckanswer {nick host hand chan text} {
588 global tgcurrentanswer
589 if {[strlwr $tgcurrentanswer] == [tgstripcodes [strlwr [string trim $text]]]} {
590 tgcorrectanswer $nick
591 }
592}
593
594#triggered when someone says the correct answer.
595proc tgcorrectanswer {nick} {
596 global tgcurrentanswer tghinttimer tgtimenext tgchan tgnextqtimer tgstreak tgstreakmin
597 global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed
598 global tgtimestart tgshowallscores tgrealnames tgscoresbyrank tgtimeanswer
599 tggetscores
600 if {![info exists tgranksbyname([strlwr $nick])]} {
601 set _oldrank 0
602 } else {
603 set _oldrank $tgranksbyname([strlwr $nick])
604 }
605 tgincrscore $nick
606 tggetscores
607 set _newrank $tgranksbyname([strlwr $nick])
608 set _timetoanswer ""
609 if {$tgtimeanswer==1} {
610 set _timetoanswer [expr [expr [clock clicks -milliseconds]-$tgtimestart]/1000.00]
611 }
612 set _msg "[tgcolmisc1][lindex $tgcongrats [rand [llength $tgcongrats]]] [tgcolmisc2]$nick[tgcolmisc1]! The answer was [tgcolmisc2]$tgcurrentanswer[tgcolmisc1].[expr $tgtimeanswer==1?" You got it in [tgcolmisc2]$_timetoanswer[tgcolmisc1] seconds.":""]"
613 if {$_newrank<$_oldrank} {
614 if {$_newrank==1} {
615 append _msg " You are now in first place!"
616 } else {
617 if {$tgshowallscores==0} {
618 append _msg " You've moved up in rank!"
619 } else {
620 append _msg " You are now ranked [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])][tgcolmisc1] of [tgcolmisc2]$tgscorestotal[tgcolmisc1], behind [tgcolmisc2]$tgrealnames($tgranksbynum([expr $_newrank-1]))[tgcolmisc1] with [tgcolmisc2]$tgscoresbyrank([expr $_newrank-1])[tgcolmisc1]."
621 }
622 }
623 }
624 tggamemsg "$_msg"
625 if {$tgstreak!=0} {
626 if {[lindex [split $tgstreak ,] 0]==[strlwr $nick]} {
627 set tgstreak [strlwr $nick],[expr [lindex [split $tgstreak ,] 1]+1]
628 if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} {
629 tggamemsg "[tgcolstrk][tgcolmisc2]$nick[tgcolstrk] is on a winning streak! [tgcolmisc2][lindex [split $tgstreak ,] 1] [tgcolstrk]in a row so far!"
630 }
631 } else {
632 if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
633 set tgstreak [strlwr $nick],1
634 }
635 } else {
636 set tgstreak [strlwr $nick],1
637 }
638 set tgmissed 0
639 tgshowscores $nick
640 catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
641 killutimer $tghinttimer
642 set tgnextqtimer [utimer $tgtimenext tgnextq]
643}
644
645#read current scores from file, sort and store in variable.
646proc tggetscores {} {
647 global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum
648 global tgrealnames tgscoresbyrank
649 if {[file exists $tgscf]&&[file size $tgscf]>2} {
650 set _sfile [open $tgscf r]
651 set tgscores [lsort -dict -decreasing [split [gets $_sfile]]]
652 close $_sfile
653 set tgscorestotal [llength $tgscores]
654 } else {
655 set tgscores ""
656 set tgscorestotal 0
657 }
658 if {[info exists tgscoresbyname]} {unset tgscoresbyname}
659 if {[info exists tgranksbyname]} {unset tgranksbyname}
660 if {[info exists tgrealnames]} {unset tgrealnames}
661 if {[info exists tgranksbynum]} {unset tgranksbynum}
662 set i 0
663 while {$i<[llength $tgscores]} {
664 set _item [lindex $tgscores $i]
665 set _nick [lindex [split $_item ,] 2]
666 set _lwrnick [lindex [split $_item ,] 3]
667 set _score [lindex [split $_item ,] 0]
668 set tgscoresbyname($_lwrnick) $_score
669 set tgrealnames($_lwrnick) $_nick
670 set tgranksbyname($_lwrnick) [expr $i+1]
671 set tgranksbynum([expr $i+1]) $_lwrnick
672 set tgscoresbyrank([expr $i+1]) $_score
673 incr i
674 }
675 return
676}
677
678#increment someone's score.
679proc tgincrscore {who} {
680 global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname
681 tggetscores
682 if {$tgscorestotal>0} {
683 set i 0
684 if {![info exists tgscoresbyname([strlwr $who])]} {
685 append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
686 }
687 while {$i<[llength $tgscores]} {
688 set _item [lindex $tgscores $i]
689 set _nick [lindex [split $_item ,] 2]
690 set _time [lindex [split $_item ,] 1]
691 set _score [lindex [split $_item ,] 0]
692 if {[strlwr $who]==[strlwr $_nick]} {
693 append _newscores "[expr $_score+$tgpointsperanswer],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
694 } else {
695 append _newscores "$_score,$_time,$_nick,[strlwr $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
696 }
697 incr i
698 }
699 } else {
700 append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
701 }
702 set _sfile [open $tgscf w]
703 puts $_sfile "$_newscores"
704 close $_sfile
705 return
706}
707
708#shows the current scores on channel.
709proc tgshowscores {nick} {
710 global tgscores tgchan tgscorestotal tgshowallscores tgranksbyname tgranksbynum
711 global tgscoresbyname tgrealnames tgscoresbyrank
712 tggetscores
713 set i 0
714 if {$tgshowallscores} {
715 while {$i<[llength $tgscores]} {
716 set _item [lindex $tgscores $i]
717 set _nick [lindex [split $_item ,] 2]
718 set _score [lindex [split $_item ,] 0]
719 if {$i==0} {
720 append _scores "[tgcolscr1]$_nick $_score"
721 } elseif {$i==1} {
722 append _scores ", [tgcolscr2]$_nick $_score"
723 } elseif {$i==2} {
724 append _scores ", [tgcolscr3]$_nick $_score"
725 } elseif {[onchan $_nick $tgchan]} {
726 append _scores ", [tgcolmisc1]$_nick $_score"
727 }
728 incr i
729 }
730 tggamemsg "[tgcolmisc1]The scores: $_scores"
731 } else {
732 if {$tgranksbyname([strlwr $nick])==1} {
733 set _tgt "."
734 } else {
735 set _tgt ", behind [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1] with [tgcolmisc2]$tgscoresbyrank([expr $tgranksbyname([strlwr $nick])-1])[tgcolmisc1]."
736 }
737 tggamemsg "[tgcolmisc2]$nick [tgcolmisc1]now has [tgcolmisc2]$tgscoresbyname([strlwr $nick]) [tgcolmisc1][expr $tgscoresbyname([strlwr $nick])==1?"point":"points"] and is ranked [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])] [tgcolmisc1]of [tgcolmisc2]$tgscorestotal[tgcolmisc1]$_tgt"
738 }
739}
740
741#reset current scores.
742proc tgresetscores {nick host hand text} {
743 global tgscf tgscorestotal tgscores tgplaying tgresetreqpw
744 if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
745 if {[file exists $tgscf]&&[file size $tgscf]>2} {
746 set _sfile [open $tgscf w]
747 puts $_sfile ""
748 close $_sfile
749 set tgscores ""
750 set tgscorestotal 0
751 }
752 tggamemsg "[tgcolrset]===== Score table reset by $nick! ====="
753 }
754}
755
756#triggered when a winning streak ends.
757proc tgstreakend {} {
758 global tgstreak tgrealnames
759 tggamemsg "[tgcolstend]So much for [tgcolmisc2]$tgrealnames([lindex [split $tgstreak ,] 0])'s[tgcolstend] winning streak."
760 return
761}
762
763#triggered when someone joins trivia chan.
764proc tgjoinmsg {nick host hand chan} {
765 global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan
766 if {$nick != $botnick} {
767 set _msg ""
768 append _msg "Welcome to $botnick's trivia channel. Trivia game is currently"
769 if {$tgplaying==1} {
770 append _msg " \002on\002."
771 } else {
772 append _msg " \002off\002."
773 }
774 if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} {
775 append _msg " To start the game, type \002$tgcmdstart\002 on $tgchan."
776 }
777 append _msg " Please type \002/MSG $botnick [strupr $tgcmdhelp]\002 if you need help. #Trivia-Quiz Admin"
778 [tgpriv] $nick "$_msg"
779 }
780}
781
782#triggered when someone /msgs the bot with the score lookup command.
783proc tgscorelookup {nick host hand text} {
784 global tgscoresbyname tgranksbyname tgscorestotal tgrealnames
785 if {$text==""} { set text $nick } else { set text [lindex [split $text] 0] }
786 tggetscores
787 if {![info exists tgscoresbyname([strlwr $text])]} {
788 if {[strlwr $text]==[strlwr $nick]} {
789 set _who "[tgcolmisc1]You are"
790 } else {
791 set _who "[tgcolmisc2]$text [tgcolmisc1]is"
792 }
793 [tgpriv] $nick "[tgbold]$_who [tgcolmisc1]not on the score list."
794 } else {
795 if {[strlwr $text]==[strlwr $nick]} {
796 set _who "[tgcolmisc1]You have"
797 } else {
798 set _who "[tgcolmisc2]$tgrealnames([strlwr $text]) [tgcolmisc1]has"
799 }
800 [tgpriv] $nick "[tgbold]$_who [tgcolmisc2]$tgscoresbyname([strlwr $text])[tgcolmisc1] points, ranked [tgcolmisc2][ordnumber $tgranksbyname([strlwr $text])] [tgcolmisc1]of [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
801 }
802}
803
804#triggered when someone /msgs the bot with the target lookup command.
805proc tgtargetlookup {nick host hand text} {
806 global tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames
807 tggetscores
808 if {![info exists tgscoresbyname([strlwr $nick])]} {
809 [tgpriv] $nick "[tgbold][tgcolmisc1]You are not on the score list yet."
810 } elseif {$tgranksbyname([strlwr $nick])==1} {
811 [tgpriv] $nick "[tgbold][tgcolmisc1]You are in first place!"
812 } else {
813 [tgpriv] $nick "[tgbold][tgcolmisc1]You are on [tgcolmisc2]$tgscoresbyname([strlwr $nick])[tgcolmisc1]. Your next target is [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1])) [tgcolmisc1]with [tgcolmisc2]$tgscoresbyname($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1], ranked [tgcolmisc2][ordnumber [expr $tgranksbyname([strlwr $nick])-1]] [tgcolmisc1]of [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
814 }
815}
816
817#triggered when someone /msgs the bot with the error reporting command.
818proc tgerror {nick host hand text} {
819 global tgquestionstotal tgquestionslist tgerrmethod tgerrfil tgerremail tgerrmailtmp
820 if {$text==""||![string is int [lindex [split $text] 0]]} {
821 [tgpriv] $nick "[tgbold][tgcolmisc1]You need to specify the number of the question."
822 return
823 }
824 tgreadqdb
825 set _qnum [lindex [split $text] 0]
826 if {$_qnum>$tgquestionstotal} {
827 [tgpriv] $nick "[tgbold][tgcolmisc1]No such question."
828 return
829 }
830 set _qques [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 1]
831 set _qans [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 0]
832 set _desc [join [lrange [split $text] 1 end]]
833 if {$_desc==""} { set _desc "No further info given for this error." }
834 if {$tgerrmethod==1} {
835 set _fname $tgerrmailtmp\trivia[rand 100000].tmp
836 set _file [open $_fname w]
837 } else {
838 set _file [open $tgerrfil a]
839 }
840 puts $_file ""
841 puts $_file "Error report generated [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S]"
842 puts $_file "Reported by:\t$nick!$host"
843 puts $_file "Question #:\t$_qnum"
844 puts $_file "Question:\t$_qques"
845 puts $_file "Answer:\t\t$_qans"
846 puts $_file "Comments:\t$_desc"
847 puts $_file "------------------------------"
848 close $_file
849 if {$tgerrmethod==1} {
850 exec mail -s "trivia.tcl error report from $nick" $tgerremail < $_fname
851 file delete $_fname
852 [tgpriv] $nick "[tgbold][tgcolmisc1]Thanks! Your error report has been e-mailed to my owner."
853 } else {
854 [tgpriv] $nick "[tgbold][tgcolmisc1]Thanks! Your error report has been logged and will be looked at as soon as possible."
855 }
856}
857
858#triggered when someone /msgs the bot with the rules command.
859proc tgrulesmsg {nick host hand text} {
860 global tgrules
861 [tgpriv] $nick "The channel's rules are as follows: $tgrules"
862}
863
864#triggered when someone /msgs the bot with the help command.
865proc tggivehelp {nick host hand {text ""}} {
866 global botnick tgcmdlookup tgcmdhelp tgcmdstart tgcmdstop tgchan tgflagsstop
867 global tgcmdstop tgflagshint tgcmdhint tgflagsskip tgcmdskip tgflagsreset tgcmdreset
868 global tgcmdtarget tgcmderror tgcmdrules tgflagsstart
869 if {$text==""} {
870 [tgpriv] $nick "You have access to the following /MSG commands:"
871 [tgpriv] $nick "To use, /MSG $botnick <command>"
872 [tgpriv] $nick " \002[strupr $tgcmdrules]\002"
873 [tgpriv] $nick " -- Lists the channel rules."
874 [tgpriv] $nick " \002[strupr $tgcmdlookup]\002 \[nick\]"
875 [tgpriv] $nick " -- Shows you the rank & score of \[nick\], if specified,"
876 [tgpriv] $nick " otherwise, shows you your own rank & score."
877 [tgpriv] $nick " \002[strupr $tgcmdtarget]\002"
878 [tgpriv] $nick " -- Shows you the rank & score of the person ranked"
879 [tgpriv] $nick " one above you."
880 [tgpriv] $nick " \002[strupr $tgcmderror]\002 <number> \[description\]"
881 [tgpriv] $nick " -- Reports an error in question <number>"
882 [tgpriv] $nick " The description is optional, but helpful."
883 if {[matchattr $hand $tgflagsreset $tgchan]} {
884 [tgpriv] $nick " \002[strupr $tgcmdreset]\002"
885 [tgpriv] $nick " -- Resets the score table."
886 }
887 [tgpriv] $nick "For a list of channel commands, /MSG $botnick [strupr $tgcmdhelp] PUBCMDS"
888 }
889 if {[strlwr $text]=="pubcmds"} {
890 [tgpriv] $nick "You have access to the following channel commands:"
891 if {[matchattr $hand $tgflagsstart $tgchan]} {
892 [tgpriv] $nick " \002$tgcmdstart\002 -- starts the trivia game."
893 }
894 if {[matchattr $hand $tgflagsstop $tgchan]} {
895 [tgpriv] $nick " \002$tgcmdstop\002 -- stops the trivia game."
896 }
897 if {[matchattr $hand $tgflagshint $tgchan]} {
898 [tgpriv] $nick " \002$tgcmdhint\002 -- shows a hint."
899 }
900 if {[matchattr $hand $tgflagsskip $tgchan]} {
901 [tgpriv] $nick " \002$tgcmdskip\002 -- skips current question."
902 }
903 [tgpriv] $nick "For a list of /MSG commands, /MSG $botnick [strupr $tgcmdhelp]"
904 }
905}
906
907# Returns text without colour, bold, etc. control codes.
908# This is a stripped down version of the proc in MC_8's mc.moretools.tcl.
909proc tgstripcodes {text} {
910 regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
911 set text "[string map -nocase [list \002 "" \017 "" \026 "" \037 ""] $text]"
912 return $text
913}
914
915proc tggamemsg {what} {
916 global tgchan
917 putquick "PRIVMSG $tgchan :[tgbold]$what"
918}
919
920proc tgbold {} {
921 global tgusebold
922 if {$tgusebold==1} { return "\002" }
923}
924proc tgcolstart {} {
925 global tgcolourstart
926 if {$tgcolourstart!=""} { return "\003$tgcolourstart" }
927}
928proc tgcolstop {} {
929 global tgcolourstop
930 if {$tgcolourstop!=""} { return "\003$tgcolourstop" }
931}
932proc tgcolskip {} {
933 global tgcolourskip
934 if {$tgcolourskip!=""} { return "\003$tgcolourskip" }
935}
936proc tgcolerr {} {
937 global tgcolourerr
938 if {$tgcolourerr!=""} { return "\003$tgcolourerr" }
939}
940proc tgcolmiss {} {
941 global tgcolourmiss
942 if {$tgcolourmiss!=""} { return "\003$tgcolourmiss" }
943}
944proc tgcolqhead {} {
945 global tgcolourqhead
946 if {$tgcolourqhead!=""} { return "\003$tgcolourqhead" }
947}
948proc tgcolqbody {} {
949 global tgcolourqbody
950 if {$tgcolourqbody!=""} { return "\003$tgcolourqbody" }
951}
952proc tgcolhint {} {
953 global tgcolourhint
954 if {$tgcolourhint!=""} { return "\003$tgcolourhint" }
955}
956proc tgcolstrk {} {
957 global tgcolourstrk
958 if {$tgcolourstrk!=""} { return "\003$tgcolourstrk" }
959}
960proc tgcolscr1 {} {
961 global tgcolourscr1
962 if {$tgcolourscr1!=""} { return "\003$tgcolourscr1" }
963}
964proc tgcolscr2 {} {
965 global tgcolourscr2
966 if {$tgcolourscr2!=""} { return "\003$tgcolourscr2" }
967}
968proc tgcolscr3 {} {
969 global tgcolourscr3
970 if {$tgcolourscr3!=""} { return "\003$tgcolourscr3" }
971}
972proc tgcolrset {} {
973 global tgcolourrset
974 if {$tgcolourrset!=""} { return "\003$tgcolourrset" }
975}
976proc tgcolstend {} {
977 global tgcolourstend
978 if {$tgcolourstend!=""} { return "\003$tgcolourstend" }
979}
980proc tgcolmisc1 {} {
981 global tgcolourmisc1
982 if {$tgcolourmisc1!=""} { return "\003$tgcolourmisc1" }
983}
984proc tgcolmisc2 {} {
985 global tgcolourmisc2
986 if {$tgcolourmisc2!=""} { return "\003$tgcolourmisc2" }
987}
988proc tgpriv {} {
989 global tgpriv2msg
990 if {$tgpriv2msg==1} { return "putmsg" } else { return "putnotc" }
991}
992
993#this generates an html file with all the people on the chan with
994#their score, as well as a list of all scores, sorted by rank
995proc tghtml {} {
996 global tgchan botnick tghtmlfile tghtmlrefresh server tgscoresbyname tgranksbyname
997 global tgscorestotal tgranksbyname tgrealnames tgscoresbyrank tgranksbynum tgplaying
998 global tgquestionstotal tghtmlrefreshtimer tghtmlfont
999 tggetscores
1000 tgreadqdb
1001 set _file [open $tghtmlfile~new w]
1002 puts $_file "<!DOCTYPE HTML PUBLIC \"-/W3C/DTD HTML 4.01 Transitional/EN\">"
1003 puts $_file "<html>"
1004 puts $_file " <head>"
1005 puts $_file " <title>$botnick's trivia channel: $tgchan on [lindex [split $server :] 0]</title>"
1006 puts $_file " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
1007 puts $_file " <meta http-equiv=\"refresh\" content=\"$tghtmlrefresh\">"
1008 puts $_file " <meta name=\"generator\" content=\"trivia.tcl script for eggdrop. http://www.eggdrop.za.net/\">"
1009 puts $_file " <style type=\"text/css\">"
1010 puts $_file " <!--"
1011 puts $_file " body,td{font-family:$tghtmlfont;font-size:13px;}"
1012 puts $_file " a{text-decoration:none;color:#09f;}"
1013 puts $_file " -->"
1014 puts $_file " </style>"
1015 puts $_file " </head>"
1016 puts $_file " <body>"
1017 puts $_file " <h1>$tgchan on [lindex [split $server :] 0]</h1>"
1018 puts $_file " <hr size=\"1\" noshade>"
1019 if {![onchan $botnick $tgchan]} {
1020 puts $_file " <p>Hmmm... for some reason I'm not on $tgchan at the moment. Please try again later.</p>"
1021 } else {
1022 puts $_file " <p>Trivia game is currently <b>[expr $tgplaying==1?"on":"off"]</b>. There are <b>$tgquestionstotal</b> questions in the database."
1023 puts $_file " <p>People on $tgchan right now:<br>"
1024 puts $_file " <table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" cellspacing=\"3\" border=\"0\">"
1025 puts $_file " <tr>"
1026 puts $_file " <td><b>Nick</b></td>"
1027 puts $_file " <td><b>Score</b></td>"
1028 puts $_file " <td><b>Rank</b></td>"
1029 puts $_file " <td><b>Idle</b></td>"
1030 puts $_file " </tr>"
1031 foreach nick [lsort [chanlist $tgchan]] {
1032 puts $_file " <tr>"
1033 puts $_file " <td>[expr [isop $nick $tgchan]?"@":""][expr [isvoice $nick $tgchan]?"+":""]$nick[expr [string match $nick $botnick]?" (that's me!)":""]</td>"
1034 if {[info exists tgscoresbyname([strlwr $nick])]} {
1035 puts $_file " <td>$tgscoresbyname([strlwr $nick])</td>"
1036 } else {
1037 puts $_file " <td>-</td>"
1038 }
1039 if {[info exists tgranksbyname([strlwr $nick])]} {
1040 puts $_file " <td>$tgranksbyname([strlwr $nick])</td>"
1041 } else {
1042 puts $_file " <td>-</td>"
1043 }
1044 puts $_file " <td>[expr [getchanidle $nick $tgchan]>10?"[getchanidle $nick $tgchan]m":"-"]</td>"
1045 puts $_file " </tr>"
1046 }
1047 puts $_file " </table></td></tr></table>"
1048 }
1049 if {$tgscorestotal>0} {
1050 puts $_file " <p><small>There [expr $tgscorestotal==1?"is":"are"] currently <b>$tgscorestotal</b> [expr $tgscorestotal==1?"nick":"nicks"] in the score table:<br>"
1051 set _rank 1
1052 while {$_rank<=$tgscorestotal} {
1053 puts $_file " <b>$_rank</b>. $tgrealnames($tgranksbynum($_rank)) $tgscoresbyrank($_rank)<br>"
1054 incr _rank
1055 }
1056 } else {
1057 puts $_file " <p><small>There are currently no nicks in the score table.<br>"
1058 }
1059 puts $_file " </small></p>"
1060 puts $_file " <hr size=\"1\" noshade>"
1061 puts $_file " <small>Generated on [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S] by <a href=\"http://www.eggdrop.za.net/\">trivia.tcl</a> for <a href=\"http://www.eggheads.org\">eggdrop</a>.<br>"
1062 puts $_file " This page is automatically updated (and refreshed if supported by your browser) every [expr $tghtmlrefresh==1?"second":"$tghtmlrefresh seconds"].</small>"
1063 puts $_file " </body>"
1064 puts $_file "</html>"
1065 close $_file
1066 file rename -force $tghtmlfile~new $tghtmlfile
1067 set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
1068}
1069
1070putlog "======================================================="
1071putlog "* trivia.tcl $tgver ($tgrel) by Souperman loaded."
1072putlog "* Visit http://www.eggdrop.za.net/ for updates."
1073tgreadqdb
1074putlog "* $tgquestionstotal questions in $tgqdb ([file size $tgqdb] bytes)"
1075putlog "======================================================="