fix(internal/controller/pipes/qq_napcat): remove debug msg echo, now it can process commands
This commit is contained in:
@@ -154,14 +154,6 @@ func (q *QQController) handleNapcatEvent(raw []byte) {
|
|||||||
// complete command to the unified processor. It returns the response text to
|
// complete command to the unified processor. It returns the response text to
|
||||||
// reply with; an empty response means the message was discarded.
|
// reply with; an empty response means the message was discarded.
|
||||||
func (q *QQController) processCommand(cmd controller.Command) string {
|
func (q *QQController) processCommand(cmd controller.Command) string {
|
||||||
cfg := config.GetConfig()
|
|
||||||
|
|
||||||
// Debug: when ShowNapcatMsg is enabled, echo the received message back in real-time.
|
|
||||||
if cfg.Debug.ShowNapcatMsg {
|
|
||||||
postLog.Debug("Napcat message received: " + cmd.RawText)
|
|
||||||
return cmd.RawText
|
|
||||||
}
|
|
||||||
|
|
||||||
text := cmd.RawText
|
text := cmd.RawText
|
||||||
|
|
||||||
// In "at" listen mode, require an @mention of the bot and strip it before
|
// In "at" listen mode, require an @mention of the bot and strip it before
|
||||||
@@ -190,7 +182,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().RouteCommand(parsed, q.cfg.TrustedGroups, q.cfg.Admins, q.cfg.ListenMethod)
|
response, err := controller.GetManager().Trigger(parsed, q.cfg.TrustedGroups, q.cfg.Admins, q.cfg.ListenMethod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
postLog.Error("Napcat command processing failed: " + err.Error())
|
postLog.Error("Napcat command processing failed: " + err.Error())
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -84,7 +84,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().RouteCommand(parsed, t.cfg.TrustedGroups, t.cfg.Admins, t.cfg.ListenMethod)
|
response, err := controller.GetManager().Trigger(parsed, t.cfg.TrustedGroups, t.cfg.Admins, t.cfg.ListenMethod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
postLog.Error("Telegram command processing failed: " + err.Error())
|
postLog.Error("Telegram command processing failed: " + err.Error())
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ import (
|
|||||||
"nukumizu-backend/postLog"
|
"nukumizu-backend/postLog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RouteCommand validates an incoming command against the pipe's authorization
|
// Trigger validates an incoming command against the pipe's authorization
|
||||||
// config (trusted groups / admins) and, if authorized, processes it through
|
// config (trusted groups / admins) and, if authorized, processes it through
|
||||||
// Trigger. It returns the response text to reply with; an empty response means
|
// RouteCommand. It returns the response text to reply with; an empty response means
|
||||||
// the command was discarded.
|
// the command was discarded.
|
||||||
//
|
//
|
||||||
// All command handling across pipes is unified here: pipes only decide whether
|
// All command handling across pipes is unified here: pipes only decide whether
|
||||||
// a received message is a command, then hand the complete command over.
|
// a received message is a command, then hand the complete command over.
|
||||||
func (m *Manager) RouteCommand(cmd Command, trustedGroups, admins []string, listenMethod string) (string, error) {
|
func (m *Manager) Trigger(cmd Command, trustedGroups, admins []string, listenMethod string) (string, error) {
|
||||||
// Check whether the command arrived in a group or a private chat.
|
// Check whether the command arrived in a group or a private chat.
|
||||||
if cmd.ChatType == "group" {
|
if cmd.ChatType == "group" {
|
||||||
// Group commands are only honored from trusted groups, otherwise discard.
|
// Group commands are only honored from trusted groups, otherwise discard.
|
||||||
@@ -34,7 +34,7 @@ func (m *Manager) RouteCommand(cmd Command, trustedGroups, admins []string, list
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := m.Trigger(cmd)
|
response, err := m.RouteCommand(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -46,9 +46,9 @@ func (m *Manager) RouteCommand(cmd Command, trustedGroups, admins []string, list
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger processes a parsed bot command and returns the response text.
|
// RouteCommand processes a parsed bot command and returns the response text.
|
||||||
// The actual command execution for every pipe is unified here.
|
// The actual command execution for every pipe is unified here.
|
||||||
func (m *Manager) Trigger(cmd Command) (string, error) {
|
func (m *Manager) RouteCommand(cmd Command) (string, error) {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
if cfg.System.DebugMode && cfg.Debug.ShowTriggerCmdEcho {
|
if cfg.System.DebugMode && cfg.Debug.ShowTriggerCmdEcho {
|
||||||
postLog.Debug("Trigger received command: /" + cmd.Command + " with args: " + strings.Join(cmd.Args, ", "))
|
postLog.Debug("Trigger received command: /" + cmd.Command + " with args: " + strings.Join(cmd.Args, ", "))
|
||||||
|
|||||||
Reference in New Issue
Block a user