mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
💫 🎉 ✨ 添加插件 DeepDanbooru二次元图标签识别
This commit is contained in:
parent
30f6b57941
commit
d983c66597
@ -154,12 +154,14 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
|||||||
- [x] 搜图[P站图片ID]
|
- [x] 搜图[P站图片ID]
|
||||||
- **搜番** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe"`
|
- **搜番** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe"`
|
||||||
- [x] 搜番|搜索番剧[图片]
|
- [x] 搜番|搜索番剧[图片]
|
||||||
- **随机图片与AI点评** `github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage`
|
- **随机图片与AI点评** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage`
|
||||||
- [x] 随机图片(评级大于6的图将私发)
|
- [x] 随机图片(评级大于6的图将私发)
|
||||||
- [x] 直接随机(无r18检测,务必小心,仅管理可用)
|
- [x] 直接随机(无r18检测,务必小心,仅管理可用)
|
||||||
- [x] 设置随机图片网址[url]
|
- [x] 设置随机图片网址[url]
|
||||||
- [x] 太涩了(撤回最近发的图)
|
- [x] 太涩了(撤回最近发的图)
|
||||||
- [x] 评价图片(发送一张图片让bot评分)
|
- [x] 评价图片(发送一张图片让bot评分)
|
||||||
|
- **DeepDanbooru二次元图标签识别** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru`
|
||||||
|
- [x] 鉴赏图片[图片]
|
||||||
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_fortune`
|
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_fortune`
|
||||||
- [x] 运势|抽签
|
- [x] 运势|抽签
|
||||||
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]
|
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]
|
||||||
|
|||||||
1
main.go
1
main.go
@ -58,6 +58,7 @@ import (
|
|||||||
// 二次元图片
|
// 二次元图片
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆
|
||||||
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru" // d
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativesetu" // 本地涩图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativesetu" // 本地涩图
|
||||||
|
|||||||
56
plugin_danbooru/main.go
Normal file
56
plugin_danbooru/main.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Package deepdanbooru 二次元图片标签识别
|
||||||
|
package deepdanbooru
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/FloatTech/AnimeAPI/danbooru"
|
||||||
|
"github.com/FloatTech/AnimeAPI/picture"
|
||||||
|
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||||
|
"github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/file"
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
)
|
||||||
|
|
||||||
|
const cachefile = "data/danbooru/"
|
||||||
|
|
||||||
|
func init() { // 插件主体
|
||||||
|
err := os.MkdirAll(cachefile, 0755)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
engine := control.Register("danbooru", &control.Options{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Help: "二次元图片标签识别\n" +
|
||||||
|
"- 鉴赏图片[图片]",
|
||||||
|
})
|
||||||
|
// 上传一张图进行评价
|
||||||
|
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(23).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||||
|
for _, url := range ctx.State["image_url"].([]string) {
|
||||||
|
name := ""
|
||||||
|
r, err := saucenao.SauceNAO(url)
|
||||||
|
if err != nil {
|
||||||
|
name = "未知图片"
|
||||||
|
} else {
|
||||||
|
name = r.Title
|
||||||
|
}
|
||||||
|
t, err := danbooru.TagURL(name, url)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
digest := md5.Sum(helper.StringToBytes(url))
|
||||||
|
f := cachefile + hex.EncodeToString(digest[:])
|
||||||
|
if file.IsNotExist(f) {
|
||||||
|
t.Canvas.SavePNG(f)
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user