-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package pool | ||
|
||
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 { | ||
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 | ||
} |