feat: 喜报不要求保证同一条消息

This commit is contained in:
lixiangwuxian
2024-11-01 22:35:39 +08:00
parent 74cb2d19ca
commit 71b3fe8bbf
4 changed files with 71 additions and 11 deletions

View File

@@ -21,13 +21,13 @@ func init() {
func xiBao(msg model.Message) (reply model.Reply) {
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
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{
ReplyMsg: "参数不足, 请使用\"喜报 [内容]\"生成喜报图片",
ReferOriginMsg: true,
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
}
}
@@ -39,15 +39,28 @@ func xiBao(msg model.Message) (reply model.Reply) {
}
}
func xiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
xibao.GenerateCongratulationImage(msg.RawMsg, "./resource/xibao_background.png", filePath, true)
handler.UnRegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId)
return model.Reply{
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///root/qqbot/tmp/%s]", fileName+".png"),
ReferOriginMsg: true,
FromMsg: msg,
}, true
}
func beiBao(msg model.Message) (reply model.Reply) {
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
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{
ReplyMsg: "参数不足, 请使用\"悲报 [内容]\"生成悲报图片",
ReferOriginMsg: true,
ReplyMsg: "",
ReferOriginMsg: false,
FromMsg: msg,
}
}
@@ -58,3 +71,15 @@ func beiBao(msg model.Message) (reply model.Reply) {
FromMsg: msg,
}
}
func beiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
fileName := uuid.New().String()
filePath := "./tmp/" + fileName + ".png"
xibao.GenerateCongratulationImage(msg.RawMsg, "./resource/beibao_background.png", filePath, false)
handler.UnRegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId)
return model.Reply{
ReplyMsg: fmt.Sprintf("[CQ:image,file=file:///root/qqbot/tmp/%s]", fileName+".png"),
ReferOriginMsg: true,
FromMsg: msg,
}, true
}