Compare commits

..

84 Commits

Author SHA1 Message Date
源文雨
29144348b3 🔖 1.4.1-beta5 2022-06-04 17:27:08 +08:00
源文雨
2f91b11672 fix manager 2022-06-04 15:01:00 +08:00
源文雨
caf0ef88ac update control 2022-06-04 14:55:15 +08:00
源文雨
c8154db108 fix workflow 2022-06-02 12:38:46 +08:00
源文雨
7ce6b5592a 🎨 优化代码格式 2022-06-02 12:30:38 +08:00
源文雨
e1bc4fdf36 优化 score 2022-06-02 12:29:37 +08:00
MoeMagicMango
fd7f5f719f fix:修复API变动造成图片无法返回的问题 (#250) 2022-06-02 12:20:17 +08:00
源文雨
6678ca6c93 💩👌 make lint happy 2022-06-02 12:19:41 +08:00
源文雨
180e03e249 try fixing #249: once SIGSEGV 2022-05-30 14:43:08 +08:00
源文雨
357f15eb01 🔖 1.4.1-beta4 2022-05-29 13:11:24 +08:00
未归404
a08704b60f 更新README.md (#247) 2022-05-29 12:50:36 +08:00
源文雨
03ba81a9c5 🎨 优化 bilibiliparse 2022-05-27 19:16:13 +08:00
源文雨
2933962df8 🎨 优化 bilibiliparse 2022-05-27 19:09:44 +08:00
源文雨
4f248c4dc7 🎨 优化 bilibiliparse 2022-05-27 19:09:07 +08:00
源文雨
14096f24ba add 设置默认限速 #241 2022-05-27 01:00:48 +08:00
源文雨
c0b75accf4 fix #243: add ctrl /改变默认启用状态 2022-05-27 00:41:44 +08:00
源文雨
cb1b7d5da7 add more limiter (#241) 2022-05-26 13:55:14 +08:00
源文雨
c8072171f0 🔖 1.4.1-beta3 2022-05-25 11:58:32 +08:00
源文雨
485f6d4cef 🐛 job panic 2022-05-25 11:58:01 +08:00
源文雨
2b85097e30 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-05-24 10:56:15 +08:00
源文雨
0904789291 🔖 1.4.1-beta2 2022-05-24 10:56:00 +08:00
方柳煜
fda69793a5 修复单身技能会报错问题 (#237) 2022-05-24 10:54:11 +08:00
源文雨
3c22aaf99d 🐛 job panic 2022-05-24 10:52:49 +08:00
MoeMagicMango
151a5d480f Fix: 更换稳定的背景api + 修复因api问题签到结果无法出现但数据库已经记录的问题 (#236)
* 通过修改顺序解决签到背景API出问题

* Update sign_in.go

* 🎨 改进代码样式

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-21 22:53:20 +08:00
源文雨
88d136626d update deps 2022-05-20 23:36:46 +08:00
源文雨
170f5bba79 🔖 1.4.1-beta1 2022-05-20 21:15:45 +08:00
源文雨
c4cbb0cd59 添加我问你答 2022-05-20 21:13:49 +08:00
源文雨
0fa04070f1 Update README.md 2022-05-20 15:23:39 +08:00
方柳煜
f8bea241a2 修复小三技能的判断逻辑的缺陷 (#230) 2022-05-16 22:51:54 +08:00
github-actions[bot]
bb6b2e4b29 🎨 改进代码样式 2022-05-16 14:45:37 +00:00
源文雨
557251a679 saucenao 搜图 使用合并转发 2022-05-16 22:44:47 +08:00
github-actions[bot]
696783b0fe 🎨 改进代码样式 2022-05-16 06:42:24 +00:00
源文雨
6eb29d2cc9 🔖 1.4.0 2022-05-16 14:41:45 +08:00
github-actions[bot]
4b4cafcda8 🎨 改进代码样式 2022-05-16 05:40:05 +00:00
方柳煜
ed2ed8d968 修复CD共用问题,新增功能 (#229) 2022-05-16 13:39:48 +08:00
Jiang-Red
fbb387bd9f fix:saucenao插件搜图相似度判断 (#228) 2022-05-14 23:50:25 +08:00
源文雨
0db2db482f 🐛 job 注入指令结果 递归 2022-05-14 19:10:05 +08:00
himawari
af2fe727fc 添加拟声鸟类型和马丁路德骂人语录 (#227)
*  mockingbird添加类型

*  添加马丁路德骂人语录

Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
2022-05-14 11:32:25 +08:00
源文雨
a7387dcf22 💩👌 make lint happy 2022-05-13 13:12:39 +08:00
github-actions[bot]
5ce44fb161 🎨 改进代码样式 2022-05-13 05:09:55 +00:00
Jiang-Red
9086b9c3ca 修复一个小问题 (#225) 2022-05-13 13:09:13 +08:00
github-actions[bot]
4837c5387a 🎨 改进代码样式 2022-05-13 05:08:51 +00:00
源文雨
5d73216238 🐛 saucenao reflect 2022-05-13 13:08:02 +08:00
源文雨
5053091e44 💩👌 make lint happy 2022-05-13 13:00:54 +08:00
源文雨
6319ed0473 hide saucenao error 2022-05-12 19:07:59 +08:00
源文雨
c67c109af6 优化 qqwife 2022-05-12 14:43:30 +08:00
源文雨
b3cdb1464b 优化 imagefinder 2022-05-12 14:05:18 +08:00
源文雨
3c01c3f0ba 优化 danbooru 2022-05-12 14:01:24 +08:00
源文雨
07d541be20 🔖 1.4.0-beta7 2022-05-12 12:38:12 +08:00
源文雨
4a0dc59585 优化 saucenao 2022-05-12 12:27:02 +08:00
源文雨
b1dd8f52e8 edit README 2022-05-12 11:24:53 +08:00
github-actions[bot]
6907fe230f 🎨 改进代码样式 2022-05-12 03:23:21 +00:00
方柳煜
f2e4071b90 修复单身狗技能逻辑 (#224)
* ⬆️ update deps

* 更改源酱提出的问题

* Update qqmapwife.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-05-12 11:22:07 +08:00
源文雨
452f5e5f83 💩👌 make lint happy 2022-05-12 11:21:20 +08:00
源文雨
c94b9f54ce ⬆️ update deps 2022-05-10 23:34:09 +08:00
源文雨
e993f93cf4 🔖 1.4.0-beta6 2022-05-10 23:22:57 +08:00
源文雨
e9fac38c1b 🔖 1.4.0-beta6 2022-05-10 23:00:20 +08:00
源文雨
31a49b8ff9 fix: gif 503 2022-05-10 22:52:46 +08:00
源文雨
7831cdf10c fix: groupwife url 2022-05-09 12:22:36 +08:00
源文雨
c0f176f0af fix #173: 今日早报变成昨日火星晚报 2022-05-09 12:18:57 +08:00
源文雨
dc96a557eb 🔖 1.4.0-beta5 2022-05-09 12:12:18 +08:00
源文雨
7a8c915e62 优化代码结构 2022-05-09 11:23:34 +08:00
github-actions[bot]
dec42cc72b 🎨 改进代码样式 2022-05-09 03:09:45 +00:00
方柳煜
92c9d1d2ce 一天一夫一妻制群老婆 (#219) 2022-05-09 11:08:22 +08:00
Kanri
de017fcd27 Update README.md 2022-05-09 01:57:38 +08:00
MSCxar#0293
1229f62abd README.md: 新增tg群组 (#222)
* README.md: 新增tg群组
2022-05-09 01:38:21 +08:00
github-actions[bot]
512852b817 🎨 改进代码样式 2022-05-08 14:13:47 +00:00
himawari
5a087000a9 🐛 疫情查询、网易点歌、qq点歌问题 (#220)
* 🐛 修复网易点歌,qq点歌问题

* 🚨 错误输出

* 🚨 错误输出
2022-05-08 22:12:27 +08:00
莫思潋
6b56d6649e feat:解塔罗牌 (#217) 2022-05-08 18:31:18 +08:00
林沐馨
5081aab497 fix #215: 摸鱼日历 (#143)
* Update calendar.go

更换API方式

* Update calendar.go

* 更换API

修复BUG

* 🎨 改进代码样式

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-07 22:35:32 +08:00
源文雨
bbb4afde53 fix: kanban scale 2022-05-06 22:30:51 +08:00
源文雨
d28495c3eb 优化显示 2022-05-06 21:11:29 +08:00
源文雨
1785e0c4a3 优化显示 2022-05-06 21:09:47 +08:00
源文雨
1e93e75aac add kanban 2022-05-06 21:06:45 +08:00
github-actions[bot]
a3ed7eeee2 🎨 改进代码样式 2022-05-06 12:04:03 +00:00
himawari
c3582637df 🎨 查成分增加可选择查uid (#214)
*  查成分添加注册日期信息

* 🐛 修复头像是webp图片使用不了的问题

* 🎨 查成分增加可选择查uid
2022-05-06 20:02:36 +08:00
源文雨
3b277b0eb0 搜图 drop yandex 2022-05-06 18:54:39 +08:00
源文雨
5e0991681f 抽n张塔罗牌 2022-05-05 14:19:52 +08:00
源文雨
354fbb7cdd 抽n张塔罗牌 2022-05-05 14:19:33 +08:00
源文雨
a166d06096 抽n张塔罗牌 2022-05-05 14:19:12 +08:00
源文雨
b8a6e07095 优化每日随机 2022-05-05 13:50:54 +08:00
源文雨
a8fba6e7b5 优化GetLazyData 2022-05-05 13:31:22 +08:00
源文雨
17a8c10f8c 🎨 modify badge 2022-05-04 23:40:37 +08:00
源文雨
7ccd29faac 🎨 modify badge 2022-05-04 23:40:01 +08:00
92 changed files with 1276 additions and 1547 deletions

BIN
.github/gopher.jpg vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -24,13 +24,13 @@ jobs:
goarch: arm64
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@master
- name: Setup Go environment
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@master
with:
go-version: 1.18
- name: Cache downloaded module
uses: actions/cache@v2
uses: actions/cache@master
with:
path: |
~/.cache/go-build
@@ -48,7 +48,7 @@ jobs:
export CGO_ENABLED=0
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@master
if: ${{ !github.head_ref }}
with:
name: ${{ matrix.goos }}_${{ matrix.goarch }}

View File

@@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: 1.18
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master

View File

@@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: 1.18
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master

View File

@@ -9,17 +9,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: '1.18'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@master
with:
version: latest
args: release --rm-dist

BIN
.github/yaya.jpg vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

BIN
.github/黒金.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@@ -1,27 +1,32 @@
<div align="center">
<img src=".github/gopher.jpg" width = "200" height = "150" alt="Gopher"><br>
<a href="https://crypko.ai/crypko/5k8HyUVTq5421/">
<img src=".github/黒金.jpg" alt="看板娘" width = "400">
</a><br>
<h1>ZeroBot-Plugin</h1>
ZeroBot-Plugin 是 ZeroBot 的 实用插件合集<br><br>
<img src="http://sayuri.fumiama.top/cmoe?name=ZeroBot-Plugin&theme=r34" />
[![GOCQ](https://img.shields.io/badge/OneBot-MiraiGo-green.svg?style=social&logo=appveyor)](https://github.com/Mrs4s/go-cqhttp)
[![OICQ](https://img.shields.io/badge/OneBot-OICQ-green.svg?style=social&logo=appveyor)](https://github.com/takayama-lily/node-onebot)
[![MIRAI](https://img.shields.io/badge/OneBot-Mirai-green.svg?style=social&logo=appveyor)](https://github.com/yyuueexxiinngg/onebot-kotlin)
<img src="http://cmoe.azurewebsites.net/cmoe?name=ZeroBot-Plugin&theme=r34" /><br>
[![Go Report Card](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/report/github.com/github.com/FloatTech/ZeroBot-Plugin)
[![Badge](https://img.shields.io/badge/onebot-v11-black?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://github.com/howmanybots/onebot)
[![Badge](https://img.shields.io/badge/zerobot-v1.5.1-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot)
[![License](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
[![qq group](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
[![miraigo](https://img.shields.io/badge/OneBot-MiraiGo-green.svg?style=social&logo=appveyor)](https://github.com/Mrs4s/MiraiGo)
[![oicq](https://img.shields.io/badge/OneBot-OICQ-green.svg?style=social&logo=appveyor)](https://github.com/takayama-lily/oicq)
[![mirai](https://img.shields.io/badge/OneBot-Mirai-green.svg?style=social&logo=appveyor)](https://github.com/mamoe/mirai)
本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互
| 项目地址 | 平台 | 核心作者 |
| --- | --- | --- |
| [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 |
[![go](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin)
[![onebot](https://img.shields.io/badge/onebot-v11-black?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://t.me/zerobotplugin)
[![zerobot](https://img.shields.io/badge/zerobot-v1.5.1-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot)
[![license](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
[![tencent-qq](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
[![telegram](https://img.shields.io/badge/Telegram-click%20me-informational?style=flat-square&logo=telegram)](https://t.me/zerobotplugin)
本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互
| 项目地址 | 平台 | 核心作者 |
| --- | --- | --- |
| [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 |
</div>
> 如果您不知道什么是 [OneBot](https://github.com/howmanybots/onebot) 或不希望运行多个程序,还可以直接前往 [gocqzbp](https://github.com/FloatTech/gocqzbp) 的 [Release](https://github.com/FloatTech/gocqzbp/releases) 页面下载单一可执行文件或前往 [Packages](https://github.com/FloatTech/gocqzbp/pkgs/container/gocqzbp) 页面使用`docker`,运行后按提示登录即可。
@@ -88,6 +93,8 @@ zerobot [-c config.json] [-h] [-s config.json] [-t token] [-u url] [-n nickname]
- 注:当全局未配置或与默认相同时,状态取决于单独配置,后备为默认配置;当全局与默认不同时,状态取决于全局配置,单独配置失效。
- [x] /改变默认启用状态 xxx
- [x] /禁止 service qq1 qq2... (禁止 qqs 使用服务 service)
- [x] /允许 service qq1 qq2... (重新允许 qqs 使用服务 service)
@@ -313,6 +320,15 @@ print("run[CQ:image,file="+j["img"]+"]")
```
![随机b站404页趣图](https://user-images.githubusercontent.com/41315874/157371451-c09ad3bb-c61a-4a42-9c47-fab3305bc0f8.png)
- [x] [我|大家|有人][说|问][正则表达式]你[答|说|做|执行][模版]
- [x] [查看|看看][我|大家|有人][说|问][正则表达式]
- [x] 删除[大家|有人|我][说|问|让你做|让你执行][正则表达式]
- 注:模版是指含有`$1` `$2`这样的未定参数,会在正则匹配时按顺序填入子匹配对应值
</details>
### *中优先级*
@@ -324,11 +340,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]
- [x] 清理缓存 (仅适用于 gocq 且需要 bot 的运行目录和 gocq 相同)
- [ ] 简易语音
- [ ] 爬图合成 [@xxx]
- [x] 设置默认限速为每 m [分钟 | 秒] n 次触发
</details>
<details>
@@ -476,6 +488,20 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global
</details>
<details>
<summary>一群一天一夫一妻制群老婆</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife"`
- [x] 娶群友
- [x] (娶|嫁)[@对方QQ]
- [x] 当[对方Q号|@对方QQ]的小三
- [x] 群老婆列表
</details>
<details>
<summary>合成emoji</summary>
@@ -614,8 +640,15 @@ print("run[CQ:image,file="+j["img"]+"]")
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon"`
- [x] 来份萝莉
- [x] 设置随机图片地址[http...]
- 每一小时发一张图
```
记录在"@every 1h"触发的指令
来份萝莉
```
</details>
<details>
<summary>摸鱼</summary>
@@ -772,12 +805,26 @@ print("run[CQ:image,file="+j["img"]+"]")
</details>
<details>
<summary>签到得分</summary>
<summary>签到得分</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/score"`
- [x] 签到
- [x] 获得签到背景[@xxx] | 获得签到背景
- [x] 获得签到背景[@xxx] | 获得签到背景
</details>
<details>
<summary>沙雕app</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao"`
- [x] 哄我
- [x] 渣我
- [x] 来碗绿茶
- [x] 发个朋友圈
- [x] 来碗毒鸡汤
- [x] 讲个段子
- [x] 马丁路德骂我
</details>
<details>
@@ -802,6 +849,8 @@ print("run[CQ:image,file="+j["img"]+"]")
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot"`
- [x] 抽塔罗牌
- [x] 抽n张塔罗牌
- [x] 解塔罗牌[牌名]
</details>
<details>

2
data

Submodule data updated: f2fa48b3d7...291200d5d4

9
go.mod
View File

@@ -3,9 +3,10 @@ module github.com/FloatTech/ZeroBot-Plugin
go 1.18
require (
github.com/FloatTech/AnimeAPI v1.3.4-0.20220502025309-31a6d419159b
github.com/FloatTech/AnimeAPI v1.4.1-0.20220604065331-115868b47839
github.com/FloatTech/sqlite v0.2.1
github.com/FloatTech/zbputils v1.3.4-0.20220504132117-3a5af38dd86c
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c
github.com/FloatTech/zbputils v1.4.1-0.20220604092500-954a65b4b453
github.com/antchfx/htmlquery v1.2.4
github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0
@@ -17,13 +18,14 @@ require (
github.com/fumiama/sqlite3 v1.14.6
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/jinzhu/gorm v1.9.16
github.com/jozsefsallai/gophersauce v1.0.1
github.com/mroth/weightedrand v0.4.1
github.com/pkumza/numcn v1.0.0
github.com/shirou/gopsutil/v3 v3.22.3
github.com/sirupsen/logrus v1.8.1
github.com/tidwall/gjson v1.14.1
github.com/wcharczuk/go-chart/v2 v2.1.0
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220429121512-29258eb2cd2d
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220509035736-f3ad8fa960d7
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
)
@@ -33,6 +35,7 @@ require (
github.com/antchfx/xpath v1.2.0 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/uuid v1.3.0 // indirect

20
go.sum
View File

@@ -1,11 +1,11 @@
github.com/FloatTech/AnimeAPI v1.3.4-0.20220502025309-31a6d419159b h1:mpNsief6QSIMxXa/HtnIrbnGx4FKeAweyaMUquoMIxE=
github.com/FloatTech/AnimeAPI v1.3.4-0.20220502025309-31a6d419159b/go.mod h1:jOKIH5uRC3LAjjCRKgABLeUZcuA/s4TGVv2kNYYoZWc=
github.com/FloatTech/AnimeAPI v1.4.1-0.20220604065331-115868b47839 h1:qwALmfMjUnGdXWL3Nee9Dm744HMOP5taFeHM6dsKp2s=
github.com/FloatTech/AnimeAPI v1.4.1-0.20220604065331-115868b47839/go.mod h1:SycOnpdMaSzRjthUUfI+mr/d2rsEwleaNW+RXoTO3ms=
github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8=
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
github.com/FloatTech/zbputils v1.3.4-0.20220502024941-dfe3f750de64 h1:LeEJpTCdh8GQxDmh0Yw82smpMNA1zuoyK4P5wn+vdr0=
github.com/FloatTech/zbputils v1.3.4-0.20220502024941-dfe3f750de64/go.mod h1:yYXxsdc8fouB9yd2XMr17wso2TV0fH1ukARwhV3U43M=
github.com/FloatTech/zbputils v1.3.4-0.20220504132117-3a5af38dd86c h1:oG8Mv4ikGm9Rle8HAN5NytwZ1atuvH8y2xLFkJGlDEU=
github.com/FloatTech/zbputils v1.3.4-0.20220504132117-3a5af38dd86c/go.mod h1:yYXxsdc8fouB9yd2XMr17wso2TV0fH1ukARwhV3U43M=
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c h1:1LhskkE5oP1Y2Vi9f4/s5Lns5M5vIzvGAAwJ4z23h+o=
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c/go.mod h1:x57TwTlC6zGhs+HHzWATD0sabyoDpSt8b7OzV3Mvrdc=
github.com/FloatTech/zbputils v1.4.1-0.20220604092500-954a65b4b453 h1:kNW9zJY0afK63DBtrVjW+wE83YoHHBVmQkPSGC8pV70=
github.com/FloatTech/zbputils v1.4.1-0.20220604092500-954a65b4b453/go.mod h1:xlw8tTnwv+pglm2WZTDr/9Gl767ALYBguwsqibDqYpI=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
@@ -44,6 +44,8 @@ github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6
github.com/fumiama/gotracemoe v0.0.3/go.mod h1:tyqahdUzHf0bQIAVY/GYmDWvYYe5ik1ZbhnGYh+zl40=
github.com/fumiama/sqlite3 v1.14.6 h1:+e+iygyiDXQJVi7xeXIviBvR7hAc5y20WA9hRwfKn10=
github.com/fumiama/sqlite3 v1.14.6/go.mod h1:Xx9a2/OtHuy9pBjow0N+bE/RhNeZ7zZz5xh25vqbA5A=
github.com/gabriel-vasile/mimetype v1.0.4 h1:uBejfH8l3/2f+5vjl1e4xIaSyNEhRBZ5N/ij7ohpNd8=
github.com/gabriel-vasile/mimetype v1.0.4/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
@@ -67,6 +69,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jozsefsallai/gophersauce v1.0.1 h1:BA3ovtQRrAb1qYU9JoRLbDHpxnDunlNcEkEfhCvDDCM=
github.com/jozsefsallai/gophersauce v1.0.1/go.mod h1:YVEI7djliMTmZ1Vh01YPF8bUHi+oKhe3yXgKf1T49vg=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@@ -109,8 +113,8 @@ github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220429121512-29258eb2cd2d h1:gi/AuWH5LRwdKzftIqMA/YGrI1g82E8Ol80HG+u3evU=
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220429121512-29258eb2cd2d/go.mod h1:LJ+VOf523i3IrykuLK53UEeWqnAclRL5d2wGT4sS4Zk=
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220509035736-f3ad8fa960d7 h1:GDJ+ZhbaGGBdlaT6qljgt61A/rlZdrNtA5fQyb5uVP4=
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20220509035736-f3ad8fa960d7/go.mod h1:LJ+VOf523i3IrykuLK53UEeWqnAclRL5d2wGT4sS4Zk=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=

View File

@@ -10,7 +10,7 @@ import (
var (
info = [...]string{
"* OneBot + ZeroBot + Golang",
"* Version 1.4.0-beta4 - 2022-05-04 23:21:30 +0800 CST",
"* Version 1.4.1-beta5 - 2022-06-04 17:26:44 +0800 CST",
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}

View File

@@ -96,6 +96,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" // 铅笔小说网搜索
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图

View File

@@ -4,24 +4,39 @@ package aifalse
import (
"fmt"
"math"
"os"
"strconv"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/mem"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
engine := control.Register("aifalse", &control.Options{
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "AIfalse\n" +
"- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]",
"- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" +
"- 设置默认限速为每 m [分钟 | 秒] n 次触发",
})
c, ok := control.Lookup("aifalse")
if !ok {
panic("register aifalse error")
}
m := c.GetData(0)
n := (m >> 16) & 0xffff
m &= 0xffff
if m != 0 || n != 0 {
ctxext.SetDefaultLimiterManagerParam(time.Duration(m)*time.Second, int(n))
logrus.Infoln("设置默认限速为每", m, "秒触发", n, "次")
}
engine.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(
@@ -31,14 +46,41 @@ func init() { // 插件主体
),
)
})
engine.OnFullMatch("清理缓存", zero.SuperUserPermission).SetBlock(true).
engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := os.RemoveAll("data/cache/*")
if err != nil {
ctx.SendChain(message.Text("错误: ", err.Error()))
} else {
ctx.SendChain(message.Text("成功!"))
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("ERROR:no such plugin"))
return
}
m, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if ctx.State["regex_matched"].([]string)[2] == "分钟" {
m *= 60
}
if m >= 65536 || m <= 0 {
ctx.SendChain(message.Text("ERROR:interval too big"))
return
}
n, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[3], 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if n >= 65536 || n <= 0 {
ctx.SendChain(message.Text("ERROR:burst too big"))
return
}
ctxext.SetDefaultLimiterManagerParam(time.Duration(m)*time.Second, int(n))
err = c.SetData(0, (m&0xffff)|((n<<16)&0xffff0000))
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("设置默认限速为每", m, "秒触发", n, "次"))
})
}

View File

@@ -1,7 +1,6 @@
package aireply
import (
"errors"
"regexp"
"strconv"
"sync"
@@ -15,6 +14,7 @@ import (
"github.com/FloatTech/AnimeAPI/tts"
"github.com/FloatTech/AnimeAPI/tts/baidutts"
"github.com/FloatTech/AnimeAPI/tts/mockingbird"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
@@ -45,25 +45,31 @@ func init() {
"百度度逍遥": baidutts.NewBaiduTTS(3),
"百度度丫丫": baidutts.NewBaiduTTS(4),
"拟声鸟阿梓": nil,
"拟声鸟文静": nil,
"拟声鸟药水哥": nil,
},
l: []string{"拟声鸟阿梓", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"},
l: []string{"拟声鸟阿梓", "拟声鸟文静", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"},
}
engine := control.Register(ttsServiceName, &control.Options{
engine := control.Register(ttsServiceName, &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "语音回复(包括拟声鸟和百度)\n" +
"- @Bot 任意文本(任意一句话回复)\n" +
"- 设置语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" +
"- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n",
"- 设置语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" +
"- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n",
})
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
r := aireply.NewAIReply(getReplyMode(ctx))
tts := t.new(t.getSoundMode(ctx))
tts, err := t.new(t.getSoundMode(ctx))
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
var reply string
if tts != nil {
ctx.SendChain(message.Record(tts.Speak(ctx.Event.UserID, func() string {
reply := r.TalkPlain(msg, zero.BotConfig.NickName[0])
rec, err := tts.Speak(ctx.Event.UserID, func() string {
reply = r.TalkPlain(msg, zero.BotConfig.NickName[0])
reply = re.ReplaceAllStringFunc(reply, func(s string) string {
f, err := strconv.ParseFloat(s, 64)
if err != nil {
@@ -74,7 +80,12 @@ func init() {
})
log.Debugln("[tts]:", reply)
return reply
})))
})
if err == nil {
ctx.SendChain(message.Record(rec))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
}
}
})
engine.OnRegex(`^设置语音模式(.*)$`, ctxext.FirstValueInList(t)).SetBlock(true).
@@ -96,7 +107,7 @@ func init() {
}
// new 语音简单工厂
func (t *ttsInstances) new(name string) (ts tts.TTS) {
func (t *ttsInstances) new(name string) (ts tts.TTS, err error) {
t.RLock()
ts = t.m[name]
t.RUnlock()
@@ -104,11 +115,15 @@ func (t *ttsInstances) new(name string) (ts tts.TTS) {
switch name {
case "拟声鸟阿梓":
t.Lock()
ts, _ = mockingbird.NewMockingBirdTTS(0)
ts, err = mockingbird.NewMockingBirdTTS(0)
t.Unlock()
case "拟声鸟文静":
t.Lock()
ts, err = mockingbird.NewMockingBirdTTS(1)
t.Unlock()
case "拟声鸟药水哥":
t.Lock()
ts, _ = mockingbird.NewMockingBirdTTS(1)
ts, err = mockingbird.NewMockingBirdTTS(2)
t.Unlock()
}
}
@@ -129,10 +144,7 @@ func (t *ttsInstances) setSoundMode(ctx *zero.Ctx, name string) error {
}
}
t.RUnlock()
m, ok := control.Lookup(ttsServiceName)
if !ok {
return errors.New("no such plugin")
}
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
return m.SetData(gid, index)
}
@@ -141,7 +153,7 @@ func (t *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := control.Lookup(ttsServiceName)
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
t.RLock()
defer t.RUnlock()

View File

@@ -6,7 +6,8 @@ import (
"time"
"github.com/FloatTech/AnimeAPI/aireply"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -19,7 +20,7 @@ const (
var replyModes = [...]string{"青云客", "小爱"}
func init() { // 插件主体
engine := control.Register(replyServiceName, &control.Options{
engine := control.Register(replyServiceName, &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "人工智能回复\n" +
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
@@ -67,7 +68,7 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
if !ok {
return errors.New("no such mode")
}
m, ok := control.Lookup(replyServiceName)
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
return errors.New("no such plugin")
}
@@ -79,7 +80,7 @@ func getReplyMode(ctx *zero.Ctx) (name string) {
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := control.Lookup(replyServiceName)
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
index := m.GetData(gid)
if int(index) < len(replyModes) {

View File

@@ -5,7 +5,8 @@ import (
"fmt"
"math/rand"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -16,7 +17,7 @@ const (
)
func init() { // 插件主体
control.Register("aiwife", &control.Options{
control.Register("aiwife", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "AIWife\n" +
"- waifu | 随机waifu",

View File

@@ -12,7 +12,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/process"
)
@@ -24,7 +25,7 @@ const (
)
func init() { // 插件主体
engine := control.Register(servicename, &control.Options{
engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "本插件基于 ATRI ,为 Golang 移植版\n" +
"- ATRI醒醒\n- ATRI睡吧\n- 萝卜子\n- 喜欢 | 爱你 | 爱 | suki | daisuki | すき | 好き | 贴贴 | 老婆 | 亲一个 | mua\n" +

View File

@@ -4,7 +4,8 @@ package b14coder
import (
"unsafe"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
base14 "github.com/fumiama/go-base16384"
tea "github.com/fumiama/gofastTEA"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -13,7 +14,7 @@ import (
)
func init() {
en := control.Register("base16384", &control.Options{
en := control.Register("base16384", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "base16384加解密\n" +
"- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",

View File

@@ -7,12 +7,13 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
func init() {
control.Register("baidu", &control.Options{
control.Register("baidu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "baidu\n" +
"- 百度下[xxx]",

View File

@@ -5,7 +5,6 @@ import (
"errors"
"io"
"net/http"
"time"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/web"
@@ -43,17 +42,6 @@ func search(keyword string) (r []searchResult, err error) {
return
}
// 用mid搜索,主要拿注册时间
func getCardByMid(mid string) (t string, err error) {
requestURL := "https://account.bilibili.com/api/member/getCardByMid?mid=" + mid
data, err := web.GetData(requestURL)
if err != nil {
return
}
t = time.Unix(gjson.ParseBytes(data).Get("card.regtime").Int(), 0).Format("2006-01-02 15:04:05")
return
}
type follower struct {
Mid int `json:"mid"`
Uname string `json:"uname"`
@@ -115,6 +103,7 @@ type userinfo struct {
Mid string `json:"mid"`
Face string `json:"face"`
Fans int64 `json:"fans"`
Regtime int64 `json:"regtime"`
Attentions []int64 `json:"attentions"`
}

View File

@@ -8,11 +8,13 @@ import (
"image/color"
"os"
"path"
"regexp"
"sort"
"strconv"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img"
@@ -25,7 +27,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
)
var engine = control.Register("bilibili", &control.Options{
var engine = control.Register("bilibili", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "bilibili\n" +
"- >vup info [xxx]\n" +
@@ -35,6 +37,7 @@ var engine = control.Register("bilibili", &control.Options{
"- 更新vup",
PublicDataFolder: "Bilibili",
})
var re = regexp.MustCompile(`^\d+$`)
// 查成分的
func init() {
@@ -43,9 +46,8 @@ func init() {
_ = os.MkdirAll(cachePath, 0755)
var getdb = ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
var err error
dbfile := engine.DataFolder() + "bilibili.db"
_, _ = file.GetLazyData(dbfile, false, false)
vdb, err = initialize(dbfile)
_, _ = engine.GetLazyData("bilibili.db", false)
vdb, err = initialize(engine.DataFolder() + "bilibili.db")
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
@@ -105,15 +107,9 @@ func init() {
))
})
engine.OnRegex(`^查成分\s?(.{1,25})$`, getdb).SetBlock(true).
engine.OnRegex(`^查成分\s?(.{1,25})$`, getdb, getPara).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
searchRes, err := search(keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
id := strconv.FormatInt(searchRes[0].Mid, 10)
id := ctx.State["uid"].(string)
today := time.Now().Format("20060102")
drawedFile := cachePath + id + today + "vupLike.png"
if file.IsExist(drawedFile) {
@@ -170,7 +166,7 @@ func init() {
ctx.SendChain(message.Text("ERROR:", err))
return
}
back = img.Limit(back, backX, backY)
back = img.Size(back, backX, backY).Im
}
if len(vups) > 50 {
ctx.SendChain(message.Text(u.Name + "关注的up主太多了只展示前50个up"))
@@ -184,7 +180,7 @@ func init() {
canvas.DrawImage(back, 0, 0)
}
canvas.SetColor(color.Black)
_, err = file.GetLazyData(text.BoldFontFile, false, true)
_, err = file.GetLazyData(text.BoldFontFile, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
}
@@ -204,10 +200,7 @@ func init() {
canvas.DrawString(fmt.Sprintf("粉丝:%d", u.Fans), 550, 240-h)
canvas.DrawString(fmt.Sprintf("关注:%d", len(u.Attentions)), 1000, 240-h)
canvas.DrawString(fmt.Sprintf("管人痴成分:%.2f%%%d/%d", float64(vupLen)/float64(len(u.Attentions))*100, vupLen, len(u.Attentions)), 550, 320-h)
regtime, err := getCardByMid(u.Mid)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
}
regtime := time.Unix(u.Regtime, 0).Format("2006-01-02 15:04:05")
canvas.DrawString("注册日期:"+regtime, 550, 400-h)
canvas.DrawString("查询日期:"+time.Now().Format("2006-01-02"), 550, 480-h)
for i, v := range vups {
@@ -315,3 +308,51 @@ func int2rbg(t int64) (int64, int64, int64) {
b, g, r := int64(buf[0]), int64(buf[1]), int64(buf[2])
return r, g, b
}
func getPara(ctx *zero.Ctx) bool {
keyword := ctx.State["regex_matched"].([]string)[1]
if !re.MatchString(keyword) {
searchRes, err := search(keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
return true
}
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
ctx.SendChain(message.Text("输入为纯数字请选择查询uid还是用户名输入对应序号\n0. 查询uid\n1. 查询用户名"))
for {
select {
case <-time.After(time.Second * 10):
ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择查询uid"))
ctx.State["uid"] = keyword
return true
case c := <-recv:
msg := c.Event.Message.ExtractPlainText()
num, err := strconv.Atoi(msg)
if err != nil {
ctx.SendChain(message.Text("请输入数字!"))
continue
}
if num < 0 || num > 1 {
ctx.SendChain(message.Text("序号非法!"))
continue
}
if num == 0 {
ctx.State["uid"] = keyword
return true
} else if num == 1 {
searchRes, err := search(keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
return true
}
}
}
}

View File

@@ -94,10 +94,7 @@ func updateVup() error {
uname := value.Get("uname").String()
roomid := value.Get("roomid").Int()
err = vdb.insertVupByMid(mid, uname, roomid)
if err != nil {
return false
}
return true
return err == nil
})
if err != nil {
return err

View File

@@ -2,9 +2,11 @@
package bilibiliparse
import (
"errors"
"regexp"
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/antchfx/htmlquery"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -12,27 +14,29 @@ import (
)
const (
bilibiliRe = "https://www.bilibili.com/video/av[0-9]+|https://www.bilibili.com/video/BV[0-9a-zA-Z]+|https://b23.tv/[0-9a-zA-Z]+|https://www.bilibili.com/video/bv[0-9a-zA-Z]+"
validRe = "https://www.bilibili.com/video/(BV[0-9a-zA-Z]+)"
validRe = "https://www.bilibili.com/video/(BV[0-9a-zA-Z]+)"
)
var re = regexp.MustCompile(validRe)
func init() {
engine := control.Register("bilibiliparse", &control.Options{
engine := control.Register("bilibiliparse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "b站视频链接解析\n" +
"- https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA | https://www.bilibili.com/video/bv1xx411c7BF",
})
engine.OnRegex(bilibiliRe).SetBlock(true).Handle(func(ctx *zero.Ctx) {
bilibiliURL := ctx.State["regex_matched"].([]string)[0]
engine.OnRegex("(av[0-9]+|BV[0-9a-zA-Z]+|https://b23.tv/[0-9a-zA-Z]+|bv[0-9a-zA-Z]+){1}").SetBlock(true).Handle(func(ctx *zero.Ctx) {
bilibiliURL := ctx.State["regex_matched"].([]string)[1]
if bilibiliURL[0] != 'h' {
bilibiliURL = "https://www.bilibili.com/video/" + bilibiliURL
}
m, err := parseURL(bilibiliURL)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if len(m) != 0 {
ctx.Send(m)
}
ctx.Send(m)
})
}
@@ -42,29 +46,32 @@ func parseURL(bilibiliURL string) (m message.Message, err error) {
return
}
videoURL := htmlquery.FindOne(doc, "/html/head/meta[@itemprop='url']").Attr[2].Val
re := regexp.MustCompile(validRe)
if !re.MatchString(videoURL) {
err = errors.New("parse html error: invalid video url")
return
}
bv := re.FindStringSubmatch(videoURL)[1]
m = make(message.Message, 0, 9)
title := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/h1/span/text()").Data
m = append(m, message.Text(title+"\n"))
m = append(m, message.Text(title, "\n"))
upName := strings.TrimSpace(htmlquery.FindOne(doc, "//*[@id='v_upinfo']/div[2]/div[1]/a[1]/text()").Data)
fanNumber := htmlquery.InnerText(htmlquery.FindOne(doc, "//i[@class='van-icon-general_addto_s']").NextSibling.NextSibling)
m = append(m, message.Text("up"+upName+",粉丝:"+fanNumber+"\n"))
m = append(m, message.Text("UP: ", upName, ", 粉丝: ", fanNumber, "\n"))
view := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='view']/text()").Data
dm := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='dm']/text()").Data
m = append(m, message.Text(view+dm+"\n"))
m = append(m, message.Text(view, dm, "\n"))
t := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[3]/text()").Data
m = append(m, message.Text(t))
image := htmlquery.FindOne(doc, "/html/head/meta[@itemprop='image']").Attr[2].Val
m = append(m, message.Image(image))
like := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='like']/text()").Data
coin := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='coin']/text()").Data
m = append(m, message.Text("\n点赞", strings.TrimSpace(like)+",投币:", strings.TrimSpace(coin)+"\n"))
m = append(m, message.Text("\n点赞: ", strings.TrimSpace(like), ", 投币: ", strings.TrimSpace(coin), "\n"))
collect := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='collect']/text()").Data
share := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='share']/text()").Data
m = append(m, message.Text("收藏", strings.TrimSpace(collect)+",分享:", strings.TrimSpace(share)+"\n"))
m = append(m, message.Text(bv))
m = append(m, message.Text("收藏: ", strings.TrimSpace(collect), ", 分享: ", strings.TrimSpace(share), "\n"))
play := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[1]/text()").Data
danmaku := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[2]/text()").Data
m = append(m, message.Text(strings.TrimSpace(play), "播放, ", strings.TrimSpace(danmaku), "弹幕\n"))
m = append(m, message.Text(videoURL))
return
}

View File

@@ -1,593 +0,0 @@
// Package bilibilipush b站推送
package bilibilipush
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
"time"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/zbputils/web"
)
const (
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
referer = "https://www.bilibili.com/"
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%d"
userDynamicURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%d&offset_dynamic_id=0&need_top=0"
liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
tURL = "https://t.bilibili.com/"
liveURL = "https://live.bilibili.com/"
serviceName = "bilibilipush"
)
// bdb bilibili推送数据库
var bdb *bilibilipushdb
var (
lastTime = map[int64]int64{}
typeMsg = map[int64]string{
1: "转发了一条动态",
2: "有图营业",
4: "无图营业",
8: "发布了新投稿",
16: "发布了短视频",
64: "发布了新专栏",
256: "发布了新音频",
2048: "发布了新简报",
}
liveStatus = map[int64]int{}
uidErrorMsg = map[int]string{
0: "输入的uid有效",
-400: "uid不存在注意uid不是房间号",
-402: "uid不存在注意uid不是房间号",
-412: "操作过于频繁IP暂时被风控请半小时后再尝试",
}
upMap = map[int64]string{}
)
func init() {
go bilibiliPushDaily()
en := control.Register(serviceName, &control.Options{
DisableOnDefault: false,
Help: "bilibilipush\n" +
"- 添加b站订阅[uid]\n" +
"- 取消b站订阅[uid]\n" +
"- 取消b站动态订阅[uid]\n" +
"- 取消b站直播订阅[uid]\n" +
"- b站推送列表",
PrivateDataFolder: serviceName,
})
// 加载数据库
go func() {
dbpath := en.DataFolder()
dbfile := dbpath + "push.db"
bdb = initialize(dbfile)
}()
en.OnRegex(`^添加b站订阅\s?(\d+)$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
var name string
var ok bool
if name, ok = upMap[buid]; !ok {
var status int
var err error
status, name, err = checkBuid(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if status != 0 {
msg, ok := uidErrorMsg[status]
if !ok {
msg = "未知错误,请私聊反馈给" + zero.BotConfig.NickName[0]
}
ctx.SendChain(message.Text(msg))
return
}
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := subscribe(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
})
en.OnRegex(`^取消b站订阅\s?(\d+)$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
var name string
var ok bool
if name, ok = upMap[buid]; !ok {
var status int
var err error
status, name, err = checkBuid(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if status != 0 {
msg, ok := uidErrorMsg[status]
if !ok {
msg = "未知错误,请私聊反馈给" + zero.BotConfig.NickName[0]
}
ctx.SendChain(message.Text(msg))
return
}
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := unsubscribe(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("已取消" + name + "的订阅"))
})
en.OnRegex(`^取消b站动态订阅\s?(\d+)$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
var name string
var ok bool
if name, ok = upMap[buid]; !ok {
var status int
var err error
status, name, err = checkBuid(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if status != 0 {
msg, ok := uidErrorMsg[status]
if !ok {
msg = "未知错误,请私聊反馈给" + zero.BotConfig.NickName[0]
}
ctx.SendChain(message.Text(msg))
return
}
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := unsubscribeDynamic(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("已取消" + name + "的动态订阅"))
})
en.OnRegex(`^取消b站直播订阅\s?(\d+)$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
var name string
var ok bool
if name, ok = upMap[buid]; !ok {
var status int
var err error
status, name, err = checkBuid(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if status != 0 {
msg, ok := uidErrorMsg[status]
if !ok {
msg = "未知错误,请私聊反馈给" + zero.BotConfig.NickName[0]
}
ctx.SendChain(message.Text(msg))
return
}
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := unsubscribeLive(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("已取消" + name + "的直播订阅"))
})
en.OnFullMatch("b站推送列表", zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
bpl := bdb.getAllPushByGroup(gid)
msg := "--------b站推送列表--------"
for _, v := range bpl {
if _, ok := upMap[v.BilibiliUID]; !ok {
bdb.updateAllUp()
}
msg += fmt.Sprintf("\nuid:%-12d 动态:", v.BilibiliUID)
if v.DynamicDisable == 0 {
msg += "●"
} else {
msg += "○"
}
msg += " 直播:"
if v.LiveDisable == 0 {
msg += "●"
} else {
msg += "○"
}
msg += " up主" + upMap[v.BilibiliUID]
}
data, err := text.RenderToBase64(msg, text.FontFile, 600, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR:可能被风控了"))
}
})
}
func bilibiliPushDaily() {
t := time.NewTicker(time.Second * 10)
defer t.Stop()
for range t.C {
log.Debugln("-----bilibilipush拉取推送信息-----")
_ = sendDynamic()
_ = sendLive()
}
}
func checkBuid(buid int64) (status int, name string, err error) {
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua)
if err != nil {
return
}
status = int(gjson.Get(binary.BytesToString(data), "code").Int())
name = gjson.Get(binary.BytesToString(data), "data.name").String()
if status == 0 {
bdb.insertBilibiliUp(buid, name)
upMap[buid] = name
}
return
}
// subscribe 订阅
func subscribe(buid, groupid int64) (err error) {
bpMap := map[string]interface{}{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 0,
"dynamic_disable": 0,
}
err = bdb.insertOrUpdateLiveAndDynamic(bpMap)
return
}
// unsubscribe 取消订阅
func unsubscribe(buid, groupid int64) (err error) {
bpMap := map[string]interface{}{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 1,
"dynamic_disable": 1,
}
err = bdb.insertOrUpdateLiveAndDynamic(bpMap)
return
}
func unsubscribeDynamic(buid, groupid int64) (err error) {
bpMap := map[string]interface{}{
"bilibili_uid": buid,
"group_id": groupid,
"dynamic_disable": 1,
}
err = bdb.insertOrUpdateLiveAndDynamic(bpMap)
return
}
func unsubscribeLive(buid, groupid int64) (err error) {
bpMap := map[string]interface{}{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 1,
}
err = bdb.insertOrUpdateLiveAndDynamic(bpMap)
return
}
func getUserDynamicCard(buid int64) (cardList []gjson.Result, err error) {
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
if err != nil {
return
}
cardList = gjson.Get(binary.BytesToString(data), "data.cards").Array()
return
}
func getLiveList(uids ...int64) (string, error) {
m := make(map[string]interface{})
m["uids"] = uids
b, _ := json.Marshal(m)
data, err := web.PostData(liveListURL, "application/json", bytes.NewReader(b))
if err != nil {
return "", err
}
return binary.BytesToString(data), nil
}
func sendDynamic() error {
uids := bdb.getAllBuidByDynamic()
for _, buid := range uids {
cardList, err := getUserDynamicCard(buid)
if err != nil {
return err
}
t, ok := lastTime[buid]
if !ok {
lastTime[buid] = cardList[0].Get("desc.timestamp").Int()
return nil
}
for i := len(cardList) - 1; i >= 0; i-- {
ct := cardList[i].Get("desc.timestamp").Int()
if ct > t && ct > time.Now().Unix()-600 {
lastTime[buid] = ct
m, ok := control.Lookup(serviceName)
if ok {
groupList := bdb.getAllGroupByBuidAndDynamic(buid)
var msg []message.MessageSegment
cType := cardList[i].Get("desc.type").Int()
cardStr := cardList[i].Get("card").String()
switch cType {
case 0:
cName := cardList[i].Get("desc.user_profile.info.uname").String()
cTime := time.Unix(cardList[i].Get("desc.timestamp").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cTime+typeMsg[cType]+"\n"))
case 1:
cName := gjson.Get(cardStr, "user.uname").String()
msg = append(msg, message.Text(cName+typeMsg[cType]+"\n"))
cContent := gjson.Get(cardStr, "item.content").String()
msg = append(msg, message.Text(cContent+"\n"))
msg = append(msg, message.Text("转发的内容:\n"))
cOrigType := gjson.Get(cardStr, "item.orig_type").Int()
cOrigin := gjson.Get(cardStr, "origin").String()
switch cOrigType {
case 1:
cName := gjson.Get(cOrigin, "user.uname").String()
msg = append(msg, message.Text(cName+typeMsg[cOrigType]+"\n"))
case 2:
cName := gjson.Get(cOrigin, "user.name").String()
cUploadTime := time.Unix(gjson.Get(cOrigin, "item.upload_time").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cUploadTime+typeMsg[cOrigType]+"\n"))
cDescription := gjson.Get(cOrigin, "item.description")
msg = append(msg, message.Text(cDescription))
if gjson.Get(cOrigin, "item.pictures.#").Int() != 0 {
gjson.Get(cOrigin, "item.pictures").ForEach(func(_, v gjson.Result) bool {
msg = append(msg, message.Image(v.Get("img_src").String()))
return true
})
}
case 4:
cName := gjson.Get(cOrigin, "user.uname").String()
cTimestamp := time.Unix(gjson.Get(cOrigin, "item.timestamp").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cTimestamp+typeMsg[cOrigType]+"\n"))
cContent := gjson.Get(cOrigin, "item.content").String()
msg = append(msg, message.Text(cContent+"\n"))
case 8:
cName := gjson.Get(cOrigin, "owner.name").String()
cTime := time.Unix(gjson.Get(cOrigin, "pubdate").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cTime+typeMsg[cOrigType]+"\n"))
cTitle := gjson.Get(cOrigin, "title").String()
msg = append(msg, message.Text(cTitle))
cPic := gjson.Get(cOrigin, "pic").String()
msg = append(msg, message.Image(cPic))
cDesc := gjson.Get(cOrigin, "desc").String()
msg = append(msg, message.Text(cDesc+"\n"))
cShareSubtitle := gjson.Get(cOrigin, "share_subtitle").String()
msg = append(msg, message.Text(cShareSubtitle+"\n"))
cShortLink := gjson.Get(cOrigin, "short_link").String()
msg = append(msg, message.Text("视频链接:"+cShortLink+"\n"))
case 16:
cName := gjson.Get(cOrigin, "user.name").String()
cUploadTime := gjson.Get(cOrigin, "item.upload_time").String()
msg = append(msg, message.Text(cName+"在"+cUploadTime+typeMsg[cOrigType]+"\n"))
cDescription := gjson.Get(cOrigin, "item.description")
msg = append(msg, message.Text(cDescription))
cCover := gjson.Get(cOrigin, "item.cover.default").String()
msg = append(msg, message.Image(cCover))
case 64:
cName := gjson.Get(cOrigin, "author.name").String()
cPublishTime := time.Unix(gjson.Get(cOrigin, "publish_time").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cPublishTime+typeMsg[cOrigType]+"\n"))
cTitle := gjson.Get(cOrigin, "title").String()
msg = append(msg, message.Text(cTitle+"\n"))
cSummary := gjson.Get(cOrigin, "summary").String()
msg = append(msg, message.Text(cSummary))
cBannerURL := gjson.Get(cOrigin, "banner_url").String()
msg = append(msg, message.Image(cBannerURL))
case 256:
cUpper := gjson.Get(cOrigin, "upper").String()
cTime := time.UnixMilli(gjson.Get(cOrigin, "ctime").Int()).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cUpper+"在"+cTime+typeMsg[cOrigType]+"\n"))
cTitle := gjson.Get(cOrigin, "title").String()
msg = append(msg, message.Text(cTitle))
cCover := gjson.Get(cOrigin, "cover").String()
msg = append(msg, message.Image(cCover))
case 2048:
cName := gjson.Get(cOrigin, "user.uname").String()
msg = append(msg, message.Text(cName+typeMsg[cOrigType]+"\n"))
cContent := gjson.Get(cOrigin, "vest.content").String()
msg = append(msg, message.Text(cContent+"\n"))
cTitle := gjson.Get(cOrigin, "sketch.title").String()
msg = append(msg, message.Text(cTitle+"\n"))
cDescText := gjson.Get(cOrigin, "sketch.desc_text").String()
msg = append(msg, message.Text(cDescText))
cCoverURL := gjson.Get(cOrigin, "sketch.cover_url").String()
msg = append(msg, message.Image(cCoverURL))
cTargetURL := gjson.Get(cOrigin, "sketch.target_url").String()
msg = append(msg, message.Text("简报链接:"+cTargetURL+"\n"))
default:
msg = append(msg, message.Text("未知动态类型"+strconv.FormatInt(cOrigType, 10)+"\n"))
}
case 2:
cName := gjson.Get(cardStr, "user.name").String()
cUploadTime := time.Unix(gjson.Get(cardStr, "item.upload_time").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cUploadTime+typeMsg[cType]+"\n"))
cDescription := gjson.Get(cardStr, "item.description")
msg = append(msg, message.Text(cDescription))
if gjson.Get(cardStr, "item.pictures.#").Int() != 0 {
gjson.Get(cardStr, "item.pictures").ForEach(func(_, v gjson.Result) bool {
msg = append(msg, message.Image(v.Get("img_src").String()))
return true
})
}
case 4:
cName := gjson.Get(cardStr, "user.uname").String()
cTimestamp := time.Unix(gjson.Get(cardStr, "item.timestamp").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cTimestamp+typeMsg[cType]+"\n"))
cContent := gjson.Get(cardStr, "item.content").String()
msg = append(msg, message.Text(cContent+"\n"))
case 8:
cName := gjson.Get(cardStr, "owner.name").String()
cTime := time.Unix(gjson.Get(cardStr, "ctime").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cTime+typeMsg[cType]+"\n"))
cTitle := gjson.Get(cardStr, "title").String()
msg = append(msg, message.Text(cTitle))
cPic := gjson.Get(cardStr, "pic").String()
msg = append(msg, message.Image(cPic))
cDesc := gjson.Get(cardStr, "desc").String()
msg = append(msg, message.Text(cDesc+"\n"))
cShareSubtitle := gjson.Get(cardStr, "share_subtitle").String()
msg = append(msg, message.Text(cShareSubtitle+"\n"))
cShortLink := gjson.Get(cardStr, "short_link").String()
msg = append(msg, message.Text("视频链接:"+cShortLink+"\n"))
case 16:
cName := gjson.Get(cardStr, "user.name").String()
cUploadTime := gjson.Get(cardStr, "item.upload_time").String()
msg = append(msg, message.Text(cName+"在"+cUploadTime+typeMsg[cType]+"\n"))
cDescription := gjson.Get(cardStr, "item.description")
msg = append(msg, message.Text(cDescription))
cCover := gjson.Get(cardStr, "item.cover.default").String()
msg = append(msg, message.Image(cCover))
case 64:
cName := gjson.Get(cardStr, "author.name").String()
cPublishTime := time.Unix(gjson.Get(cardStr, "publish_time").Int(), 0).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cName+"在"+cPublishTime+typeMsg[cType]+"\n"))
cTitle := gjson.Get(cardStr, "title").String()
msg = append(msg, message.Text(cTitle+"\n"))
cSummary := gjson.Get(cardStr, "summary").String()
msg = append(msg, message.Text(cSummary))
cBannerURL := gjson.Get(cardStr, "banner_url").String()
msg = append(msg, message.Image(cBannerURL))
case 256:
cUpper := gjson.Get(cardStr, "upper").String()
cTime := time.UnixMilli(gjson.Get(cardStr, "ctime").Int()).Format("2006-01-02 15:04:05")
msg = append(msg, message.Text(cUpper+"在"+cTime+typeMsg[cType]+"\n"))
cTitle := gjson.Get(cardStr, "title").String()
msg = append(msg, message.Text(cTitle))
cCover := gjson.Get(cardStr, "cover").String()
msg = append(msg, message.Image(cCover))
case 2048:
cName := gjson.Get(cardStr, "user.uname").String()
msg = append(msg, message.Text(cName+typeMsg[cType]+"\n"))
cContent := gjson.Get(cardStr, "vest.content").String()
msg = append(msg, message.Text(cContent+"\n"))
cTitle := gjson.Get(cardStr, "sketch.title").String()
msg = append(msg, message.Text(cTitle+"\n"))
cDescText := gjson.Get(cardStr, "sketch.desc_text").String()
msg = append(msg, message.Text(cDescText))
cCoverURL := gjson.Get(cardStr, "sketch.cover_url").String()
msg = append(msg, message.Image(cCoverURL))
cTargetURL := gjson.Get(cardStr, "sketch.target_url").String()
msg = append(msg, message.Text("简报链接:"+cTargetURL+"\n"))
default:
msg = append(msg, message.Text("未知动态类型"+strconv.FormatInt(cType, 10)+"\n"))
}
cID := cardList[i].Get("desc.dynamic_id").String()
msg = append(msg, message.Text("动态链接:", tURL+cID))
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
}
}
}
return true
})
}
}
}
}
return nil
}
func sendLive() error {
uids := bdb.getAllBuidByLive()
ll, err := getLiveList(uids...)
if err != nil {
return err
}
gjson.Get(ll, "data").ForEach(func(key, value gjson.Result) bool {
newStatus := int(value.Get("live_status").Int())
if newStatus == 2 {
newStatus = 0
}
if _, ok := liveStatus[key.Int()]; !ok {
liveStatus[key.Int()] = newStatus
return true
}
oldStatus := liveStatus[key.Int()]
if newStatus != oldStatus && newStatus == 1 {
liveStatus[key.Int()] = newStatus
m, ok := control.Lookup(serviceName)
if ok {
groupList := bdb.getAllGroupByBuidAndLive(key.Int())
roomID := value.Get("short_id").Int()
if roomID == 0 {
roomID = value.Get("room_id").Int()
}
lURL := liveURL + strconv.FormatInt(roomID, 10)
lName := value.Get("uname").String()
lTitle := value.Get("title").String()
lCover := value.Get("cover_from_user").String()
if lCover == "" {
lCover = value.Get("keyframe").String()
}
var msg []message.MessageSegment
msg = append(msg, message.Text(lName+" 正在直播:\n"))
msg = append(msg, message.Text(lTitle))
msg = append(msg, message.Image(lCover))
msg = append(msg, message.Text("直播链接:", lURL))
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
}
}
}
return true
})
}
} else if newStatus != oldStatus {
liveStatus[key.Int()] = newStatus
}
return true
})
return nil
}

View File

@@ -1,144 +0,0 @@
package bilibilipush
import (
"encoding/json"
"os"
_ "github.com/fumiama/sqlite3" // import sql
"github.com/jinzhu/gorm"
)
// bilibilipushdb bili推送数据库
type bilibilipushdb gorm.DB
type bilibilipush struct {
ID int64 `gorm:"column:id;primary_key" json:"id"`
BilibiliUID int64 `gorm:"column:bilibili_uid;index:idx_buid_gid" json:"bilibili_uid"`
GroupID int64 `gorm:"column:group_id;index:idx_buid_gid" json:"group_id"`
LiveDisable int64 `gorm:"column:live_disable;default:0" json:"live_disable"`
DynamicDisable int64 `gorm:"column:dynamic_disable;default:0" json:"dynamic_disable"`
}
// TableName ...
func (bilibilipush) TableName() string {
return "bilibili_push"
}
type bilibiliup struct {
BilibiliUID int64 `gorm:"column:bilibili_uid;primary_key"`
Name string `gorm:"column:name"`
}
// TableName ...
func (bilibiliup) TableName() string {
return "bilibili_up"
}
// initialize 初始化ScoreDB数据库
func initialize(dbpath string) *bilibilipushdb {
var err error
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
f, err := os.Create(dbpath)
if err != nil {
return nil
}
defer f.Close()
}
gdb, err := gorm.Open("sqlite3", dbpath)
if err != nil {
panic(err)
}
gdb.AutoMigrate(&bilibilipush{}).AutoMigrate(&bilibiliup{})
return (*bilibilipushdb)(gdb)
}
// insertOrUpdateLiveAndDynamic 插入或更新数据库
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interface{}) (err error) {
db := (*gorm.DB)(bdb)
bp := bilibilipush{}
data, _ := json.Marshal(&bpMap)
_ = json.Unmarshal(data, &bp)
if err = db.Model(&bilibilipush{}).First(&bp, "bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Error; err != nil {
if gorm.IsRecordNotFoundError(err) {
err = db.Model(&bilibilipush{}).Create(&bp).Error
}
} else {
err = db.Model(&bilibilipush{}).Where("bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Update(bpMap).Error
}
return
}
func (bdb *bilibilipushdb) getAllBuidByLive() (buidList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Model(&bilibilipush{}).Find(&bpl, "live_disable = 0")
temp := make(map[int64]bool)
for _, v := range bpl {
_, ok := temp[v.BilibiliUID]
if !ok {
buidList = append(buidList, v.BilibiliUID)
temp[v.BilibiliUID] = true
}
}
return
}
func (bdb *bilibilipushdb) getAllBuidByDynamic() (buidList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Model(&bilibilipush{}).Find(&bpl, "dynamic_disable = 0")
temp := make(map[int64]bool)
for _, v := range bpl {
_, ok := temp[v.BilibiliUID]
if !ok {
buidList = append(buidList, v.BilibiliUID)
temp[v.BilibiliUID] = true
}
}
return
}
func (bdb *bilibilipushdb) getAllGroupByBuidAndLive(buid int64) (groupList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and live_disable = 0", buid)
for _, v := range bpl {
groupList = append(groupList, v.GroupID)
}
return
}
func (bdb *bilibilipushdb) getAllGroupByBuidAndDynamic(buid int64) (groupList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and dynamic_disable = 0", buid)
for _, v := range bpl {
groupList = append(groupList, v.GroupID)
}
return
}
func (bdb *bilibilipushdb) getAllPushByGroup(groupID int64) (bpl []bilibilipush) {
db := (*gorm.DB)(bdb)
db.Model(&bilibilipush{}).Find(&bpl, "group_id = ? and (live_disable = 0 or dynamic_disable = 0)", groupID)
return
}
func (bdb *bilibilipushdb) insertBilibiliUp(buid int64, name string) {
db := (*gorm.DB)(bdb)
bu := bilibiliup{
BilibiliUID: buid,
Name: name,
}
db.Model(&bilibiliup{}).Create(bu)
}
func (bdb *bilibilipushdb) updateAllUp() {
db := (*gorm.DB)(bdb)
var bul []bilibiliup
db.Model(&bilibiliup{}).Find(&bul)
for _, v := range bul {
upMap[v.BilibiliUID] = v.Name
}
}

View File

@@ -6,25 +6,24 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/text"
)
func init() {
engine := control.Register("bookreview", &control.Options{
engine := control.Register("bookreview", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
PublicDataFolder: "BookReview",
})
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := engine.DataFolder()
db.DBPath = dbpath + "bookreview.db"
db.DBPath = engine.DataFolder() + "bookreview.db"
// os.RemoveAll(dbpath)
_, _ = file.GetLazyData(db.DBPath, false, true)
_, _ = engine.GetLazyData("bookreview.db", true)
err := db.Create("bookreview", &book{})
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -9,7 +9,8 @@ import (
"net/url"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/antchfx/htmlquery"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -29,7 +30,7 @@ var (
)
func init() {
engine := control.Register("cangtoushi", &control.Options{
engine := control.Register("cangtoushi", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "藏头诗\n" +
"- 藏头诗[xxx]\n- 藏尾诗[xxx]",

View File

@@ -6,7 +6,8 @@ import (
"strconv"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -14,7 +15,7 @@ import (
var (
poke = rate.NewManager[int64](time.Minute*5, 8) // 戳一戳
engine = control.Register("chat", &control.Options{
engine = control.Register("chat", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]",
})

View File

@@ -6,13 +6,14 @@ import (
"strconv"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
engine := control.Register("choose", &control.Options{
engine := control.Register("choose", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "choose\n" +
"- 选择可口可乐还是百事可乐\n" +

View File

@@ -6,13 +6,13 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
)
func init() {
en := control.Register("chouxianghua", &control.Options{
en := control.Register("chouxianghua", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "抽象话\n- 抽象翻译xxx",
PublicDataFolder: "ChouXiangHua",
@@ -20,10 +20,9 @@ func init() {
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$",
ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := en.DataFolder()
db.DBPath = dbpath + "cxh.db"
db.DBPath = en.DataFolder() + "cxh.db"
// os.RemoveAll(dbpath)
_, _ = file.GetLazyData(db.DBPath, false, true)
_, _ = en.GetLazyData("cxh.db", true)
err := db.Create("pinyin", &pinyin{})
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -10,7 +10,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
@@ -22,7 +23,7 @@ var (
)
func init() {
control.Register("coser", &control.Options{
control.Register("coser", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "三次元小姐姐\n- coser",
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).

View File

@@ -8,24 +8,23 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/math"
)
func init() {
engine := control.Register("cpstory", &control.Options{
engine := control.Register("cpstory", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
PublicDataFolder: "CpStory",
})
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := engine.DataFolder()
db.DBPath = dbpath + "cp.db"
db.DBPath = engine.DataFolder() + "cp.db"
// os.RemoveAll(dbpath)
_, _ = file.GetLazyData(db.DBPath, false, true)
_, _ = engine.GetLazyData("cp.db", true)
err := db.Create("cp_story", &cpstory{})
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -6,9 +6,9 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
)
@@ -18,16 +18,15 @@ const (
)
func init() {
engine := control.Register("curse", &control.Options{
engine := control.Register("curse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
PublicDataFolder: "Curse",
})
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := engine.DataFolder()
db.DBPath = dbpath + "curse.db"
_, err := file.GetLazyData(db.DBPath, false, true)
db.DBPath = engine.DataFolder() + "curse.db"
_, err := engine.GetLazyData("curse.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false

View File

@@ -6,7 +6,7 @@ import (
"encoding/hex"
"github.com/FloatTech/AnimeAPI/danbooru"
"github.com/FloatTech/AnimeAPI/saucenao"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/writer"
@@ -16,7 +16,7 @@ import (
)
func init() { // 插件主体
engine := control.Register("danbooru", &control.Options{
engine := control.Register("danbooru", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "二次元图片标签识别\n" +
"- 鉴赏图片[图片]",
@@ -30,14 +30,7 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
name := ""
r, err := saucenao.SauceNAO(url)
if err != nil {
name = "未知图片"
} else {
name = r[0].Title
}
t, err := danbooru.TagURL(name, url)
t, err := danbooru.TagURL("", url)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return

View File

@@ -5,13 +5,14 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
)
var engine = control.Register("diana", &control.Options{
var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "嘉然\n" +
"- 小作文\n" +

View File

@@ -20,7 +20,7 @@ type text struct {
// LoadText 加载小作文
func LoadText(dbfile string) error {
_, err := file.GetLazyData(dbfile, false, false)
_, err := file.GetLazyData(dbfile, false)
db.DBPath = dbfile
if err != nil {
return err

View File

@@ -6,6 +6,7 @@ import (
"strings"
"sync"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -13,7 +14,7 @@ import (
)
func init() {
en := control.Register("driftbottle", &control.Options{
en := control.Register("driftbottle", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "漂流瓶\n- (在群xxx)丢漂流瓶(到频道xxx) [消息]\n- (从频道xxx)捡漂流瓶\n- @BOT 创建频道 xxx\n- 跳入(频道)海中\n- 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global",
PrivateDataFolder: "driftbottle",

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/sirupsen/logrus"
@@ -16,7 +17,7 @@ import (
const bed = "https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%x.png"
func init() {
control.Register("emojimix", &control.Options{
control.Register("emojimix", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "合成emoji\n" +
"- [emoji][emoji]",

View File

@@ -7,6 +7,7 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
@@ -34,8 +35,8 @@ type epidemic struct {
type area struct {
Name string `json:"name"`
Today struct {
Confirm int `json:"confirm"`
Wzzadd int `json:"wzz_add"`
Confirm int `json:"confirm"`
Wzzadd interface{} `json:"wzz_add"`
} `json:"today"`
Total struct {
NowConfirm int `json:"nowConfirm"`
@@ -49,7 +50,7 @@ type area struct {
}
func init() {
engine := control.Register(servicename, &control.Options{
engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "城市疫情查询\n" +
"- xxx疫情\n",

View File

@@ -2,6 +2,7 @@
package font
import (
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
@@ -11,7 +12,7 @@ import (
)
func init() {
control.Register("font", &control.Options{
control.Register("font", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "渲染任意文字到图片\n- (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx",
}).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
@@ -29,6 +30,7 @@ func init() {
case "用Consolas体":
fnt = text.ConsolasFontFile
case "用苹方体":
fallthrough
default:
fnt = text.FontFile
}

View File

@@ -8,10 +8,8 @@ import (
"encoding/json"
"image"
"io"
"math/rand"
"os"
"strconv"
"time"
"github.com/fogleman/gg" // 注册了 jpg png gif
"github.com/sirupsen/logrus"
@@ -19,7 +17,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/pool"
@@ -49,7 +48,7 @@ var (
func init() {
// 插件主体
en := control.Register("fortune", &control.Options{
en := control.Register("fortune", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "每日运势: \n" +
"- 运势 | 抽签\n" +
@@ -73,7 +72,7 @@ func init() {
}
i, ok := index[ctx.State["regex_matched"].([]string)[1]]
if ok {
c, ok := control.Lookup("fortune")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
err := c.SetData(gid, int64(i)&0xff)
if err != nil {
@@ -90,7 +89,7 @@ func init() {
})
en.OnFullMatchGroup([]string{"运势", "抽签"}, ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
data, err := file.GetLazyData(omikujson, true, false)
data, err := file.GetLazyData(omikujson, false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
@@ -100,14 +99,14 @@ func init() {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
_, err = file.GetLazyData(font, false, true)
_, err = file.GetLazyData(font, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
return true
},
)).SetBlock(true).
)).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 获取该群背景类型,默认车万
kind := "车万"
@@ -117,7 +116,7 @@ func init() {
gid = -ctx.Event.UserID
}
logrus.Debugln("[fortune]gid:", ctx.Event.GroupID, "uid:", ctx.Event.UserID)
c, ok := control.Lookup("fortune")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
v := uint8(c.GetData(gid) & 0xff)
if int(v) < len(table) {
@@ -126,25 +125,22 @@ func init() {
}
// 检查背景图片是否存在
zipfile := images + kind + ".zip"
_, err := file.GetLazyData(zipfile, false, false)
_, err := file.GetLazyData(zipfile, false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
// 生成种子
t, _ := strconv.ParseInt(time.Now().Format("20060102"), 10, 64)
seed := ctx.Event.UserID + t
// 随机获取背景
background, index, err := randimage(zipfile, seed)
background, index, err := randimage(zipfile, ctx)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
// 随机获取签文
title, text := randtext(seed)
randtextindex := ctxext.RandSenderPerDayN(ctx, len(omikujis))
title, text := omikujis[randtextindex]["title"], omikujis[randtextindex]["content"]
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
cachefile := cache + hex.EncodeToString(digest[:])
@@ -166,18 +162,16 @@ func init() {
// @function randimage 随机选取zip内的文件
// @param path zip路径
// @param seed 随机数种子
// @param ctx *zero.Ctx
// @return 文件路径 & 错误信息
func randimage(path string, seed int64) (im image.Image, index int, err error) {
func randimage(path string, ctx *zero.Ctx) (im image.Image, index int, err error) {
reader, err := zip.OpenReader(path)
if err != nil {
return
}
defer reader.Close()
r := rand.New(rand.NewSource(seed))
index = r.Intn(len(reader.File))
file := reader.File[index]
file := reader.File[ctxext.RandSenderPerDayN(ctx, len(reader.File))]
f, err := file.Open()
if err != nil {
return
@@ -188,16 +182,6 @@ func randimage(path string, seed int64) (im image.Image, index int, err error) {
return
}
// @function randtext 随机选取签文
// @param file 文件路径
// @param seed 随机数种子
// @return 签名 & 签文 & 错误信息
func randtext(seed int64) (string, string) {
r := rand.New(rand.NewSource(seed))
i := r.Intn(len(omikujis))
return omikujis[i]["title"], omikujis[i]["content"]
}
// @function draw 绘制运势图
// @param background 背景图片路径
// @param seed 随机数种子

View File

@@ -9,9 +9,9 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
)
type joke struct {
@@ -22,7 +22,7 @@ type joke struct {
var db = &sql.Sqlite{}
func init() {
en := control.Register("funny", &control.Options{
en := control.Register("funny", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "讲个笑话\n" +
"- 讲个笑话[@xxx|qq号|人名] | 夸夸[@xxx|qq号|人名] ",
@@ -30,9 +30,8 @@ func init() {
})
en.OnPrefixGroup([]string{"讲个笑话", "夸夸"}, ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := en.DataFolder()
db.DBPath = dbpath + "jokes.db"
_, err := file.GetLazyData(db.DBPath, false, true)
db.DBPath = en.DataFolder() + "jokes.db"
_, err := en.GetLazyData("jokes.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false

View File

@@ -13,9 +13,9 @@ import (
"strings"
"sync/atomic"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/writer"
"github.com/FloatTech/zbputils/process"
"github.com/golang/freetype"
@@ -34,7 +34,7 @@ var (
)
func init() {
engine := control.Register("genshin", &control.Options{
engine := control.Register("genshin", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "原神抽卡\n- 原神十连\n- 切换原神卡池",
PublicDataFolder: "Genshin",
@@ -42,7 +42,7 @@ func init() {
engine.OnFullMatch("切换原神卡池").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup("genshin")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("找不到服务!"))
return
@@ -69,7 +69,7 @@ func init() {
engine.OnFullMatch("原神十连", ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
zipfile := engine.DataFolder() + "Genshin.zip"
_, err := file.GetLazyData(zipfile, false, false)
_, err := engine.GetLazyData("Genshin.zip", false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
@@ -83,7 +83,7 @@ func init() {
},
)).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup("genshin")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("找不到服务!"))
return

View File

@@ -1,6 +1,6 @@
# ZeroBot-Plugin-Gif
[ZeroBot QQ机器人](https://github.com/wdvxdr1123/ZeroBot)插件可以制作各种沙雕gif图
> 素材包地址: https://codechina.csdn.net/u011570312/imagematerials
> 素材包地址: https://gitcode.net/u011570312/imagematerials
## 触发方式
1. [指令词]+[qq号] 如爬123456

View File

@@ -20,7 +20,7 @@ func dlchan(name string, s *string, wg *sync.WaitGroup, exit func(error)) {
target := datapath + `materials/` + name
var err error
if file.IsNotExist(target) {
err = file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
err = file.DownloadTo(`https://gitcode.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
if err != nil {
exit(err)
return
@@ -35,7 +35,7 @@ func dlchan(name string, s *string, wg *sync.WaitGroup, exit func(error)) {
func dlblock(name string) (string, error) {
target := datapath + `materials/` + name
if file.IsNotExist(target) {
err := file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
err := file.DownloadTo(`https://gitcode.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
if err != nil {
return "", err
}

View File

@@ -6,7 +6,8 @@ import (
"strconv"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -20,7 +21,7 @@ var (
)
func init() { // 插件主体
en := control.Register("gif", &control.Options{
en := control.Register("gif", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "制图\n- " + strings.Join(cmds, "\n- "),
PrivateDataFolder: "gif",

View File

@@ -9,7 +9,8 @@ import (
"net/url"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -17,7 +18,7 @@ import (
)
func init() { // 插件主体
control.Register("github", &control.Options{
control.Register("github", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "GitHub仓库搜索\n" +
"- >github [xxx]\n" +

View File

@@ -11,7 +11,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/web"
@@ -40,7 +41,7 @@ const (
)
func init() {
engine := control.Register("hs", &control.Options{
engine := control.Register("hs", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "炉石\n" +
"- 搜卡[xxxx]\n" +

View File

@@ -1,3 +1,4 @@
// Package hyaku 百人一首
package hyaku
import (
@@ -9,6 +10,7 @@ import (
"strconv"
"unsafe"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
@@ -50,7 +52,7 @@ func (l *line) String() string {
var lines [100]*line
func init() {
engine := control.Register("hyaku", &control.Options{
engine := control.Register("hyaku", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "百人一首\n" +
"- 百人一首(随机发一首)\n" +

View File

@@ -13,9 +13,11 @@ import (
"github.com/FloatTech/AnimeAPI/pixiv"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/pool"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/web"
)
@@ -34,7 +36,7 @@ type resultjson struct {
}
func init() {
control.Register("imgfinder", &control.Options{
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "关键字搜图\n" +
"- 来张 [xxx]",
@@ -69,13 +71,18 @@ func init() {
// soutuapi 请求api
func soutuapi(keyword string) (r resultjson, err error) {
data, err := web.GetData("https://copymanga.azurewebsites.net/api/pixivel?" + url.QueryEscape(keyword) + "?page=0")
if err != nil {
var data []byte
for i := 0; i < 3; i++ {
data, err = web.GetData("https://copymanga.azurewebsites.net/api/pixivel?" + url.QueryEscape(keyword) + "?page=0")
if err != nil {
process.SleepAbout1sTo2s()
continue
}
err = json.Unmarshal(data, &r)
if err == nil && r.Error {
err = errors.New(r.Message)
}
return
}
err = json.Unmarshal(data, &r)
if err == nil && r.Error {
err = errors.New(r.Message)
}
return
}

View File

@@ -2,13 +2,14 @@
package inject
import (
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
en := control.Register("inject", &control.Options{
en := control.Register("inject", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "注入指令\n" +
"- run[CQ码]",

View File

@@ -7,10 +7,10 @@ import (
"regexp"
"strconv"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/antchfx/htmlquery"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -22,16 +22,15 @@ const (
)
func init() {
engine := control.Register("jandan", &control.Options{
engine := control.Register("jandan", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "煎蛋网无聊图\n- 来份[屌|弔|吊]图\n- 更新[屌|弔|吊]图\n",
PublicDataFolder: "Jandan",
})
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbpath := engine.DataFolder()
db.DBPath = dbpath + "pics.db"
_, _ = file.GetLazyData(db.DBPath, false, false)
db.DBPath = engine.DataFolder() + "pics.db"
_, _ = engine.GetLazyData("pics.db", false)
err := db.Create("picture", &picture{})
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -7,7 +7,8 @@ import (
"net/http"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -22,7 +23,7 @@ const (
)
func init() {
control.Register("juejuezi", &control.Options{
control.Register("juejuezi", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "绝绝子生成器\n" +
"- 喝奶茶绝绝子 | 绝绝子吃饭",

View File

@@ -10,7 +10,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/pool"
"github.com/FloatTech/zbputils/math"
@@ -29,13 +30,13 @@ var (
)
func init() {
en := control.Register("lolicon", &control.Options{
en := control.Register("lolicon", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "lolicon\n" +
"- 来份萝莉\n" +
"- 设置随机图片地址[http...]",
}).ApplySingle(ctxext.DefaultSingle)
en.OnFullMatch("来份萝莉").SetBlock(true).
en.OnFullMatch("来份萝莉").Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
go func() {
for i := 0; i < math.Min(cap(queue)-len(queue), 2); i++ {

View File

@@ -14,7 +14,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
@@ -59,7 +60,7 @@ var (
)
func init() { // 插件主体
engine := control.Register("manager", &control.Options{
engine := control.Register("manager", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: hint,
PrivateDataFolder: "manager",
@@ -385,7 +386,7 @@ func init() { // 插件主体
} else {
ctx.SendChain(message.Text("欢迎~"))
}
c, ok := control.Lookup("manager")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
enable := c.GetData(ctx.Event.GroupID)&1 == 1
if enable {
@@ -499,7 +500,7 @@ func init() { // 插件主体
engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["regex_matched"].([]string)[1]
c, ok := control.Lookup("manager")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
data := c.GetData(ctx.Event.GroupID)
switch option {
@@ -524,7 +525,7 @@ func init() { // 插件主体
engine.OnRegex(`^(.*)gist加群自动审批$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["regex_matched"].([]string)[1]
c, ok := control.Lookup("manager")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
data := c.GetData(ctx.Event.GroupID)
switch option {
@@ -552,7 +553,7 @@ func init() { // 插件主体
/*if ctx.Event.RequestType == "friend" {
ctx.SetFriendAddRequest(ctx.Event.Flag, true, "")
}*/
c, ok := control.Lookup("manager")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok && c.GetData(ctx.Event.GroupID)&0x10 == 0x10 && ctx.Event.RequestType == "group" && ctx.Event.SubType == "add" {
// gist 文件名是群号的 ascii 编码的 md5
// gist 内容是当前 uinx 时间戳,在 10 分钟内视为有效

View File

@@ -5,7 +5,8 @@ import (
"sync"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
@@ -17,7 +18,7 @@ var (
)
func init() { // 插件主体
control.Register("moyu", &control.Options{
control.Register("moyu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "moyu\n" +
"- /启用 moyu\n" +

View File

@@ -2,30 +2,15 @@
package moyucalendar
import (
"bufio"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"regexp"
"strings"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
xpath "github.com/antchfx/htmlquery"
)
var ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
var weixin = regexp.MustCompile(`url \+= '(.+)';`)
var client = &http.Client{}
func init() {
control.Register("moyucalendar", &control.Options{
control.Register("moyucalendar", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "摸鱼人日历\n" +
"- /启用 moyucalendar\n" +
@@ -34,159 +19,11 @@ func init() {
" - 摸鱼人日历",
}).OnFullMatch("摸鱼人日历").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
title := fmt.Sprintf("摸鱼人日历 %d月%d日", time.Now().Month(), time.Now().Day())
sg, cookies, err := sougou(title, "摸鱼人日历", ua)
data, err := web.GetData("https://api.vvhan.com/api/moyu")
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
wx, err := redirect(sg, cookies, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
image, err := calendar(wx, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image(image))
ctx.SendChain(message.ImageBytes(data))
})
}
func sougou(title, publisher, ua string) (string, []*http.Cookie, error) {
u, _ := url.Parse("https://weixin.sogou.com/weixin")
u.RawQuery = url.Values{
"type": []string{"2"},
"s_from": []string{"input"},
"query": []string{title},
}.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return "", nil, err
}
req.Header.Set("User-Agent", ua)
resp, err := client.Do(req)
if err != nil {
return "", nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", nil, errors.New("status not ok")
}
// 解析XPATH
doc, err := xpath.Parse(resp.Body)
if err != nil {
return "", nil, err
}
// 取出每个返回的结果
list := xpath.Find(doc, `//*[@class="news-list"]/li/div[@class="txt-box"]`)
if len(list) == 0 {
return "", nil, errors.New("sougou result not found")
}
var match string
for i := range list {
account := xpath.FindOne(list[i], `//div[@class="s-p"]/a[@class="account"]`)
if account == nil {
continue
}
if xpath.InnerText(account) != publisher {
continue
}
target := xpath.FindOne(list[i], `//h3/a[@target="_blank"]`)
if target == nil {
continue
}
match = xpath.SelectAttr(target, "href")
break
}
if match == "" {
return "", nil, errors.New("sougou result not found")
}
return "https://weixin.sogou.com" + match, resp.Cookies(), nil
}
func redirect(link string, cookies []*http.Cookie, ua string) (string, error) {
req, err := http.NewRequest("GET", link, nil)
if err != nil {
return "", err
}
req.Header.Set("User-Agent", ua)
var c = make([]string, 0, 4)
for _, cookie := range cookies {
if cookie.Name != "ABTEST" && cookie.Name != "SNUID" &&
cookie.Name != "IPLOC" && cookie.Name != "SUID" {
continue
}
c = append(c, cookie.Name+"="+cookie.Value)
}
req.Header.Set("Cookie", strings.Join(c, "; "))
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", errors.New("status not ok")
}
br := bufio.NewReader(resp.Body)
var u = make([]string, 0)
for {
b, _, err := br.ReadLine()
if err == io.EOF {
break
}
if err != nil {
return "", err
}
matcha := weixin.FindStringSubmatch(string(b))
if len(matcha) < 2 {
continue
}
u = append(u, strings.ReplaceAll(matcha[1], "@", ""))
}
if len(u) == 0 {
return "", errors.New("weixin url not found")
}
return strings.Join(u, ""), nil
}
func calendar(link, ua string) (string, error) {
req, err := http.NewRequest("GET", link, nil)
req.Header.Set("User-Agent", ua)
if err != nil {
return "", err
}
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", errors.New("status not ok")
}
doc, err := xpath.Parse(resp.Body)
if err != nil {
return "", err
}
html := xpath.OutputHTML(doc, false)
if !strings.Contains(html, time.Now().Format("2006-01-02")) {
return "", errors.New("calendar not today")
}
images := xpath.Find(doc, `//*[@id="js_content"]/p/img`)
if images == nil {
return "", errors.New("calendar not found")
}
var image string
for i := range images {
if xpath.SelectAttr(images[i], "data-w") != "540" {
continue
}
image = xpath.SelectAttr(images[i], "data-src")
break
}
if image == "" {
return "", errors.New("image not found")
}
return image, nil
}

View File

@@ -11,7 +11,10 @@ import (
"strings"
"time"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -19,7 +22,7 @@ import (
)
func init() {
control.Register("music", &control.Options{
control.Register("music", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "点歌\n" +
"- 点歌[xxx]\n" +
@@ -134,72 +137,28 @@ func kugou(keyword string) message.MessageSegment {
}
// cloud163 返回网易云音乐卡片
func cloud163(keyword string) message.MessageSegment {
headers := http.Header{
"Content-Type": []string{"application/x-www-form-urlencoded"},
"User-Agent": []string{"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"},
func cloud163(keyword string) (msg message.MessageSegment) {
requestURL := "https://autumnfish.cn/search?keywords=" + url.QueryEscape(keyword)
data, err := web.GetData(requestURL)
if err != nil {
msg = message.Text("ERROR:", err)
return
}
data := url.Values{
"keywords": []string{keyword},
}
// 通过API 搜索音乐信息 第一首
// 返回音乐卡片
return message.Music("163", gjson.ParseBytes(netPost("https://nemapi.windis.xyz/search", data, headers)).Get("result.songs.0.id").Int())
msg = message.Music("163", gjson.ParseBytes(data).Get("result.songs.0.id").Int())
return
}
// qqmusic 返回QQ音乐卡片
func qqmusic(keyword string) message.MessageSegment {
// 搜索音乐信息 第一首歌
h1 := http.Header{
"User-Agent": []string{"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"},
func qqmusic(keyword string) (msg message.MessageSegment) {
requestURL := "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?w=" + url.QueryEscape(keyword)
data, err := web.RequestDataWith(web.NewDefaultClient(), requestURL, "GET", "", web.RandUA())
if err != nil {
msg = message.Text("ERROR:", err)
return
}
search, _ := url.Parse("https://c.y.qq.com/soso/fcgi-bin/client_search_cp")
search.RawQuery = url.Values{
"w": []string{keyword},
}.Encode()
res := netGet(search.String(), h1)
info := gjson.ParseBytes(res[9 : len(res)-1]).Get("data.song.list.0")
// 获得音乐直链
h2 := http.Header{
"User-Agent": []string{"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1"},
"referer": []string{"http://y.qq.com"},
}
music, _ := url.Parse("https://u.y.qq.com/cgi-bin/musicu.fcg")
music.RawQuery = url.Values{
"data": []string{`{"req": {"module": "CDN.SrfCdnDispatchServer", "method": "GetCdnDispatch", "param": {"guid": "3982823384", "calltype": 0, "userip": ""}}, "req_0": {"module": "vkey.GetVkeyServer", "method": "CgiGetVkey", "param": {"guid": "3982823384", "songmid": ["` + info.Get("songmid").Str + `"], "songtype": [0], "uin": "0", "loginflag": 1, "platform": "20"}}, "comm": {"uin": 0, "format": "json", "ct": 24, "cv": 0}}`},
}.Encode()
audio := gjson.ParseBytes(netGet(music.String(), h2))
// 获得音乐封面
image := "https://y.gtimg.cn/music/photo_new/" +
find(
`photo_new\u002F`,
"?max_age",
string(
netGet("https://y.qq.com/n/yqq/song/"+info.Get("songmid").Str+".html", nil),
),
)
// 返回音乐卡片
return message.CustomMusic(
"https://y.qq.com/n/yqq/song/"+info.Get("songmid").Str+".html",
"https://isure.stream.qqmusic.qq.com/"+audio.Get("req_0.data.midurlinfo.0.purl").Str,
info.Get("songname").Str,
).Add("content", info.Get("singer.0.name").Str).Add("image", image)
}
// find 返回 pre 到 suf 之间的文本
func find(pre string, suf string, str string) string {
n := strings.Index(str, pre)
if n == -1 {
n = 0
} else {
n += len(pre)
}
str = str[n:]
m := strings.Index(str, suf)
if m == -1 {
m = len(str)
}
return str[:m]
info := gjson.ParseBytes(data[9 : len(data)-1]).Get("data.song.list.0")
msg = message.Music("qq", info.Get("songid").Int())
return
}
// md5str 返回字符串 MD5
@@ -223,17 +182,3 @@ func netGet(url string, header http.Header) []byte {
result, _ := io.ReadAll(res.Body)
return result
}
// netPost 返回请求数据
func netPost(url string, data url.Values, header http.Header) []byte {
client := &http.Client{}
request, _ := http.NewRequest("POST", url, strings.NewReader(data.Encode()))
request.Header = header
res, err := client.Do(request)
if err != nil {
return nil
}
defer res.Body.Close()
result, _ := io.ReadAll(res.Body)
return result
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
@@ -20,7 +21,7 @@ var (
)
func init() {
engine := control.Register("nativesetu", &control.Options{
engine := control.Register("nativesetu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "本地涩图\n" +
"- 本地[xxx]\n" +

View File

@@ -16,12 +16,13 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
)
func init() {
engine := control.Register("nwife", &control.Options{
engine := control.Register("nwife", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
PrivateDataFolder: "nwife",
@@ -123,9 +124,9 @@ func init() {
var err error
switch text {
case "设置", "授予", "让":
err = setEveryoneCanAddWife(ctx.Event.GroupID, true)
err = setEveryoneCanAddWife(ctx, true)
case "取消", "撤销", "不让":
err = setEveryoneCanAddWife(ctx.Event.GroupID, false)
err = setEveryoneCanAddWife(ctx, false)
}
if err == nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功!"))
@@ -138,7 +139,7 @@ func init() {
func chkAddWifePermission(ctx *zero.Ctx) bool {
gid := ctx.Event.GroupID
if gid > 0 {
m, ok := control.Lookup("nwife")
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
data := m.GetData(gid)
if data&1 == 1 {
@@ -150,13 +151,13 @@ func chkAddWifePermission(ctx *zero.Ctx) bool {
return false
}
func setEveryoneCanAddWife(gid int64, canadd bool) error {
m, ok := control.Lookup("nwife")
func setEveryoneCanAddWife(ctx *zero.Ctx, canadd bool) error {
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
if canadd {
return m.SetData(gid, 1)
return m.SetData(ctx.Event.GroupID, 1)
}
return m.SetData(gid, 0)
return m.SetData(ctx.Event.GroupID, 0)
}
return errors.New("no such plugin")
}

View File

@@ -7,6 +7,7 @@ import (
"net/url"
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -14,7 +15,7 @@ import (
)
func init() {
control.Register("nbnhhsh", &control.Options{
control.Register("nbnhhsh", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "拼音首字母释义工具\n- ?? [缩写]",
}).OnRegex(`^[?]{1,2} ?([a-z0-9]+)$`).SetBlock(false).

View File

@@ -15,8 +15,9 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
ctrl "github.com/FloatTech/zbpctrl"
ub "github.com/FloatTech/zbputils/binary"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
)
@@ -37,7 +38,7 @@ const (
var gCurCookieJar *cookiejar.Jar
func init() {
control.Register("novel", &control.Options{
control.Register("novel", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "铅笔小说网搜索\n- 小说[xxx]",
}).OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).Limit(ctxext.LimitByUser).

View File

@@ -3,6 +3,7 @@ package nsfw
import (
"github.com/FloatTech/AnimeAPI/nsfw"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/process"
@@ -13,7 +14,7 @@ import (
const hso = "https://gchat.qpic.cn/gchatpic_new//--4234EDEC5F147A4C319A41149D7E0EA9/0"
func init() {
engine := control.Register("nsfw", &control.Options{
engine := control.Register("nsfw", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "nsfw图片识别\n- nsfw打分[图片]",
}).ApplySingle(ctxext.DefaultSingle)
@@ -31,7 +32,7 @@ func init() {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(judge(p))))
}
})
control.Register("nsfwauto", &control.Options{
control.Register("nsfwauto", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "nsfw图片自动识别\n- 当图片属于非 neutral 类别时自动发送评价",
}).OnMessage(zero.HasPicture).SetBlock(false).

View File

@@ -3,25 +3,22 @@ package omikuji
import (
"fmt"
"log"
"math/rand"
"strconv"
"time"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/text"
)
const bed = "https://gitcode.net/u011570312/senso-ji-omikuji/-/raw/main/%d_%d.jpg"
func init() { // 插件主体
engine := control.Register("omikuji", &control.Options{
engine := control.Register("omikuji", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "浅草寺求签\n" +
"- 求签 | 占卜\n- 解签",
@@ -30,22 +27,17 @@ func init() { // 插件主体
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
miku, err := bangoToday(ctx.Event.UserID)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
i := ctxext.RandSenderPerDayN(ctx, 100) + 1
ctx.SendChain(
message.At(ctx.Event.UserID),
message.Image(fmt.Sprintf(bed, miku, 0)),
message.Image(fmt.Sprintf(bed, miku, 1)),
message.Image(fmt.Sprintf(bed, i, 0)),
message.Image(fmt.Sprintf(bed, i, 1)),
)
})
engine.OnFullMatch("解签", ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
dbpath := engine.DataFolder()
db.DBPath = dbpath + "kuji.db"
_, err := file.GetLazyData(db.DBPath, false, true)
db.DBPath = engine.DataFolder() + "kuji.db"
_, err := engine.GetLazyData("kuji.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
@@ -60,17 +52,17 @@ func init() { // 插件主体
ctx.SendChain(message.Text("ERROR:", err))
return false
}
log.Printf("[kuji]读取%d条签文", n)
logrus.Infof("[kuji]读取%d条签文", n)
return true
},
)).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
bg, err := bangoToday(ctx.Event.UserID)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
kujiBytes, err := text.RenderToBase64(getKujiByBango(bg), text.FontFile, 400, 20)
kujiBytes, err := text.RenderToBase64(
getKujiByBango(
uint8(ctxext.RandSenderPerDayN(ctx, 100)+1),
),
text.FontFile, 400, 20,
)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
@@ -80,13 +72,3 @@ func init() { // 插件主体
}
})
}
func bangoToday(uid int64) (uint8, error) {
today, err := strconv.ParseInt(time.Now().Format("20060102"), 10, 64)
if err != nil {
return 0, err
}
seed := uid + today
r := rand.New(rand.NewSource(seed))
return uint8(r.Intn(100) + 1), nil
}

422
plugin/qqwife/qqmapwife.go Normal file
View File

@@ -0,0 +1,422 @@
// Package qqwife 娶群友 基于“翻牌”和江林大佬的“群老婆”插件魔改作品
package qqwife
import (
"math/rand"
"sort"
"strconv"
"sync"
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/math"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
)
//nolint: asciicheck
type 婚姻登记 struct {
sync.Mutex
mp map[int64]map[int64]*userinfo
}
// 结婚证信息
type userinfo struct {
target int64 // 对象身份证号
username string // 户主名称
targetname string // 对象名称
}
//nolint: asciicheck
func 新登记处() (db 婚姻登记) {
db.mp = make(map[int64]map[int64]*userinfo, 64)
return
}
func (db *婚姻登记) 重置() {
db.Lock()
defer db.Unlock()
for k := range db.mp {
delete(db.mp, k)
}
}
func (db *婚姻登记) 离婚休妻(gid, wife int64) {
db.Lock()
defer db.Unlock()
delete(db.mp[gid], -wife)
}
func (db *婚姻登记) 离婚休夫(gid, husband int64) {
db.Lock()
defer db.Unlock()
delete(db.mp[gid], husband)
}
func (db *婚姻登记) 有登记(gid int64) (ok bool) {
db.Lock()
defer db.Unlock()
mp, ok := db.mp[gid]
if !ok {
return
}
for range mp {
return true
}
return
}
func (db *婚姻登记) 花名册(ctx *zero.Ctx, gid int64) string {
db.Lock()
defer db.Unlock()
mp, ok := db.mp[gid]
if !ok {
return "民政局的花名册出问题了额..."
}
return binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
w.WriteString("群老公←———→群老婆\n-----------")
for uid, userinfo := range mp {
if uid > 0 {
_ = w.WriteByte('\n')
w.WriteString(userinfo.username)
w.WriteString(" & ")
w.WriteString(userinfo.targetname)
}
}
}))
}
func (db *婚姻登记) 查户口(gid, uid int64) (userinfo *userinfo, gender int, ok bool) {
db.Lock()
defer db.Unlock()
gender = 0
mp, ok := db.mp[gid]
if !ok {
return
}
userinfo, ok = mp[uid]
if !ok {
gender = 1
userinfo, ok = mp[-uid]
}
return
}
func (db *婚姻登记) 登记(gid, uid, target int64, username, targetname string) {
db.Lock()
defer db.Unlock()
_, ok := db.mp[gid]
if !ok {
db.mp[gid] = make(map[int64]*userinfo, 32)
}
// 填写夫妻信息
uidinfo := &userinfo{
target: target,
username: username,
targetname: targetname,
}
targetinfo := &userinfo{
target: uid,
username: targetname,
targetname: username,
}
// 民政局登记数据
db.mp[gid][uid] = uidinfo
db.mp[gid][-target] = targetinfo
}
var (
//nolint: asciicheck
民政局 = 新登记处()
skillCD = rate.NewManager[string](time.Hour*24, 1)
lastdate time.Time
sendtext = [...][]string{
{ // 表白成功
"今天你向ta表白了ta羞涩的点了点头同意了\n",
"你对ta说“以我之名冠你指间一天相伴一天相随”.ta捂着嘴点了点头\n\n",
},
{ // 表白失败
"今天你向ta表白了ta毫无感情的拒绝了你",
"今天你向ta表白了ta对你说“你是一个非常好的人”",
"今天你向ta表白了ta给了你一个拥抱后擦肩而过",
},
{ // ntr成功
"你处心积虑的接近tata最终选择跟随你\n",
},
}
)
func init() {
engine := control.Register("qqwife", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "一群一天一夫一妻制群老婆\n每天凌晨刷新CP\n" +
"- 娶群友\n- 群老婆列表\n" +
"--------------------------------\n以下技能每人只能二选一\n CD24H不跨天刷新\n--------------------------------\n" +
"- (娶|嫁)@对方QQ\n- 当[对方Q号|@对方QQ]的小三\n",
})
engine.OnFullMatch("娶群友", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
if time.Now().Day() != lastdate.Day() {
民政局.重置()
// 更新时间
lastdate = time.Now()
}
gid := ctx.Event.GroupID
uid := ctx.Event.UserID
targetinfo, status, ok := 民政局.查户口(gid, uid)
if ok {
switch status {
case 0: // 娶过别人
ctx.SendChain(
message.At(uid),
message.Text("今天你的群老婆是"),
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.target, 10)+"&s=640").Add("cache", 0),
message.Text(
"\n",
"[", targetinfo.targetname, "]",
"(", targetinfo.target, ")哒",
),
)
default: // 嫁给别人
ctx.SendChain(
message.At(uid),
message.Text("今天你的群老公是"),
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(targetinfo.target, 10)+"&s=640").Add("cache", 0),
message.Text(
"\n",
"[", targetinfo.targetname, "]",
"(", targetinfo.target, ")哒",
),
)
}
return
}
// 无缓存获取群员列表
temp := ctx.GetThisGroupMemberListNoCache().Array()
sort.SliceStable(temp, func(i, j int) bool {
return temp[i].Get("last_sent_time").Int() < temp[j].Get("last_sent_time").Int()
})
temp = temp[math.Max(0, len(temp)-30):]
// 将已经娶过的人剔除
qqgrouplist := make([]int64, 0, len(temp))
for k := 0; k < len(temp); k++ {
usr := temp[k].Get("user_id").Int()
_, _, ok := 民政局.查户口(gid, usr)
if ok {
continue
}
qqgrouplist = append(qqgrouplist, usr)
}
// 没有人(只剩自己)的时候
if len(qqgrouplist) == 0 {
ctx.SendChain(message.Text("噢, 此时此刻你还是一只单身狗, 等待下一次情缘吧"))
return
}
// 随机抽娶
fiancee := qqgrouplist[rand.Intn(len(qqgrouplist))]
if fiancee == uid { // 如果是自己
ctx.SendChain(message.Text("噢, 此时此刻你还是一只单身狗, 等待下一次情缘吧"))
return
}
// 去民政局办证
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
// 请大家吃席
ctx.SendChain(
message.At(uid),
message.Text("今天你的群老婆是"),
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(fiancee, 10)+"&s=640").Add("cache", 0),
message.Text(
"\n",
"[", ctx.CardOrNickName(fiancee), "]",
"(", fiancee, ")哒",
),
)
})
// 单身技能
engine.OnRegex(`^(娶|嫁)\[CQ:at,qq=(\d+)\]`, zero.OnlyGroup, checkdog).SetBlock(true).Limit(cdcheck, iscding).
Handle(func(ctx *zero.Ctx) {
choice := ctx.State["regex_matched"].([]string)[1]
fiancee, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
uid := ctx.Event.UserID
if uid == fiancee { // 如果是自己
ctx.SendChain(message.Text("今日获得成就:自恋狂"))
return
}
if rand.Intn(2) == 1 { // 二分之一的概率表白成功
gid := ctx.Event.GroupID
// 去民政局登记
var choicetext string
switch choice {
case "娶":
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
choicetext = "今天你的群老婆是"
default:
民政局.登记(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
choicetext = "今天你的群老公是"
}
// 请大家吃席
ctx.SendChain(
message.Text(sendtext[0][rand.Intn(len(sendtext[0]))]),
message.At(uid),
message.Text(choicetext),
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(fiancee, 10)+"&s=640").Add("cache", 0),
message.Text(
"\n",
"[", ctx.CardOrNickName(fiancee), "]",
"(", fiancee, ")哒",
),
)
return
}
ctx.SendChain(message.Text(sendtext[1][rand.Intn(len(sendtext[1]))]))
})
// NTR技能
engine.OnRegex(`^当(\[CQ:at,qq=(\d+)\] |(\d+))的小三`, zero.OnlyGroup, checkcp).SetBlock(true).Limit(cdcheck, iscding).
Handle(func(ctx *zero.Ctx) {
fid := ctx.State["regex_matched"].([]string)
fiancee, _ := strconv.ParseInt(fid[2]+fid[3], 10, 64)
if rand.Intn(10)/4 != 0 { // 十分之三的概率NTR成功
ctx.SendChain(message.Text("你的ntr计划失败了"))
return
}
gid := ctx.Event.GroupID
uid := ctx.Event.UserID
// 判断target是老公还是老婆
var choicetext string
targetinfo, gender, _ := 民政局.查户口(gid, fiancee)
switch gender {
case 0:
// 让对象离婚
民政局.离婚休妻(gid, targetinfo.target)
// 和对象结婚登记
choicetext = "老公"
民政局.登记(gid, fiancee, uid, ctx.CardOrNickName(fiancee), ctx.CardOrNickName(uid))
default:
// 让对象离婚
民政局.离婚休夫(gid, targetinfo.target)
// 和对象结婚登记
choicetext = "老婆"
民政局.登记(gid, uid, fiancee, ctx.CardOrNickName(uid), ctx.CardOrNickName(fiancee))
}
// 输出结果
ctx.SendChain(
message.Text(sendtext[2][rand.Intn(len(sendtext[2]))]),
message.At(uid),
message.Text("今天你的群"+choicetext+"是"),
message.Image("http://q4.qlogo.cn/g?b=qq&nk="+strconv.FormatInt(fiancee, 10)+"&s=640").Add("cache", 0),
message.Text(
"\n",
"[", ctx.CardOrNickName(fiancee), "]",
"(", fiancee, ")哒",
),
)
})
engine.OnFullMatch("群老婆列表", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
if !民政局.有登记(ctx.Event.GroupID) {
ctx.SendChain(message.Text("你群并没有任何的CP额"))
return
}
ctx.SendChain(message.Text(民政局.花名册(ctx, ctx.Event.GroupID)))
})
}
// 以群号和昵称为限制
func cdcheck(ctx *zero.Ctx) *rate.Limiter {
limitID := strconv.FormatInt(ctx.Event.GroupID, 10) + strconv.FormatInt(ctx.Event.UserID, 10)
return skillCD.Load(limitID)
}
func iscding(ctx *zero.Ctx) {
ctx.SendChain(message.Text("你的技能现在正在CD中"))
}
// 注入判断 是否为单身
func checkdog(ctx *zero.Ctx) bool {
gid := ctx.Event.GroupID
if !民政局.有登记(gid) {
return true // 如果没有人登记,说明全是单身
}
fiancee, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
if err != nil {
ctx.SendChain(message.Text("额你的target好像不存在"))
return false
}
// 获取用户信息
uid := ctx.Event.UserID
uidtarget, uidstatus, ok1 := 民政局.查户口(gid, uid)
_, fianceestatus, ok2 := 民政局.查户口(gid, fiancee)
if !ok1 && !ok2 { // 必须是两个单身
return true
}
if ok1 {
if uidtarget.target == fiancee { // 如果本就是一块
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
return false
}
switch uidstatus {
case 0: // 如果如为攻
ctx.SendChain(message.Text("笨蛋~你家里还有个吃白饭的w"))
default: // 如果为受
ctx.SendChain(message.Text("该是0就是0当0有什么不好"))
}
return false
}
if ok2 {
switch fianceestatus {
case 0: // 如果如为攻
ctx.SendChain(message.Text("他有别的女人了,你该放下了"))
default: // 如果为受
ctx.SendChain(message.Text("这是一个纯爱的世界拒绝NTR"))
}
return false
}
return true
}
// 注入判断 是否满足小三要求
func checkcp(ctx *zero.Ctx) bool {
// 检查群内是否有人登记了
gid := ctx.Event.GroupID
if !民政局.有登记(gid) {
ctx.SendChain(message.Text("ta无法达成你当小三的条件"))
return false
}
// 检查target
fid := ctx.State["regex_matched"].([]string)
fiancee, err := strconv.ParseInt(fid[2]+fid[3], 10, 64)
if err != nil {
ctx.SendChain(message.Text("额,你的对象好像不存在?"))
return false
}
uid := ctx.Event.UserID
if fiancee == uid {
ctx.SendChain(message.Text("自我攻略?"))
return false
}
// 检查用户是否登记过
userinfo, uidstatus, ok := 民政局.查户口(gid, uid)
if ok {
if userinfo.target == fiancee { // 如果本就是一块
ctx.SendChain(message.Text("笨蛋~你们明明已经在一起了啊w"))
return false
}
switch uidstatus {
case 0: // 如果如为攻
ctx.SendChain(message.Text("抱歉,建国之后不支持后宫"))
default: // 如果为受
ctx.SendChain(message.Text("该是0就是0当0有什么不好"))
}
return false
}
_, _, ok = 民政局.查户口(gid, fiancee)
if !ok {
ctx.SendChain(message.Text("ta无法达成你当小三的条件"))
return false
}
return true
}

View File

@@ -8,7 +8,7 @@ import (
// load 加载rate数据
func load(area *rate, jsonfile string) error {
data, err := file.GetLazyData(jsonfile, true, true)
data, err := file.GetLazyData(jsonfile, true)
if err != nil {
return err
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"math/rand"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
wr "github.com/mroth/weightedrand"
@@ -14,7 +15,7 @@ import (
)
func init() {
en := control.Register("reborn", &control.Options{
en := control.Register("reborn", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "投胎\n- reborn",
PublicDataFolder: "Reborn",

View File

@@ -9,7 +9,8 @@ import (
"strings"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -91,7 +92,7 @@ var (
)
func init() {
control.Register("runcode", &control.Options{
control.Register("runcode", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "在线代码运行: \n" +
">runcode [language] [code block]\n" +

View File

@@ -3,6 +3,9 @@ package saucenao
import (
"fmt"
"net/http"
"os"
"reflect"
"strconv"
"github.com/sirupsen/logrus"
@@ -11,22 +14,42 @@ import (
"github.com/FloatTech/AnimeAPI/ascii2d"
"github.com/FloatTech/AnimeAPI/pixiv"
"github.com/FloatTech/AnimeAPI/saucenao"
"github.com/FloatTech/AnimeAPI/yandex"
"github.com/jozsefsallai/gophersauce"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/pool"
)
var (
saucenaocli *gophersauce.Client
)
func init() { // 插件主体
engine := control.Register("saucenao", &control.Options{
engine := control.Register("saucenao", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "搜图\n" +
"- 以图搜图 | 搜索图片 | 以图识图[图片]\n" +
"- 搜图[P站图片ID]",
PrivateDataFolder: "saucenao",
})
apikeyfile := engine.DataFolder() + "apikey.txt"
if file.IsExist(apikeyfile) {
key, err := os.ReadFile(apikeyfile)
if err != nil {
panic(err)
}
saucenaocli, err = gophersauce.NewClient(&gophersauce.Settings{
MaxResults: 1,
APIKey: binary.BytesToString(key),
})
if err != nil {
panic(err)
}
}
// 根据 PID 搜图
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
@@ -65,15 +88,22 @@ func init() { // 插件主体
imgs = append(imgs, message.Image("file:///"+f))
}
txt := message.Text(
"标题", illust.Title, "\n",
"插画ID", illust.Pid, "\n",
"画师", illust.UserName, "\n",
"画师ID", illust.UserId, "\n",
"直链", "https://pixivel.moe/detail?id=", illust.Pid,
"标题: ", illust.Title, "\n",
"插画ID: ", illust.Pid, "\n",
"画师: ", illust.UserName, "\n",
"画师ID: ", illust.UserId, "\n",
"直链: ", "https://pixivel.moe/detail?id=", illust.Pid,
)
if imgs != nil {
// 发送搜索结果
ctx.Send(append(imgs, message.Text("\n"), txt))
if zero.OnlyGroup(ctx) {
ctx.SendGroupForwardMessage(ctx.Event.GroupID, message.Message{
ctxext.FakeSenderForwardNode(ctx, txt),
ctxext.FakeSenderForwardNode(ctx, imgs...),
})
} else {
// 发送搜索结果
ctx.Send(append(imgs, message.Text("\n"), txt))
}
} else {
// 图片下载失败,仅发送文字结果
ctx.SendChain(txt)
@@ -86,43 +116,49 @@ func init() { // 插件主体
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, zero.OnlyGroup, zero.MustProvidePicture).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.SendChain(message.Text("少女祈祷中......"))
ctx.SendChain(message.Text("少女祈祷中..."))
for _, pic := range ctx.State["image_url"].([]string) {
if result, err := saucenao.SauceNAO(pic); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
if saucenaocli != nil {
resp, err := saucenaocli.FromURL(pic)
if err == nil && resp.Count() > 0 {
result := resp.First()
s, err := strconv.ParseFloat(result.Header.Similarity, 64)
if err == nil {
rr := reflect.ValueOf(&result.Data).Elem()
b := binary.NewWriterF(func(w *binary.Writer) {
r := rr.Type()
for i := 0; i < r.NumField(); i++ {
if !rr.Field(i).IsZero() {
w.WriteString("\n")
w.WriteString(r.Field(i).Name)
w.WriteString(": ")
w.WriteString(fmt.Sprint(rr.Field(i).Interface()))
}
}
})
resp, err := http.Head(result.Header.Thumbnail)
msg := make(message.Message, 0, 3)
if s > 80.0 {
msg = append(msg, message.Text("我有把握是这个!"))
} else {
msg = append(msg, message.Text("也许是这个?"))
}
if err == nil && resp.StatusCode == http.StatusOK {
msg = append(msg, message.Image(result.Header.Thumbnail))
} else {
msg = append(msg, message.Image(pic))
}
msg = append(msg, message.Text("\n图源: ", result.Header.IndexName, binary.BytesToString(b)))
ctx.Send(msg)
if s > 80.0 {
continue
}
}
}
} else {
// 返回SauceNAO的结果
ctx.SendChain(
message.Text("我有把握是这个!"),
message.Image(result[0].Thumbnail),
message.Text(
"\n",
"相似度:", result[0].Similarity, "\n",
"标题:", result[0].Title, "\n",
"插画ID", result[0].PixivID, "\n",
"画师:", result[0].MemberName, "\n",
"画师ID", result[0].MemberID, "\n",
"直链:", "https://pixivel.moe/detail?id=", result[0].PixivID,
),
)
continue
ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图, key 请前往 https://saucenao.com/user.php?page=search-api 获取"))
}
if result, err := yandex.Yandex(pic); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
} else {
ctx.SendChain(
message.Text("也许是这个?"),
message.Text(
"\n",
"标题:", result.Title, "\n",
"插画ID", result.Pid, "\n",
"画师:", result.UserName, "\n",
"画师ID", result.UserId, "\n",
"直链:", "https://pixivel.moe/detail?id=", result.Pid,
),
)
}
// 不论结果如何都执行 ascii2d 搜索
// ascii2d 搜索
if result, err := ascii2d.Ascii2d(pic); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
continue
@@ -132,7 +168,7 @@ func init() { // 插件主体
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
message.Image(result[i].Thumb),
message.Text(fmt.Sprintf(
"标题%s\n图源%s\n画师%s\n画师链接%s\n图片链接%s",
"标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s",
result[i].Name,
result[i].Type,
result[i].AuthNm,
@@ -150,4 +186,22 @@ func init() { // 插件主体
}
}
})
engine.OnRegex(`^设置\s?saucenao\s?api\s?key\s?([0-9a-f]{40})$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var err error
saucenaocli, err = gophersauce.NewClient(&gophersauce.Settings{
MaxResults: 1,
APIKey: ctx.State["regex_matched"].([]string)[1],
})
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
err = os.WriteFile(apikeyfile, binary.StringToBytes(saucenaocli.APIKey), 0644)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("成功!"))
})
}

View File

@@ -21,6 +21,7 @@ import (
"github.com/FloatTech/AnimeAPI/nsfw"
"github.com/FloatTech/AnimeAPI/scale"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
@@ -31,7 +32,7 @@ import (
)
func init() {
engine := control.Register("scale", &control.Options{
engine := control.Register("scale", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "叔叔的AI二次元图片放大\n- 放大图片[图片]",
PrivateDataFolder: "scale",

View File

@@ -15,7 +15,10 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img"
"github.com/FloatTech/zbputils/img/text"
@@ -24,7 +27,7 @@ import (
)
const (
backgroundURL = "https://iw233.cn/api.php?sort=pc&type=json"
backgroundURL = "https://mirlkoi.ifast3.vipnps.vip/api.php?sort=pc&type=json"
referer = "https://iw233.cn/main.html"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
signinMax = 1
@@ -35,7 +38,7 @@ const (
var levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
func init() {
engine := control.Register("score", &control.Options{
engine := control.Register("score", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看分数排名",
PrivateDataFolder: "score",
@@ -49,18 +52,17 @@ func init() {
}
sdb = initialize(engine.DataFolder() + "score.db")
}()
engine.OnFullMatch("签到", zero.OnlyGroup).SetBlock(true).
engine.OnFullMatch("签到", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
now := time.Now()
today := now.Format("20060102")
si := sdb.GetSignInByUID(uid)
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
if siUpdateTimeStr != today {
_ = sdb.InsertOrUpdateSignInCountByUID(uid, 0)
}
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
if si.Count >= signinMax && siUpdateTimeStr == today {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
if file.IsExist(drawedFile) {
@@ -68,21 +70,21 @@ func init() {
}
return
}
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
err := initPic(picFile)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
_ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
back, err := gg.LoadImage(picFile)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if siUpdateTimeStr != today {
_ = sdb.InsertOrUpdateSignInCountByUID(uid, 0)
}
_ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
// 避免图片过大,最大 1280*720
back = img.Limit(back, 1280, 720)
@@ -94,7 +96,7 @@ func init() {
monthWord := now.Format("01/02")
hourWord := getHourWord(now)
_, err = file.GetLazyData(text.BoldFontFile, false, true)
_, err = file.GetLazyData(text.BoldFontFile, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
@@ -107,7 +109,7 @@ func init() {
canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2)
canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2)
nickName := ctx.CardOrNickName(uid)
_, err = file.GetLazyData(text.FontFile, false, true)
_, err = file.GetLazyData(text.FontFile, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
@@ -159,7 +161,7 @@ func init() {
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
})
engine.OnPrefix("获得签到背景", zero.OnlyGroup).SetBlock(true).
engine.OnPrefix("获得签到背景", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
var uidStr string
@@ -175,7 +177,7 @@ func init() {
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile))
})
engine.OnFullMatch("查看分数排名", zero.OnlyGroup).SetBlock(true).
engine.OnFullMatch("查看分数排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
today := time.Now().Format("20060102")
drawedFile := cachePath + today + "scoreRank.png"
@@ -192,7 +194,7 @@ func init() {
ctx.SendChain(message.Text("ERROR:目前还没有人签到过"))
return
}
_, err = file.GetLazyData(text.FontFile, false, true)
_, err = file.GetLazyData(text.FontFile, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
@@ -207,14 +209,17 @@ func init() {
ctx.SendChain(message.Text("ERROR:", err))
return
}
f, err := os.Create(drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
bars := make([]chart.Value, len(st))
for i, v := range st {
bars[i] = chart.Value{
Value: float64(v.Score),
Label: ctx.CardOrNickName(v.UID),
}
bars[i].Value = float64(v.Score)
bars[i].Label = ctx.CardOrNickName(v.UID)
}
graph := chart.BarChart{
err = chart.BarChart{
Font: font,
Title: "饼干排名",
Background: chart.Style{
@@ -225,13 +230,7 @@ func init() {
Height: 500,
BarWidth: 50,
Bars: bars,
}
f, err := os.Create(drawedFile)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
err = graph.Render(chart.PNG, f)
}.Render(chart.PNG, f)
_ = f.Close()
if err != nil {
_ = os.Remove(drawedFile)
@@ -243,16 +242,17 @@ func init() {
}
func getHourWord(t time.Time) string {
h := t.Hour()
switch {
case 6 <= t.Hour() && t.Hour() < 12:
case 6 <= h && h < 12:
return "早上好"
case 12 <= t.Hour() && t.Hour() < 14:
case 12 <= h && h < 14:
return "中午好"
case 14 <= t.Hour() && t.Hour() < 19:
case 14 <= h && h < 19:
return "下午好"
case 19 <= t.Hour() && t.Hour() < 24:
case 19 <= h && h < 24:
return "晚上好"
case 0 <= t.Hour() && t.Hour() < 6:
case 0 <= h && h < 6:
return "凌晨好"
default:
return ""
@@ -271,20 +271,17 @@ func getLevel(count int) int {
}
func initPic(picFile string) error {
if file.IsNotExist(picFile) {
data, err := web.RequestDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
if err != nil {
return err
}
picURL := gjson.Get(string(data), "pic").String()
data, err = web.RequestDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
if err != nil {
return err
}
err = os.WriteFile(picFile, data, 0666)
if err != nil {
return err
}
if file.IsExist(picFile) {
return nil
}
return nil
data, err := web.RequestDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
if err != nil {
return err
}
picURL := gjson.Get(binary.BytesToString(data), "pic.0").Str
data, err = web.RequestDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
if err != nil {
return err
}
return os.WriteFile(picFile, data, 0644)
}

View File

@@ -10,7 +10,8 @@ import (
"github.com/FloatTech/AnimeAPI/pixiv"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
fileutil "github.com/FloatTech/zbputils/file"
imagepool "github.com/FloatTech/zbputils/img/pool"
@@ -49,7 +50,7 @@ var pool = &imgpool{
}
func init() { // 插件主体
engine := control.Register("setutime", &control.Options{
engine := control.Register("setutime", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "涩图\n" +
"- 来份[涩图/二次元/风景/车万]\n" +
@@ -62,7 +63,7 @@ func init() { // 插件主体
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
// 如果数据库不存在则下载
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
_, _ = engine.GetLazyData("SetuTime.db", false)
err := pool.db.Open()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -1,21 +0,0 @@
package shadiao
import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.RequestDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}

View File

@@ -1,21 +0,0 @@
package shadiao
import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.RequestDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}

View File

@@ -0,0 +1,24 @@
package shadiao
import (
"github.com/FloatTech/zbputils/ctxext"
"github.com/antchfx/htmlquery"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
engine.OnFullMatch("马丁路德骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
doc, err := htmlquery.LoadURL(ergofabulousURL)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
node, err := htmlquery.Query(doc, "//main[@role=\"main\"]/p[@class=\"larger\"]/text()")
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(node.Data))
})
}

View File

@@ -1,21 +0,0 @@
package shadiao
import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.RequestDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}

View File

@@ -2,28 +2,46 @@
package shadiao
import (
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const (
chpURL = "https://chp.shadiao.app/chp"
chpURL = "https://api.shadiao.app/chp"
duURL = "https://api.shadiao.app/du"
pyqURL = "https://api.shadiao.app/pyq"
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
ergofabulousURL = "https://ergofabulous.org/luther/?"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
chpReferer = "https://chp.shadiao.app/"
duReferer = "https://du.shadiao.app/"
pyqReferer = "https://pyq.shadiao.app/"
sdReferer = "https://api.shadiao.app/"
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
loveliveReferer = "https://lovelive.tools/"
)
var (
engine = control.Register("shadiao", &control.Options{
engine = control.Register("shadiao", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "沙雕app\n" +
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子\n- 马丁路德骂我\n",
})
sdMap = map[string]string{"哄我": chpURL, "来碗毒鸡汤": duURL, "发个朋友圈": pyqURL}
)
func init() {
engine.OnFullMatchGroup([]string{"哄我", "来碗毒鸡汤", "发个朋友圈"}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
requestURL := sdMap[ctx.State["matched"].(string)]
data, err := web.RequestDataWith(web.NewDefaultClient(), requestURL, "GET", sdReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.GetBytes(data, "data.text").String()))
})
}

View File

@@ -7,13 +7,14 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
)
func init() {
engine := control.Register("shindan", &control.Options{
engine := control.Register("shindan", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "shindan\n" +
"- 今天是什么少女[@xxx]\n" +

View File

@@ -9,11 +9,12 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
)
func init() {
engine := control.Register("sleepmanage", &control.Options{
engine := control.Register("sleepmanage", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "sleepmanage\n- 早安\n- 晚安",
PrivateDataFolder: "sleep",

View File

@@ -1,77 +1,165 @@
// Package tarot 塔罗牌
package tarot
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"strconv"
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const bed = "https://gitcode.net/shudorcl/zbp-tarot/-/raw/master/"
type card struct {
Name string `json:"name"`
Info struct {
Description string `json:"description"`
ReverseDescription string `json:"reverseDescription"`
ImgURL string `json:"imgUrl"`
} `json:"info"`
type cardInfo struct {
Description string `json:"description"`
ReverseDescription string `json:"reverseDescription"`
ImgURL string `json:"imgUrl"`
}
type cardset = map[string]card
type card struct {
Name string `json:"name"`
cardInfo `json:"info"`
}
type cardSet = map[string]card
var cardMap = make(cardset, 256)
var reasons = []string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
var position = []string{"正位", "逆位"}
var cardMap = make(cardSet, 30)
var infoMap = make(map[string]cardInfo, 30)
// var cardName = make([]string, 22)
func init() {
engine := control.Register("tarot", &control.Options{
engine := control.Register("tarot", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "塔罗牌\n" +
"- 抽塔罗牌\n",
// TODOX张塔罗牌 解塔罗牌[牌名]
"- 抽塔罗牌\n" +
"-n张塔罗牌\n" +
"- 解塔罗牌[牌名]",
PublicDataFolder: "Tarot",
}).ApplySingle(ctxext.DefaultSingle)
engine.OnFullMatch("抽塔罗牌", ctxext.DoOnceOnSuccess(
engine.OnRegex(`^抽(\d{1,2}张)?塔罗牌$`, ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
tarotPath := engine.DataFolder() + "tarots.json"
data, err := file.GetLazyData(tarotPath, true, true)
data, err := engine.GetLazyData("tarots.json", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
err = json.Unmarshal(data, &cardMap)
if err != nil {
panic(err)
ctx.SendChain(message.Text("ERROR:", err))
return false
}
log.Printf("[tarot]读取%d张塔罗牌", len(cardMap))
logrus.Infof("[tarot]读取%d张塔罗牌", len(cardMap))
return true
},
)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
i := rand.Intn(22)
p := rand.Intn(2)
card := cardMap[(strconv.Itoa(i))]
name := card.Name
var info string
if p == 0 {
info = card.Info.Description
} else {
info = card.Info.ReverseDescription
)).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
match := ctx.State["regex_matched"].([]string)[1]
n := 1
reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
position := [...]string{"正位", "逆位"}
reverse := [...]string{"", "Reverse"}
if match != "" {
var err error
n, err = strconv.Atoi(match[:len(match)-3])
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if n <= 0 {
ctx.SendChain(message.Text("ERROR:张数必须为正"))
return
}
if n > 1 && !zero.OnlyGroup(ctx) {
ctx.SendChain(message.Text("ERROR:抽取多张仅支持群聊"))
return
}
if n > 20 {
ctx.SendChain(message.Text("ERROR:抽取张数过多"))
return
}
}
if id := ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text(reasons[rand.Intn(len(reasons))], position[p], " 的 ", name, "\n"),
message.Image(fmt.Sprintf(bed+"MajorArcana/%d.png", i)),
message.Text("\n其意义为", info),
); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR:可能被风控了"))
if n == 1 {
i := rand.Intn(22)
p := rand.Intn(2)
card := cardMap[(strconv.Itoa(i))]
name := card.Name
if id := ctx.SendChain(
message.Text(reasons[rand.Intn(len(reasons))], position[p], " 的 ", name, "\n"),
message.Image(fmt.Sprintf(bed+"MajorArcana%s/%d.png", reverse[p], i))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR:可能被风控了"))
}
return
}
msg := make([]message.MessageSegment, n)
randomIntMap := make(map[int]int, 30)
for i := range msg {
j := rand.Intn(22)
_, ok := randomIntMap[j]
for ok {
j = rand.Intn(22)
_, ok = randomIntMap[j]
}
randomIntMap[j] = 0
p := rand.Intn(2)
card := cardMap[(strconv.Itoa(j))]
name := card.Name
tarotMsg := []message.MessageSegment{
message.Text(reasons[rand.Intn(len(reasons))], position[p], " 的 ", name, "\n"),
message.Image(fmt.Sprintf(bed+"MajorArcana%s/%d.png", reverse[p], j))}
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
}
ctx.SendGroupForwardMessage(ctx.Event.GroupID, msg)
})
engine.OnRegex(`^解塔罗牌\s?(.*)`, ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
if len(cardMap) > 0 {
for _, card := range cardMap {
infoMapKey := strings.Split(card.Name, "(")[0]
infoMap[infoMapKey] = card.cardInfo
// 可以拿来显示大阿尔卡纳列表
// cardName = append(cardName, infoMapKey)
}
return true
}
tempMap := make(cardSet, 30)
data, err := engine.GetLazyData("tarots.json", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
err = json.Unmarshal(data, &tempMap)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
for _, card := range tempMap {
infoMapKey := strings.Split(card.Name, "(")[0]
infoMap[infoMapKey] = card.cardInfo
// 可以拿来显示大阿尔卡纳列表
// cardName = append(cardName, infoMapKey)
}
return true
},
)).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
match := ctx.State["regex_matched"].([]string)[1]
info, ok := infoMap[match]
if ok {
ctx.SendChain(
message.Image(bed+info.ImgURL),
message.Text("\n", match, "的含义是~"),
message.Text("\n正位:", info.Description),
message.Text("\n逆位:", info.ReverseDescription))
} else {
ctx.SendChain(message.Text("没有找到", match, "噢~"))
}
})
}

View File

@@ -5,8 +5,8 @@ import (
"encoding/json"
"math/rand"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -15,13 +15,13 @@ import (
type kimo = map[string]*[]string
func init() {
engine := control.Register("thesaurus", &control.Options{
engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "thesaurus\n- 词典匹配回复",
PublicDataFolder: "Chat",
})
go func() {
data, err := file.GetLazyData(engine.DataFolder()+"kimoi.json", true, false)
data, err := engine.GetLazyData("kimoi.json", false)
if err != nil {
panic(err)
}

View File

@@ -3,9 +3,9 @@ package tiangou
import (
sql "github.com/FloatTech/sqlite"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -19,7 +19,7 @@ type tiangou struct {
var db = &sql.Sqlite{}
func init() {
en := control.Register("tiangou", &control.Options{
en := control.Register("tiangou", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "舔狗日记\n" +
"- 舔狗日记",
@@ -28,9 +28,8 @@ func init() {
en.OnFullMatch("舔狗日记", ctxext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
dbpath := en.DataFolder()
db.DBPath = dbpath + "tiangou.db"
_, err := file.GetLazyData(db.DBPath, false, true)
db.DBPath = en.DataFolder() + "tiangou.db"
_, err := en.GetLazyData("tiangou.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false

View File

@@ -2,7 +2,8 @@
package tracemoe
import (
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
trmoe "github.com/fumiama/gotracemoe"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -13,7 +14,7 @@ var (
)
func init() { // 插件主体
engine := control.Register("tracemoe", &control.Options{
engine := control.Register("tracemoe", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]",
})

View File

@@ -3,14 +3,15 @@ package translation
import (
"github.com/FloatTech/AnimeAPI/tl"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
control.Register("translation", &control.Options{
control.Register("translation", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "翻译\n" +
">TL 你好",

View File

@@ -18,7 +18,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/text"
@@ -30,7 +31,7 @@ import (
var reg = regexp.MustCompile(".*/(.*)")
func init() {
engine := control.Register("vtbquotation", &control.Options{
engine := control.Register("vtbquotation", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb\n- 更新vtb\n",
PublicDataFolder: "VtbQuotation",
@@ -43,7 +44,7 @@ func init() {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
_, err = file.GetLazyData(dbfile, false, false)
_, err = engine.GetLazyData("vtb.db", false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false

View File

@@ -2,6 +2,7 @@
package wangyiyun
import (
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
@@ -17,7 +18,7 @@ const (
)
func init() {
control.Register("wangyiyun", &control.Options{
control.Register("wangyiyun", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "wangyiyun \n- 来份网易云热评",
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).

View File

@@ -11,6 +11,7 @@ import (
"sync"
"time"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
@@ -30,7 +31,7 @@ var (
)
func init() {
engine := control.Register("wordcount", &control.Options{
engine := control.Register("wordcount", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "聊天热词\n" +
"- 热词 [群号] [消息数目]|热词 123456 1000",
@@ -40,7 +41,7 @@ func init() {
_ = os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
engine.OnRegex(`^热词\s?(\d*)\s?(\d*)$`, zero.OnlyGroup, ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
_, err := file.GetLazyData(engine.DataFolder()+"stopwords.txt", false, false)
_, err := engine.GetLazyData("stopwords.txt", false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
@@ -56,7 +57,7 @@ func init() {
return true
})).Limit(ctxext.LimitByUser).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
_, err := file.GetLazyData(text.FontFile, false, true)
_, err := file.GetLazyData(text.FontFile, true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return

View File

@@ -13,12 +13,11 @@ import (
"time"
"github.com/FloatTech/AnimeAPI/tl"
"github.com/sirupsen/logrus"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/writer"
"github.com/fogleman/gg"
zero "github.com/wdvxdr1123/ZeroBot"
@@ -61,7 +60,7 @@ type dictionary map[int]struct {
var words = make(dictionary)
func init() {
en := control.Register("wordle", &control.Options{
en := control.Register("wordle", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "猜单词\n" +
"- 个人猜单词\n" +
@@ -87,8 +86,7 @@ func init() {
wg.Add(2)
go func(i int) {
defer wg.Done()
dc, err := file.GetLazyData(fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i), true, true)
logrus.Debugln("[wordle] get", fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i))
dc, err := en.GetLazyData(fmt.Sprintf("cet-4_%d.txt", i), true)
if err != nil {
atomic.AddUint32(&errcnt, 1)
return
@@ -103,8 +101,7 @@ func init() {
}(i)
go func(i int) {
defer wg.Done()
dd, err := file.GetLazyData(fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i), true, true)
logrus.Debugln("[wordle] get", fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i))
dd, err := en.GetLazyData(fmt.Sprintf("dict_%d.txt", i), true)
if err != nil {
atomic.AddUint32(&errcnt, 1)
return

View File

@@ -5,14 +5,15 @@ import (
"fmt"
"strconv"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
en := control.Register("wtf", &control.Options{
en := control.Register("wtf", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "鬼东西\n- 鬼东西列表\n- 查询鬼东西[序号][@xxx]",
})

View File

@@ -4,22 +4,22 @@ package ymgal
import (
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
engine := control.Register("ymgal", &control.Options{
engine := control.Register("ymgal", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "月幕galgame\n- 随机galCG\n- 随机gal表情包\n- galCG[xxx]\n- gal表情包[xxx]\n- 更新gal\n",
PublicDataFolder: "Ymgal",
})
dbfile := engine.DataFolder() + "ymgal.db"
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
_, err := file.GetLazyData(dbfile, false, false)
dbfile := engine.DataFolder() + "ymgal.db"
_, err := engine.GetLazyData("ymgal.db", false)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false

View File

@@ -9,8 +9,9 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/binary"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/web"
)
@@ -27,7 +28,7 @@ var (
)
func init() { // 插件主体
engine := control.Register("zaobao", &control.Options{
engine := control.Register("zaobao", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "易即今日公众号api的今日早报\n" +
"api早上8点更新推荐定时在8点30后\n" +
@@ -49,7 +50,7 @@ func init() { // 插件主体
func getdata() error { // 获取图片链接并且下载
mu.Lock()
defer mu.Unlock()
if picdata != nil && time.Since(pictime) <= time.Hour*20 {
if picdata != nil && time.Since(pictime) <= time.Hour*8 && time.Now().Day() == pictime.Day() {
return nil
}
data, err := web.RequestDataWith(web.NewDefaultClient(), api, "GET", "", ua)