add plugin 渲染任意文字到图片

This commit is contained in:
源文雨
2022-03-27 13:54:26 +08:00
parent 1bfb76a4b3
commit 5837a765f1
31 changed files with 106 additions and 60 deletions

View File

@@ -86,13 +86,13 @@ func init() { // 插件主体
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
time.Sleep(time.Second * 10)
if pool.size(imgtype) == 0 {
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
ctx.SendChain(message.Text("ERROR:等待填充,请稍后再试......"))
return
}
}
// 从缓冲池里抽一张
if id := ctx.SendChain(*pool.pop(imgtype)); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
ctx.SendChain(message.Text("ERROR:可能被风控了"))
}
})
@@ -118,7 +118,7 @@ func init() { // 插件主体
)
// 查询数据库
if err := pool.remove(imgtype, id); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("删除成功"))
@@ -159,7 +159,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
if fileutil.IsNotExist(f) {
// 下载图片
if err := illust.DownloadToCache(0); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
ctx.SendChain(message.Text("ERROR:", err))
return
}
}
@@ -197,7 +197,7 @@ func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) {
illust := &pixiv.Illust{}
// 查询出一张图片
if err := p.db.Pick(imgtype, illust); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
ctx.SendChain(message.Text("ERROR:", err))
continue
}
// 向缓冲池添加一张图片