diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 772e5ec0..78f97b88 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -13,43 +13,43 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 - - 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: Check out code into the Go module directory + uses: actions/checkout@v2 - - 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: 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: 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 + - 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 diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 64663361..dda6cead 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -1,5 +1,5 @@ name: PullLint -on: [pull_request] +on: [ pull_request ] jobs: golangci: name: lint @@ -9,7 +9,7 @@ jobs: uses: actions/setup-go@v2 with: 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 a55776cc..99918476 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,5 @@ name: PushLint -on: [push] +on: [ push ] jobs: golangci: name: lint @@ -9,7 +9,7 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 - + - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10c1731e..95b1a654 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,43 +13,43 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 - - 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: Check out code into the Go module directory + uses: actions/checkout@v2 - - 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: 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: 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 + - 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 diff --git a/.gitignore b/.gitignore index 9f8659ce..d2478274 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ -data/SetuTime/cache -data/SetuTime/search -data/manager -data/acgimage -.idea/ -.DS_Store -.vscode +data/SetuTime/cache +data/SetuTime/search +data/manager +data/acgimage +.idea/ +.DS_Store +.vscode +go-zero* +nohup.out diff --git a/README.md b/README.md index ed2cc9b2..5678896a 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ - ## 功能 + - **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat"` - [x] [BOT名字] - [x] [戳一戳BOT] @@ -59,12 +59,12 @@ - [ ] 警告[@xxx] - [x] run[xxx] - **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_github"` - - [x] >github [xxx] - - [x] >github -p [xxx] + - [x] > github [xxx] + - [x] > github -p [xxx] - **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode"` - - [x] >runcode help - - [x] >runcode [on/off] - - [x] >runcode [language] [code block] + - [x] > runcode help + - [x] > runcode [on/off] + - [x] > runcode [language] [code block] - **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music"` - [x] 点歌[xxx] - [x] 网易点歌[xxx] @@ -86,7 +86,7 @@ - [x] 来份[涩图/二次元/风景/车万] - [x] 添加[涩图/二次元/风景/车万][P站图片ID] - [x] 删除[涩图/二次元/风景/车万][P站图片ID] - - [x] >setu status + - [x] > setu status - **lolicon** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon"` - [x] 来份萝莉 - **搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao"` @@ -102,7 +102,7 @@ - 本插件要求`Go`版本大于等于`1.17` - [x] @BOT 求签|运势|占卜 - **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili"` - - [x] >bili info [名字] + - [x] > bili info [名字] - **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana"` - [x] @BOT 小作文 - [x] @BOT 发大病 @@ -114,27 +114,37 @@ - **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"` - [x] 具体指令看代码 - 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效 - - **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"` - - [x] 搜卡[xxxx] +- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"` + - [x] 搜卡[xxxx] - [x] [卡组代码xxx] - 注:更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp +- **青云客** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"` + - [x] @Bot 任意文本(任意一句话回复) + - [x] /daily(群定时发早晚安) + - [x] @Bot 任意图片|任意表情(用图片回复图片表情) + - [x] 关闭自动回复 + - [x] 启动自动回复 + - [x] (同意加群和加好友请求) - **TODO...** ## 使用方法 -本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互 -| 项目地址 | 平台 | 核心作者 | 备注 | -| --- | --- | --- | --- | -| [Yiwen-Chan/OneBot-YaYa](https://github.com/Yiwen-Chan/OneBot-YaYa) | [先驱](https://www.xianqubot.com/) | kanri | | -| [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) | CKYU | richardchien | 可在 Mirai 平台使用 [mirai-native](https://github.com/iTXTech/mirai-native) 加载 | -| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s | | -| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) | [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg | | -| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama | | +本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互 | 项目地址 | 平台 | 核心作者 | 备注 | | --- | --- | +--- | --- | | [Yiwen-Chan/OneBot-YaYa](https://github.com/Yiwen-Chan/OneBot-YaYa) | [先驱](https://www.xianqubot.com/) | +kanri | | | [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) | CKYU | richardchien | 可在 +Mirai 平台使用 [mirai-native](https://github.com/iTXTech/mirai-native) 加载 | +| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s | | +| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) +| [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg | | +| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | +takayama | | ### 使用稳定版/测试版 (推荐) + 可以前往[Release](https://github.com/FloatTech/ZeroBot-Plugin/releases)页面下载对应系统版本可执行文件,编译时开启了全部插件。 ### 本地运行 + 1. 下载安装 [Go](https://studygolang.com/dl) 环境 2. 下载本项目[压缩包](https://github.com/Yiwen-Chan/ZeroBot-Plugin/archive/master.zip),本地解压 3. 编辑 main.go 文件,内容按需修改 @@ -144,6 +154,7 @@ ### 编译运行 #### 利用 Actions 在线编译 + 1. 点击右上角 Fork 本项目,并转跳到自己 Fork 的仓库 2. 点击仓库上方的 Actions 按钮,确认使用 Actions 3. 编辑 main.go 文件,内容按需修改 @@ -153,8 +164,10 @@ 7. 啾咪~ #### 本地编译/交叉编译 + 1. 下载安装 [Go](https://studygolang.com/dl) 环境 2. clone 并进入本项目,下载所需包 + ```bash git clone --depth=1 https://github.com/FloatTech/ZeroBot-Plugin.git cd ZeroBot-Plugin @@ -163,8 +176,10 @@ go env -w GOPROXY=https://goproxy.cn,direct go env -w GO111MODULE=auto go mod tidy ``` + 3. 编辑 main.go 文件,内容按需修改 4. 按照平台输入命令编译,下面举了两个不太常见的例子 + ```bash # 本机平台 go build -ldflags "-s -w" -o zerobot @@ -173,12 +188,14 @@ GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build -ldflags "-s -w" -o zerobot # mips Linux 平台 如 路由器 wndr4300 GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" -o zerobot ``` + 5. 运行 OneBot 框架,并同时运行本插件 ## 特别感谢 + - [ZeroBot](https://github.com/wdvxdr1123/ZeroBot) - [ATRI](https://github.com/Kyomotoi/ATRI) - ## License + [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FYiwen-Chan%2FZeroBot-Plugin.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FYiwen-Chan%2FZeroBot-Plugin?ref=badge_large) diff --git a/go.sum b/go.sum index 1c49d48e..30ab27da 100644 --- a/go.sum +++ b/go.sum @@ -6,7 +6,6 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M= github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0= -github.com/antchfx/xpath v1.1.6 h1:6sVh6hB5T6phw1pFpHRQ+C4bd8sNI+O58flqtg7h0R0= github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8= github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= @@ -18,7 +17,6 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -41,13 +39,11 @@ github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU= github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -82,25 +78,22 @@ github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU= github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE= github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8= github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tklauser/go-sysconf v0.3.8 h1:41Nq9J+pxKud4IQ830J5LlS5nl67dVQC7AuisUooaOU= github.com/tklauser/go-sysconf v0.3.8/go.mod h1:z4zYWRS+X53WUKtBcmDg1comV3fPhdQnzasnIHUoLDU= -github.com/tklauser/numcpus v0.2.3 h1:nQ0QYpiritP6ViFhrKYsiv6VVxOpum2Gks5GhnJbS/8= github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E= github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= 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/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -108,13 +101,14 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r 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/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw= golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 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= @@ -124,23 +118,24 @@ 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-20210423082822-04245dca01da/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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71 h1:ikCpsnYR+Ew0vu99XlDp55lGgDJdIMx3f4a18jfse/s= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf h1:2ucpDCmfkl8Bd/FsLtiD653Wf96cW37s+iGx93zsu4k= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/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/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 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= @@ -150,7 +145,6 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T 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= @@ -163,13 +157,11 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= -modernc.org/cc/v3 v3.33.7 h1:Rvxffgx6LHSpGS6IO8bffSYN1wpPsWHEWY9CV95vpro= modernc.org/cc/v3 v3.33.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.33.11 h1:Fc7goiKCzfHvGR4WZbVLWIh/4VhJE2Z31Jkg36Ezp7Q= modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60= -modernc.org/ccgo/v3 v3.9.6 h1:rCjLgu6iRxK2bqq8A0CCOnDP+tdA81LfbBUlM1L6ZIY= modernc.org/ccgo/v3 v3.9.6/go.mod h1:KGOi0NhaT6CO19xeSXcpXBl0OkoD6T1U4dPd633G9Sg= modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw= modernc.org/ccgo/v3 v3.10.1 h1:iS/P/unYVUpy7aAxy4Xj8BTy8afdyN1P54Ez2LlUmFI= @@ -178,7 +170,6 @@ modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= -modernc.org/libc v1.9.11 h1:QUxZMs48Ahg2F7SN41aERvMfGLY2HU/ADnB9DC4Yts8= modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q= modernc.org/libc v1.10.0 h1:VY0vRYW7BMx9vhF3ZvdgmjFOdRrV3EpjUFlRu+5O9FM= modernc.org/libc v1.10.0/go.mod h1:0/Nct1oFfLhjihlkmiJvALxOyV2rlkJ7/OZk1ni+WDQ= @@ -187,7 +178,6 @@ modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6 modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14= modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM= diff --git a/main.go b/main.go index 2ed516e7..6ef2ec25 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -package main +package main import ( "fmt" @@ -8,8 +8,9 @@ import ( // 注:以下插件均可通过前面加 // 注释,注释后停用并不加载插件 // 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用 // 词库类 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke" //青云客 // 实用类 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_github" // 搜索GitHub仓库 diff --git a/plugin_atri/atri.go b/plugin_atri/atri.go index 55b656f2..bfe1f5de 100644 --- a/plugin_atri/atri.go +++ b/plugin_atri/atri.go @@ -15,7 +15,7 @@ import ( var ( // ATRI 所有命令的优先级 - prio = -1 + prio = 2 // ATRI 表情的 codechina 镜像 res = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/plugin_atri/" // ATRI 的总开关 @@ -25,16 +25,20 @@ var ( func init() { // 插件主体 zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + enable = true + time.Sleep(time.Second * 1) ctx.SendChain(randText("嗯呜呜……夏生先生……?")) }) zero.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { enable = false + time.Sleep(time.Second * 1) ctx.SendChain(randText("Zzz……Zzz……")) }) zero.OnFullMatch("萝卜子", atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) switch rand.Intn(2) { case 0: ctx.SendChain(randText("萝卜子是对机器人的蔑称!", "是亚托莉......萝卜子可是对机器人的蔑称")) @@ -42,22 +46,24 @@ func init() { // 插件主体 ctx.SendChain(randRecord("RocketPunch.amr")) } }) - zero.OnKeywordGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio). + zero.OnFullMatchGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { - if rand.Intn(10) == 0 { - ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png")) - } + time.Sleep(time.Second * 1) + ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png")) + }) zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) ctx.SendChain(randImage("FN.jpg", "WQ.jpg", "WQ1.jpg")) }) - zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う"}, atriSwitch()).SetBlock(true).SetPriority(prio). + zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う", "早好", "早"}, atriSwitch()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { now := time.Now().Hour() switch { case now < 6: // 凌晨 - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "zzzz......", "zzzzzzzz......", "zzz...好涩哦..zzz....", @@ -66,7 +72,8 @@ func init() { // 插件主体 "...zzz....哧溜哧溜....", )) case now >= 6 && now < 9: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "啊......早上好...(哈欠)", "唔......吧唧...早上...哈啊啊~~~\n早上好......", "早上好......", @@ -78,24 +85,27 @@ func init() { // 插件主体 "早上好......欸~~~脸好近呢", )) case now >= 9 && now < 18: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "哼!这个点还早啥,昨晚干啥去了!?", "熬夜了对吧熬夜了对吧熬夜了对吧???!", "是不是熬夜是不是熬夜是不是熬夜?!", )) case now >= 18 && now < 24: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "早个啥?哼唧!我都准备洗洗睡了!", "不是...你看看几点了,哼!", "晚上好哇", )) } }) - zero.OnFullMatchGroup([]string{"中午好", "午安"}, atriSwitch()).SetBlock(true).SetPriority(prio). + zero.OnFullMatchGroup([]string{"中午好", "午安", "午好"}, atriSwitch()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { now := time.Now().Hour() if now > 11 && now < 15 { // 中午 - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "午安w", "午觉要好好睡哦,ATRI会陪伴在你身旁的w", "嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o", @@ -103,12 +113,13 @@ func init() { // 插件主体 )) } }) - zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい"}, atriSwitch()).SetBlock(true).SetPriority(prio). + zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい", "晚好","晚上好"}, atriSwitch()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { now := time.Now().Hour() switch { case now < 6: // 凌晨 - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "zzzz......", "zzzzzzzz......", "zzz...好涩哦..zzz....", @@ -117,27 +128,31 @@ func init() { // 插件主体 "...zzz....哧溜哧溜....", )) case now >= 6 && now < 11: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "你可猝死算了吧!", "?啊这", "亲,这边建议赶快去睡觉呢~~~", "不可忍不可忍不可忍!!为何这还不猝死!!", )) case now >= 11 && now < 15: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "午安w", "午觉要好好睡哦,ATRI会陪伴在你身旁的w", "嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o", "睡你午觉去!哼唧!!", )) case now >= 15 && now < 19: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "难不成??晚上不想睡觉??现在休息", "就......挺离谱的...现在睡觉", "现在还是白天哦,睡觉还太早了", )) case now >= 19 && now < 24: - ctx.SendChain(randText( + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), randText( "嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o", "......(打瞌睡)", "呼...呼...已经睡着了哦~...呼......", @@ -147,6 +162,7 @@ func init() { // 插件主体 }) zero.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) ctx.SendChain(randText( "当然,我是高性能的嘛~!", "小事一桩,我是高性能的嘛", @@ -167,6 +183,7 @@ func init() { // 插件主体 }) zero.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) ctx.SendChain(randText( "当然,我是高性能的嘛~!", "没事没事,因为我是高性能的嘛!嗯哼!", @@ -181,22 +198,26 @@ func init() { // 插件主体 zero.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) if rand.Intn(2) == 0 { ctx.SendChain(randImage("YES.png", "NO.jpg")) } }) - zero.OnFullMatchGroup([]string{"啊这"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). + zero.OnKeywordGroup([]string{"啊这"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) if rand.Intn(2) == 0 { ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg")) } }) - zero.OnFullMatchGroup([]string{"我好了"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). + zero.OnKeywordGroup([]string{"我好了"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { - ctx.SendChain(randText("不许好!", "憋回去!")) + time.Sleep(time.Second * 1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(randText("不许好!", "憋回去!"))) }) zero.OnFullMatchGroup([]string{"?", "?", "¿"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) switch rand.Intn(5) { case 0: ctx.SendChain(randText("?", "?", "嗯?", "(。´・ω・)ん?", "ん?")) @@ -215,6 +236,7 @@ func init() { // 插件主体 }) zero.OnKeyword("答应我", atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio). Handle(func(ctx *zero.Ctx) { + time.Sleep(time.Second * 1) ctx.SendChain(randText("我无法回应你的请求")) }) } diff --git a/plugin_bilibili/fansDaily.go b/plugin_bilibili/fansDaily.go index 9b5c3dae..12b0d800 100644 --- a/plugin_bilibili/fansDaily.go +++ b/plugin_bilibili/fansDaily.go @@ -25,7 +25,7 @@ type follower struct { func init() { zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission). Handle(func(ctx *zero.Ctx) { - fansDaily(130591566) // 群号传进去给下面发信息的函数 + fansDaily(ctx.Event.GroupID) // 群号传进去给下面发信息的函数 }) } diff --git a/plugin_diana/data/text.proto b/plugin_diana/data/text.proto index eb981734..2e9a0b52 100644 --- a/plugin_diana/data/text.proto +++ b/plugin_diana/data/text.proto @@ -2,5 +2,5 @@ syntax = "proto3"; package data; message composition { - repeated string array = 1; + repeated string array = 1; } diff --git a/plugin_manager/manager.proto b/plugin_manager/manager.proto index cd53bf10..5b76c02d 100644 --- a/plugin_manager/manager.proto +++ b/plugin_manager/manager.proto @@ -2,6 +2,6 @@ syntax = "proto3"; package manager; message config { - map checkin = 1; - map welcome = 2; + map checkin = 1; + map welcome = 2; } diff --git a/plugin_qingyunke/cron.go b/plugin_qingyunke/cron.go new file mode 100644 index 00000000..0ed0c4b6 --- /dev/null +++ b/plugin_qingyunke/cron.go @@ -0,0 +1,73 @@ +package qingyunke + +//定时早安,晚安 +import ( + "github.com/robfig/cron" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "log" + "math/rand" + "strconv" + "time" +) + +func init() { + //所有群添加定时早安 + + zero.OnCommand("daily").SetBlock(false).FirstPriority().Handle(func(ctx *zero.Ctx) { + log.Println(ctx.GetGroupList()) + result := ctx.GetGroupList() + for _, v := range result.Array() { + Daily(v.Get("group_id").Int()) + } + + }) + + +} + +func morningData(groupId int64) { + zero.RangeBot(func(id int64, ctx *zero.Ctx) bool { + time.Sleep(time.Second * 1) + ctx.SendGroupMessage(groupId, message.Image(getPicture())) + ctx.SendGroupMessage(groupId, randText("啊......早上好...(哈欠)", + "唔......吧唧...早上...哈啊啊~~~\n早上好......", + "早上好......", + "早上好呜......呼啊啊~~~~", + "啊......早上好。\n昨晚也很激情呢!", + "吧唧吧唧......怎么了...已经早上了么...", + "早上好!", + "......看起来像是傍晚,其实已经早上了吗?", + "早上好......欸~~~脸好近呢")) + return true + }) +} + +func eveningData(groupId int64) { + zero.RangeBot(func(id int64, ctx *zero.Ctx) bool { + time.Sleep(time.Second * 1) + ctx.SendGroupMessage(groupId, message.Image(getPicture())) + ctx.SendGroupMessage(groupId, randText("嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o", + "......(打瞌睡)", + "呼...呼...已经睡着了哦~...呼......", + "......我、我会在这守着你的,请务必好好睡着")) + return true + }) +} + +func Daily(groupId int64) { + log.Println("给" + strconv.FormatInt(groupId, 10) + "添加定时任务") + c := cron.New() + _ = c.AddFunc("0 30 7 * * ?", func() { + morningData(groupId) + }) + _ = c.AddFunc("0 30 22 * * ?", func() { + eveningData(groupId) + }) + c.Start() +} + +func randText(text ...string) message.MessageSegment { + length := len(text) + return message.Text(text[rand.Intn(length)]) +} diff --git a/plugin_qingyunke/picture.go b/plugin_qingyunke/picture.go new file mode 100644 index 00000000..94ca378b --- /dev/null +++ b/plugin_qingyunke/picture.go @@ -0,0 +1,56 @@ +package qingyunke + +import ( + "fmt" + "io/ioutil" + "log" + "math/rand" + "net/http" + "regexp" +) + +var ( + reImg = `https?://[^"]+?(\.((jpg)|(png)|(jpeg)|(gif)|(bmp)))` +) +//取图片 +func getPicture() string { + prefix := "https://fabiaoqing.com/tag/detail/id/5682/page" + url := fmt.Sprintf("%d.html", rand.Intn(11)+1) + url = prefix + url + log.Println("正在" + url + "寻找图片") + urls := getImgs(url) + fmt.Println(urls) + imageUrl := urls[rand.Intn(len(urls))] + log.Println("取到" + imageUrl) + return imageUrl +} + +func HandleError(err error, why string) { + if err != nil { + fmt.Println(why, err) + } +} + +func getImgs(url string) (urls []string) { + pageStr := GetPageStr(url) + re := regexp.MustCompile(reImg) + results := re.FindAllStringSubmatch(pageStr, -1) + fmt.Printf("共找到%d条结果\n", len(results)) + for _, result := range results { + url := result[0] + urls = append(urls, url) + } + return +} + +func GetPageStr(url string) (pageStr string) { + resp, err := http.Get(url) + HandleError(err, "http.Get url") + defer resp.Body.Close() + // 2.读取页面内容 + pageBytes, err := ioutil.ReadAll(resp.Body) + HandleError(err, "ioutil.ReadAll") + // 字节转字符串 + pageStr = string(pageBytes) + return pageStr +} diff --git a/plugin_qingyunke/qingyunke.go b/plugin_qingyunke/qingyunke.go new file mode 100644 index 00000000..2967aa37 --- /dev/null +++ b/plugin_qingyunke/qingyunke.go @@ -0,0 +1,160 @@ +package qingyunke + +import ( + "encoding/json" + "fmt" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/extension/rate" + "github.com/wdvxdr1123/ZeroBot/message" + "io/ioutil" + "math/rand" + "net/http" + "regexp" + "strconv" + "strings" + "time" +) + +var prio = -1 +var poke = rate.NewManager(time.Minute, 20) // 青云客接口回复 +var enable = true + +func init() { // 插件主体 + // 被喊名字 + zero.OnRegex("(^.{1,30}$)", zero.OnlyToMe, atriSwitch()).SetBlock(false).FirstPriority(). + Handle(func(ctx *zero.Ctx) { + switch { + case poke.Load(ctx.Event.UserID).Acquire(): + time.Sleep(time.Second * 1) + msg := ctx.State["regex_matched"].([]string)[1] + fmt.Println(msg) + reply := getMessage(msg) + reg := regexp.MustCompile(`\{face:(\d+)\}(.*)`) + faceReply := -1 + var textReply string + if reg.MatchString(reply) { + fmt.Println(reg.FindStringSubmatch(reply)) + faceReply, _ = strconv.Atoi(reg.FindStringSubmatch(reply)[1]) + textReply = reg.FindStringSubmatch(reply)[2] + } else { + textReply = reply + } + textReply = strings.Replace(textReply, "菲菲", "椛椛", -1) + if ctx.Event.DetailType == "group" { + + if faceReply != -1 { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply), message.Face(faceReply)) + } else { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply)) + } + + } + if ctx.Event.DetailType == "private" { + if faceReply != -1 { + ctx.SendChain(message.Text(textReply), message.Face(faceReply)) + } else { + ctx.SendChain(message.Text(textReply)) + } + } + + default: + //频繁触发,不回复 + } + + }) + zero.OnRegex("CQ:image,file=|CQ:face,id=", zero.OnlyToMe, atriSwitch()).SetBlock(false).FirstPriority(). + Handle(func(ctx *zero.Ctx) { + imageUrl := getPicture() + time.Sleep(time.Second * 1) + if ctx.Event.DetailType == "group" { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image(imageUrl)) + } + if ctx.Event.DetailType == "private" { + ctx.SendChain(message.Image(imageUrl)) + } + + }) + + zero.OnFullMatch("开启自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio). + Handle(func(ctx *zero.Ctx) { + + enable = true + ctx.SendChain(message.Text("自动回复开启")) + + }) + zero.OnFullMatch("关闭自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio). + Handle(func(ctx *zero.Ctx) { + + enable = false + ctx.SendChain(message.Text("自动回复关闭")) + + }) + + // 群空调 + +} + +type QYData struct { + Result int `json:"result"` + Content string `json:"content"` +} + +//青云客取消息 +func getMessage(msg string) string { + url := "http://api.qingyunke.com/api.php" + key := "free" + appid := "0" + //msg := "早上好" + url = fmt.Sprintf(url+"?key=%s&appid=%s&msg=%s", key, appid, msg) + fmt.Println(url) + + client := &http.Client{} + req, err := http.NewRequest("GET", url, nil) + if err != nil { + fmt.Println("new.request", err) + } + // 自定义Header + req.Header.Set("User-Agent", getAgent()) + req.Header.Set("Connection", "keep-alive") + req.Header.Set("Host", "api.qingyunke.com") + resp, err := client.Do(req) + if err != nil { + fmt.Println("http.get.url", err) + } + + defer resp.Body.Close() + bytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Println("ioutil.ReadAll", err) + } + fmt.Println(string(bytes)) + var QYData QYData + if err := json.Unmarshal(bytes, &QYData); err != nil { + fmt.Println("json transform", err) + } + return QYData.Content +} + +func getAgent() string { + agent := [...]string{ + "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0", + "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11", + "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11", + "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)", + "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", + "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)", + "User-Agent,Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50", + "User-Agent, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)", + "User-Agent,Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50", + } + + r := rand.New(rand.NewSource(time.Now().UnixNano())) + len1 := len(agent) + return agent[r.Intn(len1)] +} + +func atriSwitch() zero.Rule { + return func(ctx *zero.Ctx) bool { + return enable + } +} diff --git a/plugin_qingyunke/request.go b/plugin_qingyunke/request.go new file mode 100644 index 00000000..b1a08835 --- /dev/null +++ b/plugin_qingyunke/request.go @@ -0,0 +1,22 @@ +package qingyunke +import ( + + zero "github.com/wdvxdr1123/ZeroBot" + "log" + +) +//自动同意加群,加好友 +func init() { + zero.OnRequest().SetBlock(false).FirstPriority().Handle(func(ctx *zero.Ctx) { + if ctx.Event.RequestType == "friend"{ + log.Println("加好友") + ctx.SetFriendAddRequest(ctx.Event.Flag,true,"") + } + if ctx.Event.RequestType == "group" && ctx.Event.SubType == "invite"{ + log.Println("加群") + ctx.SetGroupAddRequest(ctx.Event.Flag,"invite",true,"我爱你,mua~") + } + }) + + +}