Compare commits

..

18 Commits

Author SHA1 Message Date
fumiama
0212ec51cc 🔖 v1.2.4 2022-01-25 13:34:44 +08:00
fumiama
7109e30d93 🎨 🔥 modify wyy 2022-01-24 21:48:21 +08:00
MoeMagicMango
6990819d5c feat:添加来自ovooa的网易云热评API (#111)
* Create readme.md

* 调用网易云热评API

* Update main.go

* Delete readme.md

* Delete main.go

* Create main.go

* Add files via upload

* Update prio.go

* Add files via upload

* Add files via upload

* Update prio.go

* Add files via upload

* Update prio.go

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* revert main

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-01-24 21:40:52 +08:00
fumiama
b4ff754934 🐛 修正 imgpool 2022-01-24 18:23:33 +08:00
fumiama
6ece644a7b 🐛 修正 imgpool 2022-01-24 18:17:53 +08:00
fumiama
f826b4d0bc 🐛 防止风控 2022-01-24 14:28:43 +08:00
fumiama
aa1f82d46f 增加 pixiv 多线程下载与图片缓存 2022-01-24 14:01:30 +08:00
fumiama
f7c6d67428 🐛 fix fortune 2022-01-23 13:48:45 +08:00
fumiama
cd30d6df31 🐛 fix fortune 2022-01-23 13:43:42 +08:00
fumiama
7463792de7 🐛 fix fortune 2022-01-23 13:38:56 +08:00
fumiama
80f49c47c6 🐛 fix fortune 2022-01-23 13:22:31 +08:00
fumiama
4baead3490 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-23 00:28:16 +08:00
fumiama
2d0c69344a 🐛 fix get&del msg in zb 2022-01-23 00:28:05 +08:00
github-actions[bot]
a94ea2b332 🎨 改进代码样式 2022-01-22 15:44:30 +00:00
fumiama
4ee50a6582 add image pool 2022-01-22 23:43:38 +08:00
fumiama
b21021bd6b Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-22 12:39:51 +08:00
fumiama
7238fe0b6b 🍱 add fortune 赛马娘 2022-01-22 12:38:22 +08:00
Kanri
e1b5c176c3 ✏️ 修复 pixiv.cat 2022-01-22 10:54:38 +08:00
16 changed files with 195 additions and 77 deletions

View File

@@ -164,7 +164,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 鉴赏图片[图片]
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_fortune`
- [x] 运势 | 抽签
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘]
- **睡眠管理** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage`
- [x] 早安 | 晚安
- **浅草寺求签** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji`
@@ -252,12 +252,14 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"`
- [x] 骂我
- [x] 大力骂我
- **b站推送** `_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push"`
- **b站推送** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push"`
- [x] 添加订阅[uid]
- [x] 取消订阅[uid]
- [x] 取消动态订阅[uid]
- [x] 取消直播订阅[uid]
- [x] 推送列表
- **网易云音乐热评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wangyiyun"`
- [x] 来份网易云热评
- **TODO...**
## 使用方法

2
data

Submodule data updated: 522acbf5e3...abdfd11062

6
go.mod
View File

@@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin
go 1.17
require (
github.com/FloatTech/AnimeAPI v1.2.4-beta5
github.com/FloatTech/zbputils v1.2.4-beta5
github.com/FloatTech/AnimeAPI v1.2.4
github.com/FloatTech/zbputils v1.2.4
github.com/antchfx/htmlquery v1.2.4
github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0
@@ -19,7 +19,7 @@ require (
github.com/shirou/gopsutil/v3 v3.21.12
github.com/sirupsen/logrus v1.8.1
github.com/tidwall/gjson v1.12.1
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220118054520-51ea28a32e7e
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
)

12
go.sum
View File

@@ -1,8 +1,8 @@
github.com/FloatTech/AnimeAPI v1.2.4-beta5 h1:RQY8BodjVZ+j+3nc91OKCGHDaPxgUk9P4RDOQWcwT2E=
github.com/FloatTech/AnimeAPI v1.2.4-beta5/go.mod h1:GjOmVhaOji/ibu/s3RXoatd5gJ/4cp2lsvflRBGRw5s=
github.com/FloatTech/AnimeAPI v1.2.4 h1:lo5c8s/nj3ZdpFkWrjnyEv3b79b5mAGTPQmMiaGVKo0=
github.com/FloatTech/AnimeAPI v1.2.4/go.mod h1:Ys5P/MadG6TT/5rWuPgxWgt+dDoDPKEBKCkLg4jn5uc=
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
github.com/FloatTech/zbputils v1.2.4-beta5 h1:puvvScHJ6G+VmQbj0LSBd3mJMVD+bVAf14P9kVUxfso=
github.com/FloatTech/zbputils v1.2.4-beta5/go.mod h1:yQwwXUoFhJeU+CkaDXia1E+k4iBqxIiobE3n3Vy/R3w=
github.com/FloatTech/zbputils v1.2.4 h1:8wTqL0LwY++LdIakQ1cvCfYqQdTvlCGaL6RRTy6UMnA=
github.com/FloatTech/zbputils v1.2.4/go.mod h1:mPVpKu2scTyBiitNmzCrxGc9aIKs9rwfb6iqz/+heck=
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
@@ -145,8 +145,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI=
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220118054520-51ea28a32e7e h1:byscElf065gJ/fKtwryXMouZvNwVkxtqOTZXizTwLi8=
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220118054520-51ea28a32e7e/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1 h1:x56lA0u6hSRpD1YJ/4BDiLydJ8qp5mF50xYS8ZlbkWU=
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=

25
main.go
View File

@@ -13,6 +13,9 @@ import (
// webctrl "github.com/FloatTech/zbputils/control/web" // web 后端控制
// 词库类
"github.com/FloatTech/AnimeAPI/imgpool"
"github.com/FloatTech/zbputils/control"
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
@@ -49,6 +52,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_score" // 分数
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_wangyiyun" // 网易云音乐热评
// b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
@@ -84,13 +88,14 @@ var (
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
banner = strings.Join(contents, "\n")
token *string
url *string
adana *string
prefix *string
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
banner = strings.Join(contents, "\n")
token *string
url *string
adana *string
prefix *string
poolkey *string
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
)
func init() {
@@ -108,6 +113,7 @@ func init() {
// 默认昵称
adana = flag.String("n", "椛椛", "Set default nickname.")
prefix = flag.String("p", "/", "Set command prefix.")
poolkey = flag.String("pk", "", "Set imgpool key and enable listening.")
flag.Parse()
if *h {
@@ -123,6 +129,11 @@ func init() {
logrus.SetLevel(logrus.WarnLevel)
}
}
if *poolkey != "" {
imgpool.RegisterListener(*poolkey, control.Register("imgpool", 1, &control.Options{}))
}
// 启用 gui
// webctrl.InitGui(*g)
}

View File

@@ -53,4 +53,5 @@ const (
PrioCurse
PrioMockingBird
PrioAIReply
PrioWangYiYun
)

View File

@@ -7,7 +7,7 @@ import (
"time"
"github.com/FloatTech/AnimeAPI/classify"
"github.com/FloatTech/AnimeAPI/picture"
"github.com/FloatTech/AnimeAPI/imgpool"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -90,7 +90,7 @@ func init() { // 插件主体
}
})
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyPublic, picture.CmdMatch, picture.MustGiven).SetBlock(true).
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyPublic, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
@@ -103,11 +103,22 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) {
dhash := ctx.State["regex_matched"].([]string)[1]
if len(dhash) == 5*3 {
var u string
if web.IsSupportIPv6 {
ctx.SendChain(message.Image(apiheadv6 + dhash + ".webp"))
u = apiheadv6 + dhash + ".webp"
} else {
ctx.SendChain(message.Image(apihead + dhash))
u = apihead + dhash
}
m, err := imgpool.NewImage(ctx, dhash, u)
var img message.MessageSegment
if err != nil {
img = message.Image(u)
} else {
img = message.Image(m.String())
}
ctx.SendChain(img)
}
})
}
@@ -122,11 +133,19 @@ func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload
return
}
var img message.MessageSegment
var u string
if web.IsSupportIPv6 {
img = message.Image(apiheadv6 + dhash + ".webp")
u = apiheadv6 + dhash + ".webp"
} else {
img = message.Image(apihead + dhash)
u = apihead + dhash
}
m, err := imgpool.NewImage(ctx, b14, u)
var img message.MessageSegment
if err != nil {
img = message.Image(u)
} else {
img = message.Image(m.String())
}
if class > 5 {

View File

@@ -7,9 +7,9 @@ import (
"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/ctxext"
"github.com/FloatTech/zbputils/file"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -32,7 +32,7 @@ func init() { // 插件主体
"- 鉴赏图片[图片]",
})
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyPublic, picture.CmdMatch, picture.MustGiven).SetBlock(true).
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyPublic, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {

View File

@@ -7,6 +7,7 @@ import (
"encoding/hex"
"encoding/json"
"image"
"io"
"math/rand"
"os"
"strconv"
@@ -18,6 +19,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/AnimeAPI/imgpool"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/math"
@@ -27,7 +29,7 @@ import (
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
const (
// 底图缓存位置
images = "data/Fortune/"
// 基础文件位置
@@ -36,9 +38,12 @@ var (
font = "data/Font/sakura.ttf"
// 生成图缓存位置
cache = images + "cache/"
)
var (
// 底图类型列表:车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌
// 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师"}
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘"}
// 映射底图与 index
index = make(map[string]uint8)
// 签文
@@ -53,11 +58,11 @@ func init() {
if err != nil {
panic(err)
}
_ = os.RemoveAll(cache)
err = os.MkdirAll(cache, 0755)
if err != nil {
panic(err)
}
process.SleepAbout1sTo2s()
data, err := file.GetLazyData(omikujson, true, false)
if err != nil {
panic(err)
@@ -75,7 +80,7 @@ func init() {
DisableOnDefault: false,
Help: "每日运势: \n" +
"- 运势 | 抽签\n" +
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师]",
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘]",
})
en.OnRegex(`^设置底图(.*)`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
@@ -142,27 +147,37 @@ func init() {
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
cachefile := cache + hex.EncodeToString(digest[:])
var data []byte
switch file.IsExist(cachefile) {
case true:
data, err = os.ReadFile(cachefile)
if err == nil {
break
m, err := imgpool.GetImage(ctx, cachefile)
if err != nil {
logrus.Debugln("[fortune]", err)
if file.IsNotExist(cachefile) {
f, err := os.Create(cachefile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
_, err = draw(background, title, text, f)
_ = f.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}
m, err = imgpool.NewImage(ctx, cachefile, file.BOTPATH+"/"+cachefile)
process.SleepAbout1sTo2s() // 防止风控
if err != nil {
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + cachefile))
return
}
_ = os.Remove(cachefile)
fallthrough
case false:
// 绘制背景
data, err = draw(background, title, text)
}
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
_ = os.WriteFile(cachefile, data, 0644)
// 发送图片
ctx.SendChain(message.Image("base64://" + helper.BytesToString(data)))
ctx.SendChain(message.Image(m.String()))
})
}
@@ -206,20 +221,20 @@ func randtext(seed int64) (string, string) {
// @param title 签名
// @param text 签文
// @return 错误信息
func draw(back image.Image, title, text string) ([]byte, error) {
func draw(back image.Image, title, text string, f io.Writer) (int64, error) {
canvas := gg.NewContext(back.Bounds().Size().Y, back.Bounds().Size().X)
canvas.DrawImage(back, 0, 0)
// 写标题
canvas.SetRGB(1, 1, 1)
if err := canvas.LoadFontFace(font, 45); err != nil {
return nil, err
return -1, err
}
sw, _ := canvas.MeasureString(title)
canvas.DrawString(title, 140-sw/2, 112)
// 写正文
canvas.SetRGB(0, 0, 0)
if err := canvas.LoadFontFace(font, 23); err != nil {
return nil, err
return -1, err
}
tw, th := canvas.MeasureString("测")
tw, th = tw+10, th+10
@@ -247,7 +262,7 @@ func draw(back image.Image, title, text string) ([]byte, error) {
}
}
}
return txt2img.TxtCanvas{Canvas: canvas}.ToBase64()
return txt2img.TxtCanvas{Canvas: canvas}.WriteTo(f)
}
func offest(total, now int, distance float64) float64 {

View File

@@ -6,8 +6,10 @@ import (
"fmt"
"math/rand"
"net/http"
"strings"
"time"
"github.com/FloatTech/AnimeAPI/imgpool"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -73,7 +75,13 @@ func init() {
pom1 := "https://i.pixiv.re"
rannum := randintn(len(soutujson.Illusts))
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
ctx.SendChain(message.Image(pom1 + pom2))
u := pom1 + pom2
m, err := imgpool.NewImage(ctx, u[strings.LastIndex(u, "/")+1:], u)
if err != nil {
ctx.SendChain(message.Image(u))
return
}
ctx.SendChain(message.Image(m.String()))
})
}

View File

@@ -11,8 +11,10 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/AnimeAPI/imgpool"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
@@ -52,8 +54,18 @@ func init() {
continue
}
url := json.Get("data.0.urls.original").Str
ctx.SendGroupMessage(0, message.Image(strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")))
queue <- url
url = strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")
name := url[strings.LastIndex(url, "/")+1 : len(url)-4]
m, err := imgpool.GetImage(ctx, name)
if err != nil {
m, err = imgpool.NewImage(ctx, name, url)
process.SleepAbout1sTo2s()
}
if err == nil {
queue <- m.String()
} else {
queue <- url
}
}
}()
select {

View File

@@ -12,7 +12,6 @@ import (
"strings"
"time"
"github.com/FloatTech/AnimeAPI/picture"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
@@ -63,7 +62,7 @@ func init() {
}
})
// 上传一张图
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, picture.MustGiven).SetBlock(true).
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
name := ""
for _, elem := range ctx.Event.Message {

View File

@@ -7,7 +7,7 @@ import (
"strconv"
"github.com/FloatTech/AnimeAPI/ascii2d"
"github.com/FloatTech/AnimeAPI/picture"
"github.com/FloatTech/AnimeAPI/imgpool"
"github.com/FloatTech/AnimeAPI/pixiv"
"github.com/FloatTech/AnimeAPI/saucenao"
"github.com/sirupsen/logrus"
@@ -17,6 +17,7 @@ import (
"github.com/FloatTech/ZeroBot-Plugin/order"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
)
@@ -49,22 +50,32 @@ func init() { // 插件主体
}
if illust.Pid > 0 {
name := strconv.FormatInt(illust.Pid, 10)
filepath := datapath + name
switch {
case file.IsExist(filepath + ".jpg"):
filepath = "file:///" + filepath + ".jpg"
case file.IsExist(filepath + ".png"):
filepath = "file:///" + filepath + ".png"
case file.IsExist(filepath + ".gif"):
filepath = "file:///" + filepath + ".gif"
default:
filepath = ""
}
if filepath == "" {
logrus.Debug("[sausenao]开始下载", name)
filepath, err = pixiv.Download(illust.ImageUrls, datapath, name)
if err == nil {
filepath = "file:///" + filepath
var imgs message.Message
for i, u := range illust.ImageUrls {
n := name + "_p" + strconv.Itoa(i)
filepath := datapath + n
f := ""
switch {
case file.IsExist(filepath + ".jpg"):
f = filepath + ".jpg"
case file.IsExist(filepath + ".png"):
f = filepath + ".png"
case file.IsExist(filepath + ".gif"):
f = filepath + ".gif"
default:
logrus.Debugln("[sausenao]开始下载", n)
filepath, err = pixiv.Download(u, datapath, n)
if err == nil {
f = filepath
}
}
if f != "" {
m, err := imgpool.NewImage(ctx, n, f)
if err == nil {
imgs = append(imgs, message.Image(m.String()))
} else {
imgs = append(imgs, message.Image("file:///"+f))
}
}
}
txt := message.Text(
@@ -74,9 +85,9 @@ func init() { // 插件主体
"画师ID", illust.UserId, "\n",
"直链:", "https://pixivel.moe/detail?id=", illust.Pid,
)
if filepath != "" {
if imgs != nil {
// 发送搜索结果
ctx.SendChain(message.Image(filepath), message.Text("\n"), txt)
ctx.Send(append(imgs, message.Text("\n"), txt))
} else {
// 图片下载失败,仅发送文字结果
ctx.SendChain(txt)
@@ -86,7 +97,7 @@ func init() { // 插件主体
}
})
// 以图搜图
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.SendChain(message.Text("少女祈祷中......"))

View File

@@ -245,7 +245,7 @@ func download(i *pixiv.Illust, filedir string) /*(string, */ error /*)*/ {
return /*filepath + ".gif",*/ nil
}
// 下载最大分辨率为 1200 的图片
link := i.ImageUrls
link := i.ImageUrls[0]
link = strings.ReplaceAll(link, "img-original", "img-master")
link = strings.ReplaceAll(link, "_p0", "_p0_master1200")
link = strings.ReplaceAll(link, ".png", ".jpg")

View File

@@ -4,8 +4,8 @@ package tracemoe
import (
"fmt"
"github.com/FloatTech/AnimeAPI/picture"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
trmoe "github.com/fumiama/gotracemoe"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -23,7 +23,7 @@ func init() { // 插件主体
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]",
})
// 以图搜图
engine.OnKeywordGroup([]string{"搜番", "搜索番剧"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).
engine.OnKeywordGroup([]string{"搜番", "搜索番剧"}, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.SendChain(message.Text("少女祈祷中......"))

40
plugin_wangyiyun/main.go Normal file
View File

@@ -0,0 +1,40 @@
// Package wangyiyun 网易云音乐热评
package wangyiyun
import (
"time"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
wangyiyunURL = "http://ovooa.com/API/wyrp/api.php?type=text"
wangyiyunReferer = "http://ovooa.com/"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
)
func init() {
limit := rate.NewManager(time.Minute, 60)
control.Register("wangyiyun", order.PrioWangYiYun, &control.Options{
DisableOnDefault: false,
Help: "wangyiyun \n- 来份网易云热评",
}).OnFullMatch("来份网易云热评").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text(helper.BytesToString(data)))
})
}