mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
Compare commits
159 Commits
v1.6.2-bet
...
v1.7.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9676b26de0 | ||
|
|
30f60bc7e9 | ||
|
|
9dade7f3e8 | ||
|
|
f043fbf0c0 | ||
|
|
e75814e3b3 | ||
|
|
245b50ba94 | ||
|
|
16e5b84e5c | ||
|
|
26e4b3c513 | ||
|
|
986e50705d | ||
|
|
38b11bb8c9 | ||
|
|
0357405cdf | ||
|
|
7f264964c2 | ||
|
|
c8dcdbb0b2 | ||
|
|
ebcd3cdef2 | ||
|
|
eb43f84d34 | ||
|
|
5931e03c00 | ||
|
|
aaf659f6d4 | ||
|
|
f4add826ff | ||
|
|
0d8157e2f8 | ||
|
|
283667cfe5 | ||
|
|
6403614fa8 | ||
|
|
bdcb833217 | ||
|
|
278d7e0cf9 | ||
|
|
821f8d4949 | ||
|
|
436838d2f8 | ||
|
|
30301f1aba | ||
|
|
df1d71b9b2 | ||
|
|
0315718ab7 | ||
|
|
971c179227 | ||
|
|
1c0270fda0 | ||
|
|
5463945b6c | ||
|
|
8eb058fb26 | ||
|
|
33e5b0286f | ||
|
|
296fd60cd7 | ||
|
|
667c9fbcca | ||
|
|
3d8d0ad107 | ||
|
|
f35a89e401 | ||
|
|
c5c63d0b64 | ||
|
|
3e15754031 | ||
|
|
c1e37b293c | ||
|
|
8edc3f6de6 | ||
|
|
416cb3f2b8 | ||
|
|
8050f12d51 | ||
|
|
292fc311d6 | ||
|
|
28cb0491f7 | ||
|
|
1bad611018 | ||
|
|
d49224fd50 | ||
|
|
2324837052 | ||
|
|
35f8458d67 | ||
|
|
8a6b7f65c7 | ||
|
|
7b1d2b7eaa | ||
|
|
7ced79c6bb | ||
|
|
e224bf9252 | ||
|
|
2b1caafa16 | ||
|
|
c1702c5d5e | ||
|
|
5c8ead8b1d | ||
|
|
635eb9832a | ||
|
|
f1e49dc02e | ||
|
|
573c942a9d | ||
|
|
e8b61b39f0 | ||
|
|
ed26d31326 | ||
|
|
76dbf5a4b6 | ||
|
|
f1ea658c7d | ||
|
|
2964986ee5 | ||
|
|
52ef28cd6a | ||
|
|
df4c0438a2 | ||
|
|
864f92a728 | ||
|
|
6ea50cf8b7 | ||
|
|
d66dd9b7fa | ||
|
|
4a15326977 | ||
|
|
b4a1f93993 | ||
|
|
0c8dfb3f9c | ||
|
|
1aa11879dc | ||
|
|
14c596be1f | ||
|
|
309afecadd | ||
|
|
f465e78460 | ||
|
|
aa5c324592 | ||
|
|
1a0575af64 | ||
|
|
587d3967ef | ||
|
|
d693f988bb | ||
|
|
500dcaa9ed | ||
|
|
1376803b07 | ||
|
|
68386910c4 | ||
|
|
1734f1f7d4 | ||
|
|
86b87c2b4e | ||
|
|
e9eb4c5602 | ||
|
|
6474b36ccd | ||
|
|
107149892c | ||
|
|
f1dba97922 | ||
|
|
bc3c4303be | ||
|
|
f7a61ed0ee | ||
|
|
107b38e2f5 | ||
|
|
0d85fa04e1 | ||
|
|
1d8f5a7869 | ||
|
|
5e93368e57 | ||
|
|
56e931665e | ||
|
|
e5b2b369e3 | ||
|
|
58cf08fc39 | ||
|
|
c18f9b8b72 | ||
|
|
0df465e1c6 | ||
|
|
8b010321d5 | ||
|
|
e1591c44b6 | ||
|
|
cc26eb1332 | ||
|
|
366c7acb90 | ||
|
|
d8cb5206e8 | ||
|
|
90efebf02f | ||
|
|
960cd3ad8b | ||
|
|
09a3e807c9 | ||
|
|
fb2718b495 | ||
|
|
1550cb7fcc | ||
|
|
7b27bc8f7a | ||
|
|
54598fbf54 | ||
|
|
bb844eaa40 | ||
|
|
4ef6f584c9 | ||
|
|
861b3cc82f | ||
|
|
5226548cec | ||
|
|
d41ae01f01 | ||
|
|
e294059de4 | ||
|
|
84bc79eaa6 | ||
|
|
8f9a396821 | ||
|
|
6f96c389c4 | ||
|
|
c55e31ed6f | ||
|
|
f3a0813fed | ||
|
|
c1602c323d | ||
|
|
1bceaa52ff | ||
|
|
86296a28df | ||
|
|
fe9b5023f6 | ||
|
|
d68223f63d | ||
|
|
1c274d6eb8 | ||
|
|
0e52bbe0f7 | ||
|
|
a177448315 | ||
|
|
ca3ff1b522 | ||
|
|
41f0b11469 | ||
|
|
ba0e471a19 | ||
|
|
84115a7316 | ||
|
|
4dc837854b | ||
|
|
64f9e309ef | ||
|
|
67a1050df6 | ||
|
|
d85865825e | ||
|
|
2704d3e7d4 | ||
|
|
0944fc7854 | ||
|
|
611c275092 | ||
|
|
e3e991e6ab | ||
|
|
f2cebcf95a | ||
|
|
4aca16a393 | ||
|
|
891bbb96aa | ||
|
|
d60acd3a47 | ||
|
|
7dc6499127 | ||
|
|
f28e746652 | ||
|
|
3c905d9061 | ||
|
|
091d3170fc | ||
|
|
bdc4138d78 | ||
|
|
e231235ed1 | ||
|
|
1795b9196b | ||
|
|
d5d0563544 | ||
|
|
723b7a9857 | ||
|
|
6a0a16662e | ||
|
|
f82ba852ba | ||
|
|
180945670b |
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
- name: Setup Go environment
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
- name: Cache downloaded module
|
||||
uses: actions/cache@master
|
||||
with:
|
||||
|
||||
2
.github/workflows/pull.yml
vendored
2
.github/workflows/pull.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@master
|
||||
|
||||
2
.github/workflows/push.yml
vendored
2
.github/workflows/push.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@master
|
||||
|
||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -16,12 +16,12 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@master
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ go-zero*
|
||||
nohup.out
|
||||
zerobot
|
||||
ZeroBot-Plugin*
|
||||
*.syso
|
||||
|
||||
@@ -18,7 +18,7 @@ linters:
|
||||
fast: false
|
||||
enable:
|
||||
- bodyclose
|
||||
- depguard
|
||||
#- depguard
|
||||
- dogsled
|
||||
- errcheck
|
||||
- exportloopref
|
||||
@@ -59,7 +59,7 @@ run:
|
||||
tests: false
|
||||
skip-dirs:
|
||||
- order
|
||||
go: '1.19'
|
||||
go: '1.20'
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
|
||||
@@ -4,6 +4,8 @@ env:
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go install github.com/tc-hib/go-winres@latest
|
||||
- go-winres make
|
||||
builds:
|
||||
- id: nowin
|
||||
env:
|
||||
@@ -64,7 +66,7 @@ archives:
|
||||
format: zip
|
||||
|
||||
nfpms:
|
||||
- license: GPL 3.0
|
||||
- license: AGPL 3.0
|
||||
homepage: https://github.com/FloatTech/ZeroBot-Plugin
|
||||
file_name_template: "zbp_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
||||
formats:
|
||||
|
||||
222
README.md
222
README.md
@@ -1,7 +1,6 @@
|
||||
<div align="center">
|
||||
<a href="https://crypko.ai/crypko/5k8HyUVTq5421/">
|
||||
<img src=".github/hua_nobg_512.gif" alt="椛" width = "400">
|
||||
</a><br>
|
||||
<br>
|
||||
|
||||
<h1>ZeroBot-Plugin</h1>
|
||||
|
||||
@@ -10,7 +9,7 @@
|
||||
ZeroBot-Plugin 是 ZeroBot 的 实用插件合集<br><br>
|
||||
|
||||
|
||||
<img src="http://cmoe.azurewebsites.net/cmoe?name=ZeroBot-Plugin&theme=r34" /><br>
|
||||
<img src="https://counter.seku.su/cmoe?name=ZeroBot-Plugin&theme=r34" /><br>
|
||||
|
||||
[](https://github.com/Mrs4s/MiraiGo)
|
||||
[](https://github.com/takayama-lily/oicq)
|
||||
@@ -18,7 +17,7 @@
|
||||
|
||||
[](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin)
|
||||
[](https://t.me/zerobotplugin)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
|
||||
[](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
|
||||
[](https://t.me/zerobotplugin)
|
||||
@@ -38,15 +37,19 @@
|
||||
|
||||
> 如果您对开发插件感兴趣,欢迎加入[ZeroBot-Plugin-Playground](https://github.com/FloatTech/ZeroBot-Plugin-Playground)
|
||||
|
||||
> webui持续开发中, 欢迎加入[ZeroBot-Plugin-Webui](https://github.com/FloatTech/ZeroBot-Plugin-Webui)
|
||||
|
||||
## 命令行参数
|
||||
> `[]`代表是可选参数
|
||||
```bash
|
||||
zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&]
|
||||
zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&]
|
||||
```
|
||||
- **-h**: 显示帮助
|
||||
- **-m**: 不自动标记消息为已读
|
||||
- **-n nickname**: 设置默认昵称,默认为`椛椛`
|
||||
- **-t token**: 设置`AccessToken`,默认为空
|
||||
- **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700`
|
||||
- ~~**-g url**~~(默认禁用): 设置`webui url`,默认为`127.0.0.1:3000`
|
||||
- **-p prefix**: 设置命令前缀,默认为`/`
|
||||
- **-d|w**: 开启 debug | warning 级别及以上日志输出
|
||||
- **-c config.json**: 从`config.json`加载`bot`配置
|
||||
@@ -60,34 +63,28 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.j
|
||||
默认配置文件格式如下。当选择从配置文件加载时,将忽略相应命令行参数。
|
||||
```json
|
||||
{
|
||||
"zero": {
|
||||
"nickname": [
|
||||
"椛椛",
|
||||
"ATRI",
|
||||
"atri",
|
||||
"亚托莉",
|
||||
"アトリ"
|
||||
],
|
||||
"command_prefix": "/",
|
||||
"super_users": [],
|
||||
"ring_len": 4096,
|
||||
"latency": 233000000,
|
||||
"max_process_time": 240000000000
|
||||
},
|
||||
"ws": [
|
||||
{
|
||||
"Url": "ws://127.0.0.1:6700",
|
||||
"AccessToken": ""
|
||||
}
|
||||
],
|
||||
"wss": null
|
||||
"zero": {
|
||||
"nickname": ["椛椛", "ATRI", "atri", "亚托莉", "アトリ"],
|
||||
"command_prefix": "/",
|
||||
"super_users": [],
|
||||
"ring_len": 4096,
|
||||
"latency": 233000000,
|
||||
"max_process_time": 240000000000,
|
||||
"mark_message": true
|
||||
},
|
||||
"ws": [{ "Url": "ws://127.0.0.1:6700", "AccessToken": "" }],
|
||||
"wss": null
|
||||
}
|
||||
```
|
||||
|
||||
## 功能
|
||||
> 在编译时,以下功能除插件控制外,均可通过注释`main.go`中的相应`import`而物理禁用,减小插件体积。
|
||||
|
||||
> 通过插件控制,还可动态管理某个功能在某个群的打开/关闭。
|
||||
> 插件的优先级为`import`的先后顺序
|
||||
|
||||
> 插件的优先级为`import`的先后顺序。
|
||||
|
||||
> `webui`默认禁用不编译,打开后会增加程序体积。
|
||||
|
||||
<details>
|
||||
<summary>插件控制</summary>
|
||||
@@ -130,9 +127,14 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.j
|
||||
|
||||
- [x] /服务列表
|
||||
|
||||
- [x] /设置服务列表显示行数 xx
|
||||
- [x] /设置服务列表显示行数 xx (默认值为 9, 该设置仅运行时有效, zbp 重启后重置)
|
||||
|
||||
- [x] (默认禁用) /设置webui用户名 zerobot 密码 123456
|
||||
|
||||
- [x] (默认禁用) /webui启动
|
||||
|
||||
- [x] (默认禁用) /webui停止
|
||||
|
||||
默认值为9,该设置仅运行时有效,zbp重启后重置
|
||||
- [x] @Bot 插件冲突检测 (会在本群发送一条消息并在约 1s 后撤回以检测其它同类 bot 中已启用的插件并禁用)
|
||||
|
||||
</details>
|
||||
@@ -425,11 +427,11 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>百度一下</summary>
|
||||
<summary>百科</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu"`
|
||||
|
||||
- [x] 百度下[xxx]
|
||||
- [x] 百度/百科/维基/wiki[xxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -548,7 +550,7 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] b站推送列表
|
||||
|
||||
- [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 10s"触发的指令)
|
||||
- [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 5m"触发的指令)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -560,14 +562,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 随机书评
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>打断复读</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat"`
|
||||
|
||||
- [x] (打断三次以上的复读)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>藏头诗</summary>
|
||||
@@ -620,6 +614,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 磕cp大老师 雪乃
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>今日早报</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews"`
|
||||
|
||||
- [x] 今日早报
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>DeepDanbooru二次元图标签识别</summary>
|
||||
@@ -640,6 +642,34 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 教你一篇小作文[作文]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>程序员做饭指南</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dish"`
|
||||
|
||||
- [x] 怎么做 | 烹饪[菜名]
|
||||
|
||||
- [x] 随机菜谱 | 随便做点菜
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>多功能抽签</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drawlots"`
|
||||
|
||||
支持图包文件夹和gif抽签
|
||||
|
||||
- [x] (刷新)抽签列表
|
||||
|
||||
- [x] 抽[签名]签
|
||||
|
||||
- [x] 看签[gif签名]
|
||||
|
||||
- [x] 加签[签名][gif图片]
|
||||
|
||||
- [x] 删签[gif签名]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>女装</summary>
|
||||
@@ -690,7 +720,8 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/font"`
|
||||
|
||||
- [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx
|
||||
- [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|粗苹方体|未来荧黑体|Gugi体|八丸体|Impact体|猫啃体|苹方体])渲染(抖动)文字xxx
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>每日运势</summary>
|
||||
@@ -784,6 +815,16 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 来点黑丝/白丝/jk/巨乳/足控/网红
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>一言</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/hitokoto"`
|
||||
|
||||
- [x] 一言[xxx]
|
||||
|
||||
- [x] 系列一言
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>炉石</summary>
|
||||
@@ -872,6 +913,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 喝奶茶绝绝子 | 绝绝子吃饭
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>疯狂星期四</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday"`
|
||||
|
||||
- [x] 疯狂星期四
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>kokomi原神面板</summary>
|
||||
@@ -1192,6 +1241,7 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 签到
|
||||
- [x] 获得签到背景[@xxx] | 获得签到背景
|
||||
- [x] 设置签到预设(0~3)
|
||||
- [x] 查看等级排名
|
||||
- 注:跨群排行
|
||||
- [x] 查看我的钱包
|
||||
@@ -1224,10 +1274,26 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 卖萌[@xxx]
|
||||
|
||||
- [x] 抽老婆[@xxx]
|
||||
- [x] 今日老婆[@xxx]
|
||||
|
||||
- [x] 黄油角色[@xxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>steam</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam"`
|
||||
|
||||
- [x] steam[添加|删除]订阅xxxxx
|
||||
|
||||
- [x] steam查询订阅
|
||||
|
||||
- [x] steam绑定 api key xxxxxxx
|
||||
|
||||
- [x] 查看apikey
|
||||
|
||||
- [x] 拉取steam订阅 (使用job执行定时任务------记录在"@every 1m"触发的指令)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>抽塔罗牌</summary>
|
||||
@@ -1283,6 +1349,16 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 更新vtb
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>vtb点歌</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic"`
|
||||
|
||||
- [x] vtb点歌
|
||||
|
||||
- [x] vtb随机点歌
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>钱包</summary>
|
||||
@@ -1301,7 +1377,17 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 来份网易云热评
|
||||
|
||||
</details>
|
||||
</details>
|
||||
<details>
|
||||
<summary>据意查句</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wantquotes"`
|
||||
|
||||
- [x] 据意查句 大海
|
||||
|
||||
- [x] 登录据意查句
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>星际战甲</summary>
|
||||
|
||||
@@ -1378,19 +1464,11 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>月幕galgame图</summary>
|
||||
<summary>抽老婆</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife"`
|
||||
|
||||
- [x] 随机galCG
|
||||
|
||||
- [x] 随机gal表情包
|
||||
|
||||
- [x] galCG[xxx]
|
||||
|
||||
- [x] gal表情包[xxx]
|
||||
|
||||
- [x] 更新gal
|
||||
- [x] 抽老婆
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -1439,14 +1517,19 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>词典匹配回复</summary>
|
||||
<summary>月幕galgame图</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"`
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`
|
||||
|
||||
- [x] 切换[kimo|傲娇|可爱]词库
|
||||
- [x] 设置词库触发概率0.x (0<x<9)
|
||||
- [x] 随机galCG
|
||||
|
||||
- 注:由于占用资源较大,默认注释。
|
||||
- [x] 随机gal表情包
|
||||
|
||||
- [x] galCG[xxx]
|
||||
|
||||
- [x] gal表情包[xxx]
|
||||
|
||||
- [x] 更新gal
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -1481,7 +1564,26 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] @Bot 任意文本(任意一句话回复)
|
||||
|
||||
- [x] 设置回复模式[青云客 | 小爱]
|
||||
- [x] 设置回复模式[青云客 | 小爱 | ChatGPT]
|
||||
|
||||
- [x] 设置 ChatGPT api key xxx
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>词典匹配回复</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"`
|
||||
|
||||
- [x] 切换[kimo|傲娇|可爱]词库
|
||||
- [x] 设置词库触发概率0.x (0<x<9)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>打断复读</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat"`
|
||||
|
||||
- [x] (打断三次以上的复读)
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
14
console/console_ansi.go
Normal file
14
console/console_ansi.go
Normal file
@@ -0,0 +1,14 @@
|
||||
//go:build !windows
|
||||
|
||||
// Package console sets console's behavior on init
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fmt.Print("\033]0;ZeroBot-Blugin " + banner.Version + " " + banner.Copyright + "\007")
|
||||
}
|
||||
144
console/console_windows.go
Normal file
144
console/console_windows.go
Normal file
@@ -0,0 +1,144 @@
|
||||
// Package console sets console's behavior on init
|
||||
package console
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:linkname modkernel32 golang.org/x/sys/windows.modkernel32
|
||||
modkernel32 *windows.LazyDLL
|
||||
procSetConsoleTitle = modkernel32.NewProc("SetConsoleTitleW")
|
||||
)
|
||||
|
||||
//go:linkname errnoErr golang.org/x/sys/windows.errnoErr
|
||||
func errnoErr(e syscall.Errno) error
|
||||
|
||||
func setConsoleTitle(title string) (err error) {
|
||||
var p0 *uint16
|
||||
p0, err = syscall.UTF16PtrFromString(title)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleTitle.Addr(), 1, uintptr(unsafe.Pointer(p0)), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func init() {
|
||||
stdin := windows.Handle(os.Stdin.Fd())
|
||||
|
||||
var mode uint32
|
||||
err := windows.GetConsoleMode(stdin, &mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
|
||||
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志
|
||||
|
||||
mode &^= windows.ENABLE_MOUSE_INPUT // 禁用鼠标输入
|
||||
mode |= windows.ENABLE_PROCESSED_INPUT // 启用控制输入
|
||||
|
||||
mode &^= windows.ENABLE_INSERT_MODE // 禁用插入模式
|
||||
mode |= windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT // 启用输入回显&逐行输入
|
||||
|
||||
mode &^= windows.ENABLE_WINDOW_INPUT // 禁用窗口输入
|
||||
mode &^= windows.ENABLE_VIRTUAL_TERMINAL_INPUT // 禁用虚拟终端输入
|
||||
|
||||
err = windows.SetConsoleMode(stdin, mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stdout := windows.Handle(os.Stdout.Fd())
|
||||
err = windows.GetConsoleMode(stdout, &mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING // 启用虚拟终端处理
|
||||
mode |= windows.ENABLE_PROCESSED_OUTPUT // 启用处理后的输出
|
||||
|
||||
err = windows.SetConsoleMode(stdout, mode)
|
||||
// windows 带颜色 log 自定义格式
|
||||
logrus.SetFormatter(&logFormat{hasColor: err == nil})
|
||||
if err != nil {
|
||||
logrus.Warnln("VT100设置失败, 将以无色模式输出")
|
||||
}
|
||||
|
||||
err = setConsoleTitle("ZeroBot-Plugin " + banner.Version + " " + banner.Copyright)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
|
||||
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
|
||||
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
|
||||
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
|
||||
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
|
||||
colorReset = "\x1b[0m"
|
||||
)
|
||||
|
||||
// logFormat specialize for zbp
|
||||
type logFormat struct {
|
||||
hasColor bool
|
||||
}
|
||||
|
||||
// Format implements logrus.Formatter
|
||||
func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
buf.WriteByte('[')
|
||||
if f.hasColor {
|
||||
buf.WriteString(getLogLevelColorCode(entry.Level))
|
||||
}
|
||||
buf.WriteString(strings.ToUpper(entry.Level.String()))
|
||||
if f.hasColor {
|
||||
buf.WriteString(colorReset)
|
||||
}
|
||||
buf.WriteString("] ")
|
||||
buf.WriteString(entry.Message)
|
||||
buf.WriteString(" \n")
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// getLogLevelColorCode 获取日志等级对应色彩code
|
||||
func getLogLevelColorCode(level logrus.Level) string {
|
||||
switch level {
|
||||
case logrus.PanicLevel:
|
||||
return colorCodePanic
|
||||
case logrus.FatalLevel:
|
||||
return colorCodeFatal
|
||||
case logrus.ErrorLevel:
|
||||
return colorCodeError
|
||||
case logrus.WarnLevel:
|
||||
return colorCodeWarn
|
||||
case logrus.InfoLevel:
|
||||
return colorCodeInfo
|
||||
case logrus.DebugLevel:
|
||||
return colorCodeDebug
|
||||
case logrus.TraceLevel:
|
||||
return colorCodeTrace
|
||||
|
||||
default:
|
||||
return colorCodeInfo
|
||||
}
|
||||
}
|
||||
2
data
2
data
Submodule data updated: 5e0fa81c3b...d5ec04118f
46
go.mod
46
go.mod
@@ -1,18 +1,18 @@
|
||||
module github.com/FloatTech/ZeroBot-Plugin
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230207081411-573533b18194
|
||||
github.com/FloatTech/floatbox v0.0.0-20230207075003-0f70b30c320d
|
||||
github.com/FloatTech/gg v1.1.2
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230215092509-ff0745852f23
|
||||
github.com/FloatTech/sqlite v1.5.7
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba
|
||||
github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824
|
||||
github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
|
||||
github.com/FloatTech/sqlite v1.6.2
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230215092613-4a7ebf458f16
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
|
||||
github.com/antchfx/htmlquery v1.2.5
|
||||
@@ -21,8 +21,8 @@ require (
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/fumiama/ahsai v0.1.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.6.4
|
||||
github.com/fumiama/go-registry v0.2.5
|
||||
github.com/fumiama/go-base16384 v1.7.0
|
||||
github.com/fumiama/go-registry v0.2.6
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
|
||||
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
|
||||
@@ -32,15 +32,16 @@ require (
|
||||
github.com/lithammer/fuzzysearch v1.1.5
|
||||
github.com/mroth/weightedrand v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/quic-go/quic-go v0.32.0
|
||||
github.com/quic-go/quic-go v0.38.1
|
||||
github.com/shirou/gopsutil/v3 v3.23.1
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.9
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.4
|
||||
gitlab.com/gomidi/midi/v2 v2.0.25
|
||||
golang.org/x/image v0.3.0
|
||||
golang.org/x/text v0.6.0
|
||||
golang.org/x/sys v0.8.0
|
||||
golang.org/x/text v0.9.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -53,7 +54,7 @@ require (
|
||||
github.com/fumiama/imgsz v0.0.2 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||
@@ -66,13 +67,12 @@ require (
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.2.0 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pkumza/numcn v1.0.0 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/quic-go/qpack v0.4.0 // indirect
|
||||
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
|
||||
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
@@ -83,10 +83,10 @@ require (
|
||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
||||
golang.org/x/exp/shiny v0.0.0-20221126150942-6ab00d035af9 // indirect
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f // indirect
|
||||
golang.org/x/mod v0.6.0 // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/tools v0.2.0 // indirect
|
||||
golang.org/x/mod v0.10.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/tools v0.9.1 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
modernc.org/libc v1.21.5 // indirect
|
||||
modernc.org/mathutil v1.5.0 // indirect
|
||||
modernc.org/memory v1.4.0 // indirect
|
||||
|
||||
100
go.sum
100
go.sum
@@ -2,24 +2,24 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230207081411-573533b18194 h1:+p85V0fdZNt3UoKreBeI6S3IOPvNmU5/Fnn39ipSkVk=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230207081411-573533b18194/go.mod h1:LCiKZivPVazRRCnnADQfIBFZiIPHHCFqaCpwZWsFehI=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230207075003-0f70b30c320d h1:vVqMO5Kejt5pueuZvBxfX+psa7UwE110TpITf5eV7Zw=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230207075003-0f70b30c320d/go.mod h1:OoZE4Ra7olpFaJSrlD6mcyT4chPLg9QBRE1pzTC8R84=
|
||||
github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88=
|
||||
github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9 h1:Havq0z/N79KeD50L7ms+Hv8F4Sw98Dt8lXM8jECp04o=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230215092509-ff0745852f23 h1:cffHoKe1wlm1kqmtpJ4ur/7h+E3gR1fzbaPkXAlVj38=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230215092509-ff0745852f23/go.mod h1:dsENe3jJB1LHbshfoGnIAU9V6+N1CKbf2y+RUeAPC3A=
|
||||
github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk=
|
||||
github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba h1:0tqYkIc6RK8P3/cGEMSoBBwhiEHKPJC+1F7xlVkikgY=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba/go.mod h1:6vYu7bW5gPQsBnXB+I6yk+eJQaaAwusoQ/I/wQMwOAI=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824 h1:w72fzQg1Y9+VLSRl7iKzaZ6fG3myyMJfpOSajcjaMDM=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI=
|
||||
github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU=
|
||||
github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef h1:CJbK/2FRwPuZpeb6M4sWK2d7oXDnBEGhpkQuQrgc91A=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9/go.mod h1:NBFPhWae4hqVMeG8ELBBnUQkKce3nDjkljVn6PdiUNs=
|
||||
github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCCw=
|
||||
github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52 h1:BrStRXeosWh8L0iA/EjPd8w6xNexDkqki39ITZko/9Q=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52/go.mod h1:qqMLUwR7tKpqnAqsgI7aZbn0hbs2FEVF4ylMXqIpBdY=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230215092613-4a7ebf458f16 h1:fOnI0V//DOW62vAhnC1a+qDMnlbJIAIiUHVX7CaUk5s=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230215092613-4a7ebf458f16/go.mod h1:Lo7y67u9EGt7l3ZBavc5bbryEIaeRYfbVy9KWIw6qk4=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 h1:qmwoT8xVaND01aCdwy+5/j6z490nehQWZAVyTBN8ahU=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf h1:PwH9aMnmN+m204cVIqUrI3e7nsdQi/IGW012Fjzb1bs=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf/go.mod h1:JRnGR7EGeEQgxOs+c0rZAhrS9Es2BTcGHdIDHXIPRzQ=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA=
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
|
||||
@@ -58,10 +58,10 @@ github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b h1:Zt3pFQditAdWTHCO
|
||||
github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
|
||||
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
|
||||
github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o=
|
||||
github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.2.5 h1:Y6tnHnTThQPv7E4JPM2vBprU+4EQw/LEDO33HCmxgI4=
|
||||
github.com/fumiama/go-registry v0.2.5/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
|
||||
github.com/fumiama/go-base16384 v1.7.0 h1:6fep7XPQWxRlh4Hu+KsdH+6+YdUp+w6CwRXtMWSsXCA=
|
||||
github.com/fumiama/go-base16384 v1.7.0/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.2.6 h1:+vEeBUwa1+GC87ujW3Km42fi8O/H7QcpVJWu1iuGNh0=
|
||||
github.com/fumiama/go-registry v0.2.6/go.mod h1:HjYagPZXzR2xCCxaSQerqX7JRzC0yiv2kslDdBiTq/g=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
|
||||
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
|
||||
@@ -83,13 +83,14 @@ github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebK
|
||||
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
|
||||
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
|
||||
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
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.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
@@ -99,7 +100,7 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
@@ -126,8 +127,11 @@ 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/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
@@ -148,9 +152,11 @@ github.com/mroth/weightedrand v1.0.0 h1:V8JeHChvl2MP1sAoXq4brElOcza+jxLkRuwvtQu8
|
||||
github.com/mroth/weightedrand v1.0.0/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI=
|
||||
github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
|
||||
github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=
|
||||
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
|
||||
github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k=
|
||||
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@@ -163,14 +169,10 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||
github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U=
|
||||
github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc=
|
||||
github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4nttk=
|
||||
github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
|
||||
github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI=
|
||||
github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
|
||||
github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA=
|
||||
github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||
github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE=
|
||||
github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/shirou/gopsutil/v3 v3.23.1 h1:a9KKO+kGLKEvcPIs4W62v0nu3sciVDOOOPUD0Hz7z/4=
|
||||
@@ -180,7 +182,7 @@ github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
@@ -198,8 +200,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm
|
||||
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
|
||||
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.6.9 h1:vaFqtIXpyeU60xEddg4EsN6cX6cpB3MKhLbe/MQ5OVw=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.9/go.mod h1:T5kD5vLi/YxL/fyDOCOaawi96LRBdJjcXh2CIjDyFfg=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.4 h1:+148rELpf/FCDW2EuvKqpb9bNKcwKRtoh16s2sIb5SE=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.4/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
@@ -236,8 +238,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
||||
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
|
||||
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
|
||||
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
|
||||
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -249,8 +251,8 @@ golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -272,31 +274,33 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
|
||||
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
||||
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
|
||||
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package kanban
|
||||
|
||||
// Version ...
|
||||
var Version = "v1.6.2-beta4"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - 2023-02-15 17:27:40 +0800 CST\n" +
|
||||
"* Copyright © 2020 - 2023 FloatTech. All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
15
kanban/banner/banner.go
Normal file
15
kanban/banner/banner.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Code generated by kanban/gen. DO NOT EDIT.
|
||||
|
||||
package banner
|
||||
|
||||
// Version ...
|
||||
var Version = "v1.7.3"
|
||||
|
||||
// Copyright ...
|
||||
var Copyright = "© 2020 - 2023 FloatTech"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - 2023-08-28 16:14:08 +0800 CST\n" +
|
||||
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
@@ -10,22 +10,27 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const banner = `package kanban
|
||||
const banner = `// Code generated by kanban/gen. DO NOT EDIT.
|
||||
|
||||
package banner
|
||||
|
||||
// Version ...
|
||||
var Version = "%s"
|
||||
|
||||
// Copyright ...
|
||||
var Copyright = "© 2020 - %d FloatTech"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - %s\n" +
|
||||
"* Copyright © 2020 - %d FloatTech. All Rights Reserved.\n" +
|
||||
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
`
|
||||
|
||||
const timeformat = `2006-01-02 15:04:05 +0800 CST`
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("banner.go")
|
||||
f, err := os.Create("banner/banner.go")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -39,7 +44,7 @@ func main() {
|
||||
}
|
||||
s := strings.Split(vartag.String(), "\n")
|
||||
now := time.Now()
|
||||
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Format(timeformat), now.Year())
|
||||
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Year(), now.Format(timeformat))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package kanban
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/fumiama/go-registry"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/FloatTech/ZeroBot-Plugin/kanban/gen
|
||||
|
||||
var once sync.Once
|
||||
|
||||
func init() {
|
||||
once.Do(PrintBanner)
|
||||
PrintBanner()
|
||||
}
|
||||
|
||||
var reg = registry.NewRegReader("reilia.fumiama.top:32664", control.Md5File, "fumiama")
|
||||
@@ -23,7 +22,7 @@ var reg = registry.NewRegReader("reilia.fumiama.top:32664", control.Md5File, "fu
|
||||
func PrintBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", Banner, "\n",
|
||||
"\n", banner.Banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", Kanban(), "\n",
|
||||
"============================================================\n\n",
|
||||
|
||||
5
kanban/version_less_than_1.21.go
Normal file
5
kanban/version_less_than_1.21.go
Normal file
@@ -0,0 +1,5 @@
|
||||
//go:build go1.21
|
||||
|
||||
package kanban
|
||||
|
||||
const Error int = "请使用小于1.21版本的Go"
|
||||
216
main.go
216
main.go
@@ -7,10 +7,14 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 打印 banner
|
||||
|
||||
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
|
||||
// ----------------------插件优先级按顺序从高到低---------------------- //
|
||||
@@ -56,91 +60,98 @@ import (
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/guessmusic" // 猜歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/heisi" // 黑丝
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hyaku" // 百人一首
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo" // 日语语法学习
|
||||
_ "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/quan" // QQ权重查询
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews" // 今日早报
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dish" // 程序员做饭指南
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drawlots" // 多功能抽签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/guessmusic" // 猜歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/heisi" // 黑丝
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hitokoto" // 一言
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hyaku" // 百人一首
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday" // 疯狂星期四
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo" // 日语语法学习
|
||||
_ "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/quan" // QQ权重查询
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam" // steam相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic" // vtb点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wantquotes" // 据意查句
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife" // 抽老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
|
||||
|
||||
// ^^^^ //
|
||||
@@ -165,6 +176,8 @@ import (
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply" // 人工智能回复
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读
|
||||
|
||||
// ^^^^ //
|
||||
@@ -184,6 +197,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
// webctrl "github.com/FloatTech/zbputils/control/web"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
// -----------------------以上为内置依赖,勿动------------------------ //
|
||||
)
|
||||
|
||||
@@ -201,6 +218,7 @@ func init() {
|
||||
d := flag.Bool("d", false, "Enable debug level log and higher.")
|
||||
w := flag.Bool("w", false, "Enable warning level log and higher.")
|
||||
h := flag.Bool("h", false, "Display this help.")
|
||||
// g := flag.String("g", "127.0.0.1:3000", "Set webui url.")
|
||||
// 直接写死 AccessToken 时,请更改下面第二个参数
|
||||
token := flag.String("t", "", "Set AccessToken of WSClient.")
|
||||
// 直接写死 URL 时,请更改下面第二个参数
|
||||
@@ -213,6 +231,7 @@ func init() {
|
||||
late := flag.Uint("l", 233, "Response latency (ms).")
|
||||
rsz := flag.Uint("r", 4096, "Receiving buffer ring size.")
|
||||
maxpt := flag.Uint("x", 4, "Max process time (min).")
|
||||
markmsg := flag.Bool("m", false, "Don't mark message as read automatically")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@@ -220,13 +239,12 @@ func init() {
|
||||
fmt.Println("Usage:")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(0)
|
||||
} else {
|
||||
if *d && !*w {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
if *w {
|
||||
logrus.SetLevel(logrus.WarnLevel)
|
||||
}
|
||||
}
|
||||
if *d && !*w {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
if *w {
|
||||
logrus.SetLevel(logrus.WarnLevel)
|
||||
}
|
||||
|
||||
for _, s := range flag.Args() {
|
||||
@@ -241,6 +259,9 @@ func init() {
|
||||
// sus = append(sus, 12345678)
|
||||
// sus = append(sus, 87654321)
|
||||
|
||||
// 启用 webui
|
||||
// go webctrl.RunGui(*g)
|
||||
|
||||
if *runcfg != "" {
|
||||
f, err := os.Open(*runcfg)
|
||||
if err != nil {
|
||||
@@ -270,6 +291,7 @@ func init() {
|
||||
RingLen: *rsz,
|
||||
Latency: time.Duration(*late) * time.Millisecond,
|
||||
MaxProcessTime: time.Duration(*maxpt) * time.Minute,
|
||||
MarkMessage: !*markmsg,
|
||||
Driver: []zero.Driver{config.W[0]},
|
||||
}
|
||||
|
||||
@@ -289,15 +311,17 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano()) // 全局 seed,其他插件无需再 seed
|
||||
if !strings.Contains(runtime.Version(), "go1.2") { // go1.20之前版本需要全局 seed,其他插件无需再 seed
|
||||
rand.Seed(time.Now().UnixNano()) //nolint: staticcheck
|
||||
}
|
||||
// 帮助
|
||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||
zero.OnFullMatchGroup([]string{"help", "/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(kanban.Banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
ctx.SendChain(message.Text(banner.Banner, "\n管理发送\"/服务列表\"查看 bot 功能\n发送\"/用法name\"查看功能用法"))
|
||||
})
|
||||
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(kanban.Kanban()))
|
||||
ctx.SendChain(message.Text(strings.ReplaceAll(kanban.Kanban(), "\t", "")))
|
||||
})
|
||||
zero.RunAndBlock(&config.Z, process.GlobalInitMutex.Unlock)
|
||||
}
|
||||
|
||||
70
main_win.go
70
main_win.go
@@ -1,70 +0,0 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// windows 带颜色 log 自定义格式
|
||||
logrus.SetFormatter(&LogFormat{})
|
||||
}
|
||||
|
||||
const (
|
||||
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
|
||||
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
|
||||
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
|
||||
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
|
||||
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
|
||||
colorReset = "\x1b[0m"
|
||||
)
|
||||
|
||||
// LogFormat specialize for zbp
|
||||
type LogFormat struct{}
|
||||
|
||||
// Format implements logrus.Formatter
|
||||
func (f LogFormat) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
buf.WriteString(getLogLevelColorCode(entry.Level))
|
||||
|
||||
buf.WriteByte('[')
|
||||
buf.WriteString(strings.ToUpper(entry.Level.String()))
|
||||
buf.WriteString("] ")
|
||||
buf.WriteString(entry.Message)
|
||||
buf.WriteString(" \n")
|
||||
|
||||
buf.WriteString(colorReset)
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// getLogLevelColorCode 获取日志等级对应色彩code
|
||||
func getLogLevelColorCode(level logrus.Level) string {
|
||||
switch level {
|
||||
case logrus.PanicLevel:
|
||||
return colorCodePanic
|
||||
case logrus.FatalLevel:
|
||||
return colorCodeFatal
|
||||
case logrus.ErrorLevel:
|
||||
return colorCodeError
|
||||
case logrus.WarnLevel:
|
||||
return colorCodeWarn
|
||||
case logrus.InfoLevel:
|
||||
return colorCodeInfo
|
||||
case logrus.DebugLevel:
|
||||
return colorCodeDebug
|
||||
case logrus.TraceLevel:
|
||||
return colorCodeTrace
|
||||
|
||||
default:
|
||||
return colorCodeInfo
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/bilibili"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
@@ -31,7 +33,7 @@ import (
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -42,7 +44,11 @@ const (
|
||||
referer = "https://weibo.com/"
|
||||
)
|
||||
|
||||
var boottime = time.Now()
|
||||
var (
|
||||
boottime = time.Now()
|
||||
bgdata *[]byte
|
||||
bgcount uintptr
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
|
||||
@@ -134,14 +140,22 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
return
|
||||
}
|
||||
|
||||
url, err := bilibili.GetRealURL(backgroundURL)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err != nil {
|
||||
return
|
||||
dldata := (*[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata))))
|
||||
if dldata == (*[]byte)(nil) || uintptr(time.Since(boottime).Hours()/24) >= atomic.LoadUintptr(&bgcount) {
|
||||
url, err1 := bilibili.GetRealURL(backgroundURL)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
data, err1 := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
atomic.AddUintptr(&bgcount, 1)
|
||||
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)), unsafe.Pointer(&data))
|
||||
dldata = &data
|
||||
}
|
||||
data := *dldata
|
||||
|
||||
back, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return
|
||||
@@ -173,7 +187,13 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
back = imgfactory.Size(back, int(bw*cw/bw), int(bh*cw/bw)).Image()
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
}
|
||||
|
||||
var blurback image.Image
|
||||
bwg := &sync.WaitGroup{}
|
||||
bwg.Add(1)
|
||||
go func() {
|
||||
defer bwg.Done()
|
||||
blurback = imaging.Blur(canvas.Image(), 8)
|
||||
}()
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(5)
|
||||
|
||||
@@ -186,8 +206,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
titlecard := gg.NewContext(cardw, titlecardh)
|
||||
|
||||
titlecard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70)
|
||||
bwg.Wait()
|
||||
titlecard.DrawImage(blurback, -70, -70)
|
||||
|
||||
titlecard.DrawRoundedRectangle(1, 1, float64(titlecard.W()-1*2), float64(titlecardh-1*2), 16)
|
||||
titlecard.SetLineWidth(3)
|
||||
@@ -239,8 +259,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
basiccard := gg.NewContext(cardw, basiccardh)
|
||||
|
||||
basiccard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40)
|
||||
bwg.Wait()
|
||||
basiccard.DrawImage(blurback, -70, -70-titlecardh-40)
|
||||
|
||||
basiccard.DrawRoundedRectangle(1, 1, float64(basiccard.W()-1*2), float64(basiccardh-1*2), 16)
|
||||
basiccard.SetLineWidth(3)
|
||||
@@ -303,7 +323,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
diskcard := gg.NewContext(cardw, diskcardh)
|
||||
diskcard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40-basiccardh-40)
|
||||
bwg.Wait()
|
||||
diskcard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40)
|
||||
|
||||
diskcard.DrawRoundedRectangle(1, 1, float64(diskcard.W()-1*2), float64(diskcardh-1*2), 16)
|
||||
diskcard.SetLineWidth(3)
|
||||
@@ -321,6 +342,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
if dslen == 1 {
|
||||
diskcard.SetRGBA255(192, 192, 192, 255)
|
||||
diskcard.DrawRoundedRectangle(40, 40, float64(diskcard.W())-40-100, 50, 12)
|
||||
diskcard.ClipPreserve()
|
||||
diskcard.Fill()
|
||||
|
||||
switch {
|
||||
@@ -334,7 +356,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
diskcard.DrawRoundedRectangle(40, 40, (float64(diskcard.W())-40-100)*diskstate[0].precent*0.01, 50, 12)
|
||||
diskcard.Fill()
|
||||
|
||||
diskcard.ResetClip()
|
||||
diskcard.SetRGBA255(30, 30, 30, 255)
|
||||
|
||||
fw, _ := diskcard.MeasureString(diskstate[0].name)
|
||||
@@ -378,8 +400,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
moreinfocard := gg.NewContext(cardw, moreinfocardh)
|
||||
|
||||
moreinfocard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40-basiccardh-40-diskcardh-40)
|
||||
bwg.Wait()
|
||||
moreinfocard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40-diskcardh-40)
|
||||
|
||||
moreinfocard.DrawRoundedRectangle(1, 1, float64(moreinfocard.W()-1*2), float64(moreinfocard.H()-1*2), 16)
|
||||
moreinfocard.SetLineWidth(3)
|
||||
@@ -416,7 +438,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
shadow.Stroke()
|
||||
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40), float64(cardw), float64(basiccardh), 16)
|
||||
shadow.Stroke()
|
||||
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40), float64(cardw), float64(basiccardh), 16)
|
||||
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40), float64(cardw), float64(diskcardh), 16)
|
||||
shadow.Stroke()
|
||||
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40+diskcardh+40), float64(cardw), float64(moreinfocardh), 16)
|
||||
shadow.Stroke()
|
||||
@@ -439,9 +461,9 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
return
|
||||
}
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+kanban.Version, float64(canvas.W())/2+3, float64(canvas.H())-70/2+3, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2+3, float64(canvas.H())-70/2+3, 0.5, 0.5)
|
||||
canvas.SetRGBA255(255, 255, 255, 255)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+kanban.Version, float64(canvas.W())/2, float64(canvas.H())-70/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2, float64(canvas.H())-70/2, 0.5, 0.5)
|
||||
|
||||
sendimg = canvas.Image()
|
||||
return
|
||||
@@ -553,23 +575,21 @@ func diskstate() (stateinfo []*status, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
stateinfo = make([]*status, len(parts))
|
||||
for i, v := range parts {
|
||||
stateinfo = make([]*status, 0, len(parts))
|
||||
for _, v := range parts {
|
||||
mp := v.Mountpoint
|
||||
if strings.HasPrefix(mp, "/snap/") || strings.HasPrefix(mp, "/apex/") {
|
||||
continue
|
||||
}
|
||||
diskusage, err := disk.Usage(mp)
|
||||
usage := ""
|
||||
precent := 0.0
|
||||
if err != nil {
|
||||
usage = err.Error()
|
||||
} else {
|
||||
usage = storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))
|
||||
precent = math.Round(diskusage.UsedPercent)
|
||||
continue
|
||||
}
|
||||
stateinfo[i] = &status{
|
||||
precent: precent,
|
||||
stateinfo = append(stateinfo, &status{
|
||||
precent: math.Round(diskusage.UsedPercent),
|
||||
name: mp,
|
||||
text: []string{usage},
|
||||
}
|
||||
text: []string{storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))},
|
||||
})
|
||||
}
|
||||
return stateinfo, nil
|
||||
}
|
||||
|
||||
@@ -2,50 +2,75 @@ package aireply
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/aireply"
|
||||
"github.com/FloatTech/AnimeAPI/tts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/baidutts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/genshin"
|
||||
"github.com/FloatTech/AnimeAPI/tts/mockingbird"
|
||||
"github.com/FloatTech/AnimeAPI/tts/ttscn"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
)
|
||||
|
||||
// 数据结构: [4 bits] [4 bits] [8 bits] [8 bits]
|
||||
// [拟声鸟模式] [百度模式] [tts模式] [回复模式]
|
||||
// [ttscn模式] [百度模式] [tts模式] [回复模式]
|
||||
|
||||
// defaultttsindexkey
|
||||
// 数据结构: [4 bits] [4 bits] [8 bits]
|
||||
// [拟声鸟模式] [百度模式] [tts模式]
|
||||
// [ttscn模式] [百度模式] [tts模式]
|
||||
|
||||
// [tts模式]: 0~63 genshin 64 baidu 65 mockingbird
|
||||
// [tts模式]: 0~200 genshin 201 baidu 202 ttscn
|
||||
|
||||
const (
|
||||
lastgsttsindex = 63 + iota
|
||||
lastgsttsindex = 200 + iota
|
||||
baiduttsindex
|
||||
mockingbirdttsindex
|
||||
ttscnttsindex
|
||||
)
|
||||
|
||||
const (
|
||||
defaultttsindexkey = -2905
|
||||
// extrattsname is the tts other than genshin vits
|
||||
var extrattsname = []string{"百度", "TTSCN"}
|
||||
|
||||
var ttscnspeakers = [...]string{
|
||||
"晓晓(女 - 年轻人)",
|
||||
"云扬(男 - 年轻人)",
|
||||
"晓辰(女 - 年轻人 - 抖音热门)",
|
||||
"晓涵(女 - 年轻人)",
|
||||
"晓墨(女 - 年轻人)",
|
||||
"晓秋(女 - 中年人)",
|
||||
"晓睿(女 - 老年)",
|
||||
"晓双(女 - 儿童)",
|
||||
"晓萱(女 - 年轻人)",
|
||||
"晓颜(女 - 年轻人)",
|
||||
"晓悠(女 - 儿童)",
|
||||
"云希(男 - 年轻人 - 抖音热门)",
|
||||
"云野(男 - 中年人)",
|
||||
"晓梦(女 - 年轻人)",
|
||||
"晓伊(女 - 儿童)",
|
||||
"晓甄(女 - 年轻人)",
|
||||
}
|
||||
|
||||
const defaultttsindexkey = -2905
|
||||
|
||||
var (
|
||||
原 = newapikeystore("./data/tts/o.txt")
|
||||
ཆཏ = newapikeystore("./data/tts/c.txt")
|
||||
百 = newapikeystore("./data/tts/b.txt")
|
||||
)
|
||||
|
||||
var replyModes = [...]string{"青云客", "小爱"}
|
||||
type replymode []string
|
||||
|
||||
func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
func (r replymode) setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
var ok bool
|
||||
var index int64
|
||||
for i, s := range replyModes {
|
||||
for i, s := range r {
|
||||
if s == name {
|
||||
ok = true
|
||||
index = int64(i)
|
||||
@@ -62,39 +87,44 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff))
|
||||
}
|
||||
|
||||
func getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
func (r replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
if ok {
|
||||
if m.GetData(gid)&0xff == 1 {
|
||||
switch m.GetData(gid) & 0xff {
|
||||
case 0:
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
case 1:
|
||||
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
|
||||
case 2:
|
||||
k := ཆཏ.k
|
||||
if k != "" {
|
||||
return aireply.NewChatGPT(aireply.ChatGPTURL, k)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
|
||||
var ttsins = func() map[string]tts.TTS {
|
||||
m := make(map[string]tts.TTS, 128)
|
||||
for _, mode := range append(genshin.SoundList[:], "百度", "拟声鸟") {
|
||||
m := make(map[string]tts.TTS, 512)
|
||||
for _, mode := range append(genshin.SoundList[:], extrattsname...) {
|
||||
m[mode] = nil
|
||||
}
|
||||
return m
|
||||
}()
|
||||
|
||||
var ttsModes = func() []string {
|
||||
s := append(genshin.SoundList[:], make([]string, 64-len(genshin.SoundList))...) // 0-63
|
||||
s = append(s, "百度", "拟声鸟") // 64 65
|
||||
s := append(genshin.SoundList[:], make([]string, lastgsttsindex-len(genshin.SoundList))...) // 0-200
|
||||
s = append(s, extrattsname...) // 201 202 ...
|
||||
return s
|
||||
}()
|
||||
|
||||
type ttsmode struct {
|
||||
APIKey string // APIKey is for genshin vits
|
||||
mode syncx.Map[int64, int64] `json:"-"` // mode grp index
|
||||
}
|
||||
type ttsmode syncx.Map[int64, int64]
|
||||
|
||||
func list(list []string, num int) string {
|
||||
s := ""
|
||||
@@ -112,33 +142,17 @@ func list(list []string, num int) string {
|
||||
func newttsmode() *ttsmode {
|
||||
t := &ttsmode{}
|
||||
m, ok := control.Lookup("tts")
|
||||
t.mode = syncx.Map[int64, int64]{}
|
||||
t.mode.Store(defaultttsindexkey, 0)
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, 0)
|
||||
if ok {
|
||||
index := m.GetData(defaultttsindexkey)
|
||||
msk := index & 0xff
|
||||
if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == mockingbirdttsindex) {
|
||||
t.mode.Store(defaultttsindexkey, index)
|
||||
if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == ttscnttsindex) {
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index)
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *ttsmode) getAPIKey(ctx *zero.Ctx) string {
|
||||
if t.APIKey == "" {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
_ = m.Manager.GetExtra(-1, &t)
|
||||
logrus.Debugln("[tts] get api key:", t.APIKey)
|
||||
}
|
||||
return url.QueryEscape(t.APIKey)
|
||||
}
|
||||
|
||||
func (t *ttsmode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
|
||||
t.APIKey = key
|
||||
_ = m.Manager.Response(-1)
|
||||
return m.Manager.SetExtra(-1, t)
|
||||
}
|
||||
|
||||
func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt int) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
@@ -157,16 +171,16 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt
|
||||
}
|
||||
if index == -1 {
|
||||
switch name {
|
||||
case "百度":
|
||||
case extrattsname[0]:
|
||||
index = baiduttsindex
|
||||
case "拟声鸟":
|
||||
index = mockingbirdttsindex
|
||||
case extrattsname[1]:
|
||||
index = ttscnttsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
}
|
||||
}
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
t.mode.Store(gid, index)
|
||||
(*syncx.Map[int64, int64])(t).Store(gid, index)
|
||||
return m.SetData(gid, (m.GetData(gid)&^0xffff00)|((index<<8)&0xff00)|((int64(baiduper)<<16)&0x0f0000)|((int64(mockingsynt)<<20)&0xf00000))
|
||||
}
|
||||
|
||||
@@ -175,32 +189,33 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
i, ok := t.mode.Load(gid)
|
||||
i, ok := (*syncx.Map[int64, int64])(t).Load(gid)
|
||||
if !ok {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
i = m.GetData(gid) >> 8
|
||||
}
|
||||
m := i & 0xff
|
||||
if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != mockingbirdttsindex) {
|
||||
i, _ = t.mode.Load(defaultttsindexkey)
|
||||
if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != ttscnttsindex) {
|
||||
i, _ = (*syncx.Map[int64, int64])(t).Load(defaultttsindexkey)
|
||||
m = i & 0xff
|
||||
}
|
||||
mode := ttsModes[m]
|
||||
ins, ok := ttsins[mode]
|
||||
if !ok || ins == nil {
|
||||
switch mode {
|
||||
case "百度":
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8)
|
||||
case "拟声鸟":
|
||||
case extrattsname[0]:
|
||||
id, sec, _ := strings.Cut(百.k, ",")
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00)>>8, id, sec)
|
||||
case extrattsname[1]:
|
||||
var err error
|
||||
ins, err = mockingbird.NewMockingBirdTTS(int(i&0xf000) >> 12)
|
||||
ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xf000)>>12], ttscn.KBRates[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default: // 原神
|
||||
k := t.getAPIKey(ctx)
|
||||
k := 原.k
|
||||
if k != "" {
|
||||
ins = genshin.NewGenshin(int(m), t.getAPIKey(ctx))
|
||||
ins = genshin.NewGenshin(int(m), 原.k)
|
||||
ttsins[mode] = ins
|
||||
} else {
|
||||
return nil, errors.New("no valid speaker")
|
||||
@@ -234,10 +249,10 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
}
|
||||
if index == -1 {
|
||||
switch name {
|
||||
case "百度":
|
||||
case extrattsname[0]:
|
||||
index = baiduttsindex
|
||||
case "拟声鸟":
|
||||
index = mockingbirdttsindex
|
||||
case extrattsname[1]:
|
||||
index = ttscnttsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
}
|
||||
@@ -246,6 +261,6 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
if !ok {
|
||||
return errors.New("[tts] service not found")
|
||||
}
|
||||
t.mode.Store(defaultttsindexkey, index)
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index)
|
||||
return m.SetData(defaultttsindexkey, (index&0xff)|((int64(baiduper)<<8)&0x0f00)|((int64(mockingsynt)<<12)&0xf000))
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package aireply
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -15,30 +16,35 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var t = newttsmode()
|
||||
var replmd = replymode([]string{"青云客", "小爱", "ChatGPT"})
|
||||
|
||||
var ttsmd = newttsmode()
|
||||
|
||||
func init() { // 插件主体
|
||||
ent := control.Register("tts", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Brief: "人工智能语音回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" +
|
||||
"- 设置默认语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" +
|
||||
"- 设置语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" +
|
||||
"- 设置默认语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" +
|
||||
"- 恢复成默认语音模式\n" +
|
||||
"- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
|
||||
"当前适用的原神人物含有以下:\n" + list(genshin.SoundList[:], 5),
|
||||
"- 设置百度语音 api id xxxxxx secret xxxxxx (请自行获得)\n" +
|
||||
"当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) +
|
||||
"\n当前适用的TTSCN人物含有以下(以数字顺序代表): \n" + list(ttscnspeakers[:], 5),
|
||||
PrivateDataFolder: "tts",
|
||||
})
|
||||
|
||||
enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "人工智能回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱|ChatGPT]\n- 设置 ChatGPT api key xxx",
|
||||
PrivateDataFolder: "aireply",
|
||||
})
|
||||
|
||||
enr.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
aireply := getReplyMode(ctx)
|
||||
aireply := replmd.getReplyMode(ctx)
|
||||
reply := message.ParseMessageFromString(aireply.Talk(ctx.Event.UserID, ctx.ExtractPlainText(), zero.BotConfig.NickName[0]))
|
||||
// 回复
|
||||
time.Sleep(time.Second * 1)
|
||||
@@ -52,7 +58,7 @@ func init() { // 插件主体
|
||||
|
||||
enr.OnPrefix("设置回复模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["args"].(string)
|
||||
err := setReplyMode(ctx, param)
|
||||
err := replmd.setReplyMode(ctx, param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -60,16 +66,31 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
|
||||
})
|
||||
|
||||
enr.OnRegex(`^设置\s*ChatGPT\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := ཆཏ.set(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
|
||||
endpre := regexp.MustCompile(`\pP$`)
|
||||
ttscachedir := ent.DataFolder() + "cache/"
|
||||
_ = os.RemoveAll(ttscachedir)
|
||||
err := os.MkdirAll(ttscachedir, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
// 获取回复模式
|
||||
r := getReplyMode(ctx)
|
||||
r := replmd.getReplyMode(ctx)
|
||||
// 获取回复的文本
|
||||
reply := r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0])
|
||||
// 获取语音
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -90,7 +111,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s*(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
num := ctx.State["regex_matched"].([]string)[2]
|
||||
n := 0
|
||||
@@ -104,36 +125,38 @@ func init() { // 插件主体
|
||||
}
|
||||
// 保存设置
|
||||
logrus.Debugln("[tts] t.setSoundMode( ctx", param, n, n, ")")
|
||||
err = t.setSoundMode(ctx, param, n, n)
|
||||
err = ttsmd.setSoundMode(ctx, param, n, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
if banner, ok := genshin.TestRecord[param]; ok {
|
||||
logrus.Debugln("[tts] banner:", banner, "get sound mode...")
|
||||
// 设置验证
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[tts] got sound mode, speaking...")
|
||||
rec, err := speaker.Speak(ctx.Event.UserID, func() string { return banner })
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[tts] sending...")
|
||||
if id := ctx.SendChain(message.Record(rec).Add("cache", 0)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
banner := genshin.TestRecord[param]
|
||||
if banner == "" {
|
||||
banner = genshin.TestRecord["默认"]
|
||||
}
|
||||
logrus.Debugln("[tts] banner:", banner, "get sound mode...")
|
||||
// 设置验证
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[tts] got sound mode, speaking...")
|
||||
rec, err := speaker.Speak(ctx.Event.UserID, func() string { return banner })
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[tts] sending...")
|
||||
if id := ctx.SendChain(message.Record(rec).Add("cache", 0)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功"))
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s*(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s+(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
num := ctx.State["regex_matched"].([]string)[2]
|
||||
n := 0
|
||||
@@ -146,7 +169,7 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
// 保存设置
|
||||
err = t.setDefaultSoundMode(param, n, n)
|
||||
err = ttsmd.setDefaultSoundMode(param, n, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -155,13 +178,13 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
ent.OnFullMatch("恢复成默认语音模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := t.resetSoundMode(ctx)
|
||||
err := ttsmd.resetSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
// 设置验证
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -170,7 +193,16 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := t.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
|
||||
err := 原.set(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置百度语音\s*api\s*id\s*(.*)\s*secret\s*(.*)\s*$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := 百.set(ctx.State["regex_matched"].([]string)[1] + "," + ctx.State["regex_matched"].([]string)[2])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
29
plugin/ai_reply/model.go
Normal file
29
plugin/ai_reply/model.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package aireply
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
)
|
||||
|
||||
type apikeystore struct {
|
||||
k string
|
||||
p string
|
||||
}
|
||||
|
||||
func newapikeystore(p string) (s apikeystore) {
|
||||
s.p = p
|
||||
if file.IsExist(p) {
|
||||
data, err := os.ReadFile(p)
|
||||
if err == nil {
|
||||
s.k = binary.BytesToString(data)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *apikeystore) set(k string) error {
|
||||
s.k = k
|
||||
return os.WriteFile(s.p, binary.StringToBytes(k), 0644)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func init() {
|
||||
if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil {
|
||||
t := time.Now().Unix()
|
||||
cache.Set(uid, struct{}{})
|
||||
ctx.SetGroupBan(gid, uid, int64(bandur.Minutes()))
|
||||
ctx.SetThisGroupBan(uid, int64(bandur.Minutes()))
|
||||
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur))
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
|
||||
@@ -40,7 +40,7 @@ func randText(text ...string) message.MessageSegment {
|
||||
}
|
||||
|
||||
// isAtriSleeping 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
|
||||
func isAtriSleeping(ctx *zero.Ctx) bool {
|
||||
func isAtriSleeping(*zero.Ctx) bool {
|
||||
if now := time.Now().Hour(); now >= 1 && now < 6 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,27 +1,60 @@
|
||||
// Package baidu 百度一下
|
||||
// Package baidu 百度百科
|
||||
package baidu
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
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("baidu", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "不会百度吗",
|
||||
Help: "- 百度下[xxx]",
|
||||
}).OnPrefix("百度下").SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
txt := ctx.State["args"].(string)
|
||||
if txt != "" {
|
||||
ctx.SendChain(message.Text("https://buhuibaidu.me/?s=" + url.QueryEscape(txt)))
|
||||
}
|
||||
})
|
||||
const (
|
||||
duURL = "https://api.a20safe.com/api.php?api=21&key=%s&text=%s" // api地址
|
||||
wikiURL = "https://api.a20safe.com/api.php?api=23&key=%s&text=%s"
|
||||
key = "7d06a110e9e20a684e02934549db1d3d"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data []struct {
|
||||
Content string `json:"content"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "百科\n" +
|
||||
"- 百度/百科/维基/wiki[关键字]",
|
||||
})
|
||||
en.OnRegex(`^(百度|维基|百科|wiki)\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
var es []byte
|
||||
var err error
|
||||
switch ctx.State["regex_matched"].([]string)[1] {
|
||||
case "百度", "百科":
|
||||
es, err = web.GetData(fmt.Sprintf(duURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值
|
||||
case "wiki", "维基":
|
||||
es, err = web.GetData(fmt.Sprintf(wikiURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
var r result // r数组
|
||||
err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
if r.Code == 0 && len(r.Data) > 0 {
|
||||
ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果
|
||||
} else {
|
||||
ctx.SendChain(message.Text("API访问错误"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,115 +4,51 @@ package baiduaudit
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Baidu-AIP/golang-sdk/aip/censor"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
// 服务网址:https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index
|
||||
// 返回参数说明:https://cloud.baidu.com/doc/ANTIPORN/s/Nk3h6xbb2
|
||||
type baiduRes struct {
|
||||
LogID int `json:"log_id"` // 请求唯一id
|
||||
Conclusion string `json:"conclusion"` // 审核结果,可取值:合规、不合规、疑似、审核失败
|
||||
ConclusionType int `json:"conclusionType"` // 审核结果类型,可取值1.合规,2.不合规,3.疑似,4.审核失败
|
||||
Data []auditData `json:"data"`
|
||||
ErrorCode int `json:"error_code"` // 错误提示码,失败才返回,成功不返回
|
||||
ErrorMsg string `json:"error_msg"` // 错误提示信息,失败才返回,成功不返回
|
||||
}
|
||||
|
||||
type auditData struct {
|
||||
Type int `json:"type"` // 审核主类型,11:百度官方违禁词库、12:文本反作弊、13:自定义文本黑名单、14:自定义文本白名单
|
||||
SubType int `json:"subType"` // 审核子类型,0:含多种类型,具体看官方链接,1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
Conclusion string `json:"conclusion"` // 审核结果,可取值:合规、不合规、疑似、审核失败
|
||||
ConclusionType int `json:"conclusionType"` // 审核结果类型,可取值1.合规,2.不合规,3.疑似,4.审核失败
|
||||
Msg string `json:"msg"` // 不合规项描述信息
|
||||
Hits []hit `json:"hits"`
|
||||
} // 不合规/疑似/命中白名单项详细信息。响应成功并且conclusion为疑似或不合规或命中白名单时才返回,响应失败或conclusion为合规且未命中白名单时不返回。
|
||||
|
||||
type hit struct {
|
||||
DatasetName string `json:"datasetName"` // 违规项目所属数据集名称
|
||||
Words []string `json:"words"` // 送检文本命中词库的关键词(备注:建议参考新字段“wordHitPositions”,包含信息更丰富:关键词以及对应的位置及标签信息)
|
||||
Probability float64 `json:"probability,omitempty"` // 不合规项置信度
|
||||
} // 送检文本违规原因的详细信息
|
||||
type keyConfig struct {
|
||||
Key1 string `json:"key1"` // 百度云服务内容审核key存储
|
||||
Key2 string `json:"key2"` // 百度云服务内容审核key存储
|
||||
Groups map[int64]group `json:"groups"` // 群配置存储
|
||||
}
|
||||
|
||||
type group struct {
|
||||
Enable EnableMark // 是否启用内容审核
|
||||
TextAudit EnableMark // 文本检测
|
||||
ImageAudit EnableMark // 图像检测
|
||||
DMRemind EnableMark // 撤回提示
|
||||
MoreRemind EnableMark // 详细违规提示
|
||||
DMBAN EnableMark // 撤回后禁言
|
||||
BANTimeAddEnable EnableMark // 禁言累加
|
||||
BANTime int64 // 标准禁言时间,禁用累加,但开启禁言的的情况下采用该值
|
||||
MaxBANTimeAddRange int64 // 最大禁言时间累加范围,最高禁言时间
|
||||
BANTimeAddTime int64 // 禁言累加时间,该值是开启禁累加功能后,再次触发时,根据被禁次数X该值计算出的禁言时间
|
||||
WhiteListType [8]bool // 类型白名单,处于白名单类型的违规,不会被触发 0:含多种类型,具体看官方链接,1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
AuditHistory map[int64]auditHistory // 被封禁用户列表
|
||||
}
|
||||
|
||||
// EnableMark 启用:●,禁用:○
|
||||
type EnableMark bool
|
||||
|
||||
// String 打印启用状态
|
||||
func (em EnableMark) String() string {
|
||||
if em {
|
||||
return "开启"
|
||||
}
|
||||
return "关闭"
|
||||
}
|
||||
|
||||
type auditHistory struct {
|
||||
Count int64 `json:"key2"` // 被禁次数
|
||||
ResList []baiduRes `json:"reslist"` // 禁言原因
|
||||
}
|
||||
|
||||
var bdcli *censor.ContentCensorClient // 百度云审核服务Client
|
||||
var typetext = [8]string{
|
||||
0: "默认违禁词库",
|
||||
1: "违禁违规",
|
||||
2: "文本色情",
|
||||
3: "敏感信息",
|
||||
4: "恶意推广",
|
||||
5: "低俗辱骂",
|
||||
6: "恶意推广-联系方式",
|
||||
7: "恶意推广-软文推广",
|
||||
} // 文本类型
|
||||
|
||||
var (
|
||||
config keyConfig // 插件配置
|
||||
configinit bool // 配置初始化
|
||||
configpath string // 配置路径
|
||||
bdcli *censor.ContentCensorClient // 百度云审核服务Client
|
||||
txttyp = [...]string{
|
||||
0: "默认违禁词库",
|
||||
1: "违禁违规",
|
||||
2: "文本色情",
|
||||
3: "敏感信息",
|
||||
4: "恶意推广",
|
||||
5: "低俗辱骂",
|
||||
6: "恶意推广-联系方式",
|
||||
7: "恶意推广-软文推广",
|
||||
} // 文本类型
|
||||
config = newconfig() // 插件配置
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("baiduaudit", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "百度内容审核",
|
||||
Help: "##该功能来自百度内容审核,需购买相关服务,并创建app##\n" +
|
||||
Help: "##该功能来自百度内容审核, 需购买相关服务, 并创建app##\n" +
|
||||
"- 获取BDAKey\n" +
|
||||
"- 配置BDAKey [API key] [Secret Key]\n" +
|
||||
"- 开启/关闭内容审核\n" +
|
||||
"- 开启/关闭撤回提示\n" +
|
||||
"- 开启/关闭详细提示\n" +
|
||||
"- 开启/关闭撤回禁言\n" +
|
||||
"##禁言时间设置## 禁言时间计算方式为:禁言次数*每次禁言累加时间,当达到最大禁言时间时,再次触发按最大禁言时间计算\n" +
|
||||
"##禁言时间设置## 禁言时间计算方式为:禁言次数*每次禁言累加时间,当达到最大禁言时间时, 再次触发按最大禁言时间计算\n" +
|
||||
"- 开启/关闭禁言累加\n" +
|
||||
"- 设置撤回禁言时间[分钟,默认:1]\n" +
|
||||
"- 设置最大禁言时间[分钟,默认:60,最大43200]\n" +
|
||||
"- 设置每次累加时间[分钟,默认:1]\n" +
|
||||
"- 设置撤回禁言时间[分钟, 默认:1]\n" +
|
||||
"- 设置最大禁言时间[分钟, 默认:60,最大43200]\n" +
|
||||
"- 设置每次累加时间[分钟, 默认:1]\n" +
|
||||
"##检测类型设置## 类型编号列表:[1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广]\n" +
|
||||
"- 查看检测类型\n" +
|
||||
"- 查看检测配置\n" +
|
||||
@@ -121,15 +57,19 @@ func init() {
|
||||
"- 开启/关闭文本检测\n" +
|
||||
"- 开启/关闭图像检测\n" +
|
||||
"##测试功能##\n" +
|
||||
"- 测试文本检测[文本内容]\n" +
|
||||
"- 测试图像检测[图片]\n",
|
||||
"- ^文本检测[文本内容]\n" +
|
||||
"- ^图像检测[图片]\n",
|
||||
PrivateDataFolder: "baiduaudit",
|
||||
})
|
||||
configpath = engine.DataFolder() + "config.json"
|
||||
loadConfig()
|
||||
if configinit {
|
||||
|
||||
configpath := engine.DataFolder() + "config.json"
|
||||
err := config.load(configpath)
|
||||
if err != nil {
|
||||
logrus.Warnln("[baiduaudit] 加载配置错误:", err)
|
||||
} else if config.Key1 != "" && config.Key2 != "" {
|
||||
bdcli = censor.NewClient(config.Key1, config.Key2)
|
||||
}
|
||||
|
||||
engine.OnFullMatch("获取BDAKey", zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("接口key创建网址:\n" +
|
||||
@@ -138,28 +78,33 @@ func init() {
|
||||
"https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/resource/getFree"))
|
||||
})
|
||||
|
||||
engine.OnRegex("^查看检测(类型|配置)$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
engine.OnRegex("^查看检测(类型|配置)$", zero.AdminPermission, hasinit).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 获取群配置
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
var msgs string
|
||||
group := config.groupof(ctx.Event.GroupID)
|
||||
msg := ""
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
if k1 == "类型" {
|
||||
msgs += "本群检测类型:"
|
||||
find := false
|
||||
sb := strings.Builder{}
|
||||
sb.WriteString("本群检测类型:")
|
||||
found := false
|
||||
// 遍历群检测类型名单
|
||||
for i, v := range group.WhiteListType {
|
||||
for i, v := range group.copyWhiteListType() {
|
||||
if !v {
|
||||
find = true
|
||||
msgs += fmt.Sprint("\n", i, ".", typetext[i])
|
||||
found = true
|
||||
sb.WriteByte('\n')
|
||||
sb.WriteString(strconv.Itoa(i))
|
||||
sb.WriteByte('.')
|
||||
sb.WriteString(txttyp[i])
|
||||
}
|
||||
}
|
||||
if !find {
|
||||
msgs += "无"
|
||||
if !found {
|
||||
sb.WriteString("无")
|
||||
}
|
||||
msg = sb.String()
|
||||
} else {
|
||||
// 生成配置文本
|
||||
msgs = fmt.Sprintf("本群配置:\n"+
|
||||
msg = fmt.Sprintf("本群配置:\n"+
|
||||
"内容审核:%s\n"+
|
||||
"-文本:%s\n"+
|
||||
"-图像:%s\n"+
|
||||
@@ -171,138 +116,145 @@ func init() {
|
||||
"-每次累加时间:%v分钟\n"+
|
||||
"-最大禁言时间:%v分钟", group.Enable, group.TextAudit, group.ImageAudit, group.DMRemind, group.MoreRemind, group.DMBAN, group.BANTimeAddEnable, group.BANTime, group.BANTimeAddTime, group.MaxBANTimeAddRange)
|
||||
}
|
||||
b, err := text.RenderToBase64(msgs, text.FontFile, 300, 20)
|
||||
b, err := text.RenderToBase64(msg, text.FontFile, 300, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
|
||||
})
|
||||
engine.OnRegex("^设置(不)?检测类型([01234567])$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
|
||||
engine.OnRegex("^设置(不)?检测类型([0-7])$", zero.AdminPermission, hasinit).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
group := config.groupof(ctx.Event.GroupID)
|
||||
inputType, _ := strconv.Atoi(k2)
|
||||
if k1 == "不" {
|
||||
group.WhiteListType[inputType] = true // 不检测:则进入类型白名单
|
||||
} else {
|
||||
group.WhiteListType[inputType] = false // 检测:则退出白名单
|
||||
group.setWhiteListType(inputType, k1 == "不")
|
||||
err := config.saveto(configpath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群将%s检测%s类型内容", k1, typetext[inputType])))
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群将%s检测%s类型内容", k1, txttyp[inputType])))
|
||||
})
|
||||
engine.OnRegex("^设置(最大|每次|撤回)(累加|禁言)时间(\\d{1,5})$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
|
||||
engine.OnRegex("^设置(最大|每次|撤回)(累加|禁言)时间(\\d{1,5})$", zero.AdminPermission, hasinit).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k3 := ctx.State["regex_matched"].([]string)[3]
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
time, _ := strconv.ParseInt(k1, 10, 64)
|
||||
switch k1 {
|
||||
case "最大":
|
||||
group.MaxBANTimeAddRange = time
|
||||
case "每次":
|
||||
group.BANTimeAddTime = time
|
||||
case "撤回":
|
||||
group.BANTime = time
|
||||
config.groupof(ctx.Event.GroupID).set(func(g *group) {
|
||||
switch k1 {
|
||||
case "最大":
|
||||
g.MaxBANTimeAddRange = time
|
||||
case "每次":
|
||||
g.BANTimeAddTime = time
|
||||
case "撤回":
|
||||
g.BANTime = time
|
||||
}
|
||||
})
|
||||
err := config.saveto(configpath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s禁言累加时间已设置为%s", k3, k1)))
|
||||
})
|
||||
engine.OnRegex("^(开启|关闭)(内容审核|撤回提示|撤回禁言|禁言累加|详细提示|文本检测|图像检测)$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
|
||||
engine.OnRegex("^(开启|关闭)(内容审核|撤回提示|撤回禁言|禁言累加|详细提示|文本检测|图像检测)$", zero.AdminPermission, hasinit).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
isEnable := EnableMark(false)
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
if k1 == "开启" {
|
||||
isEnable = true
|
||||
isEnable := mark(k1 == "开启")
|
||||
config.groupof(ctx.Event.GroupID).set(func(g *group) {
|
||||
switch k2 {
|
||||
case "内容审核":
|
||||
g.Enable = isEnable
|
||||
case "撤回提示":
|
||||
g.DMRemind = isEnable
|
||||
case "撤回禁言":
|
||||
g.DMBAN = isEnable
|
||||
case "禁言累加":
|
||||
g.BANTimeAddEnable = isEnable
|
||||
case "详细提示":
|
||||
g.MoreRemind = isEnable
|
||||
case "文本检测":
|
||||
g.TextAudit = isEnable
|
||||
case "图像检测":
|
||||
g.ImageAudit = isEnable
|
||||
}
|
||||
})
|
||||
err := config.saveto(configpath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
switch k2 {
|
||||
case "内容审核":
|
||||
group.Enable = isEnable
|
||||
case "撤回提示":
|
||||
group.DMRemind = isEnable
|
||||
case "撤回禁言":
|
||||
group.DMBAN = isEnable
|
||||
case "禁言累加":
|
||||
group.BANTimeAddEnable = isEnable
|
||||
case "详细提示":
|
||||
group.MoreRemind = isEnable
|
||||
case "文本检测":
|
||||
group.TextAudit = isEnable
|
||||
case "图像检测":
|
||||
group.ImageAudit = isEnable
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s已%s", k2, k1)))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^配置BDAKey\s(.*)\s(.*)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
bdcli = censor.NewClient(k1, k2)
|
||||
config.Key1 = k1
|
||||
config.Key2 = k2
|
||||
config.setkey(k1, k2)
|
||||
if bdcli != nil {
|
||||
jsonSave(config, configpath)
|
||||
err := config.saveto(configpath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("配置成功"))
|
||||
}
|
||||
})
|
||||
engine.OnMessage().SetBlock(false).Handle(func(ctx *zero.Ctx) {
|
||||
group, ok := config.Groups[ctx.Event.GroupID]
|
||||
// 如果没该配置,或者审核功能未开启直接跳过
|
||||
if !ok || !bool(group.Enable) {
|
||||
|
||||
engine.OnMessage(config.isgroupexist).SetBlock(false).Handle(func(ctx *zero.Ctx) {
|
||||
group := config.groupof(ctx.Event.GroupID)
|
||||
if !bool(group.Enable) {
|
||||
return
|
||||
}
|
||||
var bdres baiduRes
|
||||
var err error
|
||||
for _, elem := range ctx.Event.Message {
|
||||
switch elem.Type {
|
||||
case "image":
|
||||
if !group.ImageAudit {
|
||||
return
|
||||
if !group.ImageAudit || elem.Data["url"] == "" {
|
||||
continue
|
||||
}
|
||||
res := bdcli.ImgCensorUrl(elem.Data["url"], nil)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
bdres, err = parse2BaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
continue
|
||||
}
|
||||
banCheck(ctx, bdres)
|
||||
|
||||
case "text":
|
||||
if !group.TextAudit {
|
||||
return
|
||||
if !group.TextAudit || elem.Data["text"] == "" {
|
||||
continue
|
||||
}
|
||||
res := bdcli.TextCensor(elem.Data["text"])
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
bdres, err = parse2BaiduRes(bdcli.TextCensor(elem.Data["text"]))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
continue
|
||||
}
|
||||
banCheck(ctx, bdres)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
bdres.audit(ctx, configpath)
|
||||
})
|
||||
engine.OnPrefix("文本检测", clientCheck).SetBlock(false).
|
||||
|
||||
engine.OnPrefix("^文本检测", hasinit).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if bdcli == nil {
|
||||
ctx.SendChain(message.Text("Key未配置"))
|
||||
return
|
||||
}
|
||||
args := ctx.ExtractPlainText()
|
||||
res := bdcli.TextCensor(args)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
bdres, err := parse2BaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
ctx.SendChain(message.Text("ERROR: ", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
ctx.SendChain(buildResp(bdres, group)...)
|
||||
ctx.Send(config.groupof(ctx.Event.GroupID).reply(&bdres))
|
||||
})
|
||||
engine.OnPrefix("^图像检测", clientCheck).SetBlock(false).
|
||||
|
||||
engine.OnPrefix("^图像检测", hasinit).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var urls []string
|
||||
for _, elem := range ctx.Event.Message {
|
||||
@@ -316,105 +268,17 @@ func init() {
|
||||
return
|
||||
}
|
||||
res := bdcli.ImgCensorUrl(urls[0], nil)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
bdres, err := parse2BaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
ctx.SendChain(message.Text("ERROR: ", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
ctx.SendChain(buildResp(bdres, group)...)
|
||||
ctx.Send(config.groupof(ctx.Event.GroupID).reply(&bdres))
|
||||
})
|
||||
}
|
||||
|
||||
// 禁言检测
|
||||
func banCheck(ctx *zero.Ctx, bdres baiduRes) {
|
||||
// 如果返回类型为2(不合规),0为合规,3为疑似
|
||||
if bdres.ConclusionType == 2 {
|
||||
// 创建消息ID
|
||||
mid := message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64))
|
||||
// 获取群配置
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
// 检测群配置里的不检测类型白名单,忽略掉不检测的违规类型
|
||||
for i, b := range group.WhiteListType {
|
||||
if i == bdres.Data[0].SubType && b {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 生成回复文本
|
||||
res := buildResp(bdres, group)
|
||||
// 撤回消息
|
||||
ctx.DeleteMessage(mid)
|
||||
// 查看是否启用撤回后禁言
|
||||
if group.DMBAN {
|
||||
// 从历史违规记录中获取指定用户
|
||||
user := group.getUser(ctx.Event.UserID)
|
||||
// 用户违规次数自增
|
||||
user.Count++
|
||||
// 用户违规原因记录
|
||||
user.ResList = append(user.ResList, bdres)
|
||||
// 覆写该用户到群违规记录中
|
||||
group.AuditHistory[ctx.Event.UserID] = user
|
||||
// 覆写该群信息
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
// 保存到json
|
||||
jsonSave(config, configpath)
|
||||
var bantime int64
|
||||
// 查看是否开启禁言累加功能,并计算禁言时间
|
||||
if group.BANTimeAddEnable {
|
||||
bantime = user.Count * group.BANTimeAddTime * 60
|
||||
} else {
|
||||
bantime = group.BANTime * 60
|
||||
}
|
||||
// 执行禁言
|
||||
ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime)
|
||||
}
|
||||
// 查看是否开启撤回提示
|
||||
if group.DMRemind {
|
||||
res = append(res, message.At(ctx.Event.Sender.ID))
|
||||
ctx.SendChain(res...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取群配置
|
||||
func getGroup(groupID int64) group {
|
||||
g, ok := config.Groups[groupID]
|
||||
if ok {
|
||||
return g
|
||||
}
|
||||
if config.Groups == nil {
|
||||
config.Groups = make(map[int64]group)
|
||||
}
|
||||
g = group{
|
||||
TextAudit: true,
|
||||
ImageAudit: true,
|
||||
BANTime: 1,
|
||||
MaxBANTimeAddRange: 60,
|
||||
BANTimeAddTime: 1,
|
||||
WhiteListType: [8]bool{},
|
||||
AuditHistory: map[int64]auditHistory{},
|
||||
}
|
||||
config.Groups[groupID] = g
|
||||
return g
|
||||
}
|
||||
|
||||
// 从群历史违规记录中获取用户
|
||||
func (group *group) getUser(userID int64) auditHistory {
|
||||
audit, ok := group.AuditHistory[userID]
|
||||
if ok {
|
||||
return audit
|
||||
}
|
||||
// 如果没有用户,则创建一个并返回
|
||||
if group.AuditHistory == nil {
|
||||
group.AuditHistory = make(map[int64]auditHistory)
|
||||
}
|
||||
audit = auditHistory{0, []baiduRes{}}
|
||||
group.AuditHistory[userID] = audit
|
||||
return audit
|
||||
}
|
||||
|
||||
// 客户端是否初始化检测
|
||||
func clientCheck(ctx *zero.Ctx) bool {
|
||||
func hasinit(ctx *zero.Ctx) bool {
|
||||
if bdcli == nil {
|
||||
ctx.SendChain(message.Text("Key未配置"))
|
||||
return false
|
||||
@@ -422,79 +286,7 @@ func clientCheck(ctx *zero.Ctx) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 加载JSON配置文件
|
||||
func loadConfig() {
|
||||
if file.IsExist(configpath) {
|
||||
data, err := os.OpenFile(configpath, os.O_RDONLY, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.NewDecoder(data).Decode(&config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
configinit = true
|
||||
} else {
|
||||
config = keyConfig{}
|
||||
configinit = false
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置文件
|
||||
func jsonSave(v keyConfig, path string) {
|
||||
jsf, _ := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
defer func(file *os.File) {
|
||||
err := file.Close()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}(jsf) // 结束时关闭句柄,释放资源
|
||||
err := json.NewEncoder(jsf).Encode(v)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// JSON反序列化
|
||||
func jsonToBaiduRes(resjson string) (baiduRes, error) {
|
||||
var bdres baiduRes
|
||||
err := json.Unmarshal(binary.StringToBytes(resjson), &bdres)
|
||||
return bdres, err
|
||||
}
|
||||
|
||||
// 生成回复文本
|
||||
func buildResp(bdres baiduRes, group group) []message.MessageSegment {
|
||||
// 建立消息段
|
||||
msgs := make([]message.MessageSegment, 0, 8)
|
||||
// 生成简略审核结果回复
|
||||
msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
|
||||
// 查看是否开启详细审核内容提示,并确定审核内容值为疑似,或者不合规
|
||||
if !group.MoreRemind {
|
||||
return msgs
|
||||
}
|
||||
// 遍历返回的不合规数据,生成详细违规内容
|
||||
for i, datum := range bdres.Data {
|
||||
msgs = append(msgs, message.Text("[", i, "]:", datum.Msg, "\n"))
|
||||
// 检查命中词条是否大于0
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
// 遍历打印命中的违规词条
|
||||
for _, hit := range datum.Hits {
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
msgs = append(msgs, message.Text("("))
|
||||
for i4, i3 := range hit.Words {
|
||||
// 检查是否是最后一个要打印的词条,如果是则不加上逗号
|
||||
if i4 != len(hit.Words)-1 {
|
||||
msgs = append(msgs, message.Text(i3, ","))
|
||||
} else {
|
||||
msgs = append(msgs, message.Text(i3))
|
||||
}
|
||||
}
|
||||
msgs = append(msgs, message.Text(")"))
|
||||
}
|
||||
}
|
||||
return msgs
|
||||
func parse2BaiduRes(resjson string) (bdres baiduRes, err error) {
|
||||
err = json.Unmarshal(binary.StringToBytes(resjson), &bdres)
|
||||
return
|
||||
}
|
||||
|
||||
271
plugin/baiduaudit/model.go
Normal file
271
plugin/baiduaudit/model.go
Normal file
@@ -0,0 +1,271 @@
|
||||
package baiduaudit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
// 服务网址:https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index
|
||||
// 返回参数说明:https://cloud.baidu.com/doc/ANTIPORN/s/Nk3h6xbb2
|
||||
type baiduRes struct {
|
||||
mu sync.Mutex `json:"-"`
|
||||
// LogID int `json:"log_id"` // 请求唯一id
|
||||
Conclusion string `json:"conclusion"` // 审核结果, 可取值:合规、不合规、疑似、审核失败
|
||||
ConclusionType int `json:"conclusionType"` // 审核结果类型, 可取值1.合规, 2.不合规, 3.疑似, 4.审核失败
|
||||
Data []*auditData `json:"data"`
|
||||
ErrorCode int `json:"error_code"` // 错误提示码, 失败才返回, 成功不返回
|
||||
ErrorMsg string `json:"error_msg"` // 错误提示信息, 失败才返回, 成功不返回
|
||||
}
|
||||
|
||||
// 禁言检测
|
||||
func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) {
|
||||
bdres.mu.Lock()
|
||||
defer bdres.mu.Unlock()
|
||||
// 如果返回类型为2(不合规), 0为合规, 3为疑似
|
||||
if bdres.ConclusionType != 2 {
|
||||
return
|
||||
}
|
||||
// 创建消息ID
|
||||
mid := message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64))
|
||||
// 获取群配置
|
||||
group := config.groupof(ctx.Event.GroupID)
|
||||
// 检测群配置里的不检测类型白名单, 忽略掉不检测的违规类型
|
||||
for i, b := range group.copyWhiteListType() {
|
||||
if i == bdres.Data[0].SubType && b {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 生成回复文本
|
||||
res := group.reply(bdres)
|
||||
// 撤回消息
|
||||
ctx.DeleteMessage(mid)
|
||||
// 查看是否启用撤回后禁言
|
||||
if group.DMBAN {
|
||||
// 从历史违规记录中获取指定用户
|
||||
user := group.historyof(ctx.Event.UserID)
|
||||
// 用户违规次数自增
|
||||
atomic.AddInt64(&user.Count, 1)
|
||||
user.mu.Lock()
|
||||
// 用户违规原因记录
|
||||
user.ResList = append(user.ResList, bdres)
|
||||
user.mu.Unlock()
|
||||
// 保存到json
|
||||
err := config.saveto(configpath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
var bantime int64
|
||||
// 查看是否开启禁言累加功能, 并计算禁言时间
|
||||
if group.BANTimeAddEnable {
|
||||
bantime = atomic.LoadInt64(&user.Count) * group.BANTimeAddTime * 60
|
||||
} else {
|
||||
bantime = group.BANTime * 60
|
||||
}
|
||||
// 执行禁言
|
||||
ctx.SetThisGroupBan(ctx.Event.UserID, bantime)
|
||||
}
|
||||
// 查看是否开启撤回提示
|
||||
if group.DMRemind {
|
||||
res = append(res, message.At(ctx.Event.Sender.ID))
|
||||
ctx.Send(res)
|
||||
}
|
||||
}
|
||||
|
||||
type auditData struct {
|
||||
// Type int `json:"type"` // 审核主类型, 11:百度官方违禁词库、12:文本反作弊、13:自定义文本黑名单、14:自定义文本白名单
|
||||
SubType int `json:"subType"` // 审核子类型, 0:含多种类型, 具体看官方链接, 1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
// Conclusion string `json:"conclusion"` // 审核结果, 可取值:合规、不合规、疑似、审核失败
|
||||
// ConclusionType int `json:"conclusionType"` // 审核结果类型, 可取值1.合规, 2.不合规, 3.疑似, 4.审核失败
|
||||
Msg string `json:"msg"` // 不合规项描述信息
|
||||
Hits []*hit `json:"hits"`
|
||||
} // 不合规/疑似/命中白名单项详细信息.响应成功并且conclusion为疑似或不合规或命中白名单时才返回, 响应失败或conclusion为合规且未命中白名单时不返回.
|
||||
|
||||
type auditHistory struct {
|
||||
mu sync.Mutex `json:"-"`
|
||||
Count int64 `json:"key2"` // 被禁次数
|
||||
ResList []*baiduRes `json:"reslist"` // 禁言原因
|
||||
}
|
||||
|
||||
type hit struct {
|
||||
// DatasetName string `json:"datasetName"` // 违规项目所属数据集名称
|
||||
Words []string `json:"words"` // 送检文本命中词库的关键词(备注:建议参考新字段“wordHitPositions”, 包含信息更丰富:关键词以及对应的位置及标签信息)
|
||||
// Probability float64 `json:"probability,omitempty"` // 不合规项置信度
|
||||
} // 送检文本违规原因的详细信息
|
||||
|
||||
type keyConfig struct {
|
||||
mu sync.Mutex `json:"-"`
|
||||
Key1 string `json:"key1"` // 百度云服务内容审核key存储
|
||||
Key2 string `json:"key2"` // 百度云服务内容审核key存储
|
||||
Groups map[int64]*group `json:"groups"` // 群配置存储
|
||||
}
|
||||
|
||||
func newconfig() (kc keyConfig) {
|
||||
kc.Groups = make(map[int64]*group, 64)
|
||||
return
|
||||
}
|
||||
|
||||
func (kc *keyConfig) setkey(k1, k2 string) {
|
||||
kc.mu.Lock()
|
||||
defer kc.mu.Unlock()
|
||||
kc.Key1 = k1
|
||||
kc.Key2 = k2
|
||||
}
|
||||
|
||||
// 加载JSON配置文件
|
||||
func (kc *keyConfig) load(filename string) error {
|
||||
if file.IsNotExist(filename) {
|
||||
return nil
|
||||
}
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kc.mu.Lock()
|
||||
defer kc.mu.Unlock()
|
||||
return json.NewDecoder(f).Decode(kc)
|
||||
}
|
||||
|
||||
func (kc *keyConfig) isgroupexist(ctx *zero.Ctx) (ok bool) {
|
||||
kc.mu.Lock()
|
||||
defer kc.mu.Unlock()
|
||||
_, ok = kc.Groups[ctx.Event.GroupID]
|
||||
return
|
||||
}
|
||||
|
||||
// 获取群配置
|
||||
func (kc *keyConfig) groupof(groupID int64) *group {
|
||||
kc.mu.Lock()
|
||||
defer kc.mu.Unlock()
|
||||
g, ok := kc.Groups[groupID]
|
||||
if ok {
|
||||
return g
|
||||
}
|
||||
g = &group{
|
||||
TextAudit: true,
|
||||
ImageAudit: true,
|
||||
BANTime: 1,
|
||||
MaxBANTimeAddRange: 60,
|
||||
BANTimeAddTime: 1,
|
||||
AuditHistory: map[int64]*auditHistory{},
|
||||
}
|
||||
kc.Groups[groupID] = g
|
||||
return g
|
||||
}
|
||||
|
||||
// 保存配置文件
|
||||
func (kc *keyConfig) saveto(filename string) error {
|
||||
kc.mu.Lock()
|
||||
defer kc.mu.Unlock()
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
return json.NewEncoder(f).Encode(kc)
|
||||
}
|
||||
|
||||
type group struct {
|
||||
mu sync.Mutex
|
||||
Enable mark // 是否启用内容审核
|
||||
TextAudit mark // 文本检测
|
||||
ImageAudit mark // 图像检测
|
||||
DMRemind mark // 撤回提示
|
||||
MoreRemind mark // 详细违规提示
|
||||
DMBAN mark // 撤回后禁言
|
||||
BANTimeAddEnable mark // 禁言累加
|
||||
BANTime int64 // 标准禁言时间, 禁用累加, 但开启禁言的的情况下采用该值
|
||||
MaxBANTimeAddRange int64 // 最大禁言时间累加范围, 最高禁言时间
|
||||
BANTimeAddTime int64 // 禁言累加时间, 该值是开启禁累加功能后, 再次触发时, 根据被禁次数X该值计算出的禁言时间
|
||||
WhiteListType [8]bool // 类型白名单, 处于白名单类型的违规, 不会被触发 0:含多种类型, 具体看官方链接, 1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
AuditHistory map[int64]*auditHistory // 被封禁用户列表
|
||||
}
|
||||
|
||||
func (g *group) set(f func(g *group)) {
|
||||
g.mu.Lock()
|
||||
f(g)
|
||||
g.mu.Unlock()
|
||||
}
|
||||
|
||||
func (g *group) setWhiteListType(typ int, ok bool) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
g.WhiteListType[typ] = ok
|
||||
}
|
||||
|
||||
func (g *group) copyWhiteListType() [8]bool {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
return g.WhiteListType
|
||||
}
|
||||
|
||||
// 从群历史违规记录中获取用户
|
||||
func (g *group) historyof(userID int64) *auditHistory {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
audit, ok := g.AuditHistory[userID]
|
||||
if ok {
|
||||
return audit
|
||||
}
|
||||
// 如果没有用户, 则创建一个并返回
|
||||
if g.AuditHistory == nil {
|
||||
g.AuditHistory = make(map[int64]*auditHistory)
|
||||
}
|
||||
audit = &auditHistory{}
|
||||
g.AuditHistory[userID] = audit
|
||||
return audit
|
||||
}
|
||||
|
||||
// 生成回复文本
|
||||
func (g *group) reply(bdres *baiduRes) message.Message {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
// 建立消息段
|
||||
msgs := make([]message.MessageSegment, 0, 8)
|
||||
// 生成简略审核结果回复
|
||||
msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
|
||||
// 查看是否开启详细审核内容提示, 并确定审核内容值为疑似, 或者不合规
|
||||
if !g.MoreRemind {
|
||||
return msgs
|
||||
}
|
||||
// 遍历返回的不合规数据, 生成详细违规内容
|
||||
for i, datum := range bdres.Data {
|
||||
msgs = append(msgs, message.Text("[", i, "]:", datum.Msg, "\n"))
|
||||
// 检查命中词条是否大于0
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
// 遍历打印命中的违规词条
|
||||
for _, hit := range datum.Hits {
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
msgs = append(msgs, message.Text("("))
|
||||
for i4, i3 := range hit.Words {
|
||||
// 检查是否是最后一个要打印的词条, 如果是则不加上逗号
|
||||
if i4 != len(hit.Words)-1 {
|
||||
msgs = append(msgs, message.Text(i3, ","))
|
||||
} else {
|
||||
msgs = append(msgs, message.Text(i3))
|
||||
}
|
||||
}
|
||||
msgs = append(msgs, message.Text(")"))
|
||||
}
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
type mark bool
|
||||
|
||||
// String 打印启用状态
|
||||
func (em mark) String() string {
|
||||
if em {
|
||||
return "开启"
|
||||
}
|
||||
return "关闭"
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func init() {
|
||||
"- 查成分 [xxx]\n" +
|
||||
"- 查弹幕 [xxx]\n" +
|
||||
"- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" +
|
||||
"- 更新vup" +
|
||||
"- 更新vup\n" +
|
||||
"Tips: (412就是拦截的意思,建议私聊把cookie设全)\n",
|
||||
PublicDataFolder: "Bilibili",
|
||||
})
|
||||
@@ -340,7 +340,7 @@ func init() {
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
totalDanmuku += len(danmaku.Data.Data[i].Danmakus) + 1
|
||||
}
|
||||
cw := 10000
|
||||
cw := 3000
|
||||
mcw := float64(2000)
|
||||
ch := 550 + len(danmaku.Data.Data)*int(faceH) + totalDanmuku*int(danmuH)
|
||||
canvas = gg.NewContext(cw, ch)
|
||||
|
||||
@@ -3,37 +3,56 @@ package bilibili
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
bz "github.com/FloatTech/AnimeAPI/bilibili"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
)
|
||||
|
||||
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=%v"
|
||||
referer = "https://space.bilibili.com/%v"
|
||||
infoURL = "https://api.bilibili.com/x/space/wbi/acc/info?mid=%v&token=&platform=web&web_location=1550101"
|
||||
navURL = "https://api.bilibili.com/x/web-interface/nav"
|
||||
)
|
||||
|
||||
// bdb bilibili推送数据库
|
||||
var bdb *bilibilipushdb
|
||||
|
||||
var (
|
||||
lastTime = map[int64]int64{}
|
||||
liveStatus = map[int64]int{}
|
||||
upMap = map[int64]string{}
|
||||
lastTime = map[int64]int64{}
|
||||
liveStatus = map[int64]int{}
|
||||
upMap = map[int64]string{}
|
||||
mixinKeyEncTab = [...]int{
|
||||
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
|
||||
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
|
||||
61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11,
|
||||
36, 20, 34, 44, 52,
|
||||
}
|
||||
cache syncx.Map[string, string]
|
||||
lastUpdateTime time.Time
|
||||
|
||||
replacements = [...]string{"!", "'", "(", ")", "*"}
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -59,7 +78,7 @@ func init() {
|
||||
en.OnRegex(`^添加[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
|
||||
name, err := getName(buid)
|
||||
if err != nil {
|
||||
if err != nil || name == "" {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -174,15 +193,17 @@ func init() {
|
||||
func getName(buid int64) (name string, err error) {
|
||||
var ok bool
|
||||
if name, ok = upMap[buid]; !ok {
|
||||
var data []byte
|
||||
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua, nil)
|
||||
data, err := web.RequestDataWithHeaders(web.NewDefaultClient(), signURL(fmt.Sprintf(infoURL, buid)), "GET", func(r *http.Request) error {
|
||||
r.Header.Set("User-Agent", ua)
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return
|
||||
return "", err
|
||||
}
|
||||
status := int(gjson.Get(binary.BytesToString(data), "code").Int())
|
||||
if status != 0 {
|
||||
err = errors.New(gjson.Get(binary.BytesToString(data), "message").String())
|
||||
return
|
||||
return "", err
|
||||
}
|
||||
name = gjson.Get(binary.BytesToString(data), "data.name").String()
|
||||
bdb.insertBilibiliUp(buid, name)
|
||||
@@ -191,6 +212,103 @@ func getName(buid int64) (name string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func getMixinKey(orig string) string {
|
||||
var str strings.Builder
|
||||
t := 0
|
||||
for _, v := range mixinKeyEncTab {
|
||||
if v < len(orig) {
|
||||
str.WriteByte(orig[v])
|
||||
t++
|
||||
}
|
||||
if t > 31 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return str.String()
|
||||
}
|
||||
|
||||
func wbiSign(params map[string]string, imgKey string, subKey string) map[string]string {
|
||||
mixinKey := getMixinKey(imgKey + subKey)
|
||||
currTime := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
params["wts"] = currTime
|
||||
// Sort keys
|
||||
keys := make([]string, 0, len(params))
|
||||
for k, v := range params {
|
||||
keys = append(keys, k)
|
||||
for _, old := range replacements {
|
||||
v = strings.ReplaceAll(v, old, "")
|
||||
}
|
||||
params[k] = v
|
||||
}
|
||||
sort.Strings(keys)
|
||||
h := md5.New()
|
||||
for k, v := range keys {
|
||||
h.Write([]byte(v))
|
||||
h.Write([]byte{'='})
|
||||
h.Write([]byte(params[v]))
|
||||
if k < len(keys)-1 {
|
||||
h.Write([]byte{'&'})
|
||||
}
|
||||
}
|
||||
h.Write([]byte(mixinKey))
|
||||
params["w_rid"] = hex.EncodeToString(h.Sum(make([]byte, 0, md5.Size)))
|
||||
return params
|
||||
}
|
||||
|
||||
func getWbiKeysCached() (string, string) {
|
||||
if time.Since(lastUpdateTime).Minutes() > 10 {
|
||||
imgKey, subKey := getWbiKeys()
|
||||
cache.Store("imgKey", imgKey)
|
||||
cache.Store("subKey", subKey)
|
||||
lastUpdateTime = time.Now()
|
||||
return imgKey, subKey
|
||||
}
|
||||
imgKeyI, _ := cache.Load("imgKey")
|
||||
subKeyI, _ := cache.Load("subKey")
|
||||
return imgKeyI, subKeyI
|
||||
}
|
||||
|
||||
func getWbiKeys() (string, string) {
|
||||
data, _ := web.RequestDataWithHeaders(web.NewDefaultClient(), navURL, "GET", func(r *http.Request) error {
|
||||
if cfg != nil {
|
||||
cookie, err := cfg.Load()
|
||||
if err == nil {
|
||||
r.Header.Set("cookie", cookie)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return errors.New("未配置-cookie")
|
||||
}, nil)
|
||||
json := helper.BytesToString(data)
|
||||
imgURL := gjson.Get(json, "data.wbi_img.img_url").String()
|
||||
subURL := gjson.Get(json, "data.wbi_img.sub_url").String()
|
||||
imgKey := imgURL[strings.LastIndex(imgURL, "/")+1:]
|
||||
imgKey = strings.TrimSuffix(imgKey, filepath.Ext(imgKey))
|
||||
subKey := subURL[strings.LastIndex(subURL, "/")+1:]
|
||||
subKey = strings.TrimSuffix(subKey, filepath.Ext(subKey))
|
||||
return imgKey, subKey
|
||||
}
|
||||
|
||||
func signURL(urlStr string) string {
|
||||
urlObj, _ := url.Parse(urlStr)
|
||||
imgKey, subKey := getWbiKeysCached()
|
||||
query := urlObj.Query()
|
||||
params := map[string]string{}
|
||||
for k, v := range query {
|
||||
if len(v) > 0 {
|
||||
params[k] = v[0]
|
||||
}
|
||||
}
|
||||
newParams := wbiSign(params, imgKey, subKey)
|
||||
for k, v := range newParams {
|
||||
query.Set(k, v)
|
||||
}
|
||||
urlObj.RawQuery = query.Encode()
|
||||
newURL := urlObj.String()
|
||||
return newURL
|
||||
}
|
||||
|
||||
// subscribe 订阅
|
||||
func subscribe(buid, groupid int64) (err error) {
|
||||
bpMap := map[string]any{
|
||||
@@ -263,7 +381,7 @@ func sendDynamic(ctx *zero.Ctx) error {
|
||||
return err
|
||||
}
|
||||
if len(cardList) == 0 {
|
||||
return errors.Errorf("%v的历史动态数为0", buid)
|
||||
return nil
|
||||
}
|
||||
t, ok := lastTime[buid]
|
||||
// 第一次先记录时间,啥也不做
|
||||
|
||||
@@ -27,7 +27,7 @@ func init() {
|
||||
db.DBPath = engine.DataFolder() + "bookreview.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("bookreview.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -26,7 +26,7 @@ func init() {
|
||||
db.DBPath = en.DataFolder() + "cxh.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = en.GetLazyData("cxh.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -44,6 +44,9 @@ func init() {
|
||||
return "", err
|
||||
}
|
||||
arr := gjson.Get(helper.BytesToString(data), "data.data").Array()
|
||||
if len(arr) == 0 {
|
||||
return "", errors.New("data is empty")
|
||||
}
|
||||
pic := arr[rand.Intn(len(arr))]
|
||||
return pic.String(), nil
|
||||
}, web.GetData, time.Minute)
|
||||
|
||||
@@ -27,7 +27,7 @@ func init() {
|
||||
db.DBPath = engine.DataFolder() + "cp.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("cp.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -35,7 +35,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
37
plugin/dailynews/dailynews.go
Normal file
37
plugin/dailynews/dailynews.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Package dailynews 今日早报
|
||||
package dailynews
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const api = "http://dwz.2xb.cn/zaob"
|
||||
|
||||
func init() {
|
||||
engine := control.Register("dailynews", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "今日早报",
|
||||
Help: "- 今日早报",
|
||||
PrivateDataFolder: "dailynews",
|
||||
})
|
||||
|
||||
engine.OnFullMatch(`今日早报`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(api)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
picURL := gjson.Get(binary.BytesToString(data), "imageUrl").String()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(picURL))
|
||||
})
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func LoadText(dbfile string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
115
plugin/dish/dish.go
Normal file
115
plugin/dish/dish.go
Normal file
@@ -0,0 +1,115 @@
|
||||
// Package dish 程序员做饭指南zbp版,数据来源Anduin2017/HowToCook
|
||||
package dish
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
type dish struct {
|
||||
ID uint32 `db:"id"`
|
||||
Name string `db:"name"`
|
||||
Materials string `db:"materials"`
|
||||
Steps string `db:"steps"`
|
||||
}
|
||||
|
||||
var (
|
||||
db = &sql.Sqlite{}
|
||||
initialized = false
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("dish", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "程序员做饭指南",
|
||||
Help: "-怎么做[xxx]|烹饪[xxx]|随机菜谱|随便做点菜",
|
||||
PublicDataFolder: "Dish",
|
||||
})
|
||||
|
||||
db.DBPath = en.DataFolder() + "dishes.db"
|
||||
|
||||
if _, err := en.GetLazyData("dishes.db", true); err != nil {
|
||||
logrus.Warnln("[dish]获取菜谱数据库文件失败")
|
||||
} else if err = db.Open(time.Hour); err != nil {
|
||||
logrus.Warnln("[dish]连接菜谱数据库失败")
|
||||
} else if err = db.Create("dish", &dish{}); err != nil {
|
||||
logrus.Warnln("[dish]同步菜谱数据表失败")
|
||||
} else if count, err := db.Count("dish"); err != nil {
|
||||
logrus.Warnln("[dish]统计菜谱数据失败")
|
||||
} else {
|
||||
logrus.Infoln("[dish]加载", count, "条菜谱")
|
||||
initialized = true
|
||||
}
|
||||
|
||||
if !initialized {
|
||||
logrus.Warnln("[dish]插件未能成功初始化")
|
||||
}
|
||||
|
||||
en.OnPrefixGroup([]string{"怎么做", "烹饪"}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
if !initialized {
|
||||
ctx.SendChain(message.Text("客官,本店暂未开业"))
|
||||
return
|
||||
}
|
||||
|
||||
name := ctx.NickName()
|
||||
dishName := ctx.State["args"].(string)
|
||||
|
||||
if dishName == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(dishName, "'") ||
|
||||
strings.Contains(dishName, "\"") ||
|
||||
strings.Contains(dishName, "\\") ||
|
||||
strings.Contains(dishName, ";") {
|
||||
return
|
||||
}
|
||||
|
||||
var d dish
|
||||
if err := db.Find("dish", &d, fmt.Sprintf("WHERE name like %%%s%%", dishName)); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SendChain(message.Text(fmt.Sprintf(
|
||||
"已为客官%s找到%s的做法辣!\n"+
|
||||
"原材料:%s\n"+
|
||||
"步骤:\n"+
|
||||
"%s",
|
||||
name, dishName, d.Materials, d.Steps),
|
||||
))
|
||||
})
|
||||
|
||||
en.OnPrefixGroup([]string{"随机菜谱", "随便做点菜"}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
if !initialized {
|
||||
ctx.SendChain(message.Text("客官,本店暂未开业"))
|
||||
return
|
||||
}
|
||||
|
||||
name := ctx.NickName()
|
||||
var d dish
|
||||
if err := db.Pick("dish", &d); err != nil {
|
||||
ctx.SendChain(message.Text("小店好像出错了,暂时端不出菜来惹"))
|
||||
logrus.Warnln("[dish]随机菜谱请求出错:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SendChain(message.Text(fmt.Sprintf(
|
||||
"已为客官%s送上%s的做法:\n"+
|
||||
"原材料:%s\n"+
|
||||
"步骤:\n"+
|
||||
"%s",
|
||||
name, d.Name, d.Materials, d.Steps),
|
||||
))
|
||||
})
|
||||
}
|
||||
254
plugin/drawlots/main.go
Normal file
254
plugin/drawlots/main.go
Normal file
@@ -0,0 +1,254 @@
|
||||
// Package drawlots 多功能抽签插件
|
||||
package drawlots
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/gif"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/fumiama/jieba/util/helper"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
lotsType string // 文件后缀
|
||||
quantity int // 签数
|
||||
}
|
||||
|
||||
var (
|
||||
lotsList = func() map[string]info {
|
||||
lotsList, err := getList()
|
||||
if err != nil {
|
||||
logrus.Infoln("[drawlots]加载失败:", err)
|
||||
} else {
|
||||
logrus.Infoln("[drawlots]加载", len(lotsList), "个抽签")
|
||||
}
|
||||
return lotsList
|
||||
}()
|
||||
en = control.Register("drawlots", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "多功能抽签",
|
||||
Help: "支持图包文件夹和gif抽签\n" +
|
||||
"-------------\n" +
|
||||
"- (刷新)抽签列表\n- 抽[签名]签\n- 看[gif签名]签\n- 加[签名]签[gif图片]\n- 删[gif签名]签",
|
||||
PrivateDataFolder: "drawlots",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
datapath = file.BOTPATH + "/" + en.DataFolder()
|
||||
)
|
||||
|
||||
func init() {
|
||||
en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
var err error
|
||||
lotsList, err = getList() // 刷新列表
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
messageText := &strings.Builder{}
|
||||
messageText.WriteString(" 签 名 [ 类 型 ]----签数\n")
|
||||
messageText.WriteString("———————————\n")
|
||||
for name, fileInfo := range lotsList {
|
||||
messageText.WriteString(name + "[" + fileInfo.lotsType + "]----" + strconv.Itoa(fileInfo.quantity) + "\n")
|
||||
messageText.WriteString("----------\n")
|
||||
}
|
||||
textPic, err := text.RenderToBase64(messageText.String(), text.BoldFontFile, 400, 50)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + helper.BytesToString(textPic)))
|
||||
})
|
||||
en.OnRegex(`^抽(.+)签$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
lotsType := ctx.State["regex_matched"].([]string)[1]
|
||||
fileInfo, ok := lotsList[lotsType]
|
||||
if !ok {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("才...才没有", lotsType, "签这种东西啦")))
|
||||
return
|
||||
}
|
||||
if fileInfo.lotsType == "folder" {
|
||||
picPath, err := randFile(lotsType, 3)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("file:///"+picPath))
|
||||
return
|
||||
}
|
||||
lotsImg, err := randGif(lotsType + "." + fileInfo.lotsType)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 生成图片
|
||||
data, err := imgfactory.ToBytes(lotsImg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.ImageBytes(data))
|
||||
})
|
||||
en.OnRegex(`^看(.+)签$`, zero.UserOrGrpAdmin).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.Event.MessageID
|
||||
lotsName := ctx.State["regex_matched"].([]string)[1]
|
||||
fileInfo, ok := lotsList[lotsName]
|
||||
if !ok {
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦")))
|
||||
return
|
||||
}
|
||||
if fileInfo.lotsType == "folder" {
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("只能查看gif签哦~")))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Image("file:///"+datapath+lotsName+"."+fileInfo.lotsType)))
|
||||
})
|
||||
en.OnRegex(`^加(.+)签.*`, zero.SuperUserPermission, zero.MustProvidePicture).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.Event.MessageID
|
||||
lotsName := ctx.State["regex_matched"].([]string)[1]
|
||||
if lotsName == "" {
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("请使用正确的指令形式哦~")))
|
||||
return
|
||||
}
|
||||
picURL := ctx.State["image_url"].([]string)[0]
|
||||
gifdata, err := web.GetData(picURL)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
im, err := gif.DecodeAll(bytes.NewReader(gifdata))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
fileName := datapath + "/" + lotsName + ".gif"
|
||||
err = file.DownloadTo(picURL, fileName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
lotsList[lotsName] = info{
|
||||
lotsType: "gif",
|
||||
quantity: len(im.Image),
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("成功!")))
|
||||
})
|
||||
en.OnRegex(`^删(.+)签$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.Event.MessageID
|
||||
lotsName := ctx.State["regex_matched"].([]string)[1]
|
||||
fileInfo, ok := lotsList[lotsName]
|
||||
if !ok {
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦")))
|
||||
return
|
||||
}
|
||||
if fileInfo.lotsType == "folder" {
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("为了防止误删图源,图包请手动移除哦~")))
|
||||
return
|
||||
}
|
||||
err := os.Remove(datapath + lotsName + "." + fileInfo.lotsType)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
delete(lotsList, lotsName)
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("成功!")))
|
||||
})
|
||||
}
|
||||
|
||||
func getList() (list map[string]info, err error) {
|
||||
list = make(map[string]info, 100)
|
||||
files, err := os.ReadDir(datapath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(files) == 0 {
|
||||
err = errors.New("什么签也没有哦~")
|
||||
return
|
||||
}
|
||||
for _, lots := range files {
|
||||
if lots.IsDir() {
|
||||
files, _ := os.ReadDir(datapath + "/" + lots.Name())
|
||||
list[lots.Name()] = info{
|
||||
lotsType: "folder",
|
||||
quantity: len(files),
|
||||
}
|
||||
continue
|
||||
}
|
||||
before, after, ok := strings.Cut(lots.Name(), ".")
|
||||
if !ok || before == "" {
|
||||
continue
|
||||
}
|
||||
file, err := os.Open(datapath + "/" + lots.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
im, err := gif.DecodeAll(file)
|
||||
_ = file.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list[before] = info{
|
||||
lotsType: after,
|
||||
quantity: len(im.Image),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func randFile(path string, indexMax int) (string, error) {
|
||||
picPath := datapath + path
|
||||
files, err := os.ReadDir(picPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(files) > 0 {
|
||||
drawFile := files[rand.Intn(len(files))]
|
||||
// 如果是文件夹就递归
|
||||
if drawFile.IsDir() {
|
||||
indexMax--
|
||||
if indexMax <= 0 {
|
||||
return "", errors.New("图包[" + path + "]存在太多非图片文件,请清理~")
|
||||
}
|
||||
return randFile(path, indexMax)
|
||||
}
|
||||
return picPath + "/" + drawFile.Name(), err
|
||||
}
|
||||
return "", errors.New("图包[" + path + "]不存在签内容!")
|
||||
}
|
||||
|
||||
func randGif(gifName string) (image.Image, error) {
|
||||
name := datapath + gifName
|
||||
file, err := os.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
im, err := gif.DecodeAll(file)
|
||||
_ = file.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
/*
|
||||
firstImg, err := imgfactory.Load(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v := im.Image[rand.Intn(len(im.Image))]
|
||||
return imgfactory.Size(firstImg, firstImg.Bounds().Dx(), firstImg.Bounds().Dy()).InsertUpC(v, 0, 0, firstImg.Bounds().Dx()/2, firstImg.Bounds().Dy()/2).Clone().Image(),err
|
||||
/*/
|
||||
// 如果gif图片出现信息缺失请使用上面注释掉的代码,把下面注释了(上面代码部分图存在bug)
|
||||
v := im.Image[rand.Intn(len(im.Image))]
|
||||
return imgfactory.NewFactoryBG(v.Rect.Dx(), v.Rect.Dy(), color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err
|
||||
// */
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func init() {
|
||||
PrivateDataFolder: "driftbottle",
|
||||
})
|
||||
seaSide.DBPath = en.DataFolder() + "sea.db"
|
||||
err := seaSide.Open(time.Hour * 24)
|
||||
err := seaSide.Open(time.Hour)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ func init() {
|
||||
userid := ctx.Event.UserID
|
||||
username := ctx.CardOrNickName(userid)
|
||||
data := (storage)(c.GetData(-su))
|
||||
groupname := ctx.GetThisGroupInfo(true).Name
|
||||
groupid := ctx.Event.GroupID
|
||||
groupname := ctx.GetGroupInfo(groupid, true).Name
|
||||
logrus.Info("[event]收到来自[", username, "](", userid, ")的群聊邀请,群:[", groupname, "](", groupid, ")")
|
||||
if data.isinviteon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "")
|
||||
|
||||
@@ -2,7 +2,17 @@
|
||||
package font
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/gif"
|
||||
"math/rand"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -15,10 +25,10 @@ func init() {
|
||||
control.Register("font", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "渲染任意文字到图片",
|
||||
Help: "- (用[字体])渲染文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]",
|
||||
}).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
Help: "- (用[字体])渲染(抖动)文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|粗苹方体|未来荧黑体|Gugi体|八丸体|Impact体|猫啃体|苹方体]",
|
||||
}).OnRegex(`^(用.+)?渲染(抖动)?文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
fnt := ctx.State["regex_matched"].([]string)[1]
|
||||
txt := ctx.State["regex_matched"].([]string)[2]
|
||||
txt := ctx.State["regex_matched"].([]string)[3]
|
||||
switch fnt {
|
||||
case "用终末体":
|
||||
fnt = text.SyumatuFontFile
|
||||
@@ -30,16 +40,73 @@ func init() {
|
||||
fnt = text.SakuraFontFile
|
||||
case "用Consolas体":
|
||||
fnt = text.ConsolasFontFile
|
||||
case "用粗苹方体":
|
||||
fnt = text.BoldFontFile
|
||||
case "用未来荧黑体":
|
||||
fnt = text.GlowSansFontFile
|
||||
case "用Gugi体":
|
||||
fnt = text.GugiRegularFontFile
|
||||
case "用八丸体":
|
||||
fnt = text.HachiMaruPopRegularFontFile
|
||||
case "用Impact体":
|
||||
fnt = text.ImpactFontFile
|
||||
case "用猫啃体":
|
||||
fnt = text.MaokenFontFile
|
||||
case "用苹方体":
|
||||
fallthrough
|
||||
default:
|
||||
fnt = text.FontFile
|
||||
}
|
||||
b, err := text.RenderToBase64(txt, fnt, 400, 20)
|
||||
if ctx.State["regex_matched"].([]string)[2] == "" {
|
||||
b, err := text.RenderToBase64(txt, fnt, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
|
||||
return
|
||||
}
|
||||
nilx, nily := 1.0, 8.0
|
||||
s := []*image.NRGBA{}
|
||||
strlist := strings.Split(txt, "\n")
|
||||
data, err := file.GetLazyData(fnt, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
|
||||
// 获得画布预计
|
||||
testcov := gg.NewContext(1, 1)
|
||||
if err = testcov.ParseFontFace(data, 30); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 取最长段
|
||||
txt = ""
|
||||
for _, v := range strlist {
|
||||
if len([]rune(v)) > len([]rune(txt)) {
|
||||
txt = v
|
||||
}
|
||||
}
|
||||
w, h := testcov.MeasureString(txt)
|
||||
for i := 0; i < 10; i++ {
|
||||
cov := gg.NewContext(int(w+float64(len([]rune(txt)))*nilx)+40, int(h+nily)*len(strlist)+30)
|
||||
cov.SetRGB(1, 1, 1)
|
||||
cov.Clear()
|
||||
if err = cov.ParseFontFace(data, 30); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
cov.SetColor(color.NRGBA{R: 0, G: 0, B: 0, A: 127})
|
||||
for k, v := range strlist {
|
||||
for kk, vv := range []rune(v) {
|
||||
x, y := cov.MeasureString(string([]rune(v)[:kk]))
|
||||
cov.DrawString(string(vv), x+float64(rand.Intn(5))+10+nilx, y+float64(rand.Intn(5))+15+float64(k)*(y+nily))
|
||||
}
|
||||
}
|
||||
s = append(s, imgfactory.Size(cov.Image(), 0, 0).Image())
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
_ = gif.EncodeAll(&buf, imgfactory.MergeGif(5, s))
|
||||
ctx.SendChain(message.ImageBytes(buf.Bytes()))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ var (
|
||||
index = make(map[string]uint8)
|
||||
// 签文
|
||||
omikujis []map[string]string
|
||||
fontdata []byte
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -98,12 +99,13 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
fontdata, err := file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
if fontdata == nil {
|
||||
fontdata, err = file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
ctx.State["fontdata"] = fontdata
|
||||
return true
|
||||
},
|
||||
)).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
@@ -149,7 +151,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = draw(background, ctx.State["fontdata"].([]byte), title, text, f)
|
||||
_, err = draw(background, fontdata, title, text, f)
|
||||
_ = f.Close()
|
||||
return err
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
|
||||
@@ -38,7 +38,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -19,7 +19,7 @@ func mo(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "摸.gif"
|
||||
// name := cc.usrdir + "摸.gif"
|
||||
c := dlrange("mo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -44,7 +44,8 @@ func mo(cc *context, value ...string) (string, error) {
|
||||
imgs[3].InsertBottom(tou, 85, 75, 27, 37).Image(),
|
||||
imgs[4].InsertBottom(tou, 90, 70, 22, 42).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, mo))
|
||||
g := imgfactory.MergeGif(1, mo)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// cuo 搓
|
||||
@@ -53,7 +54,7 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "搓.gif"
|
||||
// name := cc.usrdir + "搓.gif"
|
||||
c := dlrange("cuo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -82,7 +83,8 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
imgs[3].InsertBottomC(m3.Image(), 0, 0, 75, 130).Image(),
|
||||
imgs[4].InsertBottomC(m4.Image(), 0, 0, 75, 130).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(5, cuo))
|
||||
g := imgfactory.MergeGif(5, cuo)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// qiao 敲
|
||||
@@ -91,7 +93,7 @@ func qiao(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "敲.gif"
|
||||
// name := cc.usrdir + "敲.gif"
|
||||
c := dlrange("qiao", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -113,7 +115,8 @@ func qiao(cc *context, value ...string) (string, error) {
|
||||
imgs[0].InsertUp(tou, 40, 33, 57, 52).Image(),
|
||||
imgs[1].InsertUp(tou, 38, 36, 58, 50).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, qiao))
|
||||
g := imgfactory.MergeGif(1, qiao)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// chi 吃
|
||||
@@ -122,7 +125,7 @@ func chi(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "吃.gif"
|
||||
// name := cc.usrdir + "吃.gif"
|
||||
c := dlrange("chi", 3, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -145,7 +148,8 @@ func chi(cc *context, value ...string) (string, error) {
|
||||
imgs[1].InsertBottom(tou, 0, 0, 1, 38).Image(),
|
||||
imgs[2].InsertBottom(tou, 0, 0, 1, 38).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chi))
|
||||
g := imgfactory.MergeGif(1, chi)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// ceng 蹭
|
||||
@@ -154,7 +158,7 @@ func ceng(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "蹭.gif"
|
||||
// name := cc.usrdir + "蹭.gif"
|
||||
c := dlrange("ceng", 6, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -184,7 +188,8 @@ func ceng(cc *context, value ...string) (string, error) {
|
||||
imgs[4].InsertUp(tou, 75, 77, 56, 110).InsertUp(imgfactory.Rotate(tou2, -66, 132, 80).Image(), 0, 0, 78, 40).Image(),
|
||||
imgs[5].InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, ceng))
|
||||
g := imgfactory.MergeGif(8, ceng)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// ken 啃
|
||||
@@ -193,7 +198,7 @@ func ken(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "啃.gif"
|
||||
// name := cc.usrdir + "啃.gif"
|
||||
c := dlrange("ken", 16, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -229,7 +234,8 @@ func ken(cc *context, value ...string) (string, error) {
|
||||
imgs[14].Image(),
|
||||
imgs[15].Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ken))
|
||||
g := imgfactory.MergeGif(7, ken)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// pai 拍
|
||||
@@ -238,7 +244,7 @@ func pai(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "拍.gif"
|
||||
// name := cc.usrdir + "拍.gif"
|
||||
c := dlrange("pai", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -260,7 +266,8 @@ func pai(cc *context, value ...string) (string, error) {
|
||||
imgs[0].InsertUp(tou, 0, 0, 1, 47).Image(),
|
||||
imgs[1].InsertUp(tou, 0, 0, 1, 67).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, pai))
|
||||
g := imgfactory.MergeGif(1, pai)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// xqe 冲
|
||||
@@ -269,7 +276,7 @@ func xqe(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "冲.gif"
|
||||
// name := cc.usrdir + "冲.gif"
|
||||
c := dlrange("xqe", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -291,7 +298,8 @@ func xqe(cc *context, value ...string) (string, error) {
|
||||
imgs[0].InsertUp(tou, 30, 30, 15, 53).Image(),
|
||||
imgs[1].InsertUp(tou, 30, 30, 40, 53).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chong))
|
||||
g := imgfactory.MergeGif(1, chong)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// diu 丢
|
||||
@@ -300,7 +308,7 @@ func diu(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "丢.gif"
|
||||
// name := cc.usrdir + "丢.gif"
|
||||
c := dlrange("diu", 8, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -328,7 +336,8 @@ func diu(cc *context, value ...string) (string, error) {
|
||||
imgs[6].InsertUp(tou, 35, 35, 259, 31).Image(),
|
||||
imgs[7].InsertUp(tou, 175, 175, -50, 220).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, diu))
|
||||
g := imgfactory.MergeGif(7, diu)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// kiss 亲
|
||||
@@ -338,7 +347,7 @@ func kiss(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 13
|
||||
name := cc.usrdir + "Kiss.gif"
|
||||
// name := cc.usrdir + "Kiss.gif"
|
||||
c := dlrange("kiss", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -367,7 +376,8 @@ func kiss(cc *context, value ...string) (string, error) {
|
||||
kiss[i] = imgs[i].InsertUp(tou, 50, 50, userLocs[i][0], userLocs[i][1]).
|
||||
InsertUp(tou2, 40, 40, selfLocs[i][0], selfLocs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, kiss))
|
||||
g := imgfactory.MergeGif(7, kiss)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// garbage 垃圾 垃圾桶
|
||||
@@ -377,7 +387,7 @@ func garbage(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 25
|
||||
name := cc.usrdir + "Garbage.gif"
|
||||
// name := cc.usrdir + "Garbage.gif"
|
||||
c := dlrange("garbage", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -400,7 +410,8 @@ func garbage(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
garbage[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, garbage))
|
||||
g := imgfactory.MergeGif(7, garbage)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// thump 捶
|
||||
@@ -410,7 +421,7 @@ func thump(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 4
|
||||
name := cc.usrdir + "Thump.gif"
|
||||
// name := cc.usrdir + "Thump.gif"
|
||||
c := dlrange("thump", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -433,7 +444,8 @@ func thump(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
thump[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, thump))
|
||||
g := imgfactory.MergeGif(7, thump)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// jiujiu 啾啾
|
||||
@@ -443,7 +455,7 @@ func jiujiu(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 8
|
||||
name := cc.usrdir + "Jiujiu.gif"
|
||||
// name := cc.usrdir + "Jiujiu.gif"
|
||||
c := dlrange("jiujiu", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -465,7 +477,8 @@ func jiujiu(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
jiujiu[i] = imgs[i].InsertBottom(im.Image(), 0, 0, 0, 0).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, jiujiu))
|
||||
g := imgfactory.MergeGif(7, jiujiu)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// knock 2敲
|
||||
@@ -475,7 +488,7 @@ func knock(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 8
|
||||
name := cc.usrdir + "Knock.gif"
|
||||
// name := cc.usrdir + "Knock.gif"
|
||||
c := dlrange("knock", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -498,7 +511,8 @@ func knock(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
knock[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, knock))
|
||||
g := imgfactory.MergeGif(7, knock)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// 听音乐 listenMusic
|
||||
@@ -508,7 +522,7 @@ func listenMusic(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 1
|
||||
name := cc.usrdir + "ListenMusic.gif"
|
||||
// name := cc.usrdir + "ListenMusic.gif"
|
||||
c := dlrange("listen_music", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -530,7 +544,8 @@ func listenMusic(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < 36; i++ {
|
||||
listenmusic[i] = imgs[0].InsertBottomC(imgfactory.Rotate(face, float64(-i*10), 215, 215).Image(), 0, 0, 207, 207).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, listenmusic))
|
||||
g := imgfactory.MergeGif(7, listenmusic)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// loveYou 永远爱你
|
||||
@@ -540,7 +555,7 @@ func loveYou(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 2
|
||||
name := cc.usrdir + "LoveYou.gif"
|
||||
// name := cc.usrdir + "LoveYou.gif"
|
||||
c := dlrange("love_you", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -563,7 +578,8 @@ func loveYou(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
loveyou[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, loveyou))
|
||||
g := imgfactory.MergeGif(7, loveyou)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// pat 2拍
|
||||
@@ -573,7 +589,7 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 10
|
||||
name := cc.usrdir + "Pat.gif"
|
||||
// name := cc.usrdir + "Pat.gif"
|
||||
c := dlrange("pat", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -605,7 +621,8 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < len(pat); i++ {
|
||||
pat[i] = p[seq[i]]
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pat))
|
||||
g := imgfactory.MergeGif(7, pat)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// jackUp 顶
|
||||
@@ -615,7 +632,7 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 23
|
||||
name := cc.usrdir + "JackUp.gif"
|
||||
// name := cc.usrdir + "JackUp.gif"
|
||||
c := dlrange("play", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -648,7 +665,8 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
play = append(play, p[0:8]...)
|
||||
play = append(play, p[12:18]...)
|
||||
play = append(play, p[18:23]...)
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, play))
|
||||
g := imgfactory.MergeGif(7, play)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// pound 捣
|
||||
@@ -658,7 +676,7 @@ func pound(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 8
|
||||
name := cc.usrdir + "Pound.gif"
|
||||
// name := cc.usrdir + "Pound.gif"
|
||||
c := dlrange("pound", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -681,7 +699,8 @@ func pound(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
pound[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pound))
|
||||
g := imgfactory.MergeGif(7, pound)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// punch 打拳
|
||||
@@ -691,7 +710,7 @@ func punch(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 13
|
||||
name := cc.usrdir + "Punch.gif"
|
||||
// name := cc.usrdir + "Punch.gif"
|
||||
c := dlrange("punch", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -714,7 +733,8 @@ func punch(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
punch[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]-15).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, punch))
|
||||
g := imgfactory.MergeGif(7, punch)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// roll 滚
|
||||
@@ -724,7 +744,7 @@ func roll(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 8
|
||||
name := cc.usrdir + "roll.gif"
|
||||
// name := cc.usrdir + "roll.gif"
|
||||
c := dlrange("roll", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -747,7 +767,8 @@ func roll(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
roll[i] = imgs[i].InsertBottomC(imgfactory.Rotate(im.Image(), float64(locs[i][2]), 0, 0).Image(), 0, 0, locs[i][0]+105, locs[i][1]+105).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, roll))
|
||||
g := imgfactory.MergeGif(7, roll)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// suck 吸 嗦
|
||||
@@ -757,7 +778,7 @@ func suck(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 12
|
||||
name := cc.usrdir + "Suck.gif"
|
||||
// name := cc.usrdir + "Suck.gif"
|
||||
c := dlrange("suck", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -780,7 +801,8 @@ func suck(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
suck[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, suck))
|
||||
g := imgfactory.MergeGif(7, suck)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// hammer 锤
|
||||
@@ -790,7 +812,7 @@ func hammer(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 7
|
||||
name := cc.usrdir + "Hammer.gif"
|
||||
// name := cc.usrdir + "Hammer.gif"
|
||||
c := dlrange("hammer", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -813,7 +835,8 @@ func hammer(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
hammer[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, hammer))
|
||||
g := imgfactory.MergeGif(7, hammer)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// tightly 紧贴 紧紧贴着
|
||||
@@ -823,7 +846,7 @@ func tightly(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 20
|
||||
name := cc.usrdir + "Tightly.gif"
|
||||
// name := cc.usrdir + "Tightly.gif"
|
||||
c := dlrange("tightly", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -846,13 +869,14 @@ func tightly(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
tightly[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tightly))
|
||||
g := imgfactory.MergeGif(7, tightly)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// turn 转
|
||||
func turn(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
name := cc.usrdir + "Turn.gif"
|
||||
// name := cc.usrdir + "Turn.gif"
|
||||
face, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -865,7 +889,8 @@ func turn(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < 36; i++ {
|
||||
turn[i] = imgfactory.Size(canvas.Image(), 0, 0).InsertUpC(imgfactory.Rotate(face, float64(10*i), 250, 250).Image(), 0, 0, 125, 125).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, turn))
|
||||
g := imgfactory.MergeGif(7, turn)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// taiguan 抬棺
|
||||
@@ -874,7 +899,7 @@ func taiguan(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "taiguan.gif"
|
||||
// name := cc.usrdir + "taiguan.gif"
|
||||
c := dlrange("taiguan", 20, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -914,7 +939,8 @@ func taiguan(cc *context, value ...string) (string, error) {
|
||||
imgs[18].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[19].InsertUp(tou, 85, 85, 175, 65).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, taiguan))
|
||||
g := imgfactory.MergeGif(7, taiguan)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// zou 揍
|
||||
@@ -923,7 +949,7 @@ func zou(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "zou.gif"
|
||||
// name := cc.usrdir + "zou.gif"
|
||||
c := dlrange("zou", 3, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -950,7 +976,8 @@ func zou(cc *context, value ...string) (string, error) {
|
||||
imgs[1].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 101, 45).Image(),
|
||||
imgs[2].InsertUp(tou, 40, 40, 89, 140).InsertUp(tou2, 55, 55, 99, 40).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, zou))
|
||||
g := imgfactory.MergeGif(8, zou)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// ci 吞
|
||||
@@ -959,7 +986,7 @@ func ci(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "ci.gif"
|
||||
// name := cc.usrdir + "ci.gif"
|
||||
c := dlrange("ci", 26, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1005,7 +1032,8 @@ func ci(cc *context, value ...string) (string, error) {
|
||||
imgs[24].Image(),
|
||||
imgs[25].Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ci))
|
||||
g := imgfactory.MergeGif(7, ci)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// worship 膜拜
|
||||
@@ -1014,7 +1042,7 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "worship.gif"
|
||||
// name := cc.usrdir + "worship.gif"
|
||||
c := dlrange("worship", 9, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -1043,7 +1071,8 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
imgs[7].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[8].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, worship))
|
||||
g := imgfactory.MergeGif(7, worship)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// 2ceng 2蹭
|
||||
@@ -1052,7 +1081,7 @@ func ceng2(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "ceng2.gif"
|
||||
// name := cc.usrdir + "ceng2.gif"
|
||||
c := dlrange("ceng2", 4, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1076,7 +1105,8 @@ func ceng2(cc *context, value ...string) (string, error) {
|
||||
imgs[2].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
imgs[3].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ceng2))
|
||||
g := imgfactory.MergeGif(7, ceng2)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// dun 炖
|
||||
@@ -1085,7 +1115,7 @@ func dun(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "dun.gif"
|
||||
// name := cc.usrdir + "dun.gif"
|
||||
c := dlrange("dun", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1110,7 +1140,8 @@ func dun(cc *context, value ...string) (string, error) {
|
||||
imgs[3].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
imgs[4].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, dun))
|
||||
g := imgfactory.MergeGif(7, dun)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// push 滚高清重置版 过渡
|
||||
@@ -1120,7 +1151,7 @@ func push(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 16
|
||||
name := cc.usrdir + "push.gif"
|
||||
// name := cc.usrdir + "push.gif"
|
||||
c := dlrange("push", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -1142,7 +1173,8 @@ func push(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
push[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-22*i), 280, 280).Image(), 0, 0, 523, 291).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, push))
|
||||
g := imgfactory.MergeGif(7, push)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// peng 砰
|
||||
@@ -1151,7 +1183,7 @@ func peng(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "peng.gif"
|
||||
// name := cc.usrdir + "peng.gif"
|
||||
c := dlrange("peng", 25, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1200,7 +1232,8 @@ func peng(cc *context, value ...string) (string, error) {
|
||||
imgs[23].InsertUp(m4.Image(), 0, 0, 89, 159).Image(),
|
||||
imgs[24].InsertUp(m4.Image(), 0, 0, 86, 160).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, peng))
|
||||
g := imgfactory.MergeGif(8, peng)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// klee 可莉吃
|
||||
@@ -1210,7 +1243,7 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 31
|
||||
name := cc.usrdir + "klee.gif"
|
||||
// name := cc.usrdir + "klee.gif"
|
||||
c := dlrange("klee", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -1233,7 +1266,8 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
klee[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, klee))
|
||||
g := imgfactory.MergeGif(7, klee)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// hutaoken 胡桃啃
|
||||
@@ -1242,7 +1276,7 @@ func hutaoken(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "hutaoken.gif"
|
||||
// name := cc.usrdir + "hutaoken.gif"
|
||||
c := dlrange("hutaoken", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1264,7 +1298,8 @@ func hutaoken(cc *context, value ...string) (string, error) {
|
||||
imgs[0].InsertBottom(tou, 98, 101, 108, 234).Image(),
|
||||
imgs[1].InsertBottom(tou, 96, 100, 108, 237).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, hutaoken))
|
||||
g := imgfactory.MergeGif(8, hutaoken)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// lick 2舔
|
||||
@@ -1273,7 +1308,7 @@ func lick(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "lick.gif"
|
||||
// name := cc.usrdir + "lick.gif"
|
||||
c := dlrange("lick", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1295,7 +1330,8 @@ func lick(cc *context, value ...string) (string, error) {
|
||||
imgs[0].InsertUp(tou, 44, 44, 10, 138).Image(),
|
||||
imgs[1].InsertUp(tou, 44, 44, 10, 138).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, lick))
|
||||
g := imgfactory.MergeGif(8, lick)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// tiqiu 踢球
|
||||
@@ -1305,7 +1341,7 @@ func tiqiu(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 15
|
||||
name := cc.usrdir + "tiqiu.gif"
|
||||
// name := cc.usrdir + "tiqiu.gif"
|
||||
c := dlrange("tiqiu", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -1328,7 +1364,8 @@ func tiqiu(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
tiqiu[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 0, 0).Image(), 0, 0, locs[i][0]+38, locs[i][1]+38).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tiqiu))
|
||||
g := imgfactory.MergeGif(7, tiqiu)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// cai 踩
|
||||
@@ -1337,7 +1374,7 @@ func cai(cc *context, value ...string) (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "cai.gif"
|
||||
// name := cc.usrdir + "cai.gif"
|
||||
c := dlrange("cai", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
errwg = e
|
||||
@@ -1363,7 +1400,8 @@ func cai(cc *context, value ...string) (string, error) {
|
||||
imgs[3].InsertBottom(tou, 85, 76, 52, 203).Image(),
|
||||
imgs[4].InsertBottom(tou, 88, 82, 49, 198).Image(),
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, cai))
|
||||
g := imgfactory.MergeGif(7, cai)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// whir 2转
|
||||
@@ -1373,7 +1411,7 @@ func whirl(cc *context, value ...string) (string, error) {
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
piclen := 15
|
||||
name := cc.usrdir + "whirl.gif"
|
||||
// name := cc.usrdir + "whirl.gif"
|
||||
c := dlrange("whirl", piclen, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
@@ -1395,7 +1433,8 @@ func whirl(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < piclen; i++ {
|
||||
whirl[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 145, 145).Image(), 0, 0, 115, 89).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, whirl))
|
||||
g := imgfactory.MergeGif(7, whirl)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
// always 一直
|
||||
@@ -1403,8 +1442,8 @@ func alwaysDoGif(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var err error
|
||||
var face []*imgfactory.Factory
|
||||
name := cc.usrdir + "AlwaysDo.gif"
|
||||
face, err = imgfactory.LoadAllFrames(cc.headimgsdir[0], 500, 500)
|
||||
// name := cc.usrdir + "AlwaysDo.gif"
|
||||
face, err = imgfactory.LoadAllTrueFrames(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
// 载入失败尝试载入第一帧
|
||||
face = nil
|
||||
@@ -1438,11 +1477,12 @@ func alwaysDoGif(cc *context, value ...string) (string, error) {
|
||||
canvas := gg.NewContext(500, 600)
|
||||
canvas.DrawImage(f.Image(), 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
// _ = canvas.ParseFontFace(data, 40)
|
||||
_ = canvas.ParseFontFace(data, 40)
|
||||
canvas.DrawString(arg, 280-l, 560)
|
||||
canvas.DrawImage(imgfactory.Size(f.Image(), 90, 90).Image(), 280, 505)
|
||||
canvas.DrawString("吗", 370, 560)
|
||||
turn[i] = imgfactory.Size(canvas.Image(), 0, 0).Image()
|
||||
}
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, turn))
|
||||
g := imgfactory.MergeGif(8, turn)
|
||||
return imgfactory.GIF2Base64(g)
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ func getlist(pathOfMusic string) (list []listinfo, err error) {
|
||||
|
||||
// 遍历群文件
|
||||
func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileURL string) {
|
||||
filesOfGroup := ctx.GetThisGroupRootFiles(ctx.Event.GroupID)
|
||||
filesOfGroup := ctx.GetThisGroupRootFiles()
|
||||
files := filesOfGroup.Get("files").Array()
|
||||
folders := filesOfGroup.Get("folders").Array()
|
||||
// 遍历当前目录的文件名
|
||||
|
||||
174
plugin/hitokoto/hitokoto.go
Normal file
174
plugin/hitokoto/hitokoto.go
Normal file
@@ -0,0 +1,174 @@
|
||||
// Package hitokoto 一言
|
||||
package hitokoto
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("hitokoto", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "一言",
|
||||
Help: "- 一言[xxx]\n" +
|
||||
"- 系列一言",
|
||||
PublicDataFolder: "Hitokoto",
|
||||
})
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbfile := engine.DataFolder() + "hitokoto.db"
|
||||
_, err := engine.GetLazyData("hitokoto.db", false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
hdb, err = initialize(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
engine.OnPrefix(`一言`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
args := ctx.State["args"].(string)
|
||||
blist, err := hdb.getByKey(strings.TrimSpace(args))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(blist) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: hitokoto empty"))
|
||||
return
|
||||
}
|
||||
m := make(message.Message, 0, 10)
|
||||
text := strings.Builder{}
|
||||
if len(blist) <= 10 {
|
||||
for _, b := range blist {
|
||||
text.WriteString(b.Hitokoto)
|
||||
text.WriteString("\n——")
|
||||
text.WriteString(b.From)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
|
||||
text.Reset()
|
||||
}
|
||||
} else {
|
||||
indexes := map[int]struct{}{}
|
||||
for i := 0; i < 10; i++ {
|
||||
ind := rand.Intn(len(blist))
|
||||
if _, ok := indexes[ind]; ok {
|
||||
i--
|
||||
continue
|
||||
}
|
||||
indexes[ind] = struct{}{}
|
||||
}
|
||||
for k := range indexes {
|
||||
b := blist[k]
|
||||
text.WriteString(b.Hitokoto)
|
||||
text.WriteString("\n——")
|
||||
text.WriteString(b.From)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
|
||||
text.Reset()
|
||||
}
|
||||
}
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch(`系列一言`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
results, err := hdb.getAllCategory()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tex := strings.Builder{}
|
||||
tex.WriteString("请输入系列一言序号\n")
|
||||
for i, v := range results {
|
||||
tex.WriteString(strconv.Itoa(i))
|
||||
tex.WriteString(". ")
|
||||
tex.WriteString(v.Category)
|
||||
tex.WriteString("\n")
|
||||
}
|
||||
base64Str, err := text.RenderToBase64(tex.String(), text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(base64Str)))
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Text("系列一言指令过期"))
|
||||
return
|
||||
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 >= len(results) {
|
||||
ctx.SendChain(message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
ctx.SendChain(message.Text("请欣赏系列一言: ", results[num].Category))
|
||||
hlist, err := hdb.getByCategory(results[num].Category)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(hlist) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: hitokoto empty"))
|
||||
return
|
||||
}
|
||||
m := make(message.Message, 0, 10)
|
||||
text := strings.Builder{}
|
||||
if len(hlist) <= 10 {
|
||||
for _, b := range hlist {
|
||||
text.WriteString(b.Hitokoto)
|
||||
text.WriteString("\n——")
|
||||
text.WriteString(b.From)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
|
||||
text.Reset()
|
||||
}
|
||||
} else {
|
||||
indexes := map[int]struct{}{}
|
||||
for i := 0; i < 10; i++ {
|
||||
ind := rand.Intn(len(hlist))
|
||||
if _, ok := indexes[ind]; ok {
|
||||
i--
|
||||
continue
|
||||
}
|
||||
indexes[ind] = struct{}{}
|
||||
}
|
||||
for k := range indexes {
|
||||
b := hlist[k]
|
||||
text.WriteString(b.Hitokoto)
|
||||
text.WriteString("\n——")
|
||||
text.WriteString(b.From)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
|
||||
text.Reset()
|
||||
}
|
||||
}
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
73
plugin/hitokoto/model.go
Normal file
73
plugin/hitokoto/model.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package hitokoto
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// hdb 表情包数据库全局变量
|
||||
var hdb *hitokotodb
|
||||
|
||||
// hitokotodb 表情包数据库
|
||||
type hitokotodb gorm.DB
|
||||
|
||||
// initialize 初始化
|
||||
func initialize(dbpath string) (db *hitokotodb, err error) {
|
||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
// 生成文件
|
||||
f, err := os.Create(dbpath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = f.Close()
|
||||
}
|
||||
gdb, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
gdb.AutoMigrate(&hitokoto{})
|
||||
return (*hitokotodb)(gdb), nil
|
||||
}
|
||||
|
||||
type hitokoto struct {
|
||||
ID int `json:"id" gorm:"column:id;primary_key"`
|
||||
Hitokoto string `json:"hitokoto" gorm:"column:hitokoto"`
|
||||
Type string `json:"type" gorm:"column:type"`
|
||||
From string `json:"from" gorm:"column:from"`
|
||||
FromWho string `json:"from_who" gorm:"column:from_who"`
|
||||
Creator string `json:"creator" gorm:"column:creator"`
|
||||
CreatorUID int `json:"creator_uid" gorm:"column:creator_uid"`
|
||||
Reviewer int `json:"reviewer" gorm:"column:reviewer"`
|
||||
UUID string `json:"uuid" gorm:"column:uuid"`
|
||||
CreatedAt string `json:"created_at" gorm:"column:created_at"`
|
||||
Category string `json:"catogory" gorm:"column:category"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (hitokoto) TableName() string {
|
||||
return "hitokoto"
|
||||
}
|
||||
|
||||
func (hdb *hitokotodb) getByKey(key string) (b []hitokoto, err error) {
|
||||
db := (*gorm.DB)(hdb)
|
||||
err = db.Where("hitokoto like ?", "%"+key+"%").Find(&b).Error
|
||||
return
|
||||
}
|
||||
|
||||
type result struct {
|
||||
Category string
|
||||
Count int
|
||||
}
|
||||
|
||||
func (hdb *hitokotodb) getAllCategory() (results []result, err error) {
|
||||
db := (*gorm.DB)(hdb)
|
||||
err = db.Table("hitokoto").Select("category, count(1) as count").Group("category").Scan(&results).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (hdb *hitokotodb) getByCategory(category string) (h []hitokoto, err error) {
|
||||
db := (*gorm.DB)(hdb)
|
||||
err = db.Where("category = ?", category).Find(&h).Error
|
||||
return
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func init() {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "pics.db"
|
||||
_, _ = engine.GetLazyData("pics.db", false)
|
||||
err := db.Open(time.Hour * 24)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址
|
||||
jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址
|
||||
jiami1 = "http://ovooa.caonm.net/API/sho_u/?msg=%v" // 加密api地址
|
||||
jiami2 = "http://ovooa.caonm.net/API/sho_u/?format=1&msg=%v" // 解密api地址
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// Package jikipedia 小鸡词典
|
||||
// 修改自https://github.com/TeamPGM/PagerMaid_Plugins_Pyro ,非常感谢!!
|
||||
package jikipedia
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
url = "https://api.jikipedia.com/go/search_entities"
|
||||
)
|
||||
|
||||
type value struct {
|
||||
Phrase string `json:"phrase"`
|
||||
Page int `json:"page"`
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 初始化engine
|
||||
engine := control.Register("jikipedia", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "小鸡词典",
|
||||
Help: "- [查梗|小鸡词典][梗]",
|
||||
},
|
||||
)
|
||||
engine.OnPrefixGroup([]string{"小鸡词典", "查梗"}).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
keyWord := strings.Trim(ctx.State["args"].(string), " ")
|
||||
|
||||
definition, err := parseKeyword(keyWord)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if definition.String() == "" {
|
||||
ctx.SendChain(message.Text("好像什么都没查到,换个关键词试一试?"))
|
||||
return
|
||||
}
|
||||
imgURL := definition.Get("images.0.scaled.path").String()
|
||||
ctx.SendChain(message.Text("【标题】:", definition.Get("term.title"),
|
||||
"\n【释义】:", definition.Get("plaintext"),
|
||||
"\n【原文】:https://jikipedia.com/definition/", definition.Get("id")),
|
||||
message.Image(imgURL))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func parseKeyword(keyWord string) (definition gjson.Result, err error) {
|
||||
client := &http.Client{}
|
||||
|
||||
values := value{Phrase: keyWord, Page: 1, Size: 10}
|
||||
jsonData, err := json.Marshal(values)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var request *http.Request
|
||||
request, err = http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
request.Header = http.Header{
|
||||
"Accept": {"application/json, text/plain, */*"},
|
||||
"Accept-Encoding": {"gzip, deflate, br"},
|
||||
"Accept-Language": {"zh-CN,zh-TW;q=0.9,zh;q=0.8"},
|
||||
"Client": {"web"},
|
||||
"Client-Version": {"2.7.2g"},
|
||||
"Connection": {"keep-alive"},
|
||||
"Host": {"api.jikipedia.com"},
|
||||
"Origin": {"https://jikipedia.com"},
|
||||
"Referer": {"https://jikipedia.com/"},
|
||||
"Sec-Fetch-Dest": {"empty"},
|
||||
"Sec-Fetch-Mode": {"cors"},
|
||||
"Sec-Fetch-Site": {"same-site"},
|
||||
"Token": {""},
|
||||
"User-Agent": {"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Mobile Safari/537.36"},
|
||||
"XID": {"uNo5bL1nyNCp/Gm7lJAHQ91220HLbMT8jqk9IJYhtHA4ofP+zgxwM6lSDIKiYoppP2k1IW/1Vxc2vOVGxOOVReebsLmWPHhTs7NCRygfDkE="},
|
||||
"sec-ch-ua": {`" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"`},
|
||||
"sec-ch-ua-mobile": {"?1"},
|
||||
"sec-ch-ua-platform": {`"Android"`},
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
var response *http.Response
|
||||
response, err = client.Do(request)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
extraInfo := ""
|
||||
if response.StatusCode == 423 {
|
||||
extraInfo = "\n调用过多被网站暂时封禁,请等待数个小时后使用该功能~"
|
||||
}
|
||||
s := fmt.Sprintf("status code: %d%s", response.StatusCode, extraInfo)
|
||||
err = errors.New(s)
|
||||
return
|
||||
}
|
||||
data, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
gjson.Get(binary.BytesToString(data), "data").ForEach(func(key, value gjson.Result) bool {
|
||||
definition = value.Get("definitions.0")
|
||||
return definition.String() == ""
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
31
plugin/kfccrazythursday/kfccrazythursday.go
Normal file
31
plugin/kfccrazythursday/kfccrazythursday.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Package kfccrazythursday 疯狂星期四
|
||||
package kfccrazythursday
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
crazyURL = "https://www.iculture.cc/demo/CrazyThursday/api/kfc.php"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("kfccrazythursday", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "疯狂星期四",
|
||||
Help: "疯狂星期四\n",
|
||||
})
|
||||
engine.OnFullMatch("疯狂星期四").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(crazyURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.ParseBytes(data).Get("@this.0.content").String()))
|
||||
})
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func init() { // 插件主体
|
||||
|
||||
go func() {
|
||||
db.DBPath = engine.DataFolder() + "config.db"
|
||||
err := db.Open(time.Hour * 24)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -95,13 +95,11 @@ func init() { // 插件主体
|
||||
// 升为管理
|
||||
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupAdmin(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupAdmin(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
|
||||
true,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被升为管理的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被升为管理的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -110,13 +108,11 @@ func init() { // 插件主体
|
||||
// 取消管理
|
||||
engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupAdmin(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupAdmin(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
|
||||
false,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被取消管理的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被取消管理的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -125,13 +121,11 @@ func init() { // 插件主体
|
||||
// 踢出群聊
|
||||
engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupKick(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupKick(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
|
||||
false,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被踢出群聊的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被踢出群聊的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -148,19 +142,13 @@ func init() { // 插件主体
|
||||
// 开启全体禁言
|
||||
engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupWholeBan(
|
||||
ctx.Event.GroupID,
|
||||
true,
|
||||
)
|
||||
ctx.SetThisGroupWholeBan(true)
|
||||
ctx.SendChain(message.Text("全员自闭开始~"))
|
||||
})
|
||||
// 解除全员禁言
|
||||
engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupWholeBan(
|
||||
ctx.Event.GroupID,
|
||||
false,
|
||||
)
|
||||
ctx.SetThisGroupWholeBan(false)
|
||||
ctx.SendChain(message.Text("全员自闭结束~"))
|
||||
})
|
||||
// 禁言
|
||||
@@ -180,8 +168,7 @@ func init() { // 插件主体
|
||||
if duration >= 43200 {
|
||||
duration = 43199 // qq禁言最大时长为一个月
|
||||
}
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq
|
||||
duration*60, // 要禁言的时间(分钟)
|
||||
)
|
||||
@@ -190,8 +177,7 @@ func init() { // 插件主体
|
||||
// 解除禁言
|
||||
engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq
|
||||
0,
|
||||
)
|
||||
@@ -214,8 +200,7 @@ func init() { // 插件主体
|
||||
if duration >= 43200 {
|
||||
duration = 43199 // qq禁言最大时长为一个月
|
||||
}
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
ctx.Event.UserID,
|
||||
duration*60, // 要自闭的时间(分钟)
|
||||
)
|
||||
@@ -228,8 +213,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("名字太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupCard(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupCard(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人
|
||||
ctx.State["regex_matched"].([]string)[2], // 修改成的群名片
|
||||
)
|
||||
@@ -246,8 +230,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupSpecialTitle(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人
|
||||
sptitle, // 修改成的群头衔
|
||||
)
|
||||
@@ -264,8 +247,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupSpecialTitle(
|
||||
ctx.Event.UserID, // 被修改群头衔的人
|
||||
sptitle, // 修改成的群头衔
|
||||
)
|
||||
@@ -445,7 +427,7 @@ func init() { // 插件主体
|
||||
case <-time.After(time.Minute):
|
||||
cancel()
|
||||
ctx.SendChain(message.Text("拜拜啦~"))
|
||||
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
|
||||
ctx.SetThisGroupKick(uid, false)
|
||||
case <-recv:
|
||||
cancel()
|
||||
ctx.SendChain(message.Text("答对啦~"))
|
||||
@@ -594,7 +576,7 @@ func init() { // 插件主体
|
||||
if ok {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", true, "")
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SetGroupCard(ctx.Event.GroupID, ctx.Event.UserID, ghun)
|
||||
ctx.SetThisGroupCard(ctx.Event.UserID, ghun)
|
||||
} else {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", false, reason)
|
||||
}
|
||||
@@ -618,7 +600,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
engine.OnCommand("精华列表", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
list := ctx.GetGroupEssenceMessageList(ctx.Event.GroupID).Array()
|
||||
list := ctx.GetThisGroupEssenceMessageList().Array()
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("本群精华列表:"))}
|
||||
n := len(list)
|
||||
if n > 30 {
|
||||
@@ -675,7 +657,7 @@ func welcometocq(ctx *zero.Ctx, welcome string) string {
|
||||
at := "[CQ:at,qq=" + uid + "]" // at用户
|
||||
avatar := "[CQ:image,file=" + "http://q4.qlogo.cn/g?b=qq&nk=" + uid + "&s=640]" // 用户头像
|
||||
gid := strconv.FormatInt(ctx.Event.GroupID, 10) // 群id
|
||||
groupname := ctx.GetGroupInfo(ctx.Event.GroupID, true).Name // 群名
|
||||
groupname := ctx.GetThisGroupInfo(true).Name // 群名
|
||||
cqstring := strings.ReplaceAll(welcome, "{at}", at)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar)
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
package moegoe
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tts/genshin"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -16,7 +21,6 @@ import (
|
||||
const (
|
||||
jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d"
|
||||
krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d"
|
||||
cnapi = "https://genshinvoice.top/api?text=%s&speaker=%s&format=wav&length=1&noise=0.6&noisew=0.8"
|
||||
)
|
||||
|
||||
var speakers = map[string]uint{
|
||||
@@ -24,13 +28,15 @@ var speakers = map[string]uint{
|
||||
"Sua": 0, "Mimiru": 1, "Arin": 2, "Yeonhwa": 3, "Yuhwa": 4, "Seonbae": 5,
|
||||
}
|
||||
|
||||
var 原 = newapikeystore("./data/tts/o.txt")
|
||||
|
||||
func init() {
|
||||
en := control.Register("moegoe", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "日韩中 VITS 模型拟声",
|
||||
Help: "- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" +
|
||||
"- 让[派蒙|空|荧|阿贝多|枫原万叶|温迪|八重神子|纳西妲|钟离|诺艾尔|凝光|托马|北斗|莫娜|荒泷一斗|提纳里|芭芭拉|艾尔海森|雷电将军|赛诺|琴|班尼特|五郎|神里绫华|迪希雅|夜兰|辛焱|安柏|宵宫|云堇|妮露|烟绯|鹿野院平藏|凯亚|达达利亚|迪卢克|可莉|早柚|香菱|重云|刻晴|久岐忍|珊瑚宫心海|迪奥娜|戴因斯雷布|魈|神里绫人|丽莎|优菈|凯瑟琳|雷泽|菲谢尔|九条裟罗|甘雨|行秋|胡桃|迪娜泽黛|柯莱|申鹤|砂糖|萍姥姥|奥兹|罗莎莉亚|式大将|哲平|坎蒂丝|托克|留云借风真君|昆钧|塞琉斯|多莉|大肉丸|莱依拉|散兵|拉赫曼|杜拉夫|阿守|玛乔丽|纳比尔|海芭夏|九条镰治|阿娜耶|阿晃|阿扎尔|七七|博士|白术|埃洛伊|大慈树王|女士|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|芽衣|雷之律者|阿波尼亚]说(中文)",
|
||||
"- 让[空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝]说(中文)",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
en.OnRegex("^让(宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海)说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -44,10 +50,23 @@ func init() {
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(krapi, url.QueryEscape(text), id)))
|
||||
})
|
||||
en.OnRegex("^让(派蒙|空|荧|阿贝多|枫原万叶|温迪|八重神子|纳西妲|钟离|诺艾尔|凝光|托马|北斗|莫娜|荒泷一斗|提纳里|芭芭拉|艾尔海森|雷电将军|赛诺|琴|班尼特|五郎|神里绫华|迪希雅|夜兰|辛焱|安柏|宵宫|云堇|妮露|烟绯|鹿野院平藏|凯亚|达达利亚|迪卢克|可莉|早柚|香菱|重云|刻晴|久岐忍|珊瑚宫心海|迪奥娜|戴因斯雷布|魈|神里绫人|丽莎|优菈|凯瑟琳|雷泽|菲谢尔|九条裟罗|甘雨|行秋|胡桃|迪娜泽黛|柯莱|申鹤|砂糖|萍姥姥|奥兹|罗莎莉亚|式大将|哲平|坎蒂丝|托克|留云借风真君|昆钧|塞琉斯|多莉|大肉丸|莱依拉|散兵|拉赫曼|杜拉夫|阿守|玛乔丽|纳比尔|海芭夏|九条镰治|阿娜耶|阿晃|阿扎尔|七七|博士|白术|埃洛伊|大慈树王|女士|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|芽衣|雷之律者|阿波尼亚)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
en.OnRegex("^让(空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if 原.k == "" {
|
||||
return
|
||||
}
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
speaker := ctx.State["regex_matched"].([]string)[1]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), speaker)))
|
||||
name := ctx.State["regex_matched"].([]string)[1]
|
||||
rec := fmt.Sprintf(genshin.CNAPI, url.QueryEscape(name), url.QueryEscape(text), url.QueryEscape(原.k))
|
||||
b := md5.Sum(binary.StringToBytes(rec))
|
||||
fn := hex.EncodeToString(b[:])
|
||||
fp := "data/tts/" + fn
|
||||
if file.IsNotExist(fp) {
|
||||
if file.DownloadTo(rec, fp) != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
rec = "file:///" + file.BOTPATH + "/" + fp
|
||||
ctx.SendChain(message.Record(rec))
|
||||
})
|
||||
}
|
||||
|
||||
24
plugin/moegoe/model.go
Normal file
24
plugin/moegoe/model.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package moegoe
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
)
|
||||
|
||||
type apikeystore struct {
|
||||
k string
|
||||
p string
|
||||
}
|
||||
|
||||
func newapikeystore(p string) (s apikeystore) {
|
||||
s.p = p
|
||||
if file.IsExist(p) {
|
||||
data, err := os.ReadFile(p)
|
||||
if err == nil {
|
||||
s.k = binary.BytesToString(data)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (n *nsetu) scanall(path string) error {
|
||||
root := os.DirFS(path)
|
||||
_ = n.db.Close()
|
||||
_ = os.Remove(n.db.DBPath)
|
||||
err := n.db.Open(time.Hour * 24)
|
||||
err := n.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func init() {
|
||||
logrus.Infoln("[nsetu] set setu dir to", setupath)
|
||||
}
|
||||
}
|
||||
err := ns.db.Open(time.Hour * 24)
|
||||
err := ns.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -42,12 +43,14 @@ const (
|
||||
var (
|
||||
cachePath string
|
||||
// apikey 由账号和密码拼接而成, 例: zerobot,123456
|
||||
apikey string
|
||||
apikey string
|
||||
apikeymu sync.Mutex
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("novel", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Extra: control.ExtraFromString("novel"),
|
||||
Brief: "铅笔小说网搜索",
|
||||
Help: "- 小说[xxx]\n" +
|
||||
"- 设置小说配置 zerobot 123456\n" +
|
||||
@@ -290,16 +293,19 @@ func download(id string, cookie string) (downloadHTML string, err error) {
|
||||
}
|
||||
|
||||
func getAPIKey(ctx *zero.Ctx) string {
|
||||
apikeymu.Lock()
|
||||
defer apikeymu.Unlock()
|
||||
if apikey == "" {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
_ = m.Manager.GetExtra(-1, &apikey)
|
||||
_ = m.GetExtra(&apikey)
|
||||
logrus.Debugln("[novel] get api key:", apikey)
|
||||
}
|
||||
return apikey
|
||||
}
|
||||
|
||||
func setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
|
||||
apikeymu.Lock()
|
||||
defer apikeymu.Unlock()
|
||||
apikey = key
|
||||
_ = m.Manager.Response(-1)
|
||||
return m.Manager.SetExtra(-1, apikey)
|
||||
return m.SetExtra(apikey)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
@@ -82,7 +82,7 @@ var (
|
||||
))
|
||||
getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db"
|
||||
err := 民政局.db.Open(time.Hour * 24)
|
||||
err := 民政局.db.Open(time.Hour)
|
||||
if err == nil {
|
||||
// 创建群配置表
|
||||
err = 民政局.db.Create("updateinfo", &updateinfo{})
|
||||
@@ -302,7 +302,7 @@ func init() {
|
||||
func (sql *婚姻登记) 查看设置(gid int64) (dbinfo updateinfo, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 创建群表哥
|
||||
// 创建群表格
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
return
|
||||
@@ -350,7 +350,7 @@ func (sql *婚姻登记) 查户口(gid, uid int64) (info userinfo, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
// 创建群表哥
|
||||
// 创建群表格
|
||||
err = sql.db.Create(gidstr, &userinfo{})
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package quan
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -11,13 +11,18 @@ import (
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
)
|
||||
|
||||
const (
|
||||
quan = "http://tc.tfkapi.top/API/qqqz.php?qq=%v" // api
|
||||
quan = "http://tfapi.top/API/qqqz.php?type=json&qq=" // api
|
||||
)
|
||||
|
||||
type result struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Qz string `json:"qz"`
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("quan", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
@@ -31,28 +36,25 @@ func init() { // 主函数
|
||||
if str == "" { // user
|
||||
str = strconv.FormatInt(ctx.Event.UserID, 10)
|
||||
}
|
||||
es, err := web.GetData(fmt.Sprintf(quan, str)) // 将网站返回结果赋值
|
||||
es, err := web.GetData(quan + str) // 将网站返回结果赋值
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
ctx.SendChain(message.Text("出现错误捏: ", err))
|
||||
return
|
||||
}
|
||||
if len(helper.BytesToString(es)) <= 24 {
|
||||
ctx.SendChain(message.Text("网站维护中")) // 输出结果
|
||||
return
|
||||
}
|
||||
f := helper.BytesToString(es)[24:]
|
||||
_, err = strconv.Atoi(f)
|
||||
var data result
|
||||
err = json.Unmarshal(es, &data)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("网站维护中")) // 输出结果
|
||||
ctx.SendChain(message.Text("解析json错误: ", err))
|
||||
return
|
||||
}
|
||||
var msg strings.Builder
|
||||
msg.WriteString("查询账号:")
|
||||
msg.WriteString("查询账号: ")
|
||||
msg.WriteString(str)
|
||||
msg.WriteString("\n")
|
||||
msg.WriteString("查询状态:成功\n")
|
||||
msg.WriteString("您的权重为:")
|
||||
msg.WriteString(f)
|
||||
msg.WriteString("查询状态: ")
|
||||
msg.WriteString(data.Msg)
|
||||
msg.WriteString("\n您的权重为: ")
|
||||
msg.WriteString(data.Qz)
|
||||
ctx.SendChain(message.Text(msg.String())) // 输出结果
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var ro = runoob.NewRunOOB("b6365362a90ac2ac7098ba52c13e352b")
|
||||
var ro = runoob.NewRunOOB("066417defb80d038228de76ec581a50a")
|
||||
|
||||
func init() {
|
||||
control.Register("runcode", &ctrl.Options[*zero.Ctx]{
|
||||
@@ -59,7 +59,7 @@ func init() {
|
||||
} else {
|
||||
// 运行成功
|
||||
output = cutTooLong(strings.Trim(output, "\n"))
|
||||
if israw {
|
||||
if israw && zero.AdminPermission(ctx) {
|
||||
ctx.SendChain(message.Text(output))
|
||||
} else {
|
||||
ctx.SendChain(
|
||||
|
||||
@@ -74,15 +74,15 @@ func init() { // 插件主体
|
||||
imgs = append(imgs, message.Image(m.String()))
|
||||
continue
|
||||
}
|
||||
logrus.Debugln("[sausenao]开始下载", n)
|
||||
logrus.Debugln("[sausenao]urls:", illust.ImageUrls)
|
||||
logrus.Debugln("[saucenao]开始下载", n)
|
||||
logrus.Debugln("[saucenao]urls:", illust.ImageUrls)
|
||||
err1 := illust.DownloadToCache(i)
|
||||
if err1 == nil {
|
||||
m.SetFile(f)
|
||||
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||
}
|
||||
if err1 != nil {
|
||||
logrus.Debugln("[sausenao]下载err:", err1)
|
||||
logrus.Debugln("[saucenao]下载err:", err1)
|
||||
}
|
||||
}
|
||||
imgs = append(imgs, message.Image("file:///"+f))
|
||||
@@ -109,8 +109,13 @@ func init() { // 插件主体
|
||||
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, zero.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 开始搜索图片
|
||||
pics, ok := ctx.State["image_url"].([]string)
|
||||
if !ok {
|
||||
ctx.SendChain(message.Text("ERROR: 未获取到图片链接"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
for _, pic := range ctx.State["image_url"].([]string) {
|
||||
for _, pic := range pics {
|
||||
if saucenaocli != nil {
|
||||
resp, err := saucenaocli.FromURL(pic)
|
||||
if err == nil && resp.Count() > 0 {
|
||||
@@ -157,27 +162,27 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取"))
|
||||
}
|
||||
// ascii2d 搜索
|
||||
if result, err := ascii2d.ASCII2d(pic); err != nil {
|
||||
result, err := ascii2d.ASCII2d(pic)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
} else {
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
for i := 0; i < len(result) && i < 5; i++ {
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s",
|
||||
result[i].Name,
|
||||
result[i].Type,
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
))),
|
||||
)
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
for i := 0; i < len(result) && i < 5; i++ {
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s",
|
||||
result[i].Name,
|
||||
result[i].Type,
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
))),
|
||||
)
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
492
plugin/score/draw.go
Normal file
492
plugin/score/draw.go
Normal file
@@ -0,0 +1,492 @@
|
||||
// Package score 签到
|
||||
package score
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/rendercard"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/disintegration/imaging"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
type scoredrawer func(a *scdata) (image.Image, error)
|
||||
|
||||
func drawScore16(a *scdata) (image.Image, error) {
|
||||
// 绘图
|
||||
getAvatar, err := initPic(a.picfile, a.uid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
back, err := gg.LoadImage(a.picfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = imgfactory.Limit(back, 1280, 720)
|
||||
imgDX := back.Bounds().Dx()
|
||||
imgDY := back.Bounds().Dy()
|
||||
canvas := gg.NewContext(imgDX, imgDY)
|
||||
// draw Aero Style
|
||||
aeroStyle := gg.NewContext(imgDX-202, imgDY-202)
|
||||
aeroStyle.DrawImage(imaging.Blur(back, 2.5), -100, -100)
|
||||
// aero draw image.
|
||||
aeroStyle.DrawRoundedRectangle(0, 0, float64(imgDX-200), float64(imgDY-200), 16)
|
||||
// SideLine
|
||||
aeroStyle.SetLineWidth(3)
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 100)
|
||||
aeroStyle.StrokePreserve()
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 140)
|
||||
// fill
|
||||
aeroStyle.Fill()
|
||||
// draw background
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
// Aero style combine
|
||||
canvas.DrawImage(aeroStyle.Image(), 100, 100)
|
||||
canvas.Fill()
|
||||
hourWord := getHourWord(time.Now())
|
||||
avatar, _, err := image.Decode(bytes.NewReader(getAvatar))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
avatarf := imgfactory.Size(avatar, 200, 200)
|
||||
canvas.DrawImage(avatarf.Circle(0).Image(), 120, 120)
|
||||
// draw info(name,coin,etc)
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// draw head
|
||||
canvas.DrawStringWrapped(a.nickname, 350, 180, 0.5, 0.5, 0.5, 0.5, gg.AlignLeft)
|
||||
canvas.Fill()
|
||||
// main draw
|
||||
data, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, 30); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored(hourWord, 350, 280, 0, 0)
|
||||
canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), 350, 350, 0, 0)
|
||||
canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(a.score), 350, 400, 0, 0)
|
||||
canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(a.level)), 350, 450, 0, 0)
|
||||
// draw Info(Time,etc.)
|
||||
getTime := time.Now().Format("2006-01-02 15:04:05")
|
||||
getTimeLengthWidth, getTimeLengthHight := canvas.MeasureString(getTime)
|
||||
canvas.DrawStringAnchored(getTime, float64(imgDX)-100-20-getTimeLengthWidth/2, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time
|
||||
var nextrankScore int
|
||||
if a.rank < 10 {
|
||||
nextrankScore = rankArray[a.rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore)
|
||||
getLevelLength, _ := canvas.MeasureString(nextLevelStyle)
|
||||
canvas.DrawStringAnchored(nextLevelStyle, 100+getLevelLength, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time
|
||||
canvas.Fill()
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
if err = canvas.ParseFontFace(data, 20); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
// Gradient
|
||||
grad := gg.NewLinearGradient(20, 320, 400, 20)
|
||||
grad.AddColorStop(0, color.RGBA{G: 255, A: 255})
|
||||
grad.AddColorStop(1, color.RGBA{B: 255, A: 255})
|
||||
grad.AddColorStop(0.5, color.RGBA{R: 255, A: 255})
|
||||
canvas.SetStrokeStyle(grad)
|
||||
canvas.SetLineWidth(4)
|
||||
// level array with rectangle work.
|
||||
gradLineLength := float64(imgDX-120) - 120
|
||||
renderLine := (float64(a.level) / float64(nextrankScore)) * gradLineLength
|
||||
canvas.MoveTo(120, float64(imgDY)-102)
|
||||
canvas.LineTo(120+renderLine, float64(imgDY)-102)
|
||||
canvas.ClosePath()
|
||||
canvas.Stroke()
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
|
||||
func drawScore15(a *scdata) (image.Image, error) {
|
||||
// 绘图
|
||||
_, err := initPic(a.picfile, a.uid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
back, err := gg.LoadImage(a.picfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = imgfactory.Limit(back, 1280, 720)
|
||||
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
canvas.Clear()
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
monthWord := time.Now().Format("01/02")
|
||||
hourWord := getHourWord(time.Now())
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
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)
|
||||
_, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawString(a.nickname+fmt.Sprintf(" ATRI币+%d", a.inc), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
|
||||
canvas.DrawString("当前ATRI币:"+strconv.FormatInt(int64(a.score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
|
||||
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(a.rank), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
var nextrankScore int
|
||||
if a.rank < 10 {
|
||||
nextrankScore = rankArray[a.rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(a.level)/float64(nextrankScore), float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
canvas.Fill()
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", a.level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
|
||||
func drawScore17(a *scdata) (image.Image, error) {
|
||||
getAvatar, err := initPic(a.picfile, a.uid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
back, err := gg.LoadImage(a.picfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = imgfactory.Limit(back, 1280, 720)
|
||||
imgDX := back.Bounds().Dx()
|
||||
imgDY := back.Bounds().Dy()
|
||||
canvas := gg.NewContext(imgDX, imgDY)
|
||||
|
||||
// draw background
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
|
||||
// Create smaller Aero Style boxes
|
||||
createAeroBox := func(x, y, width, height float64) {
|
||||
aeroStyle := gg.NewContext(int(width), int(height))
|
||||
aeroStyle.DrawRoundedRectangle(0, 0, width, height, 8)
|
||||
aeroStyle.SetLineWidth(2)
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 100)
|
||||
aeroStyle.StrokePreserve()
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 140)
|
||||
aeroStyle.Fill()
|
||||
canvas.DrawImage(aeroStyle.Image(), int(x), int(y))
|
||||
}
|
||||
|
||||
// draw aero boxes for text
|
||||
createAeroBox(20, float64(imgDY-120), 280, 100) // left bottom
|
||||
createAeroBox(float64(imgDX-272), float64(imgDY-60), 252, 40) // right bottom
|
||||
|
||||
// draw info(name, coin, etc)
|
||||
hourWord := getHourWord(time.Now())
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
data, err := file.GetLazyData(text.MaokenFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, 24); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
getNameLengthWidth, _ := canvas.MeasureString(a.nickname)
|
||||
// draw aero box
|
||||
if getNameLengthWidth > 140 {
|
||||
createAeroBox(20, 40, 140+getNameLengthWidth, 100) // left top
|
||||
} else {
|
||||
createAeroBox(20, 40, 280, 100) // left top
|
||||
}
|
||||
|
||||
// draw avatar
|
||||
avatar, _, err := image.Decode(bytes.NewReader(getAvatar))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
avatarf := imgfactory.Size(avatar, 100, 100)
|
||||
canvas.DrawImage(avatarf.Circle(0).Image(), 30, 20)
|
||||
|
||||
canvas.DrawString(a.nickname, 140, 80)
|
||||
canvas.DrawStringAnchored(hourWord, 140, 120, 0, 0)
|
||||
|
||||
if err = canvas.ParseFontFace(data, 20); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), 40, float64(imgDY-90), 0, 0)
|
||||
canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(a.score), 40, float64(imgDY-60), 0, 0)
|
||||
canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(a.level)), 40, float64(imgDY-30), 0, 0)
|
||||
|
||||
// Draw Info(Time, etc.)
|
||||
getTime := time.Now().Format("2006-01-02 15:04:05")
|
||||
canvas.DrawStringAnchored(getTime, float64(imgDX)-146, float64(imgDY)-40, 0.5, 0.5) // time
|
||||
var nextrankScore int
|
||||
if a.rank < 10 {
|
||||
nextrankScore = rankArray[a.rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore)
|
||||
canvas.DrawStringAnchored(nextLevelStyle, 190, float64(imgDY-30), 0, 0) // time
|
||||
|
||||
// Draw Zerobot-Plugin information
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
if err = canvas.ParseFontFace(data, 20); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
|
||||
func drawScore17b2(a *scdata) (img image.Image, err error) {
|
||||
fontdata, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
getAvatar, err := initPic(a.picfile, a.uid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
back, err := gg.LoadImage(a.picfile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
bx, by := float64(back.Bounds().Dx()), float64(back.Bounds().Dy())
|
||||
|
||||
sc := 1280 / bx
|
||||
|
||||
colors := gg.TakeColor(back, 3)
|
||||
|
||||
canvas := gg.NewContext(1280, 1280*int(by)/int(bx))
|
||||
|
||||
cw, ch := float64(canvas.W()), float64(canvas.H())
|
||||
|
||||
sch := ch * 6 / 10
|
||||
|
||||
var blurback, scbackimg, backshadowimg, avatarimg, avatarbackimg, avatarshadowimg, whitetext, blacktext image.Image
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(8)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
scback := gg.NewContext(canvas.W(), canvas.H())
|
||||
scback.ScaleAbout(sc, sc, cw/2, ch/2)
|
||||
scback.DrawImageAnchored(back, canvas.W()/2, canvas.H()/2, 0.5, 0.5)
|
||||
scback.Identity()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
blurback = imaging.Blur(scback.Image(), 20)
|
||||
}()
|
||||
|
||||
scbackimg = rendercard.Fillet(scback.Image(), 12)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
pureblack := gg.NewContext(canvas.W(), canvas.H())
|
||||
pureblack.SetRGBA255(0, 0, 0, 255)
|
||||
pureblack.Clear()
|
||||
|
||||
shadow := gg.NewContext(canvas.W(), canvas.H())
|
||||
shadow.ScaleAbout(0.6, 0.6, cw-cw/3, ch/2)
|
||||
shadow.DrawImageAnchored(pureblack.Image(), canvas.W()-canvas.W()/3, canvas.H()/2, 0.5, 0.5)
|
||||
shadow.Identity()
|
||||
|
||||
backshadowimg = imaging.Blur(shadow.Image(), 8)
|
||||
}()
|
||||
|
||||
aw, ah := (ch-sch)/2/2/2*3, (ch-sch)/2/2/2*3
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
avatar, _, err := image.Decode(bytes.NewReader(getAvatar))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
isc := (ch - sch) / 2 / 2 / 2 * 3 / float64(avatar.Bounds().Dy())
|
||||
|
||||
scavatar := gg.NewContext(int(aw), int(ah))
|
||||
|
||||
scavatar.ScaleAbout(isc, isc, aw/2, ah/2)
|
||||
scavatar.DrawImageAnchored(avatar, scavatar.W()/2, scavatar.H()/2, 0.5, 0.5)
|
||||
scavatar.Identity()
|
||||
|
||||
avatarimg = rendercard.Fillet(scavatar.Image(), 8)
|
||||
}()
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
namew, _ := canvas.MeasureString(a.nickname)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
avatarshadowimg = imaging.Blur(customrectangle(cw, ch, aw, ah, namew, color.Black), 8)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
avatarbackimg = customrectangle(cw, ch, aw, ah, namew, colors[0])
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
whitetext, err = customtext(a, fontdata, cw, ch, aw, color.White)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
blacktext, err = customtext(a, fontdata, cw, ch, aw, color.Black)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
if scbackimg == nil || backshadowimg == nil || avatarimg == nil || avatarbackimg == nil || avatarshadowimg == nil || whitetext == nil || blacktext == nil {
|
||||
err = errors.New("图片渲染失败")
|
||||
return
|
||||
}
|
||||
|
||||
canvas.DrawImageAnchored(blurback, canvas.W()/2, canvas.H()/2, 0.5, 0.5)
|
||||
|
||||
canvas.DrawImage(backshadowimg, 0, 0)
|
||||
|
||||
canvas.ScaleAbout(0.6, 0.6, cw-cw/3, ch/2)
|
||||
canvas.DrawImageAnchored(scbackimg, canvas.W()-canvas.W()/3, canvas.H()/2, 0.5, 0.5)
|
||||
canvas.Identity()
|
||||
|
||||
canvas.DrawImage(avatarshadowimg, 0, 0)
|
||||
canvas.DrawImage(avatarbackimg, 0, 0)
|
||||
canvas.DrawImageAnchored(avatarimg, int((ch-sch)/2/2), int((ch-sch)/2/2), 0.5, 0.5)
|
||||
|
||||
canvas.DrawImage(blacktext, 2, 2)
|
||||
canvas.DrawImage(whitetext, 0, 0)
|
||||
|
||||
img = canvas.Image()
|
||||
return
|
||||
}
|
||||
|
||||
func customrectangle(cw, ch, aw, ah, namew float64, rtgcolor color.Color) (img image.Image) {
|
||||
canvas := gg.NewContext(int(cw), int(ch))
|
||||
sch := ch * 6 / 10
|
||||
canvas.DrawRoundedRectangle((ch-sch)/2/2-aw/2-aw/40, (ch-sch)/2/2-aw/2-ah/40, aw+aw/40*2, ah+ah/40*2, 8)
|
||||
canvas.SetColor(rtgcolor)
|
||||
canvas.Fill()
|
||||
canvas.DrawRoundedRectangle((ch-sch)/2/2, (ch-sch)/2/2-ah/4, aw/2+aw/40*5+namew, ah/2, 8)
|
||||
canvas.Fill()
|
||||
|
||||
img = canvas.Image()
|
||||
return
|
||||
}
|
||||
|
||||
func customtext(a *scdata, fontdata []byte, cw, ch, aw float64, textcolor color.Color) (img image.Image, err error) {
|
||||
canvas := gg.NewContext(int(cw), int(ch))
|
||||
canvas.SetColor(textcolor)
|
||||
scw, sch := cw*6/10, ch*6/10
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
canvas.DrawStringAnchored(a.nickname, (ch-sch)/2/2+aw/2+aw/40*2, (ch-sch)/2/2, 0, 0.5)
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3*2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
canvas.DrawStringAnchored(time.Now().Format("2006/01/02"), cw-cw/6, ch/2-sch/2-canvas.FontHeight(), 0.5, 0.5)
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nextrankScore := 0
|
||||
if a.rank < 10 {
|
||||
nextrankScore = rankArray[a.rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore)
|
||||
|
||||
canvas.DrawStringAnchored("Level "+strconv.Itoa(a.rank), cw/3*2-scw/2, ch/2+sch/2+canvas.FontHeight(), 0, 0.5)
|
||||
canvas.DrawStringAnchored(nextLevelStyle, cw/3*2+scw/2, ch/2+sch/2+canvas.FontHeight(), 1, 0.5)
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
canvas.DrawStringAnchored("Create By ZeroBot-Plugin "+banner.Version, 0+4, ch, 0, -0.5)
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5*3)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
tempfh := canvas.FontHeight()
|
||||
|
||||
canvas.DrawStringAnchored(getHourWord(time.Now()), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4, 0, 0.5)
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh, 0, 0.5)
|
||||
canvas.DrawStringAnchored("EXP + 1", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh+canvas.FontHeight(), 0, 1)
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, (ch-sch)/2/4)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
canvas.DrawStringAnchored("你有 "+strconv.Itoa(a.score)+" 枚ATRI币", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4*3, 0, 0.5)
|
||||
|
||||
img = canvas.Image()
|
||||
return
|
||||
}
|
||||
@@ -122,3 +122,14 @@ func (sdb *scoredb) GetScoreRankByTopN(n int) (st []scoretable, err error) {
|
||||
err = db.Model(&scoretable{}).Order("score desc").Limit(n).Find(&st).Error
|
||||
return
|
||||
}
|
||||
|
||||
type scdata struct {
|
||||
drawedfile string
|
||||
picfile string
|
||||
uid int64
|
||||
nickname string
|
||||
inc int // 增加币
|
||||
score int // 钱包
|
||||
level int
|
||||
rank int
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Package score 签到,答题得分
|
||||
// Package score 签到
|
||||
package score
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/bilibili"
|
||||
@@ -14,14 +14,12 @@ import (
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/golang/freetype"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -40,152 +38,147 @@ var (
|
||||
engine = control.Register("score", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "签到",
|
||||
Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!",
|
||||
Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 设置签到预设(0~3)\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!",
|
||||
PrivateDataFolder: "score",
|
||||
})
|
||||
styles = []scoredrawer{
|
||||
drawScore15,
|
||||
drawScore16,
|
||||
drawScore17,
|
||||
drawScore17b2,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
go func() {
|
||||
_ = os.RemoveAll(cachePath)
|
||||
err := os.MkdirAll(cachePath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ok := file.IsExist(cachePath)
|
||||
if !ok {
|
||||
err := os.MkdirAll(cachePath, 0777)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
files, err := os.ReadDir(cachePath)
|
||||
if err == nil {
|
||||
for _, f := range files {
|
||||
if !strings.Contains(f.Name(), time.Now().Format("20060102")) {
|
||||
_ = os.Remove(cachePath + f.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
sdb = initialize(engine.DataFolder() + "score.db")
|
||||
}()
|
||||
engine.OnFullMatch("签到").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
now := time.Now()
|
||||
today := now.Format("20060102")
|
||||
// 签到图片
|
||||
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
|
||||
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
|
||||
// 获取签到时间
|
||||
si := sdb.GetSignInByUID(uid)
|
||||
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
|
||||
switch {
|
||||
case si.Count >= signinMax && siUpdateTimeStr == today:
|
||||
// 如果签到时间是今天
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
}
|
||||
return
|
||||
case siUpdateTimeStr != today:
|
||||
// 如果是跨天签到就清数据
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, 0)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
// 更新签到次数
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
|
||||
engine.OnRegex(`^签到\s?(\d*)$`).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
// 选择key
|
||||
key := ctx.State["regex_matched"].([]string)[1]
|
||||
gid := ctx.Event.GroupID
|
||||
if gid < 0 {
|
||||
// 个人用户设为负数
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
k := uint8(0)
|
||||
if key == "" {
|
||||
k = uint8(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).GetData(gid))
|
||||
} else {
|
||||
kn, err := strconv.Atoi(key)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新经验
|
||||
level := sdb.GetScoreByUID(uid).Score + 1
|
||||
if level > SCOREMAX {
|
||||
level = SCOREMAX
|
||||
ctx.SendChain(message.At(uid), message.Text("你的等级已经达到上限"))
|
||||
k = uint8(kn)
|
||||
}
|
||||
if int(k) >= len(styles) {
|
||||
ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key))
|
||||
return
|
||||
}
|
||||
uid := ctx.Event.UserID
|
||||
today := time.Now().Format("20060102")
|
||||
// 签到图片
|
||||
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
|
||||
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
|
||||
// 获取签到时间
|
||||
si := sdb.GetSignInByUID(uid)
|
||||
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
|
||||
switch {
|
||||
case si.Count >= signinMax && siUpdateTimeStr == today:
|
||||
// 如果签到时间是今天
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
}
|
||||
err = sdb.InsertOrUpdateScoreByUID(uid, level)
|
||||
return
|
||||
case siUpdateTimeStr != today:
|
||||
// 如果是跨天签到就清数据
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, 0)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新钱包
|
||||
rank := getrank(level)
|
||||
add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高
|
||||
}
|
||||
// 更新签到次数
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新经验
|
||||
level := sdb.GetScoreByUID(uid).Score + 1
|
||||
if level > SCOREMAX {
|
||||
level = SCOREMAX
|
||||
ctx.SendChain(message.At(uid), message.Text("你的等级已经达到上限"))
|
||||
}
|
||||
err = sdb.InsertOrUpdateScoreByUID(uid, level)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新钱包
|
||||
rank := getrank(level)
|
||||
add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高
|
||||
go func() {
|
||||
err = wallet.InsertWalletOf(uid, add)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
score := wallet.GetWalletOf(uid)
|
||||
// 绘图
|
||||
err = initPic(picFile)
|
||||
}()
|
||||
alldata := &scdata{
|
||||
drawedfile: drawedFile,
|
||||
picfile: picFile,
|
||||
uid: uid,
|
||||
nickname: ctx.CardOrNickName(uid),
|
||||
inc: add,
|
||||
score: wallet.GetWalletOf(uid),
|
||||
level: level,
|
||||
rank: rank,
|
||||
}
|
||||
drawimage, err := styles[k](alldata)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// done.
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
data, err := imgfactory.ToBytes(drawimage)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back, err := gg.LoadImage(picFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = imgfactory.Limit(back, 1280, 720)
|
||||
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
canvas.Clear()
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
monthWord := now.Format("01/02")
|
||||
hourWord := getHourWord(now)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, float64(back.Bounds().Size().X)*0.1); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
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)
|
||||
data, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.DrawString(nickName+fmt.Sprintf(" ATRI币+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
|
||||
canvas.DrawString("当前ATRI币:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
|
||||
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(rank), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
var nextrankScore int
|
||||
if rank < 10 {
|
||||
nextrankScore = rankArray[rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(level)/float64(nextrankScore), float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
canvas.Fill()
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
return
|
||||
}
|
||||
_, err = imgfactory.WriteTo(drawimage, f)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
data, err := imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
return
|
||||
}
|
||||
_, err = imgfactory.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
engine.OnPrefix("获得签到背景", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["args"].(string)
|
||||
@@ -200,7 +193,9 @@ func init() {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请先签到!"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile))
|
||||
if id := ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 消息发送失败, 账号可能被风控"))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("查看等级排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -274,6 +269,29 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
engine.OnRegex(`^设置签到预设\s*(\d+)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
key := ctx.State["regex_matched"].([]string)[1]
|
||||
kn, err := strconv.Atoi(key)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
k := uint8(kn)
|
||||
if int(k) >= len(styles) {
|
||||
ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key))
|
||||
return
|
||||
}
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
err = ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).SetData(gid, int64(k))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
}
|
||||
|
||||
func getHourWord(t time.Time) string {
|
||||
@@ -305,18 +323,22 @@ func getrank(count int) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func initPic(picFile string) error {
|
||||
if file.IsExist(picFile) {
|
||||
return nil
|
||||
}
|
||||
func initPic(picFile string, uid int64) (avatar []byte, err error) {
|
||||
defer process.SleepAbout1sTo2s()
|
||||
avatar, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if file.IsExist(picFile) {
|
||||
return
|
||||
}
|
||||
url, err := bilibili.GetRealURL(backgroundURL)
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
return os.WriteFile(picFile, data, 0644)
|
||||
return avatar, os.WriteFile(picFile, data, 0644)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func init() { // 插件主体
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
_, _ = engine.GetLazyData("SetuTime.db", false)
|
||||
err := pool.db.Open(time.Hour * 24)
|
||||
err := pool.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
@@ -236,10 +236,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
|
||||
return err
|
||||
}
|
||||
// 添加插画到对应的数据库table
|
||||
if err := p.db.Insert(imgtype, illust); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return p.db.Insert(imgtype, illust)
|
||||
}
|
||||
|
||||
func (p *imgpool) remove(imgtype string, id int64) error {
|
||||
|
||||
@@ -20,13 +20,13 @@ func init() {
|
||||
Help: "- 今天是什么少女[@xxx]\n" +
|
||||
"- 异世界转生[@xxx]\n" +
|
||||
"- 卖萌[@xxx]\n" +
|
||||
"- 抽老婆[@xxx]\n" +
|
||||
"- 今日老婆[@xxx]\n" +
|
||||
"- 黄油角色[@xxx]",
|
||||
})
|
||||
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
|
||||
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
|
||||
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handletxt)
|
||||
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq)
|
||||
engine.OnPrefix("今日老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq)
|
||||
engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ func timeDuration(time time.Duration) (hour, minute, second int64) {
|
||||
}
|
||||
|
||||
// 只统计6点到12点的早安
|
||||
func isMorning(ctx *zero.Ctx) bool {
|
||||
func isMorning(*zero.Ctx) bool {
|
||||
now := time.Now().Hour()
|
||||
return now >= 6 && now <= 12
|
||||
}
|
||||
|
||||
// 只统计21点到凌晨3点的晚安
|
||||
func isEvening(ctx *zero.Ctx) bool {
|
||||
func isEvening(*zero.Ctx) bool {
|
||||
now := time.Now().Hour()
|
||||
return now >= 21 || now <= 3
|
||||
}
|
||||
|
||||
142
plugin/steam/listenter.go
Normal file
142
plugin/steam/listenter.go
Normal file
@@ -0,0 +1,142 @@
|
||||
package steam
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
// ----------------------- 远程调用 ----------------------
|
||||
const (
|
||||
apiurl = "https://api.steampowered.com/" // steam API 调用地址
|
||||
statusurl = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态
|
||||
)
|
||||
|
||||
var (
|
||||
apiKey string
|
||||
apiKeyMu sync.Mutex
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnRegex(`^steam绑定\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
apiKeyMu.Lock()
|
||||
defer apiKeyMu.Unlock()
|
||||
apiKey = ctx.State["regex_matched"].([]string)[1]
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
err := m.SetExtra(apiKey)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: 保存apikey失败!"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("保存apikey成功!"))
|
||||
})
|
||||
engine.OnFullMatch("查看apikey", zero.OnlyPrivate, zero.SuperUserPermission, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
apiKeyMu.Lock()
|
||||
defer apiKeyMu.Unlock()
|
||||
ctx.SendChain(message.Text("apikey为: ", apiKey))
|
||||
})
|
||||
engine.OnFullMatch("拉取steam订阅", getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
su := zero.BotConfig.SuperUsers[0]
|
||||
// 获取所有处于监听状态的用户信息
|
||||
infos, err := database.findAll()
|
||||
if err != nil {
|
||||
// 挂了就给管理员发消息
|
||||
ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(infos) == 0 {
|
||||
return
|
||||
}
|
||||
// 收集这波用户的streamId,然后查当前的状态,并建立信息映射表
|
||||
streamIds := make([]string, len(infos))
|
||||
localPlayerMap := make(map[int64]*player)
|
||||
for i := 0; i < len(infos); i++ {
|
||||
streamIds[i] = strconv.FormatInt(infos[i].SteamID, 10)
|
||||
localPlayerMap[infos[i].SteamID] = infos[i]
|
||||
}
|
||||
// 将所有用户状态查一遍
|
||||
playerStatus, err := getPlayerStatus(streamIds...)
|
||||
if err != nil {
|
||||
// 出错就发消息
|
||||
ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 遍历返回的信息做对比,假如信息有变化则发消息
|
||||
now := time.Now()
|
||||
msg := make(message.Message, 0, len(playerStatus))
|
||||
for _, playerInfo := range playerStatus {
|
||||
msg = msg[:0]
|
||||
localInfo := localPlayerMap[playerInfo.SteamID]
|
||||
// 排除不需要处理的情况
|
||||
if localInfo.GameID == 0 && playerInfo.GameID == 0 {
|
||||
continue
|
||||
}
|
||||
// 打开游戏
|
||||
if localInfo.GameID == 0 && playerInfo.GameID != 0 {
|
||||
msg = append(msg, message.Text(playerInfo.PersonaName, "正在玩", playerInfo.GameExtraInfo))
|
||||
localInfo.LastUpdate = now.Unix()
|
||||
}
|
||||
// 更换游戏
|
||||
if localInfo.GameID != 0 && playerInfo.GameID != localInfo.GameID && playerInfo.GameID != 0 {
|
||||
msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 丢下了", localInfo.GameExtraInfo, ", 转头去玩", playerInfo.GameExtraInfo))
|
||||
localInfo.LastUpdate = now.Unix()
|
||||
}
|
||||
// 关闭游戏
|
||||
if playerInfo.GameID != localInfo.GameID && playerInfo.GameID == 0 {
|
||||
msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 关掉了", localInfo.GameExtraInfo))
|
||||
localInfo.LastUpdate = 0
|
||||
}
|
||||
if len(msg) != 0 {
|
||||
groups := strings.Split(localInfo.Target, ",")
|
||||
for _, groupString := range groups {
|
||||
group, err := strconv.ParseInt(groupString, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nOTHER: SteamID ", localInfo.SteamID))
|
||||
continue
|
||||
}
|
||||
ctx.SendGroupMessage(group, msg)
|
||||
}
|
||||
}
|
||||
// 更新数据
|
||||
localInfo.GameID = playerInfo.GameID
|
||||
localInfo.GameExtraInfo = playerInfo.GameExtraInfo
|
||||
if err = database.update(localInfo); err != nil {
|
||||
ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据失败\nOTHER: SteamID ", localInfo.SteamID))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// getPlayerStatus 获取用户状态
|
||||
func getPlayerStatus(streamIds ...string) ([]*player, error) {
|
||||
players := make([]*player, 0)
|
||||
// 拼接请求地址
|
||||
apiKeyMu.Lock()
|
||||
url := fmt.Sprintf(apiurl+statusurl, apiKey, strings.Join(streamIds, ","))
|
||||
apiKeyMu.Unlock()
|
||||
// 拉取并解析数据
|
||||
data, err := web.GetData(url)
|
||||
if err != nil {
|
||||
return players, err
|
||||
}
|
||||
dataStr := binary.BytesToString(data)
|
||||
index := gjson.Get(dataStr, "response.players.#").Uint()
|
||||
for i := uint64(0); i < index; i++ {
|
||||
players = append(players, &player{
|
||||
SteamID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.steamid", i)).Int(),
|
||||
PersonaName: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.personaname", i)).String(),
|
||||
GameID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameid", i)).Int(),
|
||||
GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(),
|
||||
})
|
||||
}
|
||||
return players, nil
|
||||
}
|
||||
159
plugin/steam/steam.go
Normal file
159
plugin/steam/steam.go
Normal file
@@ -0,0 +1,159 @@
|
||||
// Package steam 获取steam用户状态
|
||||
package steam
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("steam", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Extra: control.ExtraFromString("steam"),
|
||||
Brief: "steam相关插件",
|
||||
Help: "- steam添加订阅 xxxxxxx (可输入需要绑定的 steamid)\n" +
|
||||
"- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" +
|
||||
"- steam查询订阅 (查询本群内所有的绑定对象)\n" +
|
||||
"-----------------------\n" +
|
||||
"- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/apikey)\n" +
|
||||
"- 查看apikey (查询已经绑定的密钥)\n" +
|
||||
"- 拉取steam订阅 (使用插件定时任务开始)\n" +
|
||||
"-----------------------\n" +
|
||||
"Tips: steamID在用户资料页的链接上面, 形如7656119820673xxxx\n" +
|
||||
"需要先私聊绑定apikey, 订阅用户之后使用job插件设置定时, 例: \n" +
|
||||
"记录在\"@every 1m\"触发的指令\n" +
|
||||
"拉取steam订阅",
|
||||
PrivateDataFolder: "steam",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 创建绑定流程
|
||||
engine.OnRegex(`^steam添加订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
steamidstr := ctx.State["regex_matched"].([]string)[1]
|
||||
steamID := math.Str2Int64(steamidstr)
|
||||
// 获取用户状态
|
||||
playerStatus, err := getPlayerStatus(steamidstr)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败, 获取用户信息错误"))
|
||||
return
|
||||
}
|
||||
if len(playerStatus) == 0 {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: 需要添加的用户不存在, 请检查id或url"))
|
||||
return
|
||||
}
|
||||
playerData := playerStatus[0]
|
||||
// 判断用户是否已经初始化:若未初始化,通过用户的steamID获取当前状态并初始化;若已经初始化则更新用户信息
|
||||
info, err := database.find(steamID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败,数据库错误"))
|
||||
return
|
||||
}
|
||||
// 处理数据
|
||||
groupID := strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||
if info.Target == "" {
|
||||
info = player{
|
||||
SteamID: steamID,
|
||||
PersonaName: playerData.PersonaName,
|
||||
Target: groupID,
|
||||
GameID: playerData.GameID,
|
||||
GameExtraInfo: playerData.GameExtraInfo,
|
||||
LastUpdate: time.Now().Unix(),
|
||||
}
|
||||
} else if !strings.Contains(info.Target, groupID) {
|
||||
info.Target = strings.Join([]string{info.Target, groupID}, ",")
|
||||
}
|
||||
// 更新数据库
|
||||
if err = database.update(&info); err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据库失败"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("添加成功"))
|
||||
})
|
||||
// 删除绑定流程
|
||||
engine.OnRegex(`^steam删除订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
steamID := math.Str2Int64(ctx.State["regex_matched"].([]string)[1])
|
||||
groupID := strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||
// 判断是否已经绑定该steamID,若已绑定就将群列表从推送群列表钟去除
|
||||
info, err := database.findWithGroupID(steamID, groupID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误"))
|
||||
return
|
||||
}
|
||||
if info.SteamID == 0 {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: 所需要删除的用户不存在。"))
|
||||
return
|
||||
}
|
||||
// 从绑定列表中剔除需要删除的对象
|
||||
targets := strings.Split(info.Target, ",")
|
||||
newTargets := make([]string, 0)
|
||||
for _, target := range targets {
|
||||
if target == groupID {
|
||||
continue
|
||||
}
|
||||
newTargets = append(newTargets, target)
|
||||
}
|
||||
if len(newTargets) == 0 {
|
||||
if err = database.del(steamID); err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误"))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
info.Target = strings.Join(newTargets, ",")
|
||||
if err = database.update(&info); err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误"))
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.SendChain(message.Text("删除成功"))
|
||||
})
|
||||
// 查询当前群绑定信息
|
||||
engine.OnFullMatch("steam查询订阅", zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
// 获取群信息
|
||||
groupID := strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||
// 获取所有绑定信息
|
||||
infos, err := database.findAll()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 查询订阅失败, 数据库错误"))
|
||||
return
|
||||
}
|
||||
if len(infos) == 0 {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: 还未订阅过用户关系!"))
|
||||
return
|
||||
}
|
||||
// 遍历所有信息,如果包含该群就收集对应的steamID
|
||||
var sb strings.Builder
|
||||
head := " 查询steam订阅成功, 该群订阅的用户有: \n"
|
||||
sb.WriteString(head)
|
||||
for _, info := range infos {
|
||||
if strings.Contains(info.Target, groupID) {
|
||||
sb.WriteString(" ")
|
||||
sb.WriteString(info.PersonaName)
|
||||
sb.WriteString(":")
|
||||
sb.WriteString(strconv.FormatInt(info.SteamID, 10))
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
}
|
||||
if sb.String() == head {
|
||||
ctx.SendChain(message.Text("查询成功,该群暂时还没有被绑定的用户!"))
|
||||
return
|
||||
}
|
||||
// 组装并返回结果
|
||||
data, err := text.RenderToBase64(sb.String(), text.FontFile, 400, 18)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(data)))
|
||||
})
|
||||
}
|
||||
106
plugin/steam/store.go
Normal file
106
plugin/steam/store.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package steam
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
database streamDB
|
||||
// 开启并检查数据库链接
|
||||
getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
database.db.DBPath = engine.DataFolder() + "steam.db"
|
||||
err := database.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
if err = database.db.Create(tableListenPlayer, &player{}); err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
// 校验密钥是否初始化
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
apiKeyMu.Lock()
|
||||
defer apiKeyMu.Unlock()
|
||||
_ = m.GetExtra(&apiKey)
|
||||
if apiKey == "" {
|
||||
ctx.SendChain(message.Text("ERROR: 未设置steam apikey"))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
)
|
||||
|
||||
// streamDB 继承方法的存储结构
|
||||
type streamDB struct {
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
const (
|
||||
// tableListenPlayer 存储查询用户信息
|
||||
tableListenPlayer = "listen_player"
|
||||
)
|
||||
|
||||
// player 用户状态存储结构体
|
||||
type player struct {
|
||||
SteamID int64 `json:"steam_id"` // 绑定用户标识ID
|
||||
PersonaName string `json:"persona_name"` // 用户昵称
|
||||
Target string `json:"target"` // 信息推送群组
|
||||
GameID int64 `json:"game_id"` // 游戏ID
|
||||
GameExtraInfo string `json:"game_extra_info"` // 游戏信息
|
||||
LastUpdate int64 `json:"last_update"` // 更新时间
|
||||
}
|
||||
|
||||
// update 如果主键不存在则插入一条新的数据,如果主键存在直接复写
|
||||
func (sdb *streamDB) update(dbInfo *player) error {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
return sdb.db.Insert(tableListenPlayer, dbInfo)
|
||||
}
|
||||
|
||||
// find 根据主键查信息
|
||||
func (sdb *streamDB) find(steamID int64) (dbInfo player, err error) {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
condition := "where steam_id = " + strconv.FormatInt(steamID, 10)
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, condition)
|
||||
if err == sql.ErrNullResult { // 规避没有该用户数据的报错
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// findWithGroupID 根据用户steamID和groupID查询信息
|
||||
func (sdb *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'"
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, condition)
|
||||
if err == sql.ErrNullResult { // 规避没有该用户数据的报错
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// findAll 查询所有库信息
|
||||
func (sdb *streamDB) findAll() (dbInfos []*player, err error) {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
return sql.FindAll[player](&sdb.db, tableListenPlayer, "")
|
||||
}
|
||||
|
||||
// del 删除指定数据
|
||||
func (sdb *streamDB) del(steamID int64) error {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
return sdb.db.Del(tableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10))
|
||||
}
|
||||
@@ -5,10 +5,17 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/fumiama/jieba"
|
||||
@@ -22,10 +29,33 @@ func init() {
|
||||
engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "词典匹配回复",
|
||||
Help: "- 切换[kimo|傲娇|可爱]词库\n- 设置词库触发概率0.x (0<x<9)",
|
||||
Help: "- 切换[kimo|傲娇|可爱|🦙]词库\n- 设置词库触发概率0.x (0<x<9)",
|
||||
PublicDataFolder: "Chat",
|
||||
})
|
||||
engine.OnRegex(`^切换(kimo|傲娇|可爱)词库$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
alpacafolder := engine.DataFolder() + "alpaca/"
|
||||
err := os.MkdirAll(alpacafolder, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
alpacapifile := alpacafolder + "api.txt"
|
||||
alpacapiurl := ""
|
||||
if file.IsExist(alpacapifile) {
|
||||
data, err := os.ReadFile(alpacapifile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
alpacapiurl = binary.BytesToString(data)
|
||||
}
|
||||
alpacatokenfile := alpacafolder + "token.txt"
|
||||
alpacatoken := ""
|
||||
if file.IsExist(alpacatokenfile) {
|
||||
data, err := os.ReadFile(alpacatokenfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
alpacatoken = binary.BytesToString(data)
|
||||
}
|
||||
engine.OnRegex(`^切换(kimo|傲娇|可爱|🦙)词库$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
if !ok {
|
||||
ctx.SendChain(message.Text("ERROR: 找不到 manager"))
|
||||
@@ -44,6 +74,8 @@ func init() {
|
||||
t = tDERE
|
||||
case "可爱":
|
||||
t = tKAWA
|
||||
case "🦙":
|
||||
t = tALPACA
|
||||
}
|
||||
err := c.SetData(gid, (d&^3)|t)
|
||||
if err != nil {
|
||||
@@ -76,6 +108,24 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
engine.OnRegex(`^设置🦙API地址\s*(http.*)\s*$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
alpacapiurl = ctx.State["regex_matched"].([]string)[1]
|
||||
err := os.WriteFile(alpacapifile, binary.StringToBytes(alpacapiurl), 0644)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
engine.OnRegex(`^设置🦙token\s*([0-9a-f]{112})\s*$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
alpacatoken = ctx.State["regex_matched"].([]string)[1]
|
||||
err := os.WriteFile(alpacatokenfile, binary.StringToBytes(alpacatoken), 0644)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
go func() {
|
||||
data, err := engine.GetLazyData("dict.txt", false)
|
||||
if err != nil {
|
||||
@@ -128,6 +178,57 @@ func init() {
|
||||
engine.OnMessage(canmatch(tKAWA), match(chatListK, seg)).
|
||||
SetBlock(false).
|
||||
Handle(randreply(sm.K))
|
||||
engine.OnMessage(canmatch(tALPACA), func(ctx *zero.Ctx) bool {
|
||||
return alpacapiurl != "" && alpacatoken != ""
|
||||
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
if msg != "" {
|
||||
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply", "POST",
|
||||
func(r *http.Request) error {
|
||||
r.Header.Set("Authorization", alpacatoken)
|
||||
return nil
|
||||
}, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) {
|
||||
_ = json.NewEncoder(writer).Encode(&[]alpacamsg{{
|
||||
Name: ctx.CardOrNickName(ctx.Event.UserID),
|
||||
Message: msg,
|
||||
}})
|
||||
})))
|
||||
if err != nil {
|
||||
logrus.Warnln("[chat] 🦙 err:", err)
|
||||
return
|
||||
}
|
||||
type reply struct {
|
||||
ID int
|
||||
Msg string
|
||||
}
|
||||
m := reply{}
|
||||
err = json.Unmarshal(data, &m)
|
||||
if err != nil {
|
||||
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
||||
return
|
||||
}
|
||||
for i := 0; i < 60; i++ {
|
||||
time.Sleep(time.Second * 4)
|
||||
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/get?id="+strconv.Itoa(m.ID), "GET",
|
||||
func(r *http.Request) error {
|
||||
r.Header.Set("Authorization", alpacatoken)
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
err = json.Unmarshal(data, &m)
|
||||
if err != nil {
|
||||
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
||||
return
|
||||
}
|
||||
if len(m.Msg) > 0 {
|
||||
ctx.Send(message.Text(m.Msg))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -138,18 +239,21 @@ type simai struct {
|
||||
K map[string][]string `yaml:"可爱"`
|
||||
}
|
||||
|
||||
type alpacamsg struct {
|
||||
Name string
|
||||
Message string
|
||||
}
|
||||
|
||||
const (
|
||||
tKIMO = iota
|
||||
tDERE
|
||||
tKAWA
|
||||
tALPACA
|
||||
)
|
||||
|
||||
func match(l []string, seg *jieba.Segmenter) zero.Rule {
|
||||
return func(ctx *zero.Ctx) bool {
|
||||
if zero.FullMatchRule(l...)(ctx) {
|
||||
return true
|
||||
}
|
||||
return ctxext.JiebaFullMatch(seg, func(ctx *zero.Ctx) string {
|
||||
return ctxext.JiebaSimilarity(0.66, seg, func(ctx *zero.Ctx) string {
|
||||
return ctx.ExtractPlainText()
|
||||
}, l...)(ctx)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
err = db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
|
||||
321
plugin/vtbmusic/vtbmusic.go
Normal file
321
plugin/vtbmusic/vtbmusic.go
Normal file
@@ -0,0 +1,321 @@
|
||||
// Package vtbmusic vtb点歌
|
||||
package vtbmusic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
getGroupListURL = "https://aqua.chat/v1/GetGroupsList"
|
||||
getMusicListURL = "https://aqua.chat/v1/GetMusicList"
|
||||
fileURL = "https://cdn.aqua.chat/"
|
||||
musicListBody = `{"search":{"condition":"VocalId","keyword":"%v"},"sortField":"CreateTime","sortType":"desc","pageIndex":1,"pageRows":10000}`
|
||||
)
|
||||
|
||||
type groupsList struct {
|
||||
Total int `json:"Total"`
|
||||
Data []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
Name string `json:"Name"`
|
||||
GroupImg string `json:"GroupImg"`
|
||||
VocalList []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
ChineseName string `json:"ChineseName"`
|
||||
OriginName string `json:"OriginName"`
|
||||
AvatarImg string `json:"AvatarImg"`
|
||||
} `json:"VocalList"`
|
||||
} `json:"Data"`
|
||||
Success bool `json:"Success"`
|
||||
ErrorCode int `json:"ErrorCode"`
|
||||
Msg interface{} `json:"Msg"`
|
||||
}
|
||||
|
||||
type musicList struct {
|
||||
Total int `json:"Total"`
|
||||
Data []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
PublishTime interface{} `json:"PublishTime"`
|
||||
CreatorID interface{} `json:"CreatorId"`
|
||||
CreatorRealName interface{} `json:"CreatorRealName"`
|
||||
Deleted bool `json:"Deleted"`
|
||||
OriginName string `json:"OriginName"`
|
||||
VocalID string `json:"VocalId"`
|
||||
VocalName string `json:"VocalName"`
|
||||
CoverImg string `json:"CoverImg"`
|
||||
Music string `json:"Music"`
|
||||
Lyric interface{} `json:"Lyric"`
|
||||
CDN string `json:"CDN"`
|
||||
BiliBili interface{} `json:"BiliBili"`
|
||||
YouTube interface{} `json:"YouTube"`
|
||||
Twitter interface{} `json:"Twitter"`
|
||||
Likes interface{} `json:"Likes"`
|
||||
Length float64 `json:"Length"`
|
||||
Label interface{} `json:"Label"`
|
||||
IsLike bool `json:"isLike"`
|
||||
Duration float64 `json:"Duration"`
|
||||
Source interface{} `json:"Source"`
|
||||
SourceName interface{} `json:"SourceName"`
|
||||
Statis struct {
|
||||
PlayCount int `json:"PlayCount"`
|
||||
CommentCount int `json:"CommentCount"`
|
||||
LikeCount int `json:"LikeCount"`
|
||||
ShareCount int `json:"ShareCount"`
|
||||
} `json:"Statis"`
|
||||
VocalList []struct {
|
||||
ID string `json:"Id"`
|
||||
Cn string `json:"cn"`
|
||||
Jp string `json:"jp"`
|
||||
En string `json:"en"`
|
||||
Originlang string `json:"originlang"`
|
||||
} `json:"VocalList"`
|
||||
} `json:"Data"`
|
||||
Success bool `json:"Success"`
|
||||
ErrorCode int `json:"ErrorCode"`
|
||||
Msg interface{} `json:"Msg"`
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("vtbmusic", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "vtbmusic.com点歌",
|
||||
Help: "- vtb点歌\n" +
|
||||
"- vtb随机点歌",
|
||||
PrivateDataFolder: "vtbmusic",
|
||||
})
|
||||
storePath := engine.DataFolder()
|
||||
// 开启
|
||||
engine.OnFullMatch(`vtb点歌`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession(), zero.RegexRule(`^\d+$`))
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
i := 0
|
||||
paras := [3]int{}
|
||||
data, err := web.PostData(getGroupListURL, "application/json", strings.NewReader(`{"PageIndex":1,"PageRows":9999}`))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var (
|
||||
gl groupsList
|
||||
ml musicList
|
||||
num int
|
||||
imageBytes []byte
|
||||
)
|
||||
err = json.Unmarshal(data, &gl)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tex := "请输入群组序号\n"
|
||||
for i, v := range gl.Data {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.Name)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("vtb点歌超时"))
|
||||
return
|
||||
case c := <-recv:
|
||||
msg := c.Event.Message.ExtractPlainText()
|
||||
num, err = strconv.Atoi(msg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请输入数字!"))
|
||||
continue
|
||||
}
|
||||
switch i {
|
||||
case 0:
|
||||
if num < 0 || num >= len(gl.Data) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
if len(gl.Data[num].VocalList) == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无内容, 点歌失败"))
|
||||
return
|
||||
}
|
||||
paras[0] = num
|
||||
tex = "请输入vtb序号\n"
|
||||
for i, v := range gl.Data[paras[0]].VocalList {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.OriginName)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
case 1:
|
||||
if num < 0 || num >= len(gl.Data[paras[0]].VocalList) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
paras[1] = num
|
||||
data, err := web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(ml.Data) == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无内容, 点歌失败"))
|
||||
return
|
||||
}
|
||||
tex = "请输入歌曲序号\n"
|
||||
for i, v := range ml.Data {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.OriginName)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
case 2:
|
||||
if num < 0 || num >= len(ml.Data) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
paras[2] = num
|
||||
// 最后播放歌曲
|
||||
groupName := gl.Data[paras[0]].Name
|
||||
vtbName := gl.Data[paras[0]].VocalList[paras[1]].OriginName
|
||||
musicName := ml.Data[paras[2]].OriginName
|
||||
recURL := fileURL + ml.Data[paras[2]].Music
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏", groupName, "-", vtbName, "的《", musicName, "》"))
|
||||
recordFile := storePath + fmt.Sprintf("%d-%d-%d", paras[0], paras[1], paras[2]) + path.Ext(recURL)
|
||||
if file.IsExist(recordFile) {
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
err = dlrec(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch(`vtb随机点歌`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var (
|
||||
paras = [3]int{}
|
||||
gl groupsList
|
||||
ml musicList
|
||||
)
|
||||
data, err := web.PostData(getGroupListURL, "application/json", strings.NewReader(`{"PageIndex":1,"PageRows":9999}`))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &gl)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(gl.Data) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 数组为空"))
|
||||
return
|
||||
}
|
||||
paras[0] = rand.Intn(len(gl.Data))
|
||||
for len(gl.Data[paras[0]].VocalList) == 0 {
|
||||
paras[0] = rand.Intn(len(gl.Data))
|
||||
}
|
||||
paras[1] = rand.Intn(len(gl.Data[paras[0]].VocalList))
|
||||
data, err = web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
for len(ml.Data) == 0 {
|
||||
paras[1] = rand.Intn(len(gl.Data[paras[0]].VocalList))
|
||||
data, err = web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
paras[2] = rand.Intn(len(ml.Data))
|
||||
// 最后播放歌曲
|
||||
groupName := gl.Data[paras[0]].Name
|
||||
vtbName := gl.Data[paras[0]].VocalList[paras[1]].OriginName
|
||||
musicName := ml.Data[paras[2]].OriginName
|
||||
recURL := fileURL + ml.Data[paras[2]].Music
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏", groupName, "-", vtbName, "的《", musicName, "》"))
|
||||
recordFile := storePath + fmt.Sprintf("%d-%d-%d", paras[0], paras[1], paras[2]) + path.Ext(recURL)
|
||||
if file.IsExist(recordFile) {
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
err = dlrec(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
})
|
||||
}
|
||||
|
||||
func dlrec(recordFile, recordURL string) error {
|
||||
if file.IsNotExist(recordFile) {
|
||||
data, err := web.RequestDataWithHeaders(web.NewTLS12Client(), recordURL, "GET", func(r *http.Request) error {
|
||||
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
r.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0")
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(recordFile, data, 0666)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
203
plugin/wantquotes/wantquotes.go
Normal file
203
plugin/wantquotes/wantquotes.go
Normal file
@@ -0,0 +1,203 @@
|
||||
// Package wantquotes 据意查句
|
||||
package wantquotes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
wantquotesURL = "https://wantquotes.net"
|
||||
getQrcode = "/api/get_qrcode/"
|
||||
showqrcode = "https://mp.weixin.qq.com/cgi-bin/showqrcode"
|
||||
loginCheck = "/api/login_check/"
|
||||
semantic = "/api/semantic/"
|
||||
semanticURL = wantquotesURL + semantic + "?query=%s&type=%s&unionid=%s&secret=%s"
|
||||
)
|
||||
|
||||
var (
|
||||
typeList = [...]string{"现", "现-名言", "现-佳句", "现-佳句-文学", "现-佳句-诗歌", "现-佳句-其他", "现-网络", "现-台词", "现-台词-影视剧", "现-台词-动漫", "现-台词-综艺",
|
||||
"古", "谚", "谚-谚语", "谚-俗语", "谚-惯用语", "歇"}
|
||||
)
|
||||
|
||||
type getQrcodeRsp struct {
|
||||
Ticket string `json:"ticket"`
|
||||
SceneID string `json:"scene_id"`
|
||||
}
|
||||
|
||||
type loginCheckRsp struct {
|
||||
Login int `json:"login"`
|
||||
Secret string `json:"secret"`
|
||||
Unionid string `json:"unionid"`
|
||||
}
|
||||
|
||||
type semanticRsp struct {
|
||||
Quotes []Quotes `json:"quotes"`
|
||||
TopSim float64 `json:"top_sim"`
|
||||
}
|
||||
|
||||
// Quotes 名句结构体
|
||||
type Quotes struct {
|
||||
Quote string `json:"quote"`
|
||||
SourceType string `json:"source_type"`
|
||||
Author string `json:"author"`
|
||||
Work string `json:"work"`
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.Register("wantquotes", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Extra: control.ExtraFromString("wantquotes"),
|
||||
Brief: "据意查句",
|
||||
Help: "- 据意查句 大海 (需登录据意查句)\n" +
|
||||
"- 登录据意查句",
|
||||
PrivateDataFolder: "wantquotes",
|
||||
})
|
||||
|
||||
// 开启
|
||||
engine.OnRegex(`^据意查句\s?(.{1,25})$`, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
quotesType := ctx.State["quotesType"].(string)
|
||||
var key string
|
||||
manager := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
err := manager.GetExtra(&key)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[wantquotes] get api key:", key)
|
||||
unionid, secret, _ := strings.Cut(key, "|")
|
||||
apiURL := fmt.Sprintf(semanticURL, url.QueryEscape(keyword), url.QueryEscape(quotesType), url.QueryEscape(unionid), url.QueryEscape(secret))
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), apiURL, "GET", wantquotesURL, web.RandUA(), nil)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var rsp semanticRsp
|
||||
err = json.Unmarshal(data, &rsp)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
m := make(message.Message, 0, len(rsp.Quotes))
|
||||
text := strings.Builder{}
|
||||
for _, v := range rsp.Quotes {
|
||||
text.WriteString(v.Quote)
|
||||
text.WriteString("\n—— ")
|
||||
text.WriteString(v.Author)
|
||||
text.WriteString(" 《")
|
||||
text.WriteString(v.Work)
|
||||
text.WriteString("》")
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
|
||||
text.Reset()
|
||||
}
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch(`登录据意查句`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
getQrcodeData, err := web.RequestDataWith(web.NewDefaultClient(), wantquotesURL+getQrcode, "GET", wantquotesURL, web.RandUA(), nil)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var qrRsp getQrcodeRsp
|
||||
err = json.Unmarshal(getQrcodeData, &qrRsp)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
showQrcodeData, err := web.RequestDataWith(web.NewDefaultClient(), showqrcode+"?ticket="+qrRsp.Ticket, "GET", "", web.RandUA(), nil)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("WantQuotes\n微信扫码登录\n首次登录需关注公众号"))
|
||||
ctx.SendChain(message.ImageBytes(showQrcodeData))
|
||||
|
||||
ticker := time.NewTicker(2 * time.Second) // 创建每秒触发一次的定时器
|
||||
defer ticker.Stop()
|
||||
count := 0
|
||||
for range ticker.C {
|
||||
count++
|
||||
if count == 60 {
|
||||
ctx.SendChain(message.Text("据意查句登录超时,请重新登录"))
|
||||
return
|
||||
}
|
||||
loginCheckData, err := web.RequestDataWith(web.NewDefaultClient(), wantquotesURL+loginCheck+"?scene_id="+qrRsp.SceneID, "GET", "", web.RandUA(), nil)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var lcr loginCheckRsp
|
||||
err = json.Unmarshal(loginCheckData, &lcr)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if lcr.Login == 1 {
|
||||
manager := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
err := manager.SetExtra(lcr.Unionid + "|" + lcr.Secret)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("据意查句登录成功"))
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func getPara(ctx *zero.Ctx) bool {
|
||||
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
tex := strings.Builder{}
|
||||
tex.WriteString("请下列选择查询名句的类型\n")
|
||||
for i, v := range typeList {
|
||||
tex.WriteString(strconv.Itoa(i))
|
||||
tex.WriteString(". ")
|
||||
tex.WriteString(v)
|
||||
tex.WriteString("\n")
|
||||
}
|
||||
base64Str, err := text.RenderToBase64(tex.String(), text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("图片生成错误了, ", zero.BotConfig.NickName[0], "帮你选择查询名句类型"))
|
||||
ctx.State["quotesType"] = typeList[0]
|
||||
return true
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(base64Str)))
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 10):
|
||||
ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择查询名句类型"))
|
||||
ctx.State["quotesType"] = typeList[0]
|
||||
return true
|
||||
case c := <-recv:
|
||||
msg := c.Event.Message.ExtractPlainText()
|
||||
num, _ := strconv.Atoi(msg)
|
||||
if num < 0 || num >= len(typeList) {
|
||||
ctx.SendChain(message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
ctx.State["quotesType"] = typeList[num]
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package warframeapi
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
)
|
||||
|
||||
@@ -27,7 +31,11 @@ func newwfapi() (w wfapi, err error) {
|
||||
// 获取Warframe市场的售价表,并进行排序,cn_name为物品中文名称,onlyMaxRank表示只取最高等级的物品,返回物品售价表,物品信息,物品英文
|
||||
func getitemsorder(cnName string, onlyMaxRank bool) (od orders, it *itemsInSet, n string, err error) {
|
||||
var wfapiio wfAPIItemsOrders
|
||||
data, err := web.RequestDataWithHeaders(&http.Client{}, fmt.Sprintf("https://api.warframe.market/v1/items/%s/orders?include=item", cnName), "GET", func(request *http.Request) error {
|
||||
data, err := web.RequestDataWithHeaders(&http.Client{Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
},
|
||||
}}, fmt.Sprintf("https://api.warframe.market/v1/items/%s/orders?include=item", cnName), "GET", func(request *http.Request) error {
|
||||
request.Header.Add("Accept", "application/json")
|
||||
request.Header.Add("Platform", "pc")
|
||||
return nil
|
||||
@@ -68,27 +76,44 @@ func getitemsorder(cnName string, onlyMaxRank bool) (od orders, it *itemsInSet,
|
||||
return
|
||||
}
|
||||
|
||||
func newwm() (wmitems map[string]items, itemNames []string) {
|
||||
var itemapi wfAPIItem // WarFrame市场的数据实例
|
||||
type wmdata struct {
|
||||
wmitems map[string]items
|
||||
itemNames []string
|
||||
}
|
||||
|
||||
data, err := web.RequestDataWithHeaders(&http.Client{}, wfitemurl, "GET", func(request *http.Request) error {
|
||||
var (
|
||||
wderr error
|
||||
wd = syncx.Lazy[*wmdata]{Init: func() (d *wmdata) {
|
||||
d, wderr = newwm()
|
||||
return
|
||||
}}
|
||||
)
|
||||
|
||||
func newwm() (*wmdata, error) {
|
||||
var itemapi wfAPIItem // WarFrame市场的数据实例
|
||||
var wd wmdata
|
||||
data, err := web.RequestDataWithHeaders(&http.Client{Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
},
|
||||
}}, wfitemurl, "GET", func(request *http.Request) error {
|
||||
request.Header.Add("Accept", "application/json")
|
||||
request.Header.Add("Language", "zh-hans")
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return &wd, err
|
||||
}
|
||||
err = json.Unmarshal(data, &itemapi)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return &wd, err
|
||||
}
|
||||
|
||||
wmitems = make(map[string]items, len(itemapi.Payload.Items)*4)
|
||||
itemNames = make([]string, len(itemapi.Payload.Items))
|
||||
wd.wmitems = make(map[string]items, len(itemapi.Payload.Items)*4)
|
||||
wd.itemNames = make([]string, len(itemapi.Payload.Items))
|
||||
for i, v := range itemapi.Payload.Items {
|
||||
wmitems[v.ItemName] = v
|
||||
itemNames[i] = v.ItemName
|
||||
wd.wmitems[v.ItemName] = v
|
||||
wd.itemNames[i] = v.ItemName
|
||||
}
|
||||
return
|
||||
logrus.Infoln("[wfapi] 获取", len(wd.itemNames), "项内容")
|
||||
return &wd, nil
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ import (
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var wmitems, itemNames = newwm()
|
||||
|
||||
func init() {
|
||||
eng := control.Register("warframeapi", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
@@ -234,10 +233,24 @@ func init() {
|
||||
ctx.SendChain(message.Text("已拉取服务器时间并同步到本地模拟"))
|
||||
})
|
||||
// 根据名称从Warframe市场查询物品售价
|
||||
eng.OnPrefix(".wm ").SetBlock(true).
|
||||
eng.OnPrefix(".wm ", func(ctx *zero.Ctx) bool {
|
||||
if wd.Get().wmitems == nil || wd.Get().itemNames == nil {
|
||||
if wderr != nil { // 获取失败
|
||||
ctx.SendChain(message.Text("ERROR: 获取Warframe市场物品列表失败: ", wderr))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR: Warframe市场物品列表为空!"))
|
||||
}
|
||||
wd = syncx.Lazy[*wmdata]{Init: func() (d *wmdata) {
|
||||
d, wderr = newwm()
|
||||
return
|
||||
}}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 根据输入的名称, 从游戏物品名称列表中进行模糊搜索
|
||||
sol := fuzzy.FindNormalizedFold(ctx.State["args"].(string), itemNames)
|
||||
sol := fuzzy.FindNormalizedFold(ctx.State["args"].(string), wd.Get().itemNames)
|
||||
// 物品名称
|
||||
var name string
|
||||
|
||||
@@ -282,16 +295,17 @@ func init() {
|
||||
if onlymaxrank {
|
||||
msgs = msgs[:0]
|
||||
}
|
||||
sells, iteminfo, txt, err := getitemsorder(wmitems[name].URLName, onlymaxrank)
|
||||
|
||||
sells, iteminfo, txt, err := getitemsorder(wd.Get().wmitems[name].URLName, onlymaxrank)
|
||||
if !onlymaxrank {
|
||||
if iteminfo.ZhHans.WikiLink == "" {
|
||||
msgs = append(msgs, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image("https://warframe.market/static/assets/"+wmitems[name].Thumb),
|
||||
message.Text("\n", wmitems[name].ItemName)))
|
||||
message.Image("https://warframe.market/static/assets/"+wd.Get().wmitems[name].Thumb),
|
||||
message.Text("\n", wd.Get().wmitems[name].ItemName)))
|
||||
} else {
|
||||
msgs = append(msgs, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image("https://warframe.market/static/assets/"+wmitems[name].Thumb),
|
||||
message.Text("\n", wmitems[name].ItemName, "\nwiki: ", iteminfo.ZhHans.WikiLink)))
|
||||
message.Image("https://warframe.market/static/assets/"+wd.Get().wmitems[name].Thumb),
|
||||
message.Text("\n", wd.Get().wmitems[name].ItemName, "\nwiki: ", iteminfo.ZhHans.WikiLink)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,9 @@ func (w *world) refresh(api *wfapi) {
|
||||
|
||||
w.w[2].NextTime = api.CambionCycle.Expiry.Local()
|
||||
w.w[2].IsDay = api.CambionCycle.Active == "fass"
|
||||
for _, t := range w.w {
|
||||
t.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// 游戏时间更新
|
||||
|
||||
@@ -100,7 +100,7 @@ func init() { // 插件主体
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
vilginfo.db.DBPath = engine.DataFolder() + "ernieVilg.db"
|
||||
err := vilginfo.db.Open(time.Hour * 24)
|
||||
err := vilginfo.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return false
|
||||
@@ -302,7 +302,7 @@ func init() { // 插件主体
|
||||
))
|
||||
getmodeldb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
modelinfo.db.DBPath = engine.DataFolder() + "ernieModel.db"
|
||||
err := modelinfo.db.Open(time.Hour * 24)
|
||||
err := modelinfo.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return false
|
||||
|
||||
65
plugin/wife/main.go
Normal file
65
plugin/wife/main.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// Package wife 抽老婆
|
||||
package wife
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("wife", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "- 抽老婆",
|
||||
Brief: "从老婆库抽每日老婆",
|
||||
PublicDataFolder: "Wife",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
_ = os.MkdirAll(engine.DataFolder()+"wives", 0755)
|
||||
cards := []string{}
|
||||
engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
data, err := engine.GetLazyData("wife.json", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = json.Unmarshal(data, &cards)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infof("[wife]加载%d个老婆", len(cards))
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))]
|
||||
data, err := engine.GetLazyData("wives/"+card, true)
|
||||
card, _, _ = strings.Cut(card, ".")
|
||||
if err != nil {
|
||||
ctx.SendChain(
|
||||
message.At(ctx.Event.UserID),
|
||||
message.Text("今天的二次元老婆是~【", card, "】哒\n【图片下载失败: ", err, "】"),
|
||||
)
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(
|
||||
message.At(ctx.Event.UserID),
|
||||
message.Text("今天的二次元老婆是~【", card, "】哒"),
|
||||
message.ImageBytes(data),
|
||||
); id.ID() == 0 {
|
||||
ctx.SendChain(
|
||||
message.At(ctx.Event.UserID),
|
||||
message.Text("今天的二次元老婆是~【", card, "】哒\n【图片发送失败, 请联系维护者】"),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func init() {
|
||||
var secondname string
|
||||
if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" {
|
||||
qq, _ := strconv.ParseInt(ctx.Event.Message[1].Data["qq"], 10, 64)
|
||||
secondname = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").Str
|
||||
secondname = ctx.GetThisGroupMemberInfo(qq, false).Get("nickname").Str
|
||||
}
|
||||
name = ctx.Event.Sender.NickName
|
||||
var text string
|
||||
|
||||
2
run.bat
2
run.bat
@@ -3,5 +3,5 @@ go env -w GOPROXY=https://goproxy.cn,direct
|
||||
go env -w GO111MODULE=auto
|
||||
go mod tidy
|
||||
::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe
|
||||
go run main.go main_win.go
|
||||
go run main.go
|
||||
pause
|
||||
|
||||
2
run.sh
2
run.sh
@@ -3,4 +3,4 @@ go env -w GOPROXY=https://goproxy.cn,direct
|
||||
go env -w GO111MODULE=auto
|
||||
go mod tidy
|
||||
#go build -ldflags="-s -w" -o ZeroBot-Plugin
|
||||
go run main.go
|
||||
go run main.go
|
||||
|
||||
103
winres/gen/json.go
Normal file
103
winres/gen/json.go
Normal file
@@ -0,0 +1,103 @@
|
||||
// Package main generates winres.json
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
const js = `{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0000": [
|
||||
"icon.png",
|
||||
"icon16.png"
|
||||
]
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {
|
||||
"name": "ZeroBot-Plugin",
|
||||
"version": "%s"
|
||||
},
|
||||
"description": "",
|
||||
"minimum-os": "vista",
|
||||
"execution-level": "as invoker",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "system",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "%s",
|
||||
"product_version": "%s",
|
||||
"timestamp": "%s"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"Comments": "OneBot plugins based on ZeroBot",
|
||||
"CompanyName": "FloatTech",
|
||||
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
"FileVersion": "%s",
|
||||
"InternalName": "",
|
||||
"LegalCopyright": "%s",
|
||||
"LegalTrademarks": "",
|
||||
"OriginalFilename": "ZBP.EXE",
|
||||
"PrivateBuild": "",
|
||||
"ProductName": "ZeroBot-Plugin",
|
||||
"ProductVersion": "%s",
|
||||
"SpecialBuild": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
const timeformat = `2006-01-02T15:04:05+08:00`
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("winres.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
i := strings.LastIndex(banner.Version, "-")
|
||||
if i <= 0 {
|
||||
i = len(banner.Version)
|
||||
}
|
||||
commitcnt := strings.Builder{}
|
||||
commitcnt.WriteString(banner.Version[1:i])
|
||||
commitcnt.WriteByte('.')
|
||||
commitcntcmd := exec.Command("git", "rev-list", "--count", "HEAD")
|
||||
commitcntcmd.Stdout = &commitcnt
|
||||
err = commitcntcmd.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fv := commitcnt.String()[:commitcnt.Len()-1]
|
||||
_, err = fmt.Fprintf(f, js, fv, fv, banner.Version, time.Now().Format(timeformat), fv, banner.Copyright+". All Rights Reserved.", banner.Version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
BIN
winres/icon.png
Normal file
BIN
winres/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
BIN
winres/icon16.png
Normal file
BIN
winres/icon16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
4
winres/init.go
Normal file
4
winres/init.go
Normal file
@@ -0,0 +1,4 @@
|
||||
// Package winres 生成windows资源
|
||||
package winres
|
||||
|
||||
//go:generate go run github.com/FloatTech/ZeroBot-Plugin/winres/gen
|
||||
62
winres/winres.json
Normal file
62
winres/winres.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0000": [
|
||||
"icon.png",
|
||||
"icon16.png"
|
||||
]
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {
|
||||
"name": "ZeroBot-Plugin",
|
||||
"version": "1.7.3.1842"
|
||||
},
|
||||
"description": "",
|
||||
"minimum-os": "vista",
|
||||
"execution-level": "as invoker",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "system",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "1.7.3.1842",
|
||||
"product_version": "v1.7.3",
|
||||
"timestamp": "2023-08-28T16:14:29+08:00"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"Comments": "OneBot plugins based on ZeroBot",
|
||||
"CompanyName": "FloatTech",
|
||||
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
"FileVersion": "1.7.3.1842",
|
||||
"InternalName": "",
|
||||
"LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.",
|
||||
"LegalTrademarks": "",
|
||||
"OriginalFilename": "ZBP.EXE",
|
||||
"PrivateBuild": "",
|
||||
"ProductName": "ZeroBot-Plugin",
|
||||
"ProductVersion": "v1.7.3",
|
||||
"SpecialBuild": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user