feat(controller): add help command with message template for bot commands
This commit is contained in:
@@ -91,6 +91,9 @@ func LoadConfig(configPath string) (*Config, error) {
|
|||||||
if cfg.ControllerMessage.BotStarted == "" {
|
if cfg.ControllerMessage.BotStarted == "" {
|
||||||
cfg.ControllerMessage.BotStarted = "Nukumizu Alert Bot Started\nVersion: {{ softwareVersion }}.{{ softwareBuildVer }}.{{ softwareCommitHash }}.{{ softwareBuildType }}\nDeveloper: {{ softwareDeveloper }}\nTime: {{ time }}"
|
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 <uuid> - Show status of a specific server\n/shutdown <uuid> - Shutdown a specific server\n/reboot <uuid> - Reboot a specific server\n/run <uuid> <command> - Run a command on a specific server\n/info - Show bot information"
|
||||||
|
}
|
||||||
if cfg.ControllerMessage.ServerStatusChanged == "" {
|
if cfg.ControllerMessage.ServerStatusChanged == "" {
|
||||||
cfg.ControllerMessage.ServerStatusChanged = "Server Status Changed Alert\n{{ serverName }} - {{ upStatus }}\nEvent: {{ event }}\nServer Name: {{ serverName }}\nMessage: {{ message }}\nTime: {{ time }}"
|
cfg.ControllerMessage.ServerStatusChanged = "Server Status Changed Alert\n{{ serverName }} - {{ upStatus }}\nEvent: {{ event }}\nServer Name: {{ serverName }}\nMessage: {{ message }}\nTime: {{ time }}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ type ControllerMethodConfig struct {
|
|||||||
// ControllerMessageConfig holds message templates for controller responses.
|
// ControllerMessageConfig holds message templates for controller responses.
|
||||||
type ControllerMessageConfig struct {
|
type ControllerMessageConfig struct {
|
||||||
BotStarted string `json:"BOT_STARTED"`
|
BotStarted string `json:"BOT_STARTED"`
|
||||||
|
BotHelp string `json:"BOT_HELP"`
|
||||||
ServerStatusChanged string `json:"SERVER_STATUS_CHANGED"`
|
ServerStatusChanged string `json:"SERVER_STATUS_CHANGED"`
|
||||||
ServerList string `json:"SERVER_LIST"`
|
ServerList string `json:"SERVER_LIST"`
|
||||||
ServerExecuteResult string `json:"SERVER_EXECUTE_RESULT"`
|
ServerExecuteResult string `json:"SERVER_EXECUTE_RESULT"`
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ func (m *Manager) RouteCommand(cmd Command) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch cmd.Command {
|
switch cmd.Command {
|
||||||
|
case "help":
|
||||||
|
return handleHelp()
|
||||||
case "list":
|
case "list":
|
||||||
return handleList()
|
return handleList()
|
||||||
case "status":
|
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) {
|
func handleList() (string, error) {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
params := template.BuildParamsFromServerList()
|
params := template.BuildParamsFromServerList()
|
||||||
|
|||||||
Reference in New Issue
Block a user