refactor: 优化 SendMsg 函数中的消息构建逻辑,使用切片拼接替代字符串格式化,提升性能和可读性

This commit is contained in:
lixiangwuxian 2025-05-05 02:52:45 +08:00
parent 1a31652751
commit 5f8609bef2

View File

@ -2,7 +2,6 @@ package action
import ( import (
"encoding/json" "encoding/json"
"fmt"
"log" "log"
"strconv" "strconv"
"sync" "sync"
@ -45,7 +44,7 @@ func (am *actionManager) SendMsg(reply *model.Reply) error {
ID: int(reply.FromMsg.OriginMsgId), ID: int(reply.FromMsg.OriginMsgId),
}, },
} }
reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), reply.ReplyMsg) reply.ReplyMsg = append([]any{replyMsg}, reply.ReplyMsg)
} }
userID := strconv.FormatInt(reply.FromMsg.UserId, 10) userID := strconv.FormatInt(reply.FromMsg.UserId, 10)
if reply.FromMsg.UserId == 0 { if reply.FromMsg.UserId == 0 {