Back to Blog

AstrBot / Roleplay / Safety

Persona Binding and Scope Control in a Roleplay Chat Plugin

A constrained AstrBot roleplay plugin with memory isolation and image guards.

A roleplay plugin needs strict scope control. General chat enhancement can provide memory and image understanding, but a dedicated persona must only operate in selected scenes.

Project Overview

main.py integrates with AstrBot, while utils contains modules for attention, probability, cooldowns, mood, persona binding, image handling, context, proactive chat, response filters, allowlists, and memory namespaces.

The plugin builds a strongly constrained game roleplay interface. It fits roleplay communities, persona-based group chat, and bots that must stay within specific groups and character boundaries.

Implementation

Messages are preprocessed, then trigger probability and contextual value are calculated. Before generation, role prompts, short-term context, long-term memory, and image descriptions may be injected. After generation, quality filters, repetition guards, and reply-density control decide whether to send.

Memory is separated by persona and session namespace so one character or group cannot pollute another.