feat(config): implement loading and saving of bot node configuration with default notification settings

This commit is contained in:
2026-09-06 14:00:45 +08:00
parent 6a0c2d1fc4
commit ec1cf20347
3 changed files with 63 additions and 36 deletions
+12 -8
View File
@@ -175,14 +175,18 @@ var C_botUserConfig *BotUserConfig
// file is auto-populated by the node tracker for every node Komari reports;
// per-node options are edited by hand in the JSON file.
type BotNodeOptions struct {
// EnableStatusNotify is an allow-list switch: a node broadcasts status-change
// notifications only when this is true. Nodes default to false (silent)
// unless explicitly enabled.
EnableStatusNotify bool `json:"enableStatusNotify"`
// EnableStatusNotify controls whether this node broadcasts status-change
// notifications. It defaults to true: only an explicit false in the JSON
// file disables a node's notifications. The pointer (rather than a plain
// bool) lets an absent field be told apart from an explicit false, and
// omitempty keeps untouched nodes stored as {}.
EnableStatusNotify *bool `json:"enableStatusNotify,omitempty"`
}
// BotNodeMembers maps a node UUID (as reported by Komari) to its per-node
// options, e.g. bot_node_config.json:
//
// {"<uuid1>": {"enableStatusNotify": true}, "<uuid2>": {}}
type BotNodeMembers map[string]BotNodeOptions
// options.
type BotNodeMembers map[string]BotNodeOptions
// C_botNodeConfig is the global singleton mirroring bot_node_config.json,
// populated by LoadBotNodeConfig.
var C_botNodeConfig BotNodeMembers