Files
aurorabot/shared/modules/trivia/AGENTS.md
syntaxbullet 6abbd4652a
Some checks failed
Deploy to Production / test (push) Failing after 33s
Refresh repository documentation
- Rewrite AGENTS and README files to match the current app layout
- Document API routes, trivia UI, and the active panel design language
2026-04-09 21:10:10 +02:00

23 lines
957 B
Markdown

# Trivia module
## Model
- `triviaService` is a class-backed singleton
- active sessions live in memory
- expired sessions are cleaned every 30 seconds
## Flow
1. `canPlayTrivia()` checks the cooldown timer.
2. `startTrivia()` deducts the entry fee, fetches a question from OpenTDB, creates the session, and sets the cooldown.
3. The bot view layer renders answer buttons using the stored shuffled answers and `correctIndex`.
4. `submitAnswer()` removes the session and pays the reward only if the caller says the answer was correct.
## Notes
- questions are fetched from OpenTDB with `encode=base64` and decoded server-side
- entry fee is deducted before the question fetch completes
- cooldown is applied when the session starts, not when the answer is submitted
- `submitAnswer()` trusts the caller's `isCorrect` boolean
- reward payment currently reads and writes the balance directly inside the transaction instead of using `modifyUserBalance()`