mud_server.db.chat_repo

Chat repository operations for the SQLite backend.

This module isolates room/whisper chat persistence from the compatibility facade in mud_server.db.database.

Functions

add_chat_message(character_name, message, room[, ...])

Insert a chat message row for room chat or whispers.

prune_chat_messages(max_age_hours, *[, world_id, room])

Delete chat messages older than max_age_hours.

get_room_messages(room, *[, limit, character_name, ...])

Return recent room messages with whisper visibility filtering.

Module Contents

mud_server.db.chat_repo.add_chat_message(character_name, message, room, recipient_character_name=None, recipient=None, *, world_id)[source]

Insert a chat message row for room chat or whispers.

Compatibility behavior: - recipient alias is still accepted and mapped to

recipient_character_name.

  • Sender and recipient names require explicit character identities.

mud_server.db.chat_repo.prune_chat_messages(max_age_hours, *, world_id=None, room=None)[source]

Delete chat messages older than max_age_hours.

Parameters:
  • max_age_hours (int) – Delete messages with timestamp older than this many hours. Must be a positive integer (>= 1).

  • world_id (str | None) – If provided, restrict deletion to this world only.

  • room (str | None) – If provided (requires world_id), restrict to a single room.

Returns:

Number of rows deleted.

Raises:
Return type:

int

mud_server.db.chat_repo.get_room_messages(room, *, limit=50, character_name=None, username=None, world_id)[source]

Return recent room messages with whisper visibility filtering.

When a character identity is provided, this returns: - public messages in the room, - whispers to that character, - whispers sent by that character.