From 8cd7cfd6e7b49f793005e5ce2fa3a4baba92fea1 Mon Sep 17 00:00:00 2001 From: NanamiAdmin Date: Fri, 7 Aug 2026 22:39:57 +0800 Subject: [PATCH] feat(controller): add help command with message template for bot commands --- config/config.go | 3 +++ config/variables.go | 1 + internal/controller/processor.go | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/config/config.go b/config/config.go index 5dc80c2..a2ffdbf 100644 --- a/config/config.go +++ b/config/config.go @@ -91,6 +91,9 @@ func LoadConfig(configPath string) (*Config, error) { if cfg.ControllerMessage.BotStarted == "" { cfg.ControllerMessage.BotStarted = "Nukumizu Alert Bot Started\nVersion: {{ softwareVersion }}.{{ softwareBuildVer }}.{{ softwareCommitHash }}.{{ softwareBuildType }}\nDeveloper: {{ softwareDeveloper }}\nTime: {{ time }}" } + if cfg.ControllerMessage.BotHelp == "" { + cfg.ControllerMessage.BotHelp = "Available commands:\n/help - Show this help message\n/list - List all servers\n/status - Show status of a specific server\n/shutdown - Shutdown a specific server\n/reboot - Reboot a specific server\n/run - Run a command on a specific server\n/info - Show bot information" + } if cfg.ControllerMessage.ServerStatusChanged == "" { cfg.ControllerMessage.ServerStatusChanged = "Server Status Changed Alert\n{{ serverName }} - {{ upStatus }}\nEvent: {{ event }}\nServer Name: {{ serverName }}\nMessage: {{ message }}\nTime: {{ time }}" } diff --git a/config/variables.go b/config/variables.go index 588f6bd..5821413 100644 --- a/config/variables.go +++ b/config/variables.go @@ -91,6 +91,7 @@ type ControllerMethodConfig struct { // ControllerMessageConfig holds message templates for controller responses. type ControllerMessageConfig struct { BotStarted string `json:"BOT_STARTED"` + BotHelp string `json:"BOT_HELP"` ServerStatusChanged string `json:"SERVER_STATUS_CHANGED"` ServerList string `json:"SERVER_LIST"` ServerExecuteResult string `json:"SERVER_EXECUTE_RESULT"` diff --git a/internal/controller/processor.go b/internal/controller/processor.go index d6eace0..108a73c 100644 --- a/internal/controller/processor.go +++ b/internal/controller/processor.go @@ -55,6 +55,8 @@ func (m *Manager) RouteCommand(cmd Command) (string, error) { } switch cmd.Command { + case "help": + return handleHelp() case "list": return handleList() case "status": @@ -72,6 +74,12 @@ func (m *Manager) RouteCommand(cmd Command) (string, error) { } } +func handleHelp() (string, error) { + cfg := config.GetConfig() + params := template.BuildBotInitializationMsgParams() + return template.Render(cfg.ControllerMessage.BotHelp, params), nil +} + func handleList() (string, error) { cfg := config.GetConfig() params := template.BuildParamsFromServerList()