star_avatar

Star Avatar Expression System – backend emotion-to-avatar mapping.

Reads Star’s current dominant emotional state from the NCM limbic shard and updates her Matrix avatar to match. Called once per response, just before the reply is sent.

The avatar images must already be uploaded to the Matrix homeserver as mxc:// URIs. On first run (or when the Redis key star:avatar:mxc_map is empty), the images are uploaded from disk and the mxc URIs are cached.

Expression mapping:

default -> star-avatar.png (confident cigar pose) laugh -> star-laugh.png (cry-laughing, amused) rage -> star-rage.png (fists clenched, angry) facepalm -> star-facepalm.png (hand over eye, exasperated)

star_avatar.classify_expression(dominant_emotions)[source]

Map a list of dominant emotions to an expression bucket.

Returns one of: ‘default’, ‘laugh’, ‘rage’, ‘facepalm’.

Return type:

str

Parameters:

dominant_emotions (list[str])

async star_avatar.get_expression_mxc_map(redis_client, matrix_client=None, *, base_dir=None)[source]

Load or lazily create the expression -> mxc:// URI mapping.

On first call, uploads the expression images to Matrix and caches the mxc URIs in Redis. Subsequent calls read from cache.

Return type:

dict[str, str]

Parameters:
  • redis_client (Any)

  • matrix_client (Any)

  • base_dir (str | Path | None)

async star_avatar.update_star_avatar(redis_client, matrix_client, channel_id, dominant_emotions=None)[source]

Update Star’s Matrix avatar based on current emotional state.

If dominant_emotions is not provided, reads from the NCM limbic shard in Redis.

Return type:

None

Parameters:
  • redis_client (Any)

  • matrix_client (Any)

  • channel_id (str)

  • dominant_emotions (list[str] | None)