diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml deleted file mode 100644 index 9fbd2008..00000000 --- a/.github/workflows/latest.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: 最新版 -on: - push: - branches: - - dev - -env: - GITHUB_TOKEN: ${{ github.token }} - -jobs: - my-job: - name: Build ZeroBot-Plugin on Push 🚀 - 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 Build Artifact - uses: actions/upload-artifact@v2 - with: - name: zerobot-plugin-all.zip - path: ./artifacts/zerobot-plugin-* \ No newline at end of file diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index bef9f483..772e5ec0 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ad5510b0..4dbe5b27 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,11 +5,12 @@ jobs: name: lint_golangci-lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2 - name: golangci-lint - uses: golangci/golangci-lint-action@v2.5.2 + uses: golangci/golangci-lint-action@v2 with: version: latest + args: --issues-exit-code=0 - name: Commit back continue-on-error: true run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d59f4750..10c1731e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 9842d743..9f8659ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ data/SetuTime/cache data/SetuTime/search data/manager +data/acgimage .idea/ .DS_Store .vscode diff --git a/go.mod b/go.mod index b30d36dc..bcb3650b 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.16 require ( - github.com/FloatTech/AnimeAPI v1.1.3 - github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.2 + github.com/FloatTech/AnimeAPI v1.1.9 + github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3 github.com/StackExchange/wmi v1.2.1 // indirect github.com/golang/protobuf v1.5.2 github.com/robfig/cron v1.2.0 @@ -15,8 +15,5 @@ require ( github.com/tidwall/pretty v1.2.0 // indirect github.com/tklauser/go-sysconf v0.3.7 // indirect github.com/wdvxdr1123/ZeroBot v1.2.2 - golang.org/x/text v0.3.6 // indirect - golang.org/x/tools v0.1.5 // indirect - google.golang.org/protobuf v1.27.1 // indirect modernc.org/sqlite v1.12.0 ) diff --git a/go.sum b/go.sum index 0dc14146..7dae58e7 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ -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/FloatTech/AnimeAPI v1.1.9 h1:H1hZmgwZPNHdx39K9JvY3awT8TTsCl9kKA1uVMyCjRg= +github.com/FloatTech/AnimeAPI v1.1.9/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI= +github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3 h1:jn/dH+OwPSRozkmeCeQQPrAGJRBudcm3OK5tXhGItRk= +github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3/go.mod h1:MVOQQ4e6AVGFm993blXXU4Sd6bAsLY2+Zb+/HMrEeEc= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M= @@ -82,24 +82,20 @@ github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8 github.com/wdvxdr1123/ZeroBot v1.2.2 h1:BKEy3l80BMrQWpFWaII0AfFMyf9bqrB0TxfWhTdoV58= github.com/wdvxdr1123/ZeroBot v1.2.2/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -109,32 +105,25 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/main.go b/main.go index 8968e0b7..0879c630 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石 @@ -29,6 +30,7 @@ import ( // 二次元图片 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao" // 以图搜图 @@ -61,7 +63,7 @@ func init() { func main() { fmt.Print( - "======================[ZeroBot-Plugin]======================", + "\n======================[ZeroBot-Plugin]======================", "\n", banner, "\n", "============================================================\n", ) // 启动打印 diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index 886aa6d7..7e18a51b 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -14,8 +14,8 @@ import ( ) const ( - lolipxy = "http://sayuri.fumiama.top:62002/dice?class=0&loli=true&r18=true" - apihead = "http://sayuri.fumiama.top:8080/img?path=" + lolipxy = "https://sayuri.fumiama.top/dice?class=0&loli=true&r18=true" + apihead = "https://sayuri.fumiama.top/img?path=" ) var ( diff --git a/plugin_aiwife/non-existent.go b/plugin_aiwife/non-existent.go new file mode 100644 index 00000000..b66b0fa9 --- /dev/null +++ b/plugin_aiwife/non-existent.go @@ -0,0 +1,24 @@ +// Package aiwife 随机老婆 +package aiwife + +import ( + "fmt" + "math/rand" + "time" + + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +const ( + bed = "https://www.thiswaifudoesnotexist.net/example-%d.jpg" +) + +func init() { // 插件主体 + rand.Seed(time.Now().UnixMicro()) + zero.OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10). + Handle(func(ctx *zero.Ctx) { + miku := rand.Intn(100000) + 1 + ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku))) + }) +} diff --git a/plugin_atri/atri.go b/plugin_atri/atri.go index 3485812b..55b656f2 100644 --- a/plugin_atri/atri.go +++ b/plugin_atri/atri.go @@ -16,8 +16,8 @@ import ( var ( // ATRI 所有命令的优先级 prio = -1 - // ATRI 表情的 GitHub 镜像位置 - res = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/" + // ATRI 表情的 codechina 镜像 + res = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/plugin_atri/" // ATRI 的总开关 enable = true ) diff --git a/plugin_diana/data/text.go b/plugin_diana/data/text.go index 10a87e26..14d8e68a 100644 --- a/plugin_diana/data/text.go +++ b/plugin_diana/data/text.go @@ -3,6 +3,7 @@ package data import ( "io" + "net/http" "os" "time" @@ -12,6 +13,7 @@ import ( const ( datapath = "data/Diana" pbfile = datapath + "/text.pb" + pburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/data/Diana/text.pb" ) var ( @@ -41,6 +43,7 @@ func LoadText() error { if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) { f, err := os.Open(pbfile) if err == nil { + defer f.Close() data, err1 := io.ReadAll(f) if err1 == nil { if len(data) > 0 { @@ -49,6 +52,26 @@ func LoadText() error { } return err1 } + } else { // 如果没有小作文,则从 url 下载 + f, err := os.Create(pbfile) + if err != nil { + return err + } + defer f.Close() + resp, err := http.Get(pburl) + if err == nil { + defer resp.Body.Close() + if resp.ContentLength > 0 { + log.Printf("[Diana]从镜像下载小作文%d字节...", resp.ContentLength) + data, err := io.ReadAll(resp.Body) + if err == nil && len(data) > 0 { + f.Write(data) + return compo.Unmarshal(data) + } + return err + } + return nil + } return err } return nil diff --git a/plugin_manager/manager.go b/plugin_manager/manager.go index 20abae21..10bf988d 100644 --- a/plugin_manager/manager.go +++ b/plugin_manager/manager.go @@ -3,7 +3,9 @@ package manager import ( "fmt" + "io" "math/rand" + "os" "strconv" "strings" "time" @@ -14,27 +16,44 @@ import ( timer "github.com/FloatTech/ZeroBot-Plugin-Timer" ) +const ( + datapath = "data/manager/" + confile = datapath + "config.pb" + hint = "====群管====\n" + + "- 禁言@QQ 1分钟\n" + + "- 解除禁言 @QQ\n" + + "- 我要自闭 1分钟\n" + + "- 开启全员禁言\n" + + "- 解除全员禁言\n" + + "- 升为管理@QQ\n" + + "- 取消管理@QQ\n" + + "- 修改名片@QQ XXX\n" + + "- 修改头衔@QQ XXX\n" + + "- 申请头衔 XXX\n" + + "- 踢出群聊@QQ\n" + + "- 退出群聊 1234\n" + + "- 群聊转发 1234 XXX\n" + + "- 私聊转发 0000 XXX\n" + + "- 在MM月dd日的hh点mm分时(用http://url)提醒大家XXX\n" + + "- 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家XXX\n" + + "- 取消在MM月dd日的hh点mm分的提醒\n" + + "- 取消在MM月[每周|周几]的hh点mm分的提醒\n" + + "- 列出所有提醒\n" + + "- 翻牌\n" + + "- 设置欢迎语XXX\n" + + "- [开启|关闭]入群验证" +) + +var ( + config Config +) + func init() { // 插件主体 + loadConfig() // 菜单 zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority(). Handle(func(ctx *zero.Ctx) { - ctx.SendChain(message.Text( - "====群管====", "\n", - "- 禁言@QQ 1分钟", "\n", - "- 解除禁言 @QQ", "\n", - "- 我要自闭 1分钟", "\n", - "- 开启全员禁言", "\n", - "- 解除全员禁言", "\n", - "- 升为管理@QQ", "\n", - "- 取消管理@QQ", "\n", - "- 修改名片@QQ XXX", "\n", - "- 修改头衔@QQ XXX", "\n", - "- 申请头衔 XXX", "\n", - "- 踢出群聊@QQ", "\n", - "- 退出群聊 1234", "\n", - "- 群聊转发 1234 XXX", "\n", - "- 私聊转发 0000 XXX", - )) + ctx.Send(hint) }) // 升为管理 zero.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40). @@ -222,7 +241,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1])) }) // 定时提醒 - zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40). + zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.AdminPermission).SetBlock(true).SetPriority(40). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { dateStrs := ctx.State["regex_matched"].([]string) @@ -237,7 +256,7 @@ func init() { // 插件主体 } }) // 取消定时 - zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.SuperUserPermission).SetBlock(true).SetPriority(40). + zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.AdminPermission).SetBlock(true).SetPriority(40). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { dateStrs := ctx.State["regex_matched"].([]string) @@ -256,7 +275,7 @@ func init() { // 插件主体 } }) // 列出本群所有定时 - zero.OnFullMatch("列出所有提醒", zero.SuperUserPermission).SetBlock(true).SetPriority(40). + zero.OnFullMatch("列出所有提醒", zero.AdminPermission).SetBlock(true).SetPriority(40). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { ctx.Send(fmt.Sprint(timer.ListTimers(uint64(ctx.Event.GroupID)))) @@ -277,10 +296,51 @@ func init() { // 插件主体 } }) // 入群欢迎 - zero.OnNotice().SetBlock(false).SetPriority(40). + zero.OnNotice().SetBlock(false).FirstPriority(). Handle(func(ctx *zero.Ctx) { if ctx.Event.NoticeType == "group_increase" { - ctx.SendChain(message.Text("欢迎~")) + word, ok := config.Welcome[uint64(ctx.Event.GroupID)] + if ok { + ctx.Send(word) + } else { + ctx.Send("欢迎~") + } + enable, ok1 := config.Checkin[uint64(ctx.Event.GroupID)] + if ok1 && enable { + uid := ctx.Event.UserID + a := rand.Intn(100) + b := rand.Intn(100) + r := a + b + ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("考你一道题:%d+%d=?\n如果60秒之内答不上来,%s就要把你踢出去了哦~", a, b, zero.BotConfig.NickName[0]))) + // 匹配发送者进行验证 + rule := func(ctx *zero.Ctx) bool { + for _, elem := range ctx.Event.Message { + if elem.Type == "text" { + text := strings.ReplaceAll(elem.Data["text"], " ", "") + ans, err := strconv.Atoi(text) + if err == nil { + if ans != r { + ctx.Send("答案不对哦,再想想吧~") + return false + } + return true + } + } + } + return false + } + next := zero.NewFutureEvent("message", 999, false, zero.CheckUser(ctx.Event.UserID), rule) + recv, cancel := next.Repeat() + select { + case <-time.After(time.Minute): + ctx.Send("拜拜啦~") + ctx.SetGroupKick(ctx.Event.GroupID, uid, false) + cancel() + case <-recv: + cancel() + ctx.Send("答对啦~") + } + } } }) // 退群提醒 @@ -290,6 +350,34 @@ func init() { // 插件主体 ctx.SendChain(message.Text("有人跑路了~")) } }) + // 设置欢迎语 + zero.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40). + Handle(func(ctx *zero.Ctx) { + config.Welcome[uint64(ctx.Event.GroupID)] = ctx.State["regex_matched"].([]string)[1] + if saveConfig() == nil { + ctx.Send("记住啦!") + } else { + ctx.Send("出错啦!") + } + }) + // 入群验证开关 + zero.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40). + Handle(func(ctx *zero.Ctx) { + option := ctx.State["regex_matched"].([]string)[1] + switch option { + case "开启": + config.Checkin[uint64(ctx.Event.GroupID)] = true + case "关闭": + config.Checkin[uint64(ctx.Event.GroupID)] = false + default: + return + } + if saveConfig() == nil { + ctx.Send("已" + option) + } else { + ctx.Send("出错啦!") + } + }) // 运行 CQ 码 zero.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(0). Handle(func(ctx *zero.Ctx) { @@ -304,3 +392,44 @@ func strToInt(str string) int64 { val, _ := strconv.ParseInt(str, 10, 64) return val } + +// loadConfig 加载设置,没有则手动初始化 +func loadConfig() { + mkdirerr := os.MkdirAll(datapath, 0755) + if mkdirerr == nil { + if _, err := os.Stat(confile); err == nil || os.IsExist(err) { + f, err := os.Open(confile) + if err == nil { + data, err1 := io.ReadAll(f) + if err1 == nil { + if len(data) > 0 { + if config.Unmarshal(data) == nil { + return + } + } + } + } + } + config.Checkin = make(map[uint64]bool) + config.Welcome = make(map[uint64]string) + } else { + panic(mkdirerr) + } +} + +// saveConfig 保存设置,无此文件则新建 +func saveConfig() error { + data, err := config.Marshal() + if err != nil { + return err + } else if _, err := os.Stat(datapath); err == nil || os.IsExist(err) { + f, err1 := os.OpenFile(confile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + if err1 != nil { + return err1 + } + defer f.Close() + _, err2 := f.Write(data) + return err2 + } + return nil +} diff --git a/plugin_manager/manager.pb.go b/plugin_manager/manager.pb.go new file mode 100644 index 00000000..a0ac3fcc --- /dev/null +++ b/plugin_manager/manager.pb.go @@ -0,0 +1,561 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: manager.proto + +package manager + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type Config struct { + Checkin map[uint64]bool `protobuf:"bytes,1,rep,name=checkin,proto3" json:"checkin,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Welcome map[uint64]string `protobuf:"bytes,2,rep,name=welcome,proto3" json:"welcome,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Config) Reset() { *m = Config{} } +func (m *Config) String() string { return proto.CompactTextString(m) } +func (*Config) ProtoMessage() {} +func (*Config) Descriptor() ([]byte, []int) { + return fileDescriptor_cde9ec64f0d2c859, []int{0} +} +func (m *Config) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Config.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Config) XXX_Merge(src proto.Message) { + xxx_messageInfo_Config.Merge(m, src) +} +func (m *Config) XXX_Size() int { + return m.Size() +} +func (m *Config) XXX_DiscardUnknown() { + xxx_messageInfo_Config.DiscardUnknown(m) +} + +var xxx_messageInfo_Config proto.InternalMessageInfo + +func (m *Config) GetCheckin() map[uint64]bool { + if m != nil { + return m.Checkin + } + return nil +} + +func (m *Config) GetWelcome() map[uint64]string { + if m != nil { + return m.Welcome + } + return nil +} + +func init() { + proto.RegisterType((*Config)(nil), "manager.config") + proto.RegisterMapType((map[uint64]bool)(nil), "manager.config.CheckinEntry") + proto.RegisterMapType((map[uint64]string)(nil), "manager.config.WelcomeEntry") +} + +func init() { proto.RegisterFile("manager.proto", fileDescriptor_cde9ec64f0d2c859) } + +var fileDescriptor_cde9ec64f0d2c859 = []byte{ + // 186 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0x4d, 0xcc, 0x4b, + 0x4c, 0x4f, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0x3e, 0x30, + 0x72, 0xb1, 0x25, 0xe7, 0xe7, 0xa5, 0x65, 0xa6, 0x0b, 0x99, 0x71, 0xb1, 0x27, 0x67, 0xa4, 0x26, + 0x67, 0x67, 0xe6, 0x49, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xe8, 0xc1, 0x34, 0x41, 0x54, + 0xe8, 0x39, 0x43, 0xa4, 0x5d, 0xf3, 0x4a, 0x8a, 0x2a, 0x83, 0x60, 0x8a, 0x41, 0xfa, 0xca, 0x53, + 0x73, 0x92, 0xf3, 0x73, 0x53, 0x25, 0x98, 0xb0, 0xeb, 0x0b, 0x87, 0x48, 0x43, 0xf5, 0x41, 0x15, + 0x4b, 0x59, 0x71, 0xf1, 0x20, 0x1b, 0x28, 0x24, 0xc0, 0xc5, 0x9c, 0x9d, 0x5a, 0x29, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62, 0x0a, 0x89, 0x70, 0xb1, 0x96, 0x25, 0xe6, 0x94, 0x82, 0xcc, + 0x65, 0xd4, 0xe0, 0x08, 0x82, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x41, 0x7a, 0x91, 0x0d, 0x25, 0xa4, + 0x97, 0x13, 0x49, 0xaf, 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, + 0x24, 0xc7, 0x38, 0xe3, 0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0x50, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x2a, 0xe6, 0x90, 0x6e, 0x25, 0x01, 0x00, 0x00, +} + +func (m *Config) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Config) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Config) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Welcome) > 0 { + for k := range m.Welcome { + v := m.Welcome[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintManager(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i = encodeVarintManager(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintManager(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Checkin) > 0 { + for k := range m.Checkin { + v := m.Checkin[k] + baseI := i + i-- + if v { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + i = encodeVarintManager(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintManager(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintManager(dAtA []byte, offset int, v uint64) int { + offset -= sovManager(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Config) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Checkin) > 0 { + for k, v := range m.Checkin { + _ = k + _ = v + mapEntrySize := 1 + sovManager(uint64(k)) + 1 + 1 + n += mapEntrySize + 1 + sovManager(uint64(mapEntrySize)) + } + } + if len(m.Welcome) > 0 { + for k, v := range m.Welcome { + _ = k + _ = v + mapEntrySize := 1 + sovManager(uint64(k)) + 1 + len(v) + sovManager(uint64(len(v))) + n += mapEntrySize + 1 + sovManager(uint64(mapEntrySize)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovManager(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozManager(x uint64) (n int) { + return sovManager(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Config) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: config: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: config: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checkin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthManager + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthManager + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Checkin == nil { + m.Checkin = make(map[uint64]bool) + } + var mapkey uint64 + var mapvalue bool + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapvaluetemp int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvaluetemp |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + mapvalue = bool(mapvaluetemp != 0) + } else { + iNdEx = entryPreIndex + skippy, err := skipManager(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthManager + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Checkin[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Welcome", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthManager + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthManager + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Welcome == nil { + m.Welcome = make(map[uint64]string) + } + var mapkey uint64 + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowManager + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthManager + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthManager + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipManager(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthManager + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Welcome[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipManager(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthManager + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipManager(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowManager + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowManager + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowManager + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthManager + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupManager + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthManager + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthManager = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowManager = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupManager = fmt.Errorf("proto: unexpected end of group") +) diff --git a/plugin_manager/manager.proto b/plugin_manager/manager.proto new file mode 100644 index 00000000..cd53bf10 --- /dev/null +++ b/plugin_manager/manager.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package manager; + +message config { + map checkin = 1; + map welcome = 2; +} diff --git a/plugin_music/selecter.go b/plugin_music/selecter.go index e40d0ebd..db4ae577 100644 --- a/plugin_music/selecter.go +++ b/plugin_music/selecter.go @@ -177,9 +177,9 @@ func qqmusic(keyword string) message.MessageSegment { }.Encode() audio := gjson.ParseBytes(netGet(music.String(), h2)) // 获得音乐封面 - image := "https://y.gtimg.cn/music/photo_new" + + image := "https://y.gtimg.cn/music/photo_new/" + find( - "src=\"//y.gtimg.cn/music/photo_new", + `photo_new\u002F`, "?max_age", string( netGet("https://y.qq.com/n/yqq/song/"+info.Get("songmid").Str+".html", nil), diff --git a/plugin_omikuji/sensou.go b/plugin_omikuji/sensou.go new file mode 100644 index 00000000..48e83c30 --- /dev/null +++ b/plugin_omikuji/sensou.go @@ -0,0 +1,24 @@ +// Package omikuji 浅草寺求签 +package omikuji + +import ( + "fmt" + "math/rand" + "time" + + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +const ( + bed = "https://codechina.csdn.net/u011570312/senso-ji-omikuji/-/raw/main/%d_%d.jpg" +) + +func init() { // 插件主体 + rand.Seed(time.Now().UnixMicro()) + zero.OnFullMatchGroup([]string{"求签", "运势", "占卜"}, zero.OnlyToMe).SetPriority(10). + Handle(func(ctx *zero.Ctx) { + miku := rand.Intn(100) + 1 + ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku, 0)), message.Image(fmt.Sprintf(bed, miku, 1))) + }) +} diff --git a/plugin_setutime/setu_geter.go b/plugin_setutime/setu_geter.go index 52c338c3..198de29f 100644 --- a/plugin_setutime/setu_geter.go +++ b/plugin_setutime/setu_geter.go @@ -3,6 +3,9 @@ package setutime import ( "fmt" + "io" + "log" + "net/http" "os" "strconv" "strings" @@ -28,6 +31,10 @@ type imgpool struct { Form int64 } +const ( + dburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/data/SetuTime/SetuTime.db" +) + // NewPoolsCache 返回一个缓冲池对象 func newPools() *imgpool { cache := &imgpool{ @@ -43,6 +50,24 @@ func newPools() *imgpool { if err != nil { panic(err) } + // 如果数据库不存在则下载 + if _, err := os.Stat(cache.DB.DBPath); err != nil || os.IsNotExist(err) { + f, err := os.Create(cache.DB.DBPath) + if err == nil { + resp, err := http.Get(dburl) + if err == nil { + defer resp.Body.Close() + if resp.ContentLength > 0 { + log.Printf("[Setu]从镜像下载数据库%d字节...", resp.ContentLength) + data, err := io.ReadAll(resp.Body) + if err == nil && len(data) > 0 { + f.Write(data) + } + } + } + f.Close() + } + } for i := range cache.List { if err := cache.DB.create(cache.List[i], &pixiv.Illust{}); err != nil { panic(err) diff --git a/plugin_shindan/shindan.go b/plugin_shindan/shindan.go index c34892c5..5eff7428 100644 --- a/plugin_shindan/shindan.go +++ b/plugin_shindan/shindan.go @@ -5,11 +5,10 @@ import ( "strconv" "time" + "github.com/FloatTech/AnimeAPI/shindanmaker" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/extension/rate" "github.com/wdvxdr1123/ZeroBot/message" - - "github.com/FloatTech/AnimeAPI/shindanmaker" ) var ( @@ -21,10 +20,11 @@ func init() { zero.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle) zero.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle) zero.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle) + zero.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle) } // shindanmaker 处理函数 -var handle = func(ctx *zero.Ctx) { +func handle(ctx *zero.Ctx) { if !limit.Load(ctx.Event.UserID).Acquire() { ctx.SendChain(message.Text("请稍后重试0x0...")) return @@ -42,11 +42,11 @@ var handle = func(ctx *zero.Ctx) { if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) } - ctx.SendChain(message.Text(text)) + ctx.Send(text) } // 传入 shindanmaker id -var number = func(id int64) func(ctx *zero.Ctx) bool { +func number(id int64) func(ctx *zero.Ctx) bool { return func(ctx *zero.Ctx) bool { ctx.State["id"] = id return true