Skip to content

Commit

Permalink
[fix issues 840] Modify the "plugin\score" of the Image send type
Browse files Browse the repository at this point in the history
Modify the "plugin\score" of the Image send type
适配shamrock,修改图片发送方式,把发送路径改成发送完整图片
  • Loading branch information
vatebur committed Jan 18, 2024
1 parent a006b30 commit 9c51254
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions plugin/score/sign_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ func init() {
// 如果签到时间是今天
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
if file.IsExist(drawedFile) {
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
// 读取图片文件
drawedFileData, err := os.ReadFile(file.BOTPATH + "/" + drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: 无法读取图片文件", err))
return
}
ctx.SendChain(message.ImageBytes(drawedFileData))
}
return
case siUpdateTimeStr != today:
Expand Down Expand Up @@ -176,7 +182,13 @@ func init() {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
// 读取图片文件
drawedFileData, err := os.ReadFile(file.BOTPATH + "/" + drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: 无法读取图片文件", err))
return
}
ctx.SendChain(message.ImageBytes(drawedFileData))
})

engine.OnPrefix("获得签到背景", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Expand All @@ -193,7 +205,12 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请先签到!"))
return
}
if id := ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile)); id.ID() == 0 {
picFileeData, err := os.ReadFile(file.BOTPATH + "/" + picFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: 无法读取图片文件", err))
return
}
if id := ctx.SendChain(message.ImageBytes(picFileeData)); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 消息发送失败, 账号可能被风控"))
}
})
Expand All @@ -202,7 +219,13 @@ func init() {
today := time.Now().Format("20060102")
drawedFile := cachePath + today + "scoreRank.png"
if file.IsExist(drawedFile) {
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
// 读取图片文件
drawedFileData, err := os.ReadFile(file.BOTPATH + "/" + drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: 无法读取图片文件", err))
return
}
ctx.SendChain(message.ImageBytes(drawedFileData))
return
}
st, err := sdb.GetScoreRankByTopN(10)
Expand Down Expand Up @@ -267,7 +290,13 @@ func init() {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
// 读取图片文件
drawedFileData, err := os.ReadFile(file.BOTPATH + "/" + drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: 无法读取图片文件", err))
return
}
ctx.SendChain(message.ImageBytes(drawedFileData))
})
engine.OnRegex(`^设置签到预设\s*(\d+)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) {
key := ctx.State["regex_matched"].([]string)[1]
Expand Down

0 comments on commit 9c51254

Please sign in to comment.