Swiddis / word-debt-bot

A Discord bot for running a little reading game.
MIT License
2 stars 2 forks source link

Journal Replay #15

Open Swiddis opened 8 months ago

Swiddis commented 8 months ago

The bot currently keeps a journal of state modifications so it can retrace its steps. As part of syncing the game state to the manually run version available on the spreadsheet, there are some modifications that should be applied at a specific timestamp to the game history, to get the numbers back in sync with where they should be. A decent way to do this is to append these modifications to the journal directly, and then replay the journal chronologically to get the state to where it should be.

Currently the journal is an append-only NDJson log that has all the modification commands:

{ "command": "register", "user": "1234", "timestamp": 1705605000.0 }
{ "command": "log", "user": "1234", "timestamp": 1705606000.0, "words": 1500 }

Replaying the log would look roughly like:

  1. Sort entries by timestamp
  2. Convert entries to commands
  3. Run entries with simulated timestamp
  4. Override game state with new simulated game state

This can either be done as an admin operation behind the scenes (with a supplementary script that uses the game files) or added to the bot as a command (maybe admin-only?).

Swiddis commented 8 months ago

Started working on this but shifted to other issues, feel free to pick up on the draft work in #26 or start anew