Skip to content

Commit

Permalink
chore: restore useful image pool
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Oct 13, 2024
1 parent 2b2983e commit 84964a8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions img/pool/sender.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package pool

Check failure on line 1 in img/pool/sender.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: should have a package comment (revive)

import (
"errors"

"github.com/wdvxdr1123/ZeroBot/message"

"github.com/FloatTech/floatbox/file"

"github.com/FloatTech/zbputils/ctxext"
)

// SendImageFromPool ...
func SendImageFromPool(imgname, imgpath string, genimg func() error, send ctxext.NoCtxSendMsg, get ctxext.NoCtxGetMsg) error {

Check failure on line 14 in img/pool/sender.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'imgname' seems to be unused, consider removing or renaming it as _ (revive)
if file.IsNotExist(imgpath) {
err := genimg()
if err != nil {
return err
}
}
// 发送图片
img := message.Image(file.BOTPATH + "/" + imgpath)
id := send(message.Message{img})
if id == 0 {
id = send(message.Message{img.Add("cache", "0")})
if id == 0 {
return errors.New("图片发送失败, 可能被风控了~")
}
}
return nil
}

0 comments on commit 84964a8

Please sign in to comment.