fix: 更新喜报和悲报的帮助信息,支持换行或多消息发送;修正图片文件路径的构建方式,使用动态路径替代静态路径
This commit is contained in:
parent
c0764036ab
commit
c6fbedc859
@ -15,9 +15,9 @@ import (
|
||||
|
||||
func init() {
|
||||
handler.RegisterHandler("喜报", xiBao, constants.LEVEL_USER)
|
||||
handler.RegisterHelpInform("喜报 [内容]", "喜报/悲报", "生成喜报图片,支持换行")
|
||||
handler.RegisterHelpInform("喜报 [内容]", "喜报/悲报", "生成喜报图片,支持换行或多消息发送")
|
||||
handler.RegisterHandler("悲报", beiBao, constants.LEVEL_USER)
|
||||
handler.RegisterHelpInform("悲报 [内容]", "喜报/悲报", "生成悲报图片,支持换行")
|
||||
handler.RegisterHelpInform("悲报 [内容]", "喜报/悲报", "生成悲报图片,支持换行或多消息发送")
|
||||
}
|
||||
|
||||
func xiBao(msg model.Message) (reply model.Reply) {
|
||||
@ -37,7 +37,7 @@ func xiBao(msg model.Message) (reply model.Reply) {
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
File: "file://" + filePath,
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
@ -55,7 +55,7 @@ func xiBaoTemp(msg model.Message) (reply model.Reply, isTrigger bool) {
|
||||
imageMsg := message.ImageMessage{
|
||||
Type: "image",
|
||||
Data: message.ImageMessageData{
|
||||
File: "file:///tmp/qqbot/" + fileName + ".png",
|
||||
File: "file://" + filePath,
|
||||
},
|
||||
}
|
||||
return model.Reply{
|
||||
|
@ -3,6 +3,7 @@ package message
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -48,6 +49,7 @@ func (msg *ImageMessage) ToCQString() string {
|
||||
}
|
||||
|
||||
func (msg *ImageMessage) ParseMessage(data string) error {
|
||||
log.Println("ParseMessage", data)
|
||||
// 使用正则表达式提取各个字段
|
||||
re := regexp.MustCompile(`\[CQ:image,file=(.*?),sub_type=(.*?),file_id=(.*?),url=(.*?),file_size=(\d+),file_unique=(.*?)\]`)
|
||||
matches := re.FindStringSubmatch(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user