# 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()`
