fix: 修改多个处理函数的返回类型为指针类型,以提高内存使用效率并避免不必要的拷贝

This commit is contained in:
lixiangwuxian
2025-04-09 23:28:39 +08:00
parent 144034939c
commit 7f0560b56e
32 changed files with 211 additions and 210 deletions

View File

@@ -2,8 +2,8 @@ package model
import "git.lxtend.com/qqbot/constants"
type Handler func(msg Message) (reply Reply)
type TryCatchHandler func(msg Message) (reply Reply, catched bool)
type Handler func(msg Message) (reply *Reply)
type TryCatchHandler func(msg Message) (reply *Reply, catched bool)
type HandlerInfo[H Handler | TryCatchHandler] struct {
Trigger string

View File

@@ -15,13 +15,7 @@ type GroupInfo struct {
}
type Reply struct {
ReplyMsg string `json:"replyMsg"`
ReferOriginMsg bool `json:"referOriginMsg"`
FromMsg Message `json:"fromMsg"`
}
var NotReply = Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: Message{},
ReplyMsg interface{} `json:"replyMsg"`
ReferOriginMsg bool `json:"referOriginMsg"`
FromMsg Message `json:"fromMsg"`
}

View File

@@ -14,13 +14,13 @@ type SendPkg struct {
// 上游包的参数结构体
type UpstreamParams struct {
UserID int64 `json:"user_id"`
GroupID int64 `json:"group_id"`
Message string `json:"message"`
AutoEscape bool `json:"auto_escape"`
UserID int64 `json:"user_id"`
GroupID int64 `json:"group_id"`
Message interface{} `json:"message"`
AutoEscape bool `json:"auto_escape"`
}
func GenSendPkg(userID int64, groupID int64, message string, autoEscape bool) SendPkg {
func GenSendPkg(userID int64, groupID int64, message interface{}, autoEscape bool) SendPkg {
if groupID == 0 {
return SendPkg{
Action: constants.PRIVATE_MSG_SEND,