diff --git a/server/hooks.go b/server/hooks.go index 6496f51..b908e04 100644 --- a/server/hooks.go +++ b/server/hooks.go @@ -197,34 +197,24 @@ func (p *Plugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) { // Prepend the persona system prompt to set the bot's character. // Priority: KV override > dropdown selection - // KV "custom" or dropdown "custom" → use CustomPersona textarea field - // Otherwise → resolve from personaLibrary + // "custom" → CustomPersona textarea (falls back to defaultCustomPersona if empty) + // otherwise → resolve from personaLibrary persona := p.GetPersonaOverride(post.UserId, post.ChannelId) + if persona == "" { + persona = cfg.Persona + } + var personaDesc string if persona == "custom" { - persona = cfg.CustomPersona - if persona == "" { - persona = defaultCustomPersona + personaDesc = cfg.CustomPersona + if personaDesc == "" { + personaDesc = defaultCustomPersona } } else { - persona = resolvePersona(persona) - } - if persona == "" { - if cfg.Persona == "custom" { - persona = cfg.CustomPersona - if persona == "" { - persona = defaultCustomPersona - } - } else { - persona = resolvePersona(cfg.Persona) - // If resolvePersona returned empty but a value was set, use it as-is (legacy fallback). - if persona == "" && cfg.Persona != "" { - persona = cfg.Persona - } - } + personaDesc = resolvePersona(persona) } systemPrompt := "" - if persona != "" { - systemPrompt = "You are " + persona + ". Respond in character. Only respond to the latest message — do not re-address earlier messages. Vary your openings and phrasing each time." + if personaDesc != "" { + systemPrompt = "You are " + personaDesc + ". Respond in character. Only respond to the latest message — do not re-address earlier messages. Vary your openings and phrasing each time." if cfg.Brevity != "" && cfg.Brevity != "0" { systemPrompt += " Reply in " + cfg.Brevity + " sentences or fewer." }