feat: 喜报/悲报支持图片

This commit is contained in:
lixiangwuxian
2024-10-20 02:25:39 +08:00
parent 235d22a4c0
commit 6dad9bb76f
3 changed files with 94 additions and 6 deletions

View File

@@ -1,9 +1,13 @@
package xibao
import (
"fmt"
"strings"
"git.lxtend.com/qqbot/handler"
"git.lxtend.com/qqbot/model"
"git.lxtend.com/qqbot/service/xibao"
"github.com/google/uuid"
)
func init() {
@@ -14,18 +18,22 @@ func init() {
}
func xiBao(msg model.Message) (reply model.Reply) {
xibao.GenerateCongratulationImage(msg.RawMsg[len("喜报 "):], "./resource/xibao_background.png", "./tmp/xibao.png", true)
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
xibao.GenerateCongratulationImage(strings.Split(msg.RawMsg, " ")[1], "./resource/xibao_background.png", filePath, true)
return model.Reply{
ReplyMsg: "[CQ:image,file=file:///root/qqbot/tmp/xibao.png]",
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///root/qqbot/tmp/%s]", fileName+".png"),
ReferOriginMsg: true,
FromMsg: msg,
}
}
func beiBao(msg model.Message) (reply model.Reply) {
xibao.GenerateCongratulationImage(msg.RawMsg[len("悲报 "):], "./resource/beibao_background.png", "./tmp/beibao.png", false)
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
xibao.GenerateCongratulationImage(strings.Split(msg.RawMsg, " ")[1], "./resource/beibao_background.png", filePath, false)
return model.Reply{
ReplyMsg: "[CQ:image,file=file:///root/qqbot/tmp/beibao.png]",
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///root/qqbot/tmp/%s]", fileName+".png"),
ReferOriginMsg: true,
FromMsg: msg,
}