tools.wipe_game_data module

Wipe all game data for a channel β€” session, history, memories, assets.

# πŸ’€πŸ”₯ NUCLEAR GAME RESET

async tools.wipe_game_data.run(confirm=False, ctx=None, **_kw)[source]

Irreversibly wipe every trace of game state for the current channel.

Admin-only nuclear reset used to recover a channel whose game data was corrupted by an older version or when the user explicitly wants a clean slate. It tears down the in-memory session, the persisted Redis session and history, and the game’s memories, assets and index entry in one pass, requiring an explicit confirm=True so it cannot fire by accident.

Interactions: gates on tools.alter_privileges.has_privilege with the UNSANDBOXED_EXEC privilege (reading ctx.redis, ctx.config and ctx.user_id). Resolves the channel from ctx.channel_id and a Redis client from ctx.redis (falling back to ctx.config.redis). Calls game_session.get_session / game_session.remove_session to drop the live session, then deletes the Redis keys game:session:{channel_id} and its :history companion, the game:mem:basic:{game_id}, game:mem:channel:{game_id} and game:assets:{game_id} keys, and the game_id field of the game:index hash. Logs a summary line on completion. Per-step errors are collected rather than aborting the wipe.

Called by the tool-dispatch layer: tool_loader.py registers this module via its TOOL_NAME / run contract and the registry invokes run with the parsed arguments and ctx; there are no direct internal callers.

Parameters:
  • confirm (bool) – Must be True to proceed; any falsy value returns an error without touching data.

  • ctx (Any) – The tool ToolContext providing Redis, config, the user id for the privilege check, and the target channel_id.

  • **_kw (Any) – Ignored extra keyword arguments tolerated for dispatch.

Returns:

A JSON string. On success {"success": True, "channel_id": ..., "game_id": ..., "game_name": ..., "deleted": [...]} (plus an errors list when any individual step failed). On refusal or setup problems an {"error": ...} / {"success": False, "error": ...} object (missing context, missing privilege, unset confirm, missing channel_id, or no Redis connection).

Return type:

str