style: replace GetConfig() with variable C_globalConfig

This commit is contained in:
2026-09-02 21:24:27 +08:00
parent bf4cdf0d88
commit 16341972af
13 changed files with 44 additions and 49 deletions
-5
View File
@@ -99,11 +99,6 @@ func LoadGlobalConfig(configPath string) (*Config, error) {
return &cfg, nil return &cfg, nil
} }
// GetGlobalConfig returns the global configuration singleton.
func GetGlobalConfig() *Config {
return C_globalConfig
}
// LoadBotUserConfig reads and parses bot_user_config.json and stores it as the // LoadBotUserConfig reads and parses bot_user_config.json and stores it as the
// global C_botUserConfig singleton, mirroring LoadGlobalConfig. // global C_botUserConfig singleton, mirroring LoadGlobalConfig.
func LoadBotUserConfig(configPath string) (*BotUserConfig, error) { func LoadBotUserConfig(configPath string) (*BotUserConfig, error) {
+3 -3
View File
@@ -77,7 +77,7 @@ func (m *Manager) ShowBotInitMessage() {
m.mu.RLock() m.mu.RLock()
defer m.mu.RUnlock() defer m.mu.RUnlock()
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildBotInitializationMsgParams() params := template.BuildBotInitializationMsgParams()
message := template.Render(cfg.ControllerMessage.BotStarted, params) message := template.Render(cfg.ControllerMessage.BotStarted, params)
@@ -102,7 +102,7 @@ func (m *Manager) ShowBotServerList() {
m.mu.RLock() m.mu.RLock()
defer m.mu.RUnlock() defer m.mu.RUnlock()
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
message := template.Render(cfg.ControllerMessage.ServerList, params) message := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -125,7 +125,7 @@ func (m *Manager) NotifyStatusChange(change node.StatusChange) {
m.mu.RLock() m.mu.RLock()
defer m.mu.RUnlock() defer m.mu.RUnlock()
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
templateStr := cfg.ControllerMessage.ServerStatusChanged templateStr := cfg.ControllerMessage.ServerStatusChanged
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
+3 -3
View File
@@ -64,7 +64,7 @@ func (e *EmailController) SendStatusChange(change node.StatusChange) error {
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
body := template.Render(cfg.ControllerMessage.ServerStatusChanged, params) body := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
@@ -78,7 +78,7 @@ func (e *EmailController) SendServerList(onlineServers, offlineServers string) e
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
body := template.Render(cfg.ControllerMessage.ServerList, params) body := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -91,7 +91,7 @@ func (e *EmailController) SendExecuteResult(serverName, serverUUID, command, res
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result) params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result)
body := template.Render(cfg.ControllerMessage.ServerExecuteResult, params) body := template.Render(cfg.ControllerMessage.ServerExecuteResult, params)
+3 -3
View File
@@ -58,7 +58,7 @@ func (n *NtfyController) SendStatusChange(change node.StatusChange) error {
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params) message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
@@ -72,7 +72,7 @@ func (n *NtfyController) SendServerList(onlineServers, offlineServers string) er
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
message := template.Render(cfg.ControllerMessage.ServerList, params) message := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -85,7 +85,7 @@ func (n *NtfyController) SendExecuteResult(serverName, serverUUID, command, resu
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result) params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result)
message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params) message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params)
@@ -155,7 +155,7 @@ func (c *Client) SendMsg(targetType string, targetID int64, msg string, hasAt bo
return nil, fmt.Errorf("failed to marshal request: %w", err) return nil, fmt.Errorf("failed to marshal request: %w", err)
} }
if config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug(fmt.Sprintf("[Napcat] SendMsg -> %s (%s): %s", endpoint, targetType, message)) postLog.Debug(fmt.Sprintf("[Napcat] SendMsg -> %s (%s): %s", endpoint, targetType, message))
} }
@@ -176,7 +176,7 @@ func (c *Client) RecallMsg(msgID int64) (*APIResponse, error) {
return nil, fmt.Errorf("failed to marshal request: %w", err) return nil, fmt.Errorf("failed to marshal request: %w", err)
} }
if config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug(fmt.Sprintf("[Napcat] RecallMsg -> /delete_msg: %d", msgID)) postLog.Debug(fmt.Sprintf("[Napcat] RecallMsg -> /delete_msg: %d", msgID))
} }
@@ -190,7 +190,7 @@ func (c *Client) RecallMsg(msgID int64) (*APIResponse, error) {
// GetGroupList retrieves the list of joined groups from NapCat. // GetGroupList retrieves the list of joined groups from NapCat.
func (c *Client) GetGroupList() (*APIResponse, error) { func (c *Client) GetGroupList() (*APIResponse, error) {
if config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("[Napcat] GetGroupList -> /get_group_list") postLog.Debug("[Napcat] GetGroupList -> /get_group_list")
} }
@@ -211,7 +211,7 @@ func (c *Client) GetGroupInfo(groupID int64) (*APIResponse, error) {
return nil, fmt.Errorf("failed to marshal request: %w", err) return nil, fmt.Errorf("failed to marshal request: %w", err)
} }
if config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug(fmt.Sprintf("[Napcat] GetGroupInfo -> /get_group_info: %d", groupID)) postLog.Debug(fmt.Sprintf("[Napcat] GetGroupInfo -> /get_group_info: %d", groupID))
} }
@@ -225,7 +225,7 @@ func (c *Client) GetGroupInfo(groupID int64) (*APIResponse, error) {
// GetFriendsList retrieves the friends list from NapCat. // GetFriendsList retrieves the friends list from NapCat.
func (c *Client) GetFriendsList() (*APIResponse, error) { func (c *Client) GetFriendsList() (*APIResponse, error) {
if config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("[Napcat] GetFriendsList -> /get_friend_list") postLog.Debug("[Napcat] GetFriendsList -> /get_friend_list")
} }
+11 -11
View File
@@ -94,24 +94,24 @@ func (q *QQController) handleNapcatEvent(raw []byte) {
return return
} }
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowNapcatMsg { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowNapcatMsg {
postLog.Debug("Napcat WS event received: " + string(raw)) postLog.Debug("Napcat WS event received: " + string(raw))
} }
// Only handle message events; ignore notice/request/meta_event. // Only handle message events; ignore notice/request/meta_event.
if ev.PostType != "message" { if ev.PostType != "message" {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("Ignoring Napcat WS event: " + string(raw)) postLog.Debug("Ignoring Napcat WS event: " + string(raw))
} }
return return
} }
// Ignore messages the bot itself sent (echo prevention). // Ignore messages the bot itself sent (echo prevention).
if q.isSelfMessage(ev) && !config.GetGlobalConfig().System.DebugMode { if q.isSelfMessage(ev) && !config.C_globalConfig.System.DebugMode {
return return
} }
if q.isSelfMessage(ev) && config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.NapcatIgnoreSelfMsg { if q.isSelfMessage(ev) && config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.NapcatIgnoreSelfMsg {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("Ignoring Napcat WS self message: " + string(raw)) postLog.Debug("Ignoring Napcat WS self message: " + string(raw))
} }
return return
@@ -132,7 +132,7 @@ func (q *QQController) handleNapcatEvent(raw []byte) {
response := q.processCommand(cmd) response := q.processCommand(cmd)
if response == "" { if response == "" {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("Napcat WS command discarded: " + string(raw)) postLog.Debug("Napcat WS command discarded: " + string(raw))
} }
return return
@@ -162,7 +162,7 @@ func (q *QQController) processCommand(cmd controller.Command) string {
if q.cfg.ListenMethod == "at" { if q.cfg.ListenMethod == "at" {
atMention := fmt.Sprintf("[CQ:at,qq=%d]", q.cfg.BotQQID) atMention := fmt.Sprintf("[CQ:at,qq=%d]", q.cfg.BotQQID)
if !strings.Contains(text, atMention) { if !strings.Contains(text, atMention) {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowNapcatAction { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowNapcatAction {
postLog.Debug("Napcat WS message ignored (no @mention): " + text) postLog.Debug("Napcat WS message ignored (no @mention): " + text)
} }
return "" // Not mentioned, ignore. return "" // Not mentioned, ignore.
@@ -184,7 +184,7 @@ func (q *QQController) processCommand(cmd controller.Command) string {
// Hand the complete command to the unified processor, which checks group // Hand the complete command to the unified processor, which checks group
// vs private, trusted groups, admin permissions, and executes it. // vs private, trusted groups, admin permissions, and executes it.
response, err := controller.GetManager().Trigger(parsed, q.trustedGroupIDs(), q.adminIDs(), q.cfg.ListenMethod) response, err := controller.GetManager().Trigger(parsed, q.trustedGroupIDs(), q.adminIDs(), q.cfg.ListenMethod)
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowTriggerCmdEcho { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowTriggerCmdEcho {
postLog.Debug(fmt.Sprintf("[qq_napcat] triggered command: \"/%s\" with args: \"%s\" from chatID: %d and senderID: %d", parsed.Command, strings.Join(parsed.Args, ", "), cmd.ChatID, cmd.SenderID)) postLog.Debug(fmt.Sprintf("[qq_napcat] triggered command: \"/%s\" with args: \"%s\" from chatID: %d and senderID: %d", parsed.Command, strings.Join(parsed.Args, ", "), cmd.ChatID, cmd.SenderID))
} }
if err != nil { if err != nil {
@@ -243,7 +243,7 @@ func (q *QQController) SendStatusChange(change node.StatusChange) error {
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params) message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
@@ -266,7 +266,7 @@ func (q *QQController) SendServerList(onlineServers, offlineServers string) erro
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
message := template.Render(cfg.ControllerMessage.ServerList, params) message := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -282,7 +282,7 @@ func (q *QQController) SendExecuteResult(serverName, serverUUID, command, result
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result) params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result)
message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params) message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params)
@@ -142,7 +142,7 @@ func (t *TelegramController) handleUpdate(_ context.Context, _ *bot.Bot, update
} }
msg := update.Message msg := update.Message
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowTelegramMsg { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowTelegramMsg {
raw, _ := json.Marshal(update) raw, _ := json.Marshal(update)
postLog.Debug("Telegram update received: " + string(raw)) postLog.Debug("Telegram update received: " + string(raw))
} }
@@ -219,7 +219,7 @@ func (t *TelegramController) processCommand(cmd controller.Command) string {
// Hand the complete command to the unified processor, which checks group // Hand the complete command to the unified processor, which checks group
// vs private, trusted groups, admin permissions, and executes it. // vs private, trusted groups, admin permissions, and executes it.
response, err := controller.GetManager().Trigger(parsed, t.trustedGroupIDs(), t.resolvedAdminList(), t.cfg.ListenMethod) response, err := controller.GetManager().Trigger(parsed, t.trustedGroupIDs(), t.resolvedAdminList(), t.cfg.ListenMethod)
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowTriggerCmdEcho { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowTriggerCmdEcho {
postLog.Debug(fmt.Sprintf("[telegram] triggered command: \"/%s\" with args: \"%s\" from chatID: %d and senderID: %d", parsed.Command, strings.Join(parsed.Args, ", "), cmd.ChatID, cmd.SenderID)) postLog.Debug(fmt.Sprintf("[telegram] triggered command: \"/%s\" with args: \"%s\" from chatID: %d and senderID: %d", parsed.Command, strings.Join(parsed.Args, ", "), cmd.ChatID, cmd.SenderID))
} }
if err != nil { if err != nil {
@@ -245,7 +245,7 @@ func (t *TelegramController) SendStatusChange(change node.StatusChange) error {
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params) message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
@@ -259,7 +259,7 @@ func (t *TelegramController) SendServerList(onlineServers, offlineServers string
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
message := template.Render(cfg.ControllerMessage.ServerList, params) message := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -273,7 +273,7 @@ func (t *TelegramController) SendExecuteResult(serverName, serverUUID, command,
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result) params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result)
message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params) message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params)
+3 -3
View File
@@ -59,7 +59,7 @@ func (w *WebhookController) SendStatusChange(change node.StatusChange) error {
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromStatusChange(change) params := template.BuildParamsFromStatusChange(change)
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params) message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
@@ -80,7 +80,7 @@ func (w *WebhookController) SendServerList(onlineServers, offlineServers string)
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
message := template.Render(cfg.ControllerMessage.ServerList, params) message := template.Render(cfg.ControllerMessage.ServerList, params)
@@ -101,7 +101,7 @@ func (w *WebhookController) SendExecuteResult(serverName, serverUUID, command, r
return nil return nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result) params := template.BuildParamsFromExecResult(serverName, serverUUID, command, result)
message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params) message := template.Render(cfg.ControllerMessage.ServerExecuteResult, params)
+4 -4
View File
@@ -11,13 +11,13 @@ import (
) )
func handleHelp(cmd Command) (string, error) { func handleHelp(cmd Command) (string, error) {
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildBotInitializationMsgParams() params := template.BuildBotInitializationMsgParams()
return template.Render(cfg.ControllerMessage.BotHelp, params, cmd.Source), nil return template.Render(cfg.ControllerMessage.BotHelp, params, cmd.Source), nil
} }
func handleList(cmd Command) (string, error) { func handleList(cmd Command) (string, error) {
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromServerList() params := template.BuildParamsFromServerList()
return template.Render(cfg.ControllerMessage.ServerList, params, cmd.Source), nil return template.Render(cfg.ControllerMessage.ServerList, params, cmd.Source), nil
} }
@@ -128,7 +128,7 @@ func handleRun(cmd Command) (string, error) {
return fmt.Sprintf("Error getting results: %v", err), nil return fmt.Sprintf("Error getting results: %v", err), nil
} }
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildParamsFromExecResult(uuidArg, uuidArg, command, formatTaskResults(results)) params := template.BuildParamsFromExecResult(uuidArg, uuidArg, command, formatTaskResults(results))
return template.Render(cfg.ControllerMessage.ServerExecuteResult, params, cmd.Source), nil return template.Render(cfg.ControllerMessage.ServerExecuteResult, params, cmd.Source), nil
} }
@@ -178,7 +178,7 @@ func handleInfo(cmd Command) (string, error) {
} }
func telegram_handleStart() (string, error) { func telegram_handleStart() (string, error) {
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
params := template.BuildBotInitializationMsgParams() params := template.BuildBotInitializationMsgParams()
return template.Render(cfg.ControllerMessage.Tg_BotStart, params, "telegram"), nil return template.Render(cfg.ControllerMessage.Tg_BotStart, params, "telegram"), nil
} }
+4 -4
View File
@@ -145,7 +145,7 @@ func (c *Client) Login(username, password string) error {
var kr KomariResponse var kr KomariResponse
if err := json.NewDecoder(resp.Body).Decode(&kr); err != nil { if err := json.NewDecoder(resp.Body).Decode(&kr); err != nil {
if config.GetGlobalConfig().System.DebugMode { if config.C_globalConfig.System.DebugMode {
respBody, _ := io.ReadAll(resp.Body) respBody, _ := io.ReadAll(resp.Body)
return fmt.Errorf("failed to parse komari login response: %w.\nResponse: %s", err, respBody) return fmt.Errorf("failed to parse komari login response: %w.\nResponse: %s", err, respBody)
} }
@@ -317,7 +317,7 @@ func (c *Client) ExecTask(uuids []string, command string) (string, error) {
return "", fmt.Errorf("failed to parse komari task exec data: %w", err) return "", fmt.Errorf("failed to parse komari task exec data: %w", err)
} }
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowKomariTaskEcho { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowKomariTaskEcho {
postLog.Debug(fmt.Sprintf("Created Komari task %s for %d clients", result.TaskID, len(uuids))) postLog.Debug(fmt.Sprintf("Created Komari task %s for %d clients", result.TaskID, len(uuids)))
} }
return result.TaskID, nil return result.TaskID, nil
@@ -360,7 +360,7 @@ func (c *Client) GetTaskResult(taskID string) ([]TaskResult, bool, error) {
// PollTaskResult polls for task results every 1 second until all results are // PollTaskResult polls for task results every 1 second until all results are
// available or 60 seconds have elapsed. // available or 60 seconds have elapsed.
func (c *Client) PollTaskResult(taskID string) ([]TaskResult, error) { func (c *Client) PollTaskResult(taskID string) ([]TaskResult, error) {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowKomariTaskEcho { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowKomariTaskEcho {
postLog.Debug(fmt.Sprintf("Polling for Komari task %s results...", taskID)) postLog.Debug(fmt.Sprintf("Polling for Komari task %s results...", taskID))
} }
@@ -378,7 +378,7 @@ func (c *Client) PollTaskResult(taskID string) ([]TaskResult, error) {
return nil, err return nil, err
} }
if done { if done {
if config.GetGlobalConfig().System.DebugMode && config.GetGlobalConfig().Debug.ShowKomariTaskEcho { if config.C_globalConfig.System.DebugMode && config.C_globalConfig.Debug.ShowKomariTaskEcho {
postLog.Info(fmt.Sprintf("Task %s completed with %d results", taskID, len(results))) postLog.Info(fmt.Sprintf("Task %s completed with %d results", taskID, len(results)))
} }
return results, nil return results, nil
+1 -1
View File
@@ -409,7 +409,7 @@ func GetWSClient() *WSClient {
// LoginAndStart performs the Komari login and returns an error if it fails. // LoginAndStart performs the Komari login and returns an error if it fails.
func LoginAndStart() error { func LoginAndStart() error {
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
client := GetClient() client := GetClient()
if client == nil { if client == nil {
return fmt.Errorf("komari client not initialized") return fmt.Errorf("komari client not initialized")
+1 -1
View File
@@ -20,7 +20,7 @@ import (
// proxyURL returns the system-wide network proxy URL, or nil when none is // proxyURL returns the system-wide network proxy URL, or nil when none is
// configured. A missing scheme is normalized to http:// for convenience. // configured. A missing scheme is normalized to http:// for convenience.
func proxyURL() *url.URL { func proxyURL() *url.URL {
raw := config.GetGlobalConfig().System.NetworkProxy raw := config.C_globalConfig.System.NetworkProxy
if raw == "" { if raw == "" {
return nil return nil
} }
+1 -1
View File
@@ -168,7 +168,7 @@ func main() {
// initControllers initializes and starts all configured controllers. // initControllers initializes and starts all configured controllers.
func initControllers() { func initControllers() {
cfg := config.GetGlobalConfig() cfg := config.C_globalConfig
mgr := controller.GetManager() mgr := controller.GetManager()
if mgr == nil { if mgr == nil {
return return