From cd6534097ed3974061f634590113b4a1a1539b28 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 7 Aug 2021 14:01:58 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88=EF=BC=8C=E6=9C=80=E6=96=B0=E7=89=88=E4=BB=85=E7=BC=96?= =?UTF-8?q?=E8=AF=91dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/latest.yml | 2 +- .github/workflows/prerelease.yml | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/prerelease.yml diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index f898a531..9fbd2008 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -2,7 +2,7 @@ name: 最新版 on: push: branches: - - master + - dev env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 00000000..bef9f483 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,55 @@ +name: 测试版 +on: + push: + tags: + - p* + +env: + GITHUB_TOKEN: ${{ github.token }} + +jobs: + my-job: + name: Build ZeroBot-Plugin on Push Tag 🚀 + runs-on: ubuntu-latest + steps: + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Cache Go + id: cache + uses: actions/cache@v2 + with: + # A list of files, directories, and wildcard patterns to cache and restore + path: ~/go/pkg/mod + key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} + + - name: Tidy Go modules + run: go mod tidy + + - name: Build linux-x64 + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x64 + - name: Build linux-x86 + run: CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x86 + - name: Build windows-x64 + run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x64.exe + - name: Build windows-x86 + run: CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x86.exe + - name: Build arm64 + run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-arm64 + - name: Build armv6 + run: CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-armv6 + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: artifacts/zerobot-plugin-* + tag: ${{ github.ref }} + overwrite: true + file_glob: true From 72fa62622f76282c056e726f3f79e6f419c9c587 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 7 Aug 2021 14:11:02 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_acgimage/classify.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index 2a590d81..f36e3baf 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -15,6 +15,7 @@ import ( const ( lolipxy = "http://sayuri.fumiama.top:62002/dice?class=0&loli=true&r18=true" + apihead = "http://sayuri.fumiama.top:8080/img?path=" ) var ( @@ -90,6 +91,13 @@ func init() { // 插件主体 } } }) + zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20). + Handle(func(ctx *zero.Ctx) { + dhash := ctx.State["regex_matched"].([]string)[1] + if len(dhash) == 5 { + ctx.Send(message.Image(apihead + dhash)) + } + }) } func setLastMsg(id int64, msg int64) { From a094d1c2baaf86ecf24257366970f8b0b3b72bac Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 7 Aug 2021 14:15:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 8 ++------ plugin_acgimage/classify.go | 2 +- plugin_saucenao/searcher.go | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index d3dbf0f7..b30d36dc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.16 require ( - github.com/FloatTech/AnimeAPI v1.1.2 + github.com/FloatTech/AnimeAPI v1.1.3 github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.2 github.com/StackExchange/wmi v1.2.1 // indirect github.com/golang/protobuf v1.5.2 diff --git a/go.sum b/go.sum index 0ad5ea4e..0dc14146 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,5 @@ -github.com/FloatTech/AnimeAPI v1.1.0 h1:X6UMkl6eC8NHHeInt40x0AHb8a3GiQSmE1HigyTG/Qg= -github.com/FloatTech/AnimeAPI v1.1.0/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI= -github.com/FloatTech/AnimeAPI v1.1.1 h1:SPyrVlqRVQHfYOm9x8eGBJWlT+3gj1wtFsbH1bCgkXs= -github.com/FloatTech/AnimeAPI v1.1.1/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI= -github.com/FloatTech/AnimeAPI v1.1.2 h1:u+aVY1HlRi6jCvOQ9dePNGtCv71ESt79SG1Y4JZNx38= -github.com/FloatTech/AnimeAPI v1.1.2/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI= +github.com/FloatTech/AnimeAPI v1.1.3 h1:VZA0XDEKOGAtmm0PU6/8ty6wI2n0Xg21QmngQVvUMhw= +github.com/FloatTech/AnimeAPI v1.1.3/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI= github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.2 h1:w/JerL8DwdyoxZYB4HRMaHANRV2j+r5XxaQhVB0sjBw= github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.2/go.mod h1:MVOQQ4e6AVGFm993blXXU4Sd6bAsLY2+Zb+/HMrEeEc= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index f36e3baf..c98143f6 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -79,7 +79,7 @@ func init() { // 插件主体 go cancel(ctx) }) // 上传一张图进行评价 - zero.OnKeywordGroup([]string{"评价图片"}, picture.CmdMatch(), picture.MustGiven()).SetBlock(true).SetPriority(24). + zero.OnKeywordGroup([]string{"评价图片"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { ctx.Send("少女祈祷中...") diff --git a/plugin_saucenao/searcher.go b/plugin_saucenao/searcher.go index 99e66a7b..6a48cc9c 100644 --- a/plugin_saucenao/searcher.go +++ b/plugin_saucenao/searcher.go @@ -44,7 +44,7 @@ func init() { // 插件主体 ) }) // 以图搜图 - zero.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch(), picture.MustGiven()).SetBlock(true).FirstPriority(). + zero.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority(). Handle(func(ctx *zero.Ctx) { // 开始搜索图片 ctx.Send("少女祈祷中......") From 1d2960a51c59badce54f44f7f1dc4afea9c27a26 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 7 Aug 2021 14:20:13 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E2=9C=A8=20=E7=A7=81=E8=81=8A=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_acgimage/classify.go | 63 +++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index c98143f6..f8228ec9 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -31,46 +31,43 @@ var ( func init() { // 插件主体 // 初始化 classify classify.Init(datapath) - zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20). + zero.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).SetPriority(20). Handle(func(ctx *zero.Ctx) { url := ctx.State["regex_matched"].([]string)[1] if !strings.HasPrefix(url, "http") { ctx.Send("URL非法!") } else { randapi = url + ctx.Send("设置好啦") } }) // 有保护的随机图片 - zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). + zero.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if ctx.Event.GroupID > 0 { - if classify.CanVisit(5) { - go func() { - class, lastvisit, dhash, comment := classify.Classify(randapi, false) - replyClass(ctx, dhash, class, false, lastvisit, comment) - }() - } else { - ctx.Send("你太快啦!") - } + if classify.CanVisit(5) { + go func() { + class, lastvisit, dhash, comment := classify.Classify(randapi, false) + replyClass(ctx, dhash, class, false, lastvisit, comment) + }() + } else { + ctx.Send("你太快啦!") } }) // 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回 - zero.OnFullMatch("直接随机", zero.AdminPermission).SetBlock(true).SetPriority(24). + zero.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if ctx.Event.GroupID > 0 { - if block { - ctx.Send("请稍后再试哦") - } else if randapi != "" { - block = true - var url string - if randapi[0] == '&' { - url = lolipxy - } else { - url = randapi - } - setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0"))) - block = false + if block { + ctx.Send("请稍后再试哦") + } else if randapi != "" { + block = true + var url string + if randapi[0] == '&' { + url = lolipxy + } else { + url = randapi } + setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0"))) + block = false } }) // 撤回最后的直接随机图片 @@ -79,16 +76,14 @@ func init() { // 插件主体 go cancel(ctx) }) // 上传一张图进行评价 - zero.OnKeywordGroup([]string{"评价图片"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24). + zero.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if ctx.Event.GroupID > 0 { - ctx.Send("少女祈祷中...") - for _, url := range ctx.State["image_url"].([]string) { - go func(target string) { - class, lastvisit, dhash, comment := classify.Classify(target, true) - replyClass(ctx, dhash, class, true, lastvisit, comment) - }(url) - } + ctx.Send("少女祈祷中...") + for _, url := range ctx.State["image_url"].([]string) { + go func(target string) { + class, lastvisit, dhash, comment := classify.Classify(target, true) + replyClass(ctx, dhash, class, true, lastvisit, comment) + }(url) } }) zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20). From f0fd1eaf22a31d1838c429b395f289f8efa18d06 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 7 Aug 2021 15:05:37 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=A8=20=E5=AE=8C=E5=96=84=E7=A7=81?= =?UTF-8?q?=E8=81=8A=E8=8E=B7=E5=8F=96=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_acgimage/classify.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index f8228ec9..886aa6d7 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -89,7 +89,7 @@ func init() { // 插件主体 zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20). Handle(func(ctx *zero.Ctx) { dhash := ctx.State["regex_matched"].([]string)[1] - if len(dhash) == 5 { + if len(dhash) == 5*3 { ctx.Send(message.Image(apihead + dhash)) } })