feat: permitir comandos de robots sin prefijo !
Cuando command_prefix es "" en el config, el parser trata el primer token del mensaje como nombre de comando sin requerir el prefijo !. Si el token empieza con !, se le quita igualmente para retrocompatibilidad. Cambios: - pkg/message/parse.go: modo sin prefijo en Parse() (puro, sin side effects) - agents/robot.go: mensaje "comando desconocido" y !help adaptados al prefijo - agents/handler.go: mensaje "comando desconocido" adaptado al prefijo - internal/config/schema.go: documentar command_prefix: "" en FiltersCfg - agents/_template_robot/config.yaml: ejemplo comentado de command_prefix: "" El comportamiento con command_prefix: "!" no cambia (retrocompatible).
This commit is contained in:
@@ -44,7 +44,8 @@ matrix:
|
||||
admin: []
|
||||
|
||||
filters:
|
||||
command_prefix: "!"
|
||||
command_prefix: "!" # usar "" para permitir comandos sin prefijo !
|
||||
# command_prefix: "" # sin prefijo: todo mensaje es un posible comando
|
||||
mention_respond: false # robots no responden a menciones (no hay LLM)
|
||||
dm_respond: false # robots no responden a DMs (no hay LLM)
|
||||
ignore_bots: true
|
||||
|
||||
+5
-2
@@ -74,8 +74,11 @@ func (a *Agent) handleEvent(ctx context.Context, msgCtx decision.MessageContext,
|
||||
} else {
|
||||
// Unknown command — never falls through to rules or LLM
|
||||
a.logger.Info("command_unknown", "command", msgCtx.Command)
|
||||
_ = a.sendReply(ctx, roomID, msgCtx.EventID, msgCtx.ThreadID,
|
||||
fmt.Sprintf("Comando desconocido: `!%s`. Usa `!help` para ver comandos disponibles.", msgCtx.Command))
|
||||
unknownMsg := fmt.Sprintf("Comando desconocido: `!%s`. Usa `!help` para ver comandos disponibles.", msgCtx.Command)
|
||||
if a.cfg.Matrix.Filters.CommandPrefix == "" {
|
||||
unknownMsg = fmt.Sprintf("Comando desconocido: `%s`. Usa `help` para ver comandos disponibles.", msgCtx.Command)
|
||||
}
|
||||
_ = a.sendReply(ctx, roomID, msgCtx.EventID, msgCtx.ThreadID, unknownMsg)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+12
-7
@@ -206,8 +206,11 @@ func (r *Robot) handleEvent(ctx context.Context, msgCtx decision.MessageContext,
|
||||
|
||||
// Unknown command
|
||||
r.logger.Info("command_unknown", "command", msgCtx.Command)
|
||||
_ = r.sendReply(ctx, roomID, msgCtx.EventID, msgCtx.ThreadID,
|
||||
fmt.Sprintf("Comando desconocido: `!%s`. Usa `!help` para ver comandos disponibles.", msgCtx.Command))
|
||||
unknownMsg := fmt.Sprintf("Comando desconocido: `!%s`. Usa `!help` para ver comandos disponibles.", msgCtx.Command)
|
||||
if r.cfg.Matrix.Filters.CommandPrefix == "" {
|
||||
unknownMsg = fmt.Sprintf("Comando desconocido: `%s`. Usa `help` para ver comandos disponibles.", msgCtx.Command)
|
||||
}
|
||||
_ = r.sendReply(ctx, roomID, msgCtx.EventID, msgCtx.ThreadID, unknownMsg)
|
||||
}
|
||||
|
||||
// sendReply sends a markdown reply that respects thread context.
|
||||
@@ -224,13 +227,15 @@ func (r *Robot) cmdHelp(_ context.Context, _ decision.MessageContext) string {
|
||||
var b strings.Builder
|
||||
b.WriteString("**Comandos disponibles:**\n\n")
|
||||
|
||||
prefix := r.cfg.Matrix.Filters.CommandPrefix // "!" or ""
|
||||
|
||||
// Built-in commands appropriate for robots
|
||||
robotBuiltins := []command.Spec{
|
||||
{Name: "help", Aliases: []string{"h"}, Description: "Lista comandos disponibles", Usage: "!help"},
|
||||
{Name: "ping", Description: "Alive check", Usage: "!ping"},
|
||||
{Name: "status", Description: "Info del robot: uptime", Usage: "!status"},
|
||||
{Name: "info", Description: "Nombre, version y descripcion", Usage: "!info"},
|
||||
{Name: "version", Aliases: []string{"v"}, Description: "Version del robot", Usage: "!version"},
|
||||
{Name: "help", Aliases: []string{"h"}, Description: "Lista comandos disponibles", Usage: prefix + "help"},
|
||||
{Name: "ping", Description: "Alive check", Usage: prefix + "ping"},
|
||||
{Name: "status", Description: "Info del robot: uptime", Usage: prefix + "status"},
|
||||
{Name: "info", Description: "Nombre, version y descripcion", Usage: prefix + "info"},
|
||||
{Name: "version", Aliases: []string{"v"}, Description: "Version del robot", Usage: prefix + "version"},
|
||||
}
|
||||
for _, spec := range robotBuiltins {
|
||||
writeSpec(&b, spec)
|
||||
|
||||
Reference in New Issue
Block a user