mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-01-03 09:49:05 +08:00
commit
bf5feae717
2
.github/workflows/latest.yml
vendored
2
.github/workflows/latest.yml
vendored
@ -2,7 +2,7 @@ name: 最新版
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- dev
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|||||||
55
.github/workflows/prerelease.yml
vendored
Normal file
55
.github/workflows/prerelease.yml
vendored
Normal file
@ -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
|
||||||
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/FloatTech/ZeroBot-Plugin
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
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/FloatTech/ZeroBot-Plugin-Timer v1.4.2
|
||||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
|
|||||||
8
go.sum
8
go.sum
@ -1,9 +1,5 @@
|
|||||||
github.com/FloatTech/AnimeAPI v1.1.0 h1:X6UMkl6eC8NHHeInt40x0AHb8a3GiQSmE1HigyTG/Qg=
|
github.com/FloatTech/AnimeAPI v1.1.3 h1:VZA0XDEKOGAtmm0PU6/8ty6wI2n0Xg21QmngQVvUMhw=
|
||||||
github.com/FloatTech/AnimeAPI v1.1.0/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
|
github.com/FloatTech/AnimeAPI v1.1.3/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/ZeroBot-Plugin-Timer v1.4.2 h1:w/JerL8DwdyoxZYB4HRMaHANRV2j+r5XxaQhVB0sjBw=
|
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/FloatTech/ZeroBot-Plugin-Timer v1.4.2/go.mod h1:MVOQQ4e6AVGFm993blXXU4Sd6bAsLY2+Zb+/HMrEeEc=
|
||||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
lolipxy = "http://sayuri.fumiama.top:62002/dice?class=0&loli=true&r18=true"
|
lolipxy = "http://sayuri.fumiama.top:62002/dice?class=0&loli=true&r18=true"
|
||||||
|
apihead = "http://sayuri.fumiama.top:8080/img?path="
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -30,46 +31,43 @@ var (
|
|||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
// 初始化 classify
|
// 初始化 classify
|
||||||
classify.Init(datapath)
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
url := ctx.State["regex_matched"].([]string)[1]
|
url := ctx.State["regex_matched"].([]string)[1]
|
||||||
if !strings.HasPrefix(url, "http") {
|
if !strings.HasPrefix(url, "http") {
|
||||||
ctx.Send("URL非法!")
|
ctx.Send("URL非法!")
|
||||||
} else {
|
} else {
|
||||||
randapi = url
|
randapi = url
|
||||||
|
ctx.Send("设置好啦")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 有保护的随机图片
|
// 有保护的随机图片
|
||||||
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
|
zero.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if classify.CanVisit(5) {
|
||||||
if classify.CanVisit(5) {
|
go func() {
|
||||||
go func() {
|
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
|
||||||
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
|
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
||||||
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
}()
|
||||||
}()
|
} else {
|
||||||
} else {
|
ctx.Send("你太快啦!")
|
||||||
ctx.Send("你太快啦!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
// 直接随机图片,无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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if block {
|
||||||
if block {
|
ctx.Send("请稍后再试哦")
|
||||||
ctx.Send("请稍后再试哦")
|
} else if randapi != "" {
|
||||||
} else if randapi != "" {
|
block = true
|
||||||
block = true
|
var url string
|
||||||
var url string
|
if randapi[0] == '&' {
|
||||||
if randapi[0] == '&' {
|
url = lolipxy
|
||||||
url = lolipxy
|
} else {
|
||||||
} else {
|
url = randapi
|
||||||
url = randapi
|
|
||||||
}
|
|
||||||
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
|
|
||||||
block = false
|
|
||||||
}
|
}
|
||||||
|
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
|
||||||
|
block = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 撤回最后的直接随机图片
|
// 撤回最后的直接随机图片
|
||||||
@ -78,16 +76,21 @@ func init() { // 插件主体
|
|||||||
go cancel(ctx)
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
ctx.Send("少女祈祷中...")
|
||||||
ctx.Send("少女祈祷中...")
|
for _, url := range ctx.State["image_url"].([]string) {
|
||||||
for _, url := range ctx.State["image_url"].([]string) {
|
go func(target string) {
|
||||||
go func(target string) {
|
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
||||||
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
replyClass(ctx, dhash, class, true, lastvisit, comment)
|
||||||
replyClass(ctx, dhash, class, true, lastvisit, comment)
|
}(url)
|
||||||
}(url)
|
}
|
||||||
}
|
})
|
||||||
|
zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
dhash := ctx.State["regex_matched"].([]string)[1]
|
||||||
|
if len(dhash) == 5*3 {
|
||||||
|
ctx.Send(message.Image(apihead + dhash))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// 开始搜索图片
|
// 开始搜索图片
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.Send("少女祈祷中......")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user