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

@@ -20,14 +20,14 @@ func init() {
handler.RegisterHelpInform("悲报 [内容]", "喜报/悲报", "生成悲报图片,支持换行或多消息发送")
}
func xiBao(msg model.Message) (reply model.Reply) {
func xiBao(msg model.Message) (reply *model.Reply) {
fileName := uuid.New().String()
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
re := regexp.MustCompile(`\s+`)
tokens := re.Split(msg.RawMsg, 2)
if len(tokens) < 2 {
handler.RegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId, xiBaoTemp)
return model.Reply{
return &model.Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
@@ -40,14 +40,14 @@ func xiBao(msg model.Message) (reply model.Reply) {
File: "file://" + filePath,
},
}
return model.Reply{
return &model.Reply{
ReplyMsg: imageMsg.ToCQString(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
func xiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
func xiBaoTemp(msg model.Message) (reply *model.Reply, isTrigger bool) {
handler.UnRegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId)
fileName := uuid.New().String()
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
@@ -58,21 +58,21 @@ func xiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
File: "file://" + filePath,
},
}
return model.Reply{
return &model.Reply{
ReplyMsg: imageMsg.ToCQString(),
ReferOriginMsg: true,
FromMsg: msg,
}, true
}
func beiBao(msg model.Message) (reply model.Reply) {
func beiBao(msg model.Message) (reply *model.Reply) {
fileName := uuid.New().String()
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
re := regexp.MustCompile(`\s+`)
tokens := re.Split(msg.RawMsg, 2)
if len(tokens) < 2 {
handler.RegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId, beiBaoTemp)
return model.Reply{
return &model.Reply{
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
@@ -85,14 +85,14 @@ func beiBao(msg model.Message) (reply model.Reply) {
File: "file:///tmp/qqbot/" + fileName + ".png",
},
}
return model.Reply{
return &model.Reply{
ReplyMsg: imageMsg.ToCQString(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
func beiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
func beiBaoTemp(msg model.Message) (reply *model.Reply, isTrigger bool) {
handler.UnRegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId)
fileName := uuid.New().String()
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
@@ -103,7 +103,7 @@ func beiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
File: "file:///tmp/qqbot/" + fileName + ".png",
},
}
return model.Reply{
return &model.Reply{
ReplyMsg: imageMsg.ToCQString(),
ReferOriginMsg: true,
FromMsg: msg,