Some checks failed
Deploy to Production / test (push) Failing after 33s
- Rewrite AGENTS and README files to match the current app layout - Document API routes, trivia UI, and the active panel design language
957 B
957 B
Trivia module
Model
triviaServiceis a class-backed singleton- active sessions live in memory
- expired sessions are cleaned every 30 seconds
Flow
canPlayTrivia()checks the cooldown timer.startTrivia()deducts the entry fee, fetches a question from OpenTDB, creates the session, and sets the cooldown.- The bot view layer renders answer buttons using the stored shuffled answers and
correctIndex. 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=base64and 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'sisCorrectboolean- reward payment currently reads and writes the balance directly inside the transaction instead of using
modifyUserBalance()