fix: 修改多个处理函数的返回类型为指针类型,以提高内存使用效率并避免不必要的拷贝
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user