From 105fa478117adfd57f634e6f35c7b8427abc90da Mon Sep 17 00:00:00 2001 From: NanamiAdmin Date: Wed, 12 Aug 2026 22:29:57 +0800 Subject: [PATCH] feat(debug): make komari task echo log to debug level and selectable feat(internal/controller/qq_napcat): add trigger log display and detailed to chatID and senderID --- config/variables.go | 1 + internal/controller/pipes/qq_napcat/qq.go | 4 ++++ internal/controller/processor.go | 6 ------ internal/komari/client.go | 12 +++++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config/variables.go b/config/variables.go index 5821413..d9bfa6d 100644 --- a/config/variables.go +++ b/config/variables.go @@ -13,6 +13,7 @@ type DebugConfig struct { ShowNapcatAction bool `json:"showNapcatAction"` ShowTelegramMsg bool `json:"showTelegramMsg"` ShowTriggerCmdEcho bool `json:"showTriggerCmdEcho"` + ShowKomariTaskEcho bool `json:"showKomariTaskEcho"` NapcatIgnoreSelfMsg bool `json:"napcatIgnoreSelfMsg"` } diff --git a/internal/controller/pipes/qq_napcat/qq.go b/internal/controller/pipes/qq_napcat/qq.go index 96c1a23..cdb7e8e 100644 --- a/internal/controller/pipes/qq_napcat/qq.go +++ b/internal/controller/pipes/qq_napcat/qq.go @@ -183,6 +183,10 @@ func (q *QQController) processCommand(cmd controller.Command) string { // Hand the complete command to the unified processor, which checks group // vs private, trusted groups, admin permissions, and executes it. response, err := controller.GetManager().Trigger(parsed, q.cfg.TrustedGroups, q.cfg.Admins, q.cfg.ListenMethod) + cfg := config.GetConfig() + if cfg.System.DebugMode && cfg.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)) + } if err != nil { postLog.Error("Napcat command processing failed: " + err.Error()) return "" diff --git a/internal/controller/processor.go b/internal/controller/processor.go index 108a73c..8ed8cf9 100644 --- a/internal/controller/processor.go +++ b/internal/controller/processor.go @@ -8,7 +8,6 @@ import ( "nukumizu-backend/internal/komari" "nukumizu-backend/internal/node" "nukumizu-backend/internal/template" - "nukumizu-backend/postLog" ) // Trigger validates an incoming command against the pipe's authorization @@ -49,11 +48,6 @@ func (m *Manager) Trigger(cmd Command, trustedGroups, admins []string, listenMet // RouteCommand processes a parsed bot command and returns the response text. // The actual command execution for every pipe is unified here. func (m *Manager) RouteCommand(cmd Command) (string, error) { - cfg := config.GetConfig() - if cfg.System.DebugMode && cfg.Debug.ShowTriggerCmdEcho { - postLog.Debug("Trigger received command: /" + cmd.Command + " with args: " + strings.Join(cmd.Args, ", ")) - } - switch cmd.Command { case "help": return handleHelp() diff --git a/internal/komari/client.go b/internal/komari/client.go index 6bad168..4f22948 100644 --- a/internal/komari/client.go +++ b/internal/komari/client.go @@ -292,7 +292,9 @@ func (c *Client) ExecTask(uuids []string, command string) (string, error) { return "", fmt.Errorf("failed to parse komari task exec data: %w", err) } - postLog.Info(fmt.Sprintf("Created Komari task %s for %d clients", result.TaskID, len(uuids))) + if config.GetConfig().System.DebugMode && config.GetConfig().Debug.ShowKomariTaskEcho { + postLog.Debug(fmt.Sprintf("Created Komari task %s for %d clients", result.TaskID, len(uuids))) + } return result.TaskID, nil } @@ -333,7 +335,9 @@ func (c *Client) GetTaskResult(taskID string) ([]TaskResult, bool, error) { // PollTaskResult polls for task results every 1 second until all results are // available or 60 seconds have elapsed. func (c *Client) PollTaskResult(taskID string) ([]TaskResult, error) { - postLog.Info(fmt.Sprintf("Polling for Komari task %s results...", taskID)) + if config.GetConfig().System.DebugMode && config.GetConfig().Debug.ShowKomariTaskEcho { + postLog.Debug(fmt.Sprintf("Polling for Komari task %s results...", taskID)) + } timeout := time.After(60 * time.Second) ticker := time.NewTicker(1 * time.Second) @@ -349,7 +353,9 @@ func (c *Client) PollTaskResult(taskID string) ([]TaskResult, error) { return nil, err } if done { - postLog.Info(fmt.Sprintf("Task %s completed with %d results", taskID, len(results))) + if config.GetConfig().System.DebugMode && config.GetConfig().Debug.ShowKomariTaskEcho { + postLog.Info(fmt.Sprintf("Task %s completed with %d results", taskID, len(results))) + } return results, nil } }