feat: 重构消息处理模块,引入统一的消息接口和类型安全的消息解析
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"git.lxtend.com/qqbot/constants"
|
||||
"git.lxtend.com/qqbot/handler"
|
||||
"git.lxtend.com/qqbot/message"
|
||||
"git.lxtend.com/qqbot/model"
|
||||
"git.lxtend.com/qqbot/service/xibao"
|
||||
"git.lxtend.com/qqbot/util"
|
||||
@@ -33,8 +34,14 @@ func xiBao(msg model.Message) (reply model.Reply) {
|
||||
}
|
||||
}
|
||||
xibao.GenerateCongratulationImage(tokens[1], "./resource/xibao_background.png", filePath, true)
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///tmp/qqbot/%s]", fileName+".png"),
|
||||
ReplyMsg: imageMsg.ToCQString(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
@@ -45,8 +52,14 @@ func xiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
|
||||
fileName := uuid.New().String()
|
||||
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
|
||||
xibao.GenerateCongratulationImage(msg.RawMsg, "./resource/xibao_background.png", filePath, true)
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///tmp/qqbot/%s]", fileName+".png"),
|
||||
ReplyMsg: imageMsg.ToCQString(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}, true
|
||||
@@ -66,8 +79,14 @@ func beiBao(msg model.Message) (reply model.Reply) {
|
||||
}
|
||||
}
|
||||
xibao.GenerateCongratulationImage(tokens[1], "./resource/beibao_background.png", filePath, false)
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///tmp/qqbot/%s]", fileName+".png"),
|
||||
ReplyMsg: imageMsg.ToCQString(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}
|
||||
@@ -78,8 +97,14 @@ func beiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
|
||||
fileName := uuid.New().String()
|
||||
filePath := util.GenTempFilePath(fmt.Sprintf("%s.png", fileName))
|
||||
xibao.GenerateCongratulationImage(msg.RawMsg, "./resource/beibao_background.png", filePath, false)
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///tmp/qqbot/%s]", fileName+".png"),
|
||||
ReplyMsg: imageMsg.ToCQString(),
|
||||
ReferOriginMsg: true,
|
||||
FromMsg: msg,
|
||||
}, true
|
||||
|
||||
Reference in New Issue
Block a user