From b963bf8f38828a8d04e624440ca1feda744d8816 Mon Sep 17 00:00:00 2001 From: grant Date: Fri, 8 Dec 2023 09:35:52 -0600 Subject: [PATCH 1/2] adding todos --- src/Classes/ArtIndexerBot.ts | 7 ++++++- src/Classes/TriviaBot.ts | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Classes/ArtIndexerBot.ts b/src/Classes/ArtIndexerBot.ts index 1ec5992..9b395b5 100644 --- a/src/Classes/ArtIndexerBot.ts +++ b/src/Classes/ArtIndexerBot.ts @@ -653,7 +653,12 @@ export class ArtIndexerBot { const keys = Object.keys(this.flagship) const projectKey = keys[Math.floor(Math.random() * keys.length)] const projBot = this.flagship[projectKey] - if (projBot && projBot.editionSize > 1 && projBot.projectActive) { + if ( + projBot && + projBot.editionSize > 1 && + projBot.projectActive && + !triviaBot.alreadyAsked(projBot) + ) { triviaBot.askTriviaQuestion(projBot) return } diff --git a/src/Classes/TriviaBot.ts b/src/Classes/TriviaBot.ts index a1b3c46..7fd10e5 100644 --- a/src/Classes/TriviaBot.ts +++ b/src/Classes/TriviaBot.ts @@ -16,6 +16,7 @@ export class TriviaBot { channel?: TextChannel previousQuestion?: Message + previousAnswers: string[] = [] currentTriviaAnswer: string constructor(bot: Client) { this.bot = bot @@ -44,9 +45,21 @@ export class TriviaBot { isArtistActiveTriviaAnswer(artist: string): boolean { return artist === this.currentTriviaAnswer } + alreadyAsked(projectBot: ProjectBot): boolean { + return ( + this.previousAnswers.includes(projectBot.projectName) || + this.previousAnswers.includes(projectBot.artistName) + ) + } async askTriviaQuestion(project: ProjectBot) { // List of ideas: + + // TODO: build out trivia hour functionality + // TODO: String replace project name in description with "______" + // TODO: "close one! not quite" on typo + // TODO: trivia info call (maybe restates last question too) + // Phase 2: // TODO: Different triggers? Not just time based - number of sales, LJ cursing, thank grant, etc. // TODO: Trait data type questions? (e.g. "Name a project that has a trait of 'blue'"), Which of these is not a Meridian trait? @@ -55,7 +68,9 @@ export class TriviaBot { if (this.currentTriviaAnswer && this.previousQuestion) { this.previousQuestion.reply( - 'No one got this one! The answer was: ' + this.currentTriviaAnswer + `Looks like no one got this one! The answer was: ${this.currentTriviaAnswer}. + +Next question:` ) } @@ -97,6 +112,8 @@ export class TriviaBot { return } + this.previousAnswers.push(this.currentTriviaAnswer) + this.channel = this.bot.channels?.cache?.get( CHANNEL_BLOCK_TALK ) as TextChannel From c808ef48897fab5aa60876c805adb3b18f3fe2d3 Mon Sep 17 00:00:00 2001 From: grant Date: Fri, 15 Dec 2023 12:46:31 -0600 Subject: [PATCH 2/2] turn on trivia!! --- src/Classes/SchedulerBot.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Classes/SchedulerBot.ts b/src/Classes/SchedulerBot.ts index 7816ae0..7e1486d 100644 --- a/src/Classes/SchedulerBot.ts +++ b/src/Classes/SchedulerBot.ts @@ -42,10 +42,17 @@ export class ScheduleBot { } ) - // TODO: Uncomment when trivia is ready - // Cron('* * * * *', { timezone: 'America/Chicago', name: 'Trivia' }, () => { - // console.log('Trivia Time!') - // artIndexerBot.askRandomTriviaQuestion() - // }) + const triviaCadence = parseInt(process.env.TRIVIA_CADENCE ?? '0') + + if (triviaCadence > 0) { + Cron( + `0 */${triviaCadence} * * *`, + { timezone: 'America/Chicago', name: 'Trivia' }, + () => { + console.log('Trivia Time!') + artIndexerBot.askRandomTriviaQuestion() + } + ) + } } }