xecho -b Lyrics Trivia script loaded! xecho -b Written by gircobain 26/05/2002 assign LYRICS_TRIVIA_ON 0 assign SONGSFILE ~/lyrics.txt assign SCORESFILE ~/scores assign MSCORESFILE ~/mscores assign MTCHAN #Lyrics_Trivia assign TIMEOUT 72 eval assign HINTTO ${1 + TIMEOUT/4} assign NOTIFY 1 alias answer echo $wordtoguess alias load_songs { @delarray(songs) @delarray(lyrics) @:fd = open($SONGSFILE r) while (!eof($fd)) { @:line = read($fd) if (match(SONG: $line) == 1) { @setitem(songs $numitems(songs) $restw(1 $line)) }{ @setitem(lyrics $numitems(lyrics) $numitems(songs) $line) } } @close($fd) } alias load_scores { @delarray(nicks) @delarray(points) @delarray(records) if (fsize($SCORESFILE) > 0) { @:fd = open($SCORESFILE r) ^local line while (!eof($fd)) { if ((line = read($fd)) != []) { @setitem(nicks $numitems(nicks) $word(0 $line)) @setitem(points $numitems(points) $word(1 $line)) @setitem(records $numitems(records) $word(2 $line)) if (word(2 $line) > record) { @champion = word(0 $line) @record = word(2 $line) } } } @close($fd) }{ ^assign record 0 ^assign champion nobody } @delarray(mnicks) @delarray(mpoints) @delarray(mrecords) if (fsize($MSCORESFILE) > 0) { @:fd = open($MSCORESFILE r) ^assign month $read($fd) while (!eof($fd)) { @:line = read($fd) @setitem(mnicks $numitems(mnicks) $word(0 $line)) @setitem(mpoints $numitems(mpoints) $word(1 $line)) @setitem(mrecords $numitems(mrecords) $word(2 $line)) if (word(2 $line) > mrecord) { @mchampion = word(0 $line) @mrecord = word(2 $line) } } @close($fd) }{ ^assign mrecord 0 ^assign mchampion nobody ^assign month $strftime(%B) } } alias save_scores { @unlink($SCORESFILE) @:fd = open($SCORESFILE w) for (@:count = 0,count < numitems(nicks),@:count++) { @write($fd $getitem(nicks $count) $getitem(points $count) $getitem(records $count)) } @close($fd) @unlink($MSCORESFILE) @:fd = open($MSCORESFILE w) @write($fd $month) for (@:count = 0,count < numitems(mnicks),@:count++) { @write($fd $getitem(mnicks $count) $getitem(mpoints $count) $getitem(mrecords $count)) } @close($fd) } alias show_scores (number) { msg $MTCHAN $cparse(%R*** Top $number scores ***%N) @:sorted = revw($numsort($listarray(mpoints))) if (number > [$#sorted]) @number = [$#sorted] @:sorted = leftw($number $sorted) @:nicks = listarray(mnicks) @:points = listarray(mpoints) for (@:count = 0,count < [$#sorted],@:count++) { @:pos = findw($word($count $sorted) $points) msg $MTCHAN $cparse(%W\[$[-2]{count+1}\] %y$[20]word($pos $nicks) %c$[-5]word($pos $points)%N) @:points = remw($word($pos $points) $points) @:nicks = remw($word($pos $nicks) $nicks) } msg $MTCHAN $cparse(%C$mchampion%B has the record for this month with%C $mrecord %Bpoints in a round!%N) } alias show_overall (number) { msg $MTCHAN $cparse(%R*** Top $number %cOverall%R scores ***%N) @:sorted = revw($numsort($listarray(points))) if (number > [$#sorted]) @number = [$#sorted] @:sorted = leftw($number $sorted) @:nicks = listarray(nicks) @:points = listarray(points) for (@:count = 0,count < [$#sorted],@:count++) { @:pos = findw($word($count $sorted) $points) msg $MTCHAN $cparse(%W\[$[-2]{count+1}\] %y$[20]word($pos $nicks) %c$[-5]word($pos $points)%N) @:points = remw($word($pos $points) $points) @:nicks = remw($word($pos $nicks) $nicks) } msg $MTCHAN $cparse(%C$champion%B has the actual record with%C $record %Bpoints in a round!%N) } alias start { if (LYRICS_TRIVIA_ON) { xecho -b Lyrics Trivia is already on! }{ ^assign LYRICS_TRIVIA_ON 1 ^assign -wordtoguess ^assign -record ^assign -champion ^assign -mrecord ^assign -mchampion ^assign STIME $time() @delarray(hints) load_songs load_scores @srand($time()) xecho -b Lyrics Trivia is now on! topic $MTCHAN $cparse(%GLyrics Trivia is currently On, come play!) msg $MTCHAN $cparse(%RTrivia is now On!) msg $MTCHAN $cparse(%RThere are currently%Y $numitems(songs) %Rsongs and%Y $numitems(lyrics) %Rline in the database) msg $MTCHAN $cparse(%RThe Game will begin now!) timer -ref SAVE -rep -1 600 save_scores inquire } } alias stop { if (LYRICS_TRIVIA_ON) { timer -del INQUIRY timer -del HINT timer -del TEMP timer -del SAVE ^assign LYRICS_TRIVIA_ON 0 ^assign -inquiry ^assign -wordtoguess ^assign -wtgindex save_scores xecho -b Lyrics Trivia is now off! topic $MTCHAN $cparse(%GLyrics Trivia is Off) msg $MTCHAN $cparse(%RThe Game has stopped!) msg $MTCHAN $cparse(%RTrivia is now Off) }{ xecho -b Lyrics Trivia is already off! } } alias inquire { ^set RANDOM_SOURCE 2 ^assign BETWEEN_QUESTIONS 0 ^local line @delarray(hints) do { @line = getitem(lyrics $rand(${numitems(lyrics)-1})) } while (numwords($line) < 3) @:songinfo = getitem(songs ${word(0 $line)-1}) ^assign inquiry $restw(1 $line) ^assign wtgindex $rand(${#inquiry - 1}) ^assign already_hinted 0 ^local hint_header Song Author Album Year ^local hintlist ^set RANDOM_SOURCE 0 repeat 4 @push(hintlist $rand(1000)) @:sortedhints = numsort($hintlist) for (@:count = 0,count < 4,@:count++) { @:pos = findw($word($count $sortedhints) $hintlist) @setitem(hints $numitems(hints) $word($pos $hint_header) $word($pos $songinfo)) } msg $MTCHAN $cparse(%BLine:%c "$genwordtoguess()"%N) timer -ref HINT $HINTTO hint timer -ref INQUIRY $TIMEOUT { timer -del HINT @delarray(hints) ^assign -wordtoguess ^assign -inquiry msg $MTCHAN $cparse(%BTime over!%N) timer -ref TEMP 3 { msg $MTCHAN $cparse(%BGet ready for the next one!%N) timer -ref TEMP 3 inquire } } } alias genwordtoguess { ^local masked ^assign -wordtoguess @:fullword = word($wtgindex $inquiry) @:flag = 1 fec ($reverse($fullword)) char { if (match(*$char* ,.?!) && flag) { @masked #~ char }{ if (flag) @flag = 0 @masked #~ [*] @wordtoguess #~ char } } return $chngw($wtgindex $masked $inquiry) } alias hint { @already_hinted++ @:curhint = getitem(hints 0) if (curhint != []) { msg $MTCHAN $cparse(%R\(Hint\)%B $word(0 $curhint):%y $restw(1 $curhint)%N) @delitem(hints 0) if (already_hinted < 3 && numitems(hints)) timer -ref HINT $HINTTO hint } } alias show_points (nick) { @:pos = matchitem(mnicks $nick) if (pos > -1) { msg $MTCHAN $cparse(%Y$nick%B has scored%Y $getitem(mpoints $pos) %Bpoints this month%N) msg $MTCHAN $cparse(%Y$nick%B's record this month is%Y $getitem(mrecords $pos) %Bpoints in a round%N) }{ msg $MTCHAN $cparse(%Y$nick%B has not scored yet this month%N) } } alias show_total (nick) { @:pos = matchitem(nicks $nick) if (pos > -1) { msg $MTCHAN $cparse(%Y$nick%B has scored%Y $getitem(points $pos) %Bpoints%N) msg $MTCHAN $cparse(%Y$nick%B's record is%Y $getitem(records $pos) %Bpoints in a round%N) }{ msg $MTCHAN $cparse(%Y$nick%B has not scored yet%N) } } alias gettimestring (timeinsecs, void) { stack push set Floating_Point ^set Floating_Point 0 @:time_string = [] @:days = timeinsecs/86400 @:hours = (timeinsecs % 86400)/3600 @:mins = ((timeinsecs % 86400) % 3600)/60 @:secs = ((timeinsecs % 86400) % 3600) % 60 switch ($days) { (0) {} (1) { @time_string = days ## [ day ] } (*) { @time_string = days ## [ days ] } } switch ($hours) { (0) {} (1) { @time_string = time_string ## hours ## [ hour ] } (*) { @time_string = time_string ## hours ## [ hours ] } } switch ($minutes) { (0) {} (1) { @time_string = time_string ## mins ## [ min ] } (*) { @time_string = time_string ## mins ## [ mins ] } } switch ($seconds) { (0) {} (1) { @time_string = time_string ## secs ## [ sec] } (*) { @time_string = time_string ## secs ## [ secs] } } stack pop set Floating_Point @function_return = time_string } on #-public 1246 '% $MTCHAN $wordtoguess' if (LYRICS_TRIVIA_ON && wordtoguess != []) { timer -del INQUIRY timer -del HINT @:score = @wordtoguess + numitems(hints) msg $MTcHAN $cparse(%BWell done,%Y $0,%B the answer was%Y $wordtoguess%B ! \(%Y$score points%B\)%N) @:pos = matchitem(nicks $0) if (pos > -1) { @setitem(points $pos ${getitem(points $pos) + score}) if (score > getitem(records $pos)) @setitem(records $pos $score) }{ @setitem(nicks $numitems(nicks) $0) @setitem(points $numitems(points) $score) @setitem(records $numitems(records) $score) } @:pos = matchitem(mnicks $0) if (pos > -1) { @setitem(mpoints $pos ${getitem(mpoints $pos) + score}) if (score > getitem(mrecords $pos)) @setitem(mrecords $pos $score) }{ @setitem(mnicks $numitems(mnicks) $0) @setitem(mpoints $numitems(mpoints) $score) @setitem(mrecords $numitems(mrecords) $score) } if (score > record) { @record = mrecord = score @champion = mchampion = [$0] msg $MTCHAN $cparse(%Y$0%B has set a new record with%Y $score %Bpoints in a round!%N) }{ if (score > mrecord) { @mrecord = score @mchampion = [$0] msg $MTCHAN $cparse(%Y$0%B has set a new monthly record with%Y $score %Bpoints in a round!%N) } } ^assign -wordtoguess ^assign -inquiry timer -ref TEMP 3 { msg $MTCHAN $cparse(%BGet ready for the next one!%N) timer -ref TEMP 3 inquire } } on #-public 8925 '% on #-public 3214 '% $MTCHAN *' { @:pos = matchitem(hints % $2-) if (pos > -1) { @:got = getitem(hints $pos) switch ($word(0 $got)) { (Song) { msg $MTCHAN $cparse(%BVery good,%Y $0,%B the song is%Y $restw(1 $got) %B\(%Y1 point%B\)%N) } (Author) { msg $MTCHAN $cparse(%BVery good,%Y $0,%B this song is by%Y $restw(1 $got) %B\(%Y1 point%B\)%N) } (Album) { msg $MTCHAN $cparse(%BVery good,%Y $0,%B this song belongs to%Y $restw(1 $got) %B\(%Y1 point%B\)%N) } (Year) { msg $MTCHAN $cparse(%BVery good,%Y $0,%B this song was released in%Y $restw(1 $got) %B\(%Y1 point%B\)%N) } } @delitem(hints $pos) @:pos = matchitem(nicks $0) if (pos > -1) { @setitem(points $pos ${getitem(points $pos) + 1}) }{ @setitem(nicks $numitems(nicks) $0) @setitem(points $numitems(points) 1) @setitem(points $numitems(records) 1) } @:pos = matchitem(mnicks $0) if (pos > -1) { @setitem(mpoints $pos ${getitem(mpoints $pos) + 1}) }{ @setitem(mnicks $numitems(mnicks) $0) @setitem(mpoints $numitems(mpoints) 1) @setitem(mpoints $numitems(mrecords) 1) } } } on #-public 4375 '% $MTCHAN !won' if (LYRICS_TRIVIA_ON) show_points $0 on #-public 5262 '% $MTCHAN !won %' if (LYRICS_TRIVIA_ON) show_points $3 on #-public 8292 '% $MTCHAN !scores' if (LYRICS_TRIVIA_ON) show_scores 10 on #-public 4375 '% $MTCHAN !total' if (LYRICS_TRIVIA_ON) show_total $0 on #-public 5262 '% $MTCHAN !total %' if (LYRICS_TRIVIA_ON) show_total $3 on #-public 2678 '% $MTCHAN !overall' if (LYRICS_TRIVIA_ON) show_overall 10 on #-public 1251 '% $MTCHAN !next' if (LYRICS_TRIVIA_ON && wordtoguess != []) { @:pos = matchitem(nicks $0) if (pos > -1 && getitem(nicks $pos) < 0 && [$0] != [$N]) { msg $MTCHAN $cparse(%BSorry you can't cheat anymore, loser.) }{ if ([$0] != [$N]) { msg $MTCHAN $cparse(%C$0%B has lost%C 1 %Bpoint for skipping a question!) if (pos < 0) { @setitem(nicks $numitems(nicks) $0) @setitem(points $numitems(points) -1) @setitem(records $numitems(records) 0) @:pos = matchitem(mnicks $0) if (pos < 0) { @setitem(mnicks $numitems(mnicks) $0) @setitem(mpoints $numitems(mpoints) -1) @setitem(mrecords $numitems(mrecords) 0) }{ @setitem(mpoints $pos ${getitem(mpoints $pos) - 1}) } }{ @setitem(points $pos ${getitem(points $pos) - 1}) } } timer -del INQUIRY timer -del HINT @delarray(hints) ^assign -wordtoguess ^assign -inquiry timer -ref TEMP 3 { msg $MTCHAN $cparse(%BGet ready for the next one!%N) timer -ref TEMP 3 inquire } } } on #-public 5352 '% $MTCHAN !repeat' { if (inquiry) msg $MTCHAN $cparse(%gLine:%y "$genwordtoguess()"%N) } on #-public 8953 '% $MTCHAN !uptime' if (LYRICS_TRIVIA_ON) { @:uptime = gettimestring(${time() - STIME}) msg $MTCHAN $cparse(%cTrivia has been running for%W $uptime %c\(since%W $strftime($STIME %b %d %X)%c\)) } on #-public 2778 '% $MTCHAN !lyrics' if (LYRICS_TRIVIA_ON) { msg $MTCHAN $cparse(%cThere are currently%Y $numitems(songs) %csongs and%Y $numitems(lyrics) %cline in the database.) } on #-join 211 '$MTCHAN *' if (NOTIFY) { if ([$1] != [$N]) { msg $1 Welcome to the Lyrics Trivia channel, $1 if (LYRICS_TRIVIA_ON) { msg $1 Enjoy your stay and have fun! msg $1 For help, /msg $N !help }{ msg $1 We're sorry but the Trivia game is currently off } } } on #-leave 572 '$MTCHAN *' if (NOTIFY) { if ([$0] != [$N]) { msg $1 Thanks for stopping by, $1 msg $1 Come back anytime! } } on #-msg 287 "% !help" { ^raw 205 $0 Score table: ^raw 205 $0 Missing word - points ^raw 205 $0 Song title - 1 point ^raw 205 $0 Song author - 1 point ^raw 205 $0 Album - 1 point ^raw 205 $0 Year of release - 1 point ^raw 205 $0 Available commands: ^raw 205 $0 !repeat - repeats last question asked ^raw 205 $0 !uptime - shows trivia's uptime # ^raw 205 $0 !asked - shows number of questions asked since last start # ^raw 205 $0 !questions - shows number of questions in the database ^raw 205 $0 !won - shows current month wins for (if omitted, shows own) ^raw 205 $0 !total - shows total wins for (if omitted, shows own) # ^raw 205 $0 !average - shows average wins per hour for (if omitted, shows own) ^raw 205 $0 !scores - shows top 10 scores for current month ^raw 205 $0 !overall - shows overal top 10 scores ^raw 205 $0 !next - skip to next question ^raw 205 $0 !lyrics - shows info about the database # ^raw 205 $0 !cheat - gives answer for current question # ^raw 205 $0 !hint - shows hint for current question when hintmode is ON # ^raw 205 $0 !autohint - toggles hintmode between OFF and AUTO (Admin+) # ^raw 205 $0 !start - starts trivia (Admin+) # ^raw 205 $0 !stop - stops trivia (Admin+) } on ^timer "00:00" if (LYRICS_TRIVIA_ON) { if (strftime(%B) != month) { show_scores 20 @:scores = revw($numsort($listarray(mpoints))) @:mwins = word(0 $scores) @:mwinner = getitem(mnicks $finditem(mpoints $mwins)) msg $MTCHAN $cparse(%CCongrats to%G $mwinner %C, this month trivia winner, with%G $mwins %Cwins!) timer 2 { msg $MTCHAN $cparse(%CAlso, congrats to%G $mchampion %C, for their%G $mrecord %Cpoints in a round!) timer 2 msg $MTCHAN $cparse(%RThe month of%c $month %Ris over and the scores were reset!) } @unlink($MSCORESFILE) load_scores } }