Skip to content

Commit

Permalink
优化 ctx ERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 25, 2023
1 parent 1aa1187 commit 0c8dfb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugin/dailynews/dailynews.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func init() {
}
picURL := gjson.Get(binary.BytesToString(data), "imageUrl").String()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image(picURL))
Expand Down
16 changes: 8 additions & 8 deletions plugin/drawlots/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
lotsList, err := getList() // 刷新列表
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
messageText := &strings.Builder{}
Expand All @@ -67,7 +67,7 @@ func init() {
}
textPic, err := text.RenderToBase64(messageText.String(), text.BoldFontFile, 400, 50)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("base64://" + helper.BytesToString(textPic)))
Expand All @@ -82,21 +82,21 @@ func init() {
if fileInfo.lotsType == "folder" {
picPath, err := randFile(lotsType, 3)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("file:///"+picPath))
return
}
lotsImg, err := randGif(lotsType + "." + fileInfo.lotsType)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 生成图片
data, err := imgfactory.ToBytes(lotsImg)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.ImageBytes(data))
Expand Down Expand Up @@ -129,13 +129,13 @@ func init() {
}
im, err := gif.DecodeAll(bytes.NewReader(gifdata))
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
fileName := datapath + "/" + lotsName + ".gif"
err = file.DownloadTo(picURL, fileName)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
lotsList[lotsName] = info{
Expand All @@ -158,7 +158,7 @@ func init() {
}
err := os.Remove(datapath + lotsName + "." + fileInfo.lotsType)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return
}
delete(lotsList, lotsName)
Expand Down
4 changes: 2 additions & 2 deletions plugin/wife/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func init() {
func(ctx *zero.Ctx) bool {
data, err := engine.GetLazyData("wife.json", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = json.Unmarshal(data, &cards)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
logrus.Infof("[wife]加载%d个老婆", len(cards))
Expand Down

0 comments on commit 0c8dfb3

Please sign in to comment.