mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-07 07:40:21 +00:00
Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bab5c4c308 | ||
|
|
e0891200af | ||
|
|
b050b5d5b5 | ||
|
|
2ff164c2df | ||
|
|
cab917d054 | ||
|
|
dfe6d347a5 | ||
|
|
5c6af1af61 | ||
|
|
d7cdfb1544 | ||
|
|
cf0e87ab9a | ||
|
|
0a33224571 | ||
|
|
dd878f7dfe | ||
|
|
ac52c9cfca | ||
|
|
ece68dae9b | ||
|
|
6c20f22548 | ||
|
|
6f2c9f7fc0 | ||
|
|
b8858f0acd | ||
|
|
9c65383a7c | ||
|
|
a006b30392 | ||
|
|
54c67e30f4 | ||
|
|
61168adb2e | ||
|
|
73b879a6f4 | ||
|
|
a5d2e3dfc3 | ||
|
|
0ea804fc86 | ||
|
|
17bfa2a35c | ||
|
|
ff3d1d1de3 | ||
|
|
3a31802735 | ||
|
|
a514bde4e6 | ||
|
|
7f90ba278a | ||
|
|
2e77703571 | ||
|
|
192eef2bbb | ||
|
|
73ecc47e4c | ||
|
|
714df78ea2 | ||
|
|
f4f50acb1d | ||
|
|
8c24194772 | ||
|
|
844b727859 | ||
|
|
148f271586 | ||
|
|
b062198fae | ||
|
|
1c57a64002 | ||
|
|
13bb760f9f | ||
|
|
6c1257184b | ||
|
|
b0463b3cb4 | ||
|
|
1bb8e8b058 | ||
|
|
209b2e8a1f | ||
|
|
0c55c743f7 | ||
|
|
ba7c6cb0a0 | ||
|
|
d3e587f935 | ||
|
|
36190a4f6a | ||
|
|
54d9486c06 | ||
|
|
fe6130872b | ||
|
|
5e41c15d88 | ||
|
|
e776d02d98 | ||
|
|
cc39d0fdb4 | ||
|
|
1456bed668 | ||
|
|
8d2da4199d | ||
|
|
50e75b2257 | ||
|
|
a6e82d578a | ||
|
|
5b6ab7e20d | ||
|
|
23fea2dae9 | ||
|
|
97c1985479 | ||
|
|
035ed3bd13 | ||
|
|
3e04445cac | ||
|
|
f0078bb23f | ||
|
|
1a8ebe02fb | ||
|
|
de986d8be8 | ||
|
|
ab7daa6bdc | ||
|
|
0bf3253cbb | ||
|
|
21269ee835 | ||
|
|
df927d0b7f | ||
|
|
6a3456f4b0 | ||
|
|
db1d583a37 | ||
|
|
146ea6812e | ||
|
|
99b14e183a | ||
|
|
cb52bf6af7 | ||
|
|
a534c9efbd | ||
|
|
7ac397373d | ||
|
|
73c6f4795e | ||
|
|
598efe182c | ||
|
|
a9bb078079 | ||
|
|
673c715d2f | ||
|
|
dbda1b466d | ||
|
|
b7e21fc111 | ||
|
|
6bff62b91b | ||
|
|
5485cc3be9 | ||
|
|
ba0ef37b74 |
20
.github/workflows/pull.yml
vendored
20
.github/workflows/pull.yml
vendored
@@ -1,6 +1,24 @@
|
||||
name: PullLint
|
||||
on: [ pull_request ]
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [assigned, opened, synchronize, reopened]
|
||||
jobs:
|
||||
# This workflow closes invalid PR
|
||||
close-pr:
|
||||
name: closepr
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- name: Close PR if commit message contains ".go"
|
||||
if: contains(github.event.pull_request.title, '.go')
|
||||
uses: superbrothers/close-pull-request@v3
|
||||
with:
|
||||
# Optional. Post a issue comment just before closing a pull request.
|
||||
comment: "非法PR. 请`fork`后修改自己的仓库, 而不是向主仓库提交更改. 如果您确信您的PR是为了给主仓库新增功能或修复bug, 请更改默认PR标题. **注意**: 如果您再次触发本提示, 则有可能导致账号被封禁."
|
||||
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
4
.github/workflows/push.yml
vendored
4
.github/workflows/push.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: golangci-lint
|
||||
- name: Run Lint
|
||||
uses: golangci/golangci-lint-action@master
|
||||
with:
|
||||
version: latest
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
git config --local user.name 'github-actions[bot]'
|
||||
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
git add --all
|
||||
git commit -m "🎨 改进代码样式"
|
||||
git commit -m "chore(lint): 改进代码样式"
|
||||
|
||||
- name: Create Pull Request
|
||||
if: ${{ !github.head_ref }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ nohup.out
|
||||
zerobot
|
||||
ZeroBot-Plugin*
|
||||
*.syso
|
||||
/.direnv
|
||||
|
||||
113
README.md
113
README.md
@@ -15,11 +15,17 @@
|
||||
[](https://github.com/takayama-lily/oicq)
|
||||
[](https://github.com/mamoe/mirai)
|
||||
|
||||
|
||||
|
||||
[](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin)
|
||||
[](https://t.me/zerobotplugin)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
|
||||
|
||||
|
||||
[](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
|
||||
[](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
|
||||
[](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
|
||||
[](https://pd.qq.com/s/fjkx81mnr)
|
||||
[](https://t.me/zerobotplugin)
|
||||
|
||||
本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互
|
||||
@@ -33,6 +39,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
> 专为[后 go-cqhttp 时代](https://github.com/Mrs4s/go-cqhttp/issues/2471)开发迁移的`类zbp`新机器人现已出炉,基于官方api,稳定不风控: [NanoBot-Plugin](https://github.com/FloatTech/NanoBot-Plugin)
|
||||
|
||||
> 如果您不知道什么是 [OneBot](https://github.com/howmanybots/onebot) 或不希望运行多个程序,还可以直接前往 [gocqzbp](https://github.com/FloatTech/gocqzbp) 的 [Release](https://github.com/FloatTech/gocqzbp/releases) 页面下载单一可执行文件或前往 [Packages](https://github.com/FloatTech/gocqzbp/pkgs/container/gocqzbp) 页面使用`docker`,运行后按提示登录即可。
|
||||
|
||||
> 如果您对开发插件感兴趣,欢迎加入[ZeroBot-Plugin-Playground](https://github.com/FloatTech/ZeroBot-Plugin-Playground)
|
||||
@@ -234,6 +242,8 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
|
||||
- [x] 列出所有提醒
|
||||
|
||||
- [x] 翻牌
|
||||
|
||||
- [x] 赞我
|
||||
|
||||
- [x] [开启 | 关闭]入群验证
|
||||
|
||||
@@ -951,6 +961,24 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
来份萝莉
|
||||
```
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>桑帛云 API</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolimi"`
|
||||
|
||||
- [x] 随机妹子
|
||||
|
||||
- [x] 随机绕口令
|
||||
|
||||
- [x] 颜值鉴定[图片]
|
||||
|
||||
- [x] 随机情话
|
||||
|
||||
- [x] 发病 嘉然
|
||||
|
||||
- [x] 让[嘉然|塔菲|东雪莲|懒羊羊|科比|孙笑川|陈泽|丁真|空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然]说我测尼玛
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>MagicPrompt-Stable-Diffusion吟唱提示</summary>
|
||||
@@ -959,6 +987,23 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 吟唱提示[xxxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>钓鱼模拟器</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/mcfish"`
|
||||
|
||||
- [x] 钓鱼商店
|
||||
- [x] 购买xxx [数量]
|
||||
- [x] 出售xxx [数量]
|
||||
- [x] 钓鱼背包
|
||||
- [x] 装备[xx竿|三叉戟|美西螈]
|
||||
- [x] 附魔[诱钓|海之眷顾]
|
||||
- [x] 修复鱼竿
|
||||
- [x] 合成[xx竿|三叉戟]
|
||||
- [x] 进行钓鱼
|
||||
- [x] 进行n次钓鱼
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>简易midi音乐制作</summary>
|
||||
@@ -987,10 +1032,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe"`
|
||||
|
||||
- [x] 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)
|
||||
|
||||
- [x] 让[수아|미미르|아린|연화|유화|선배]说(韩语)
|
||||
|
||||
- [x] 让[派蒙|空|荧|阿贝多|枫原万叶|温迪|八重神子|纳西妲|钟离|诺艾尔|凝光|托马|北斗|莫娜|荒泷一斗|提纳里|芭芭拉|艾尔海森|雷电将军|赛诺|琴|班尼特|五郎|神里绫华|迪希雅|夜兰|辛焱|安柏|宵宫|云堇|妮露|烟绯|鹿野院平藏|凯亚|达达利亚|迪卢克|可莉|早柚|香菱|重云|刻晴|久岐忍|珊瑚宫心海|迪奥娜|戴因斯雷布|魈|神里绫人|丽莎|优菈|凯瑟琳|雷泽|菲谢尔|九条裟罗|甘雨|行秋|胡桃|迪娜泽黛|柯莱|申鹤|砂糖|萍姥姥|奥兹|罗莎莉亚|式大将|哲平|坎蒂丝|托克|留云借风真君|昆钧|塞琉斯|多莉|大肉丸|莱依拉|散兵|拉赫曼|杜拉夫|阿守|玛乔丽|纳比尔|海芭夏|九条镰治|阿娜耶|阿晃|阿扎尔|七七|博士|白术|埃洛伊|大慈树王|女士|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|芽衣|雷之律者|阿波尼亚]说(中文)
|
||||
|
||||
</details>
|
||||
@@ -1225,14 +1266,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 设置 saucenao api key [apikey]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>叔叔的AI二次元图片放大</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale"`
|
||||
|
||||
- [x] 放大图片[图片]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>签到得分</summary>
|
||||
@@ -1492,6 +1525,18 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 团队七阶猜单词
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>鬼东西</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf"`
|
||||
|
||||
- [x] 鬼东西列表
|
||||
|
||||
- [x] 查询鬼东西[序号][@xxx]
|
||||
|
||||
- 注:由于需要科学,默认注释。
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>一些游戏王插件</summary>
|
||||
@@ -1533,15 +1578,39 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>鬼东西</summary>
|
||||
<summary>遇见API</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf"`
|
||||
|
||||
- [x] 鬼东西列表
|
||||
|
||||
- [x] 查询鬼东西[序号][@xxx]
|
||||
|
||||
- 注:由于需要科学,默认注释。
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/yujn"`
|
||||
|
||||
- [x] 小姐姐视频
|
||||
- [x] 小姐姐视频2
|
||||
- [x] 黑丝视频
|
||||
- [x] 白丝视频
|
||||
- [x] 欲梦视频
|
||||
- [x] 甜妹视频
|
||||
- [x] 双倍快乐
|
||||
- [x] 纯情女高
|
||||
- [x] 萝莉视频
|
||||
- [x] 玉足视频
|
||||
- [x] 帅哥视频
|
||||
- [x] 热舞视频
|
||||
- [x] 吊带视频
|
||||
- [x] 汉服视频
|
||||
- [x] 极品狱卒
|
||||
- [x] 清纯视频
|
||||
- [x] 快手变装
|
||||
- [x] 抖音变装
|
||||
- [x] 萌娃视频
|
||||
- [x] 穿搭视频
|
||||
- [x] 完美身材
|
||||
- [x] 御姐撒娇
|
||||
- [x] 绿茶语音
|
||||
- [x] 怼人语音
|
||||
- [x] 随机骚话
|
||||
- [x] 随机污句子
|
||||
- [x] 随机美句
|
||||
- [x] 土味情话
|
||||
- [x] 让[lulu]说我测尼玛
|
||||
|
||||
</details>
|
||||
|
||||
@@ -1564,7 +1633,7 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] @Bot 任意文本(任意一句话回复)
|
||||
|
||||
- [x] 设置回复模式[青云客 | 小爱 | ChatGPT]
|
||||
- [x] 设置文字回复模式[婧枫|沫沫|青云客|小爱|ChatGPT]
|
||||
|
||||
- [x] 设置 ChatGPT api key xxx
|
||||
|
||||
|
||||
2
data
2
data
Submodule data updated: d5ec04118f...9b983625ca
25
default.nix
Normal file
25
default.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
pkgs ? (
|
||||
let
|
||||
inherit (builtins) fetchTree fromJSON readFile;
|
||||
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
|
||||
in
|
||||
import (fetchTree nixpkgs.locked) {
|
||||
overlays = [
|
||||
(import "${fetchTree gomod2nix.locked}/overlay.nix")
|
||||
];
|
||||
}
|
||||
),
|
||||
buildGoApplication ? pkgs.buildGoApplication,
|
||||
}:
|
||||
buildGoApplication {
|
||||
pname = "ZeroBot-Plugin";
|
||||
version = "1.7.6";
|
||||
pwd = ./.;
|
||||
src = ./.;
|
||||
# spec go version manually bcs
|
||||
# https://github.com/nix-community/gomod2nix/blob/30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6/builder/default.nix#L130
|
||||
# do no work
|
||||
go = pkgs.go_1_20;
|
||||
modules = ./gomod2nix.toml;
|
||||
}
|
||||
85
flake.lock
generated
Normal file
85
flake.lock
generated
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gomod2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705314449,
|
||||
"narHash": "sha256-yfQQ67dLejP0FLK76LKHbkzcQqNIrux6MFe32MMFGNQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "gomod2nix",
|
||||
"rev": "30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "gomod2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1705856552,
|
||||
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"gomod2nix": "gomod2nix",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
36
flake.nix
Normal file
36
flake.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
description = "基于 ZeroBot 的 OneBot 插件";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
|
||||
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
gomod2nix,
|
||||
}: (
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
||||
# This has no effect on other platforms.
|
||||
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
||||
in {
|
||||
# doCheck will fail at write files
|
||||
packages.default =
|
||||
(callPackage ./. {
|
||||
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
|
||||
})
|
||||
.overrideAttrs (_: {doCheck = false;});
|
||||
devShells.default = callPackage ./shell.nix {
|
||||
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
|
||||
};
|
||||
formatter = pkgs.alejandra;
|
||||
})
|
||||
);
|
||||
}
|
||||
22
go.mod
22
go.mod
@@ -4,15 +4,15 @@ go 1.20
|
||||
|
||||
require (
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba
|
||||
github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20240423052513-58ad4b85322a
|
||||
github.com/FloatTech/floatbox v0.0.0-20240304064110-78a83f1af9a6
|
||||
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/sqlite v1.6.3
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf
|
||||
github.com/FloatTech/zbpctrl v1.6.0
|
||||
github.com/FloatTech/zbputils v1.7.1-0.20231107124514-083e678fbfe6
|
||||
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
|
||||
@@ -29,15 +29,18 @@ require (
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/jozsefsallai/gophersauce v1.0.1
|
||||
github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5
|
||||
github.com/lithammer/fuzzysearch v1.1.5
|
||||
github.com/liuzl/gocc v0.0.0-20231231122217-0372e1059ca5
|
||||
github.com/mroth/weightedrand v1.0.0
|
||||
github.com/notnil/chess v1.9.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
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/sirupsen/logrus v1.9.3
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.4
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54
|
||||
gitlab.com/gomidi/midi/v2 v2.0.25
|
||||
golang.org/x/image v0.3.0
|
||||
golang.org/x/sys v0.8.0
|
||||
@@ -46,6 +49,8 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
|
||||
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca // indirect
|
||||
github.com/antchfx/xpath v1.2.1 // indirect
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
|
||||
github.com/faiface/beep v1.1.0 // indirect
|
||||
@@ -64,6 +69,8 @@ require (
|
||||
github.com/jfreymuth/vorbis v1.0.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
|
||||
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d // indirect
|
||||
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
|
||||
@@ -74,6 +81,7 @@ require (
|
||||
github.com/quic-go/qpack v0.4.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/tetratelabs/wazero v1.5.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
|
||||
44
go.sum
44
go.sum
@@ -2,29 +2,33 @@ 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.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/AnimeAPI v1.7.1-0.20240423052513-58ad4b85322a h1:K+1RAkIBb+3kkSxSkSTdTugSIsXJXrjEbwuv/BwUsP8=
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20240423052513-58ad4b85322a/go.mod h1:bNHsYcUd1+Y5Al3CR6tdzKxcc0XLivXjmUsL9xG6sSw=
|
||||
github.com/FloatTech/floatbox v0.0.0-20240304064110-78a83f1af9a6 h1:Vaj8ulVbN8vTD4W7aj+BYeT6x8iKFneDnkgBCezomDY=
|
||||
github.com/FloatTech/floatbox v0.0.0-20240304064110-78a83f1af9a6/go.mod h1:TeTlp+hTxpJti4JSdmUqzxGEr4wUBOVct9YWBepilpc=
|
||||
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/sqlite v1.6.3 h1:MQkqBNlkPuCoKQQgoNLuTL/2Ci3tBTFAnVYBdD0Wy4M=
|
||||
github.com/FloatTech/sqlite v1.6.3/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.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/FloatTech/zbpctrl v1.6.0 h1:BWg9aRR4bUCmNNKj6GPH0TmzFRWYImIi6rQcQTTYRs4=
|
||||
github.com/FloatTech/zbpctrl v1.6.0/go.mod h1:i3GGM5K4HiDsXzvmXQSYoH1QT3tsSaAHjRzHwKGsHG0=
|
||||
github.com/FloatTech/zbputils v1.7.1-0.20231107124514-083e678fbfe6 h1:EMdvLnt6i5dSFloLD1klOM8bdoFZqTtILcMCciOpcMo=
|
||||
github.com/FloatTech/zbputils v1.7.1-0.20231107124514-083e678fbfe6/go.mod h1:4oXgjQ6bGosAF4GbuL/keAhTrGWOV369X5X0ISFebmw=
|
||||
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=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 h1:bBmmB7he0iVN4m5mcehfheeRUEer/Avo4ujnxI3uCqs=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5/go.mod h1:0UcFaCkhp6vZw6l5Dpq0Dp673CoF9GdvA8lTfst0GiU=
|
||||
github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d h1:ir/IFJU5xbja5UaBEQLjcvn7aAU01nqU/NUyOBEU+ew=
|
||||
github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:PRWNwWq0yifz6XDPZu48aSld8BWwBfr2JKB2bGWiEd4=
|
||||
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca h1:kWzLcty5V2rzOqJM7Tp/MfSX0RMSI1x4IOLApEefYxA=
|
||||
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/antchfx/htmlquery v1.2.5 h1:1lXnx46/1wtv1E/kzmH8vrfMuUKYgkdDBA9pIdMJnk4=
|
||||
github.com/antchfx/htmlquery v1.2.5/go.mod h1:2MCVBzYVafPBmKbrmwB9F5xdd+IEgRY61ci2oOsOQVw=
|
||||
@@ -127,6 +131,8 @@ 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/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5 h1:BXnB1Gz4y/zwQh+ZFNy7rgd+ZfMOrwRr4uZSHEI+ieY=
|
||||
github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5/go.mod h1:c9+VS9GaommgIOzNWb5ze4lYwfT8BZ2UDyGiuQTT7yc=
|
||||
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=
|
||||
@@ -138,6 +144,12 @@ github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c=
|
||||
github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
|
||||
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d h1:qSmEGTgjkESUX5kPMSGJ4pcBUtYVDdkNzMrjQyvRvp0=
|
||||
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:x7SghIWwLVcJObXbjK7S2ENsT1cAcdJcPl7dRaSFog0=
|
||||
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d h1:hTRDIpJ1FjS9ULJuEzu69n3qTgc18eI+ztw/pJv47hs=
|
||||
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d/go.mod h1:7xD3p0XnHvJFQ3t/stEJd877CSIMkH/fACVWen5pYnc=
|
||||
github.com/liuzl/gocc v0.0.0-20231231122217-0372e1059ca5 h1:wnbHIeP1UX8ClYEWKGnw66PfYvReCHu9G5lXSte3Sqc=
|
||||
github.com/liuzl/gocc v0.0.0-20231231122217-0372e1059ca5/go.mod h1:7KaV9YIR92M1FpbczAcfYQ3UZ5ayT27pNtunDmXvLBo=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||
@@ -152,6 +164,8 @@ 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/notnil/chess v1.9.0 h1:YMxR5kUVjtwcuFptGU0/3q7eG3MSHQNbg0VUekvRKV0=
|
||||
github.com/notnil/chess v1.9.0/go.mod h1:cRuJUIBFq9Xki05TWHJxHYkC+fFpq45IWwk94DdlCrA=
|
||||
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=
|
||||
@@ -177,8 +191,8 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV
|
||||
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=
|
||||
github.com/shirou/gopsutil/v3 v3.23.1/go.mod h1:NN6mnm5/0k8jw4cBfCnJtr5L7ErOTg18tMNpgFkn0hA=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
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=
|
||||
@@ -188,6 +202,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0=
|
||||
github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
@@ -200,8 +216,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.7.4 h1:+148rELpf/FCDW2EuvKqpb9bNKcwKRtoh16s2sIb5SE=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.4/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54 h1:s7k0Pf4RoeCUHe9rlVsg0mqAH3WO7xLMhe9qih/CxnE=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54/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=
|
||||
|
||||
284
gomod2nix.toml
Normal file
284
gomod2nix.toml
Normal file
@@ -0,0 +1,284 @@
|
||||
schema = 3
|
||||
|
||||
[mod]
|
||||
[mod."github.com/Baidu-AIP/golang-sdk"]
|
||||
version = "v1.1.1"
|
||||
hash = "sha256-hKshA0K92bKuK92mmtM0osVmqLJcSbeobeWSDpQoRCo="
|
||||
[mod."github.com/FloatTech/AnimeAPI"]
|
||||
version = "v1.7.1-0.20231017135344-aefd1d56e900"
|
||||
hash = "sha256-YV9VQ7bA8R5g5dcAsbzS6MicVwDgMu08d9GF4uqXH7M="
|
||||
[mod."github.com/FloatTech/floatbox"]
|
||||
version = "v0.0.0-20231107124407-e38535efa2a2"
|
||||
hash = "sha256-B86GBuJAjeFjhAjNbBF6OO6DTH2/fpPkrdQynwX+sxg="
|
||||
[mod."github.com/FloatTech/gg"]
|
||||
version = "v1.1.3-0.20230226151425-6ea91286ba08"
|
||||
hash = "sha256-AeMzjMK1ZwFERb5xuNAV5PdHp7rzoT4ZF7kZ6Kj2/0s="
|
||||
[mod."github.com/FloatTech/imgfactory"]
|
||||
version = "v0.2.2-0.20230413152719-e101cc3606ef"
|
||||
hash = "sha256-2okFyPQSYIxrc8hxICsbjEM9xq25a3I2A4wmDIYFCg8="
|
||||
[mod."github.com/FloatTech/rendercard"]
|
||||
version = "v0.0.10-0.20230223064326-45d29fa4ede9"
|
||||
hash = "sha256-Zn8agmyWWEC2QQfIBa60jlQrEap9Bps+z1Ekay6Y0cg="
|
||||
[mod."github.com/FloatTech/sqlite"]
|
||||
version = "v1.6.3"
|
||||
hash = "sha256-zWPByEMi89ms67ubPg0fAPIRxfpBC2IRKc0iNVLqkPU="
|
||||
[mod."github.com/FloatTech/ttl"]
|
||||
version = "v0.0.0-20220715042055-15612be72f5b"
|
||||
hash = "sha256-vVQTn7f2dFPNrLqutWbeHMCpEdNi7uPxUzpphzaYPpM="
|
||||
[mod."github.com/FloatTech/zbpctrl"]
|
||||
version = "v1.6.0"
|
||||
hash = "sha256-2ZPGFvSgTWcPOo8+p8kmg590HY2b8v/L3674ba+b7+A="
|
||||
[mod."github.com/FloatTech/zbputils"]
|
||||
version = "v1.7.1-0.20231107124514-083e678fbfe6"
|
||||
hash = "sha256-Bg3aAI8oDx71kWielITcK5Rg2H47/DQZX+4+dO5AtK4="
|
||||
[mod."github.com/RomiChan/syncx"]
|
||||
version = "v0.0.0-20221202055724-5f842c53020e"
|
||||
hash = "sha256-FbmvziRRDEzeXW17IQdyWMWsCVq4fvwKGjbFZqJKAMQ="
|
||||
[mod."github.com/RomiChan/websocket"]
|
||||
version = "v1.4.3-0.20220227141055-9b2c6168c9c5"
|
||||
hash = "sha256-Adx+gvqB+CCoUXx7ebIaBDjVkav+wS5qZPmaqcApBWA="
|
||||
[mod."github.com/adamzy/cedar-go"]
|
||||
version = "v0.0.0-20170805034717-80a9c64b256d"
|
||||
hash = "sha256-N19KTxh70IUBqnchFuWkrJD8uuFOIVqv1iSuN3YFIT0="
|
||||
[mod."github.com/ajstarks/svgo"]
|
||||
version = "v0.0.0-20200320125537-f189e35d30ca"
|
||||
hash = "sha256-ALeRuEJN9jHjGb4wNKJcxC59vVx8Tj7hHikEGkaZZ0s="
|
||||
[mod."github.com/antchfx/htmlquery"]
|
||||
version = "v1.2.5"
|
||||
hash = "sha256-lkpdz+NNHadn0VIshszAZS5ZodOic0sp2d7VN6sIl/M="
|
||||
[mod."github.com/antchfx/xpath"]
|
||||
version = "v1.2.1"
|
||||
hash = "sha256-ffHNkJiraDyjy6NsFDNTfqreiY+DER/93J/i11xUPw8="
|
||||
[mod."github.com/corona10/goimagehash"]
|
||||
version = "v1.1.0"
|
||||
hash = "sha256-HyS8nc7kUNnDaVBDzJ9Ym4pRs83YB4M2vHSRwfm6mr4="
|
||||
[mod."github.com/davidscholberg/go-durationfmt"]
|
||||
version = "v0.0.0-20170122144659-64843a2083d3"
|
||||
hash = "sha256-0rdbpBf3AAjMpxvVEGFb2ImgB2i7vdEhIwCyqJs1iHE="
|
||||
[mod."github.com/disintegration/imaging"]
|
||||
version = "v1.6.2"
|
||||
hash = "sha256-pSeMTPvSkxlthh65LjNYYhPLvCZDkBgVgAGYWW0Aguo="
|
||||
[mod."github.com/ericpauley/go-quantize"]
|
||||
version = "v0.0.0-20200331213906-ae555eb2afa4"
|
||||
hash = "sha256-sMN6D7IlDpDqUWM8ppoE5Sdb7DvLAJaN6qAucBWJ3rs="
|
||||
[mod."github.com/faiface/beep"]
|
||||
version = "v1.1.0"
|
||||
hash = "sha256-66qAbnJjUjhXofxlGCa6G1+vjQcSTyN/POCZvYzHaQo="
|
||||
[mod."github.com/fumiama/ahsai"]
|
||||
version = "v0.1.0"
|
||||
hash = "sha256-lSoos+SFjALcL0ZYPsbOb8wntwn2fcubvSsz0YKgL9c="
|
||||
[mod."github.com/fumiama/cron"]
|
||||
version = "v1.3.0"
|
||||
hash = "sha256-/sN7X8dKXQgv8J+EDzVUB+o+AY9gBC8e1C6sYhaTy1k="
|
||||
[mod."github.com/fumiama/go-base16384"]
|
||||
version = "v1.7.0"
|
||||
hash = "sha256-vTAsBBYe2ISzb2Nba5E96unodZSkhMcqo6hbwR01nz8="
|
||||
[mod."github.com/fumiama/go-registry"]
|
||||
version = "v0.2.6"
|
||||
hash = "sha256-DgkdYYWsCs/bBrIiCHK4tPInv8pTy5/AqwHmI5UPTo8="
|
||||
[mod."github.com/fumiama/go-simple-protobuf"]
|
||||
version = "v0.1.0"
|
||||
hash = "sha256-itOBeIU4PRBANDP79eRWlCDNhNUnde6dgcpUlUbm0zU="
|
||||
[mod."github.com/fumiama/gofastTEA"]
|
||||
version = "v0.0.10"
|
||||
hash = "sha256-FOCbkXoS8s/K54yZbhX5pmaN/ouELnCHZoNS8a90VAg="
|
||||
[mod."github.com/fumiama/gotracemoe"]
|
||||
version = "v0.0.3"
|
||||
hash = "sha256-O3cDkVXu5NG1ZtzubxhH+S91zfgu4uH1L+OiSGYSNXQ="
|
||||
[mod."github.com/fumiama/imgsz"]
|
||||
version = "v0.0.2"
|
||||
hash = "sha256-eYUjP1TKWUrsY++rzg4rezOvmvmjADZFBizIIDHnZtY="
|
||||
[mod."github.com/fumiama/jieba"]
|
||||
version = "v0.0.0-20221203025406-36c17a10b565"
|
||||
hash = "sha256-DvDx1pdldkdaSszrbadM/VwqT9TTSmWl6G6a+ysXYEM="
|
||||
[mod."github.com/fumiama/unibase2n"]
|
||||
version = "v0.0.0-20221020155353-02876e777430"
|
||||
hash = "sha256-//vCLy5/vgId7m9WnRGqmh/wnglboiYz2YzQruIe97o="
|
||||
[mod."github.com/gabriel-vasile/mimetype"]
|
||||
version = "v1.0.4"
|
||||
hash = "sha256-5hl9zBo3nkPt8dZfcLoOix8lAKLm3qIkWhopoS4V34E="
|
||||
[mod."github.com/go-ole/go-ole"]
|
||||
version = "v1.2.6"
|
||||
hash = "sha256-+oxitLeJxYF19Z6g+6CgmCHJ1Y5D8raMi2Cb3M6nXCs="
|
||||
[mod."github.com/go-task/slim-sprig"]
|
||||
version = "v0.0.0-20230315185526-52ccab3ef572"
|
||||
hash = "sha256-D6NjCQbcYC53NdwzyAm4i9M1OjTJIVu4EIt3AD/Vxfg="
|
||||
[mod."github.com/golang/freetype"]
|
||||
version = "v0.0.0-20170609003504-e2365dfdc4a0"
|
||||
hash = "sha256-AHAFBd20/tqxohkWyQkui2bUef9i1HWYgk9LOIFErvA="
|
||||
[mod."github.com/golang/groupcache"]
|
||||
version = "v0.0.0-20210331224755-41bb18bfe9da"
|
||||
hash = "sha256-7Gs7CS9gEYZkbu5P4hqPGBpeGZWC64VDwraSKFF+VR0="
|
||||
[mod."github.com/golang/mock"]
|
||||
version = "v1.6.0"
|
||||
hash = "sha256-fWdnMQisRbiRzGT3ISrUHovquzLRHWvcv1JEsJFZRno="
|
||||
[mod."github.com/google/pprof"]
|
||||
version = "v0.0.0-20210407192527-94a9f03dee38"
|
||||
hash = "sha256-ryvI75ePFCfy0qvAhEFbtB/c/Er7nvLwm7CVASBRhsI="
|
||||
[mod."github.com/google/uuid"]
|
||||
version = "v1.3.0"
|
||||
hash = "sha256-QoR55eBtA94T2tBszyxfDtO7/pjZZSGb5vm7U0Xhs0Y="
|
||||
[mod."github.com/hajimehoshi/oto"]
|
||||
version = "v0.7.1"
|
||||
hash = "sha256-eRgbEbsziY5F0oI7wAe29FepZG7uGmq2M4deouDHcXI="
|
||||
[mod."github.com/jfreymuth/oggvorbis"]
|
||||
version = "v1.0.1"
|
||||
hash = "sha256-DpkiTLxAA/iCoiylpNRvMzvaDWtK+U4UMJYNnnCmJMU="
|
||||
[mod."github.com/jfreymuth/vorbis"]
|
||||
version = "v1.0.0"
|
||||
hash = "sha256-6kTol+g3NnZ3MazD786fvraw7ydUf0RWNBzHpzgN9Jk="
|
||||
[mod."github.com/jinzhu/gorm"]
|
||||
version = "v1.9.16"
|
||||
hash = "sha256-qKEwgNE8NxcX1uzT20LwC1TKVmve/nIy+oxdAKlxAuc="
|
||||
[mod."github.com/jinzhu/inflection"]
|
||||
version = "v1.0.0"
|
||||
hash = "sha256-3h3pHib5MaCXKyKLIMyQnSptDJ16kPjCOQPoEBoQsZg="
|
||||
[mod."github.com/jozsefsallai/gophersauce"]
|
||||
version = "v1.0.1"
|
||||
hash = "sha256-29DsfnGmK51DPunR/leRBKCcokN/yLoB7S2HxCsqtgY="
|
||||
[mod."github.com/kanrichan/resvg-go"]
|
||||
version = "v0.0.2-0.20231001163256-63db194ca9f5"
|
||||
hash = "sha256-plRZ3yhyCafCXmAD4vnFUoCTRsHmLp7Jn9gFKcEKbds="
|
||||
[mod."github.com/kr/pretty"]
|
||||
version = "v0.3.1"
|
||||
hash = "sha256-DlER7XM+xiaLjvebcIPiB12oVNjyZHuJHoRGITzzpKU="
|
||||
[mod."github.com/lithammer/fuzzysearch"]
|
||||
version = "v1.1.5"
|
||||
hash = "sha256-2vJLR4z5o3ch9q4tV7NT5RnfNxEdYspjI8YxQao2A6w="
|
||||
[mod."github.com/liuzl/cedar-go"]
|
||||
version = "v0.0.0-20170805034717-80a9c64b256d"
|
||||
hash = "sha256-N19KTxh70IUBqnchFuWkrJD8uuFOIVqv1iSuN3YFIT0="
|
||||
[mod."github.com/liuzl/da"]
|
||||
version = "v0.0.0-20180704015230-14771aad5b1d"
|
||||
hash = "sha256-J43kwDFmB6LzDhS3Ig/4ddZUTXz1cKztbTA3hILScs8="
|
||||
[mod."github.com/liuzl/gocc"]
|
||||
version = "v0.0.0-20231231122217-0372e1059ca5"
|
||||
hash = "sha256-Dr1xDbO+eR4Y/EpPgQ/S6g6C5etRFKWr8de77skcJR8="
|
||||
[mod."github.com/lufia/plan9stats"]
|
||||
version = "v0.0.0-20211012122336-39d0f177ccd0"
|
||||
hash = "sha256-thb+rkDx5IeWMgw5/5jgu5gZ+6RjJAUXeMgSkJHhRlA="
|
||||
[mod."github.com/mattn/go-isatty"]
|
||||
version = "v0.0.16"
|
||||
hash = "sha256-YMaPZvShDfA98vqw1+zWWl7M1IT4nHPGBrAt7kHo8Iw="
|
||||
[mod."github.com/mroth/weightedrand"]
|
||||
version = "v1.0.0"
|
||||
hash = "sha256-bP+yIaBUY5+oI455mNM8zh14z/SNPaQg44L3RJ0/v/c="
|
||||
[mod."github.com/nfnt/resize"]
|
||||
version = "v0.0.0-20180221191011-83c6a9932646"
|
||||
hash = "sha256-yvPV+HlDOyJsiwAcVHQkmtw8DHSXyw+cXHkigXm8rAA="
|
||||
[mod."github.com/notnil/chess"]
|
||||
version = "v1.9.0"
|
||||
hash = "sha256-2bHp/H5hBE/hPMT1HLOBqMaCZ/DYWJMDri26O9Yzoms="
|
||||
[mod."github.com/onsi/ginkgo/v2"]
|
||||
version = "v2.9.5"
|
||||
hash = "sha256-3HO85y+nGsg92NEg3OOYXy5GxB59Yl1idF5sBZnyIi4="
|
||||
[mod."github.com/pbnjay/memory"]
|
||||
version = "v0.0.0-20210728143218-7b4eea64cf58"
|
||||
hash = "sha256-QI+F1oPLOOtwNp8+m45OOoSfYFs3QVjGzE0rFdpF/IA="
|
||||
[mod."github.com/pkg/errors"]
|
||||
version = "v0.9.1"
|
||||
hash = "sha256-mNfQtcrQmu3sNg/7IwiieKWOgFQOVVe2yXgKBpe/wZw="
|
||||
[mod."github.com/pkumza/numcn"]
|
||||
version = "v1.0.0"
|
||||
hash = "sha256-cPxqj5tb10+MurN1Lehkk/v8KjaxXpL08+pVgL4x4Hg="
|
||||
[mod."github.com/power-devops/perfstat"]
|
||||
version = "v0.0.0-20210106213030-5aafc221ea8c"
|
||||
hash = "sha256-ywykDYuqcMt0TvZOz1l9Z6Z2JMTYQw8cP2fT8AtpmX4="
|
||||
[mod."github.com/quic-go/qpack"]
|
||||
version = "v0.4.0"
|
||||
hash = "sha256-QWIumzmHD94DlNp9G3AQf9QCtF+Kv0pShT1+FH7/I/c="
|
||||
[mod."github.com/quic-go/qtls-go1-20"]
|
||||
version = "v0.3.3"
|
||||
hash = "sha256-YiT0g2gUxaZgJlQqQDkQqJme44LYHdzErHVEbY3bIa0="
|
||||
[mod."github.com/quic-go/quic-go"]
|
||||
version = "v0.38.1"
|
||||
hash = "sha256-CC1E4sLcoMA1Jb9QdiVBaBq9GNUmxAPGBz3f/SJaHDY="
|
||||
[mod."github.com/remyoudompheng/bigfft"]
|
||||
version = "v0.0.0-20211011143303-6e0bfa3c836b"
|
||||
hash = "sha256-SHwiLdLvGHYnbWm+03ddYc2550RdFdx/VadJfZyQEKA="
|
||||
replaced = "github.com/fumiama/bigfft"
|
||||
[mod."github.com/shirou/gopsutil/v3"]
|
||||
version = "v3.23.1"
|
||||
hash = "sha256-DYoN9o+PGrnYev7i+NISAKEqFdCKpimpi4s0FWmFpkY="
|
||||
[mod."github.com/sirupsen/logrus"]
|
||||
version = "v1.9.3"
|
||||
hash = "sha256-EnxsWdEUPYid+aZ9H4/iMTs1XMvCLbXZRDyvj89Ebms="
|
||||
[mod."github.com/tetratelabs/wazero"]
|
||||
version = "v1.5.0"
|
||||
hash = "sha256-fGdJM4LJrZA9jxHuYVo4EUQ3I1k0IVG3QQCBCgZkeZI="
|
||||
[mod."github.com/tidwall/gjson"]
|
||||
version = "v1.14.4"
|
||||
hash = "sha256-3DS2YNL95wG0qSajgRtIABD32J+oblaKVk8LIw+KSOc="
|
||||
[mod."github.com/tidwall/match"]
|
||||
version = "v1.1.1"
|
||||
hash = "sha256-M2klhPId3Q3T3VGkSbOkYl/2nLHnsG+yMbXkPkyrRdg="
|
||||
[mod."github.com/tidwall/pretty"]
|
||||
version = "v1.2.0"
|
||||
hash = "sha256-esRQGsn2Ee/CiySlwyuOICSLdqUkH4P7u8qXszos8Yc="
|
||||
[mod."github.com/tklauser/go-sysconf"]
|
||||
version = "v0.3.11"
|
||||
hash = "sha256-io8s7PJi4OX+wXkCm+v5pKy4yiqA/RE/I4ksy6mKX30="
|
||||
[mod."github.com/tklauser/numcpus"]
|
||||
version = "v0.6.0"
|
||||
hash = "sha256-6jssTsP5L6yVl43tXfqDdgeI+tEkBp3BpiWwKXLTHAM="
|
||||
[mod."github.com/wcharczuk/go-chart/v2"]
|
||||
version = "v2.1.0"
|
||||
hash = "sha256-0s07aT7i3zMyVaS1hHO6SaCilVy39HwC8Po6wcENn9E="
|
||||
[mod."github.com/wdvxdr1123/ZeroBot"]
|
||||
version = "v1.7.5-0.20231009162356-57f71b9f5258"
|
||||
hash = "sha256-sIrH0WUDJeEGMD8FWh8UyrI3aHNN6NT7l+/isSl3ico="
|
||||
[mod."github.com/yusufpapurcu/wmi"]
|
||||
version = "v1.2.2"
|
||||
hash = "sha256-Rno6F82JIeglBobQl6YKl3U6+FvWXmFavJlzpOJgoXI="
|
||||
[mod."gitlab.com/gomidi/midi/v2"]
|
||||
version = "v2.0.25"
|
||||
hash = "sha256-3oTPzuPX1hNd+6/5kRUcMfMztvQa2UWHPppp8OPiP90="
|
||||
[mod."golang.org/x/crypto"]
|
||||
version = "v0.4.0"
|
||||
hash = "sha256-PvHIbuooDItiNyQEi8kKgybkc0o95B0aeMd9awVGFCY="
|
||||
[mod."golang.org/x/exp"]
|
||||
version = "v0.0.0-20221205204356-47842c84f3db"
|
||||
hash = "sha256-HWHDTTbsKZp1bMN06ZKluiLt8Yfjtnf1XhR9GWp4rQk="
|
||||
[mod."golang.org/x/exp/shiny"]
|
||||
version = "v0.0.0-20221126150942-6ab00d035af9"
|
||||
hash = "sha256-+OAzuS+wyjOBSarGBuHjMeQV3vZzTbmF7CH8wnE7aA8="
|
||||
[mod."golang.org/x/image"]
|
||||
version = "v0.3.0"
|
||||
hash = "sha256-d6/w/CwI5GRGjuOGA7L7x4rEPfcHAVV3ZzsKxKmMYR4="
|
||||
[mod."golang.org/x/mobile"]
|
||||
version = "v0.0.0-20201217150744-e6ae53a27f4f"
|
||||
hash = "sha256-NdxlpSJhVpmE/T84HHoPtQ1GPCvDNkbNzNTYa5HEEYE="
|
||||
[mod."golang.org/x/mod"]
|
||||
version = "v0.10.0"
|
||||
hash = "sha256-g0T2wz+K0nhPWdVQJRGGqEqzlTHMBahv+9C3y090eIM="
|
||||
[mod."golang.org/x/net"]
|
||||
version = "v0.10.0"
|
||||
hash = "sha256-HkGiUYBZOBdOtt7mYo3N3swFjjAXzW++pG2JeWGJR9Q="
|
||||
[mod."golang.org/x/sys"]
|
||||
version = "v0.8.0"
|
||||
hash = "sha256-wLPPnoFkHM1HPUaFIfRyQZOJjrqXVZimB0nMySly7Xg="
|
||||
[mod."golang.org/x/text"]
|
||||
version = "v0.9.0"
|
||||
hash = "sha256-tkhDeMsSQZr3jo7vmKehWs3DvWetwXR0IB+DCLbQ4nk="
|
||||
[mod."golang.org/x/tools"]
|
||||
version = "v0.9.1"
|
||||
hash = "sha256-6jvh0cvdVMvGBceeBxWFj0+bFvboB8wuIYPHabxrST0="
|
||||
[mod."gopkg.in/check.v1"]
|
||||
version = "v1.0.0-20201130134442-10cb98267c6c"
|
||||
hash = "sha256-VlIpM2r/OD+kkyItn6vW35dyc0rtkJufA93rjFyzncs="
|
||||
[mod."gopkg.in/yaml.v3"]
|
||||
version = "v3.0.1"
|
||||
hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU="
|
||||
[mod."modernc.org/libc"]
|
||||
version = "v1.21.5"
|
||||
hash = "sha256-q2ZMb7TY1mp/Ia6e/I+44mrmpUBHErW4Q6/lPXpep28="
|
||||
[mod."modernc.org/mathutil"]
|
||||
version = "v1.5.0"
|
||||
hash = "sha256-5xM9HjjHf9sB0vLfN53PdGpT0qPF1+KI1/lgN0/4LQo="
|
||||
[mod."modernc.org/memory"]
|
||||
version = "v1.4.0"
|
||||
hash = "sha256-x78QWQ1H82eolL7JiG6eP6l4fHhRNyIlSryQKpibcBo="
|
||||
[mod."modernc.org/sqlite"]
|
||||
version = "v1.20.0-with-win386"
|
||||
hash = "sha256-ICV8xqeBvySJtmVV4DpqihUyRbXdaq11ba+UvMltFn8="
|
||||
replaced = "github.com/fumiama/sqlite3"
|
||||
@@ -3,13 +3,13 @@
|
||||
package banner
|
||||
|
||||
// Version ...
|
||||
var Version = "v1.7.3"
|
||||
var Version = "v1.7.8"
|
||||
|
||||
// Copyright ...
|
||||
var Copyright = "© 2020 - 2023 FloatTech"
|
||||
var Copyright = "© 2020 - 2024 FloatTech"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - 2023-08-28 16:14:08 +0800 CST\n" +
|
||||
"* Version " + Version + " - 2024-04-30 17:51:12 +0900 JST\n" +
|
||||
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
|
||||
@@ -27,7 +27,7 @@ var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
`
|
||||
|
||||
const timeformat = `2006-01-02 15:04:05 +0800 CST`
|
||||
const timeformat = `2006-01-02 15:04:05 +0900 JST`
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("banner/banner.go")
|
||||
|
||||
27
main.go
27
main.go
@@ -34,7 +34,7 @@ import (
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat" // 基础词库
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage" // 统计睡眠时间
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleepmanage" // 统计睡眠时间
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/atri" // ATRI词库
|
||||
|
||||
@@ -61,19 +61,20 @@ import (
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aifalse" // 服务器监控
|
||||
_ "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/base16384" // base16384加解密
|
||||
_ "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/bookreview" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chess" // 国际象棋
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
|
||||
@@ -85,7 +86,7 @@ import (
|
||||
_ "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/driftbottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
|
||||
@@ -99,7 +100,7 @@ import (
|
||||
_ "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/imgfinder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
@@ -107,18 +108,20 @@ import (
|
||||
_ "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/lolimi" // 桑帛云 API
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/mcfish" // 钓鱼模拟器
|
||||
_ "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/moyucalendar" // 摸鱼人日历
|
||||
_ "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/nwife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/quan" // QQ权重查询
|
||||
@@ -127,7 +130,6 @@ import (
|
||||
_ "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
|
||||
@@ -138,19 +140,20 @@ import (
|
||||
_ "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/vtbquotation" // 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/wenxinvilg" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife" // 抽老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordcount" // 聊天热词
|
||||
_ "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/yujn" // 遇见API
|
||||
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("ahsai", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "フリーテキスト音声合成",
|
||||
Help: "- 使[伊織弓鶴|紲星あかり|結月ゆかり|京町セイカ|東北きりたん|東北イタコ|ついなちゃん標準語|ついなちゃん関西弁|音街ウナ|琴葉茜|吉田くん|民安ともえ|桜乃そら|月読アイ|琴葉葵|東北ずん子|月読ショウタ|水奈瀬コウ]说(日语)",
|
||||
|
||||
@@ -11,28 +11,29 @@ import (
|
||||
"github.com/FloatTech/AnimeAPI/tts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/baidutts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/genshin"
|
||||
"github.com/FloatTech/AnimeAPI/tts/lolimi"
|
||||
"github.com/FloatTech/AnimeAPI/tts/ttscn"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
)
|
||||
|
||||
// 数据结构: [4 bits] [4 bits] [8 bits] [8 bits]
|
||||
// [ttscn模式] [百度模式] [tts模式] [回复模式]
|
||||
// 数据结构: [8 bits] [8 bits] [8 bits]
|
||||
// [具体人物] [tts模式] [回复模式]
|
||||
|
||||
// defaultttsindexkey
|
||||
// 数据结构: [4 bits] [4 bits] [8 bits]
|
||||
// [ttscn模式] [百度模式] [tts模式]
|
||||
// 数据结构: [8 bits] [8 bits]
|
||||
// [具体人物] [tts模式]
|
||||
|
||||
// [tts模式]: 0~200 genshin 201 baidu 202 ttscn
|
||||
// [tts模式]: 0~200 genshin 201 baidu 202 ttscn 203 lolimi
|
||||
|
||||
const (
|
||||
lastgsttsindex = 200 + iota
|
||||
baiduttsindex
|
||||
baiduttsindex = 201 + iota
|
||||
ttscnttsindex
|
||||
lolimittsindex
|
||||
)
|
||||
|
||||
// extrattsname is the tts other than genshin vits
|
||||
var extrattsname = []string{"百度", "TTSCN"}
|
||||
var extrattsname = []string{"百度", "TTSCN", "桑帛云"}
|
||||
|
||||
var ttscnspeakers = [...]string{
|
||||
"晓晓(女 - 年轻人)",
|
||||
@@ -84,7 +85,7 @@ func (r replymode) setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
if !ok {
|
||||
return errors.New("no such plugin")
|
||||
}
|
||||
return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff))
|
||||
return m.SetData(gid, (m.GetData(gid)&^0xff)|(index&0xff))
|
||||
}
|
||||
|
||||
func (r replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
@@ -96,18 +97,22 @@ func (r replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
if ok {
|
||||
switch m.GetData(gid) & 0xff {
|
||||
case 0:
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
return aireply.NewLolimiAi(aireply.JingfengURL, aireply.JingfengBotName)
|
||||
case 1:
|
||||
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
|
||||
return aireply.NewLolimiAi(aireply.MomoURL, aireply.MomoBotName)
|
||||
case 2:
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
case 3:
|
||||
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
|
||||
case 4:
|
||||
k := ཆཏ.k
|
||||
if k != "" {
|
||||
return aireply.NewChatGPT(aireply.ChatGPTURL, k)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
return aireply.NewLolimiAi(aireply.JingfengURL, aireply.JingfengBotName)
|
||||
}
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
return aireply.NewLolimiAi(aireply.JingfengURL, aireply.JingfengBotName)
|
||||
}
|
||||
|
||||
var ttsins = func() map[string]tts.TTS {
|
||||
@@ -119,8 +124,8 @@ var ttsins = func() map[string]tts.TTS {
|
||||
}()
|
||||
|
||||
var ttsModes = func() []string {
|
||||
s := append(genshin.SoundList[:], make([]string, lastgsttsindex-len(genshin.SoundList))...) // 0-200
|
||||
s = append(s, extrattsname...) // 201 202 ...
|
||||
s := append(genshin.SoundList[:], make([]string, baiduttsindex-len(genshin.SoundList))...) // 0-200
|
||||
s = append(s, extrattsname...) // 201 202 ...
|
||||
return s
|
||||
}()
|
||||
|
||||
@@ -146,14 +151,14 @@ func newttsmode() *ttsmode {
|
||||
if ok {
|
||||
index := m.GetData(defaultttsindexkey)
|
||||
msk := index & 0xff
|
||||
if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == ttscnttsindex) {
|
||||
if msk >= 0 && (msk < int64(len(ttsModes))) {
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index)
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt int) error {
|
||||
func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, character int) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
@@ -165,7 +170,7 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt
|
||||
var index = int64(-1)
|
||||
for i, s := range genshin.SoundList {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
index = int64(i + 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -175,13 +180,17 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt
|
||||
index = baiduttsindex
|
||||
case extrattsname[1]:
|
||||
index = ttscnttsindex
|
||||
case extrattsname[2]:
|
||||
index = lolimittsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
}
|
||||
}
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
(*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))
|
||||
// 按原来的逻辑map存的是前16位
|
||||
storeIndex := (m.GetData(gid) &^ 0xffff00) | ((index << 8) & 0xff00) | ((int64(character) << 16) & 0xff0000)
|
||||
(*syncx.Map[int64, int64])(t).Store(gid, (storeIndex>>8)&0xffff)
|
||||
return m.SetData(gid, storeIndex)
|
||||
}
|
||||
|
||||
func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
@@ -195,8 +204,12 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
i = m.GetData(gid) >> 8
|
||||
}
|
||||
m := i & 0xff
|
||||
if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != ttscnttsindex) {
|
||||
if m <= 0 || (m >= int64(len(ttsModes))) {
|
||||
i, _ = (*syncx.Map[int64, int64])(t).Load(defaultttsindexkey)
|
||||
if i == 0 {
|
||||
i = ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).GetData(defaultttsindexkey)
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, i)
|
||||
}
|
||||
m = i & 0xff
|
||||
}
|
||||
mode := ttsModes[m]
|
||||
@@ -205,20 +218,22 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
switch mode {
|
||||
case extrattsname[0]:
|
||||
id, sec, _ := strings.Cut(百.k, ",")
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00)>>8, id, sec)
|
||||
ins = baidutts.NewBaiduTTS(int(i&0xff00)>>8, id, sec)
|
||||
case extrattsname[1]:
|
||||
var err error
|
||||
ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xf000)>>12], ttscn.KBRates[0])
|
||||
ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xff00)>>8], ttscn.KBRates[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case extrattsname[2]:
|
||||
ins = lolimi.NewLolimi(int(i&0xff00) >> 8)
|
||||
default: // 原神
|
||||
k := 原.k
|
||||
if k != "" {
|
||||
ins = genshin.NewGenshin(int(m), 原.k)
|
||||
ins = genshin.NewGenshin(int(m-1), 原.k)
|
||||
ttsins[mode] = ins
|
||||
} else {
|
||||
return nil, errors.New("no valid speaker")
|
||||
ins = lolimi.NewLolimi(int(i&0xff00) >> 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,11 +246,12 @@ func (t *ttsmode) resetSoundMode(ctx *zero.Ctx) error {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
index := m.GetData(defaultttsindexkey)
|
||||
return m.SetData(gid, (m.GetData(gid)&0xff)|((index&^0xff)<<8)) // 重置数据
|
||||
// 只保留后面8位
|
||||
(*syncx.Map[int64, int64])(t).Delete(gid)
|
||||
return m.SetData(gid, (m.GetData(gid) & 0xff)) // 重置数据
|
||||
}
|
||||
|
||||
func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) error {
|
||||
func (t *ttsmode) setDefaultSoundMode(name string, character int) error {
|
||||
_, ok := ttsins[name]
|
||||
if !ok {
|
||||
return errors.New("不支持设置语音人物" + name)
|
||||
@@ -243,7 +259,7 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
index := int64(-1)
|
||||
for i, s := range genshin.SoundList {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
index = int64(i + 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -253,6 +269,8 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
index = baiduttsindex
|
||||
case extrattsname[1]:
|
||||
index = ttscnttsindex
|
||||
case extrattsname[2]:
|
||||
index = lolimittsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
}
|
||||
@@ -261,6 +279,7 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
if !ok {
|
||||
return errors.New("[tts] service not found")
|
||||
}
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index)
|
||||
return m.SetData(defaultttsindexkey, (index&0xff)|((int64(baiduper)<<8)&0x0f00)|((int64(mockingsynt)<<12)&0xf000))
|
||||
storeIndex := (index & 0xff) | ((int64(character) << 8) & 0xff00)
|
||||
(*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, storeIndex)
|
||||
return m.SetData(defaultttsindexkey, storeIndex)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tts/genshin"
|
||||
@@ -16,7 +17,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var replmd = replymode([]string{"青云客", "小爱", "ChatGPT"})
|
||||
var replmd = replymode([]string{"婧枫", "沫沫", "青云客", "小爱", "ChatGPT"})
|
||||
|
||||
var ttsmd = newttsmode()
|
||||
|
||||
@@ -25,9 +26,10 @@ func init() { // 插件主体
|
||||
DisableOnDefault: true,
|
||||
Brief: "人工智能语音回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" +
|
||||
"- 设置默认语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" +
|
||||
"- 设置语音模式[原神人物/百度/TTSCN/桑帛云] 数字(百度/TTSCN说话人/桑帛云)\n" +
|
||||
"- 设置默认语音模式[原神人物/百度/TTSCN/桑帛云] 数字(百度/TTSCN说话人/桑帛云)\n" +
|
||||
"- 恢复成默认语音模式\n" +
|
||||
"- 设置语音回复模式[沫沫|婧枫|青云客|小爱|ChatGPT]\n" +
|
||||
"- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
|
||||
"- 设置百度语音 api id xxxxxx secret xxxxxx (请自行获得)\n" +
|
||||
"当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) +
|
||||
@@ -38,7 +40,7 @@ func init() { // 插件主体
|
||||
enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "人工智能回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱|ChatGPT]\n- 设置 ChatGPT api key xxx",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置文字回复模式[婧枫|沫沫|青云客|小爱|ChatGPT]\n- 设置 ChatGPT api key xxx",
|
||||
PrivateDataFolder: "aireply",
|
||||
})
|
||||
|
||||
@@ -48,15 +50,10 @@ func init() { // 插件主体
|
||||
reply := message.ParseMessageFromString(aireply.Talk(ctx.Event.UserID, ctx.ExtractPlainText(), zero.BotConfig.NickName[0]))
|
||||
// 回复
|
||||
time.Sleep(time.Second * 1)
|
||||
if zero.OnlyPublic(ctx) {
|
||||
reply = append(reply, message.Reply(ctx.Event.MessageID))
|
||||
ctx.Send(reply)
|
||||
return
|
||||
}
|
||||
reply = append(reply, message.Reply(ctx.Event.MessageID))
|
||||
ctx.Send(reply)
|
||||
})
|
||||
|
||||
enr.OnPrefix("设置回复模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
setReplyMode := func(ctx *zero.Ctx) {
|
||||
param := ctx.State["args"].(string)
|
||||
err := replmd.setReplyMode(ctx, param)
|
||||
if err != nil {
|
||||
@@ -64,8 +61,8 @@ func init() { // 插件主体
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
|
||||
})
|
||||
|
||||
}
|
||||
enr.OnPrefix("设置文字回复模式", zero.AdminPermission).SetBlock(true).Handle(setReplyMode)
|
||||
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 {
|
||||
@@ -88,7 +85,20 @@ func init() { // 插件主体
|
||||
// 获取回复模式
|
||||
r := replmd.getReplyMode(ctx)
|
||||
// 获取回复的文本
|
||||
reply := r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0])
|
||||
reply := message.ParseMessageFromString(r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0]))
|
||||
// 过滤掉文字消息
|
||||
filterMsg := make([]message.MessageSegment, 0, len(reply))
|
||||
sb := strings.Builder{}
|
||||
for _, v := range reply {
|
||||
if v.Type != "text" {
|
||||
filterMsg = append(filterMsg, v)
|
||||
} else {
|
||||
sb.WriteString(v.Data["text"])
|
||||
}
|
||||
}
|
||||
// 纯文本
|
||||
plainReply := sb.String()
|
||||
plainReply = strings.ReplaceAll(plainReply, "\n", "")
|
||||
// 获取语音
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
@@ -96,21 +106,26 @@ func init() { // 插件主体
|
||||
return
|
||||
}
|
||||
rec, err := speaker.Speak(ctx.Event.UserID, func() string {
|
||||
if !endpre.MatchString(reply) {
|
||||
return reply + "。"
|
||||
if !endpre.MatchString(plainReply) {
|
||||
return plainReply + "。"
|
||||
}
|
||||
return reply
|
||||
return plainReply
|
||||
})
|
||||
// 发送前面的图片
|
||||
if len(filterMsg) != 0 {
|
||||
filterMsg = append(filterMsg, message.Reply(ctx.Event.MessageID))
|
||||
ctx.Send(filterMsg)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(plainReply))
|
||||
return
|
||||
}
|
||||
// 发送语音
|
||||
if id := ctx.SendChain(message.Record(rec)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(plainReply))
|
||||
}
|
||||
})
|
||||
|
||||
ent.OnPrefix("设置语音回复模式", zero.AdminPermission).SetBlock(true).Handle(setReplyMode)
|
||||
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]
|
||||
@@ -124,8 +139,8 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
// 保存设置
|
||||
logrus.Debugln("[tts] t.setSoundMode( ctx", param, n, n, ")")
|
||||
err = ttsmd.setSoundMode(ctx, param, n, n)
|
||||
logrus.Debugln("[tts] t.setSoundMode( ctx", param, n, ")")
|
||||
err = ttsmd.setSoundMode(ctx, param, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -153,7 +168,7 @@ func init() { // 插件主体
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功"))
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前为", speaker))
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s+(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
@@ -169,7 +184,7 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
// 保存设置
|
||||
err = ttsmd.setDefaultSoundMode(param, n, n)
|
||||
err = ttsmd.setDefaultSoundMode(param, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"math"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -45,13 +46,16 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
boottime = time.Now()
|
||||
bgdata *[]byte
|
||||
bgcount uintptr
|
||||
boottime = time.Now()
|
||||
bgdata *[]byte
|
||||
bgcount uintptr
|
||||
isday bool
|
||||
lightcolor = [3][4]uint8{{255, 70, 0, 255}, {255, 165, 0, 255}, {145, 240, 145, 255}}
|
||||
darkcolor = [3][4]uint8{{215, 50, 0, 255}, {205, 135, 0, 255}, {115, 200, 115, 255}}
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "自检, 全局限速",
|
||||
Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" +
|
||||
@@ -70,7 +74,26 @@ func init() { // 插件主体
|
||||
}
|
||||
engine.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0])
|
||||
now := time.Now().Hour()
|
||||
isday = now > 7 && now < 19
|
||||
|
||||
botrunstatus := ctx.CallAction("get_status", zero.Params{}).Data
|
||||
botverisoninfo := ctx.GetVersionInfo()
|
||||
sb := &strings.Builder{}
|
||||
sb.WriteString("在线(")
|
||||
sb.WriteString(botverisoninfo.Get("app_name").String())
|
||||
sb.WriteString("-")
|
||||
sb.WriteString(botverisoninfo.Get("app_version").String())
|
||||
sb.WriteString(") | 收")
|
||||
sb.WriteString(botrunstatus.Get("stat").Get("message_received").String())
|
||||
sb.WriteString(" | 发")
|
||||
sb.WriteString(botrunstatus.Get("stat").Get("message_sent").String())
|
||||
sb.WriteString(" | 群")
|
||||
sb.WriteString(strconv.Itoa(len(ctx.GetGroupList().Array())))
|
||||
sb.WriteString(" | 好友")
|
||||
sb.WriteString(strconv.Itoa(len(ctx.GetFriendList().Array())))
|
||||
|
||||
img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0], sb.String())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -122,7 +145,7 @@ func init() { // 插件主体
|
||||
})
|
||||
}
|
||||
|
||||
func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg image.Image, err error) {
|
||||
func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string, botrunstatus string) (sendimg image.Image, err error) {
|
||||
diskstate, err := diskstate()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -194,6 +217,13 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
defer bwg.Done()
|
||||
blurback = imaging.Blur(canvas.Image(), 8)
|
||||
}()
|
||||
|
||||
if !isday {
|
||||
canvas.SetRGBA255(0, 0, 0, 50)
|
||||
canvas.DrawRectangle(0, 0, cw, ch)
|
||||
canvas.Fill()
|
||||
}
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(5)
|
||||
|
||||
@@ -211,9 +241,9 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
titlecard.DrawRoundedRectangle(1, 1, float64(titlecard.W()-1*2), float64(titlecardh-1*2), 16)
|
||||
titlecard.SetLineWidth(3)
|
||||
titlecard.SetRGBA255(255, 255, 255, 100)
|
||||
titlecard.SetColor(colorswitch(100))
|
||||
titlecard.StrokePreserve()
|
||||
titlecard.SetRGBA255(255, 255, 255, 140)
|
||||
titlecard.SetColor(colorswitch(140))
|
||||
titlecard.Fill()
|
||||
|
||||
titlecard.DrawImage(avatarf.Circle(0).Image(), (titlecardh-avatarf.H())/2, (titlecardh-avatarf.H())/2)
|
||||
@@ -224,7 +254,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
}
|
||||
fw, _ := titlecard.MeasureString(botname)
|
||||
|
||||
titlecard.SetRGBA255(30, 30, 30, 255)
|
||||
titlecard.SetColor(fontcolorswitch())
|
||||
|
||||
titlecard.DrawStringAnchored(botname, float64(titlecardh)+fw/2, float64(titlecardh)*0.5/2, 0.5, 0.5)
|
||||
|
||||
@@ -232,20 +262,24 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
titlecard.SetRGBA255(30, 30, 30, 180)
|
||||
titlecard.SetColor(fontcolorswitch())
|
||||
|
||||
titlecard.NewSubPath()
|
||||
titlecard.MoveTo(float64(titlecardh), float64(titlecardh)/2)
|
||||
titlecard.LineTo(float64(titlecard.W()-titlecardh), float64(titlecardh)/2)
|
||||
titlecard.Stroke()
|
||||
|
||||
fw, _ = titlecard.MeasureString(botrunstatus)
|
||||
|
||||
titlecard.DrawStringAnchored(botrunstatus, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.25/2), 0.5, 0.5)
|
||||
|
||||
brt, err := botruntime()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fw, _ = titlecard.MeasureString(brt)
|
||||
|
||||
titlecard.DrawStringAnchored(brt, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.25/2), 0.5, 0.5)
|
||||
titlecard.DrawStringAnchored(brt, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.5/2), 0.5, 0.5)
|
||||
|
||||
bs, err := botstatus()
|
||||
if err != nil {
|
||||
@@ -253,7 +287,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
}
|
||||
fw, _ = titlecard.MeasureString(bs)
|
||||
|
||||
titlecard.DrawStringAnchored(bs, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.5/2), 0.5, 0.5)
|
||||
titlecard.DrawStringAnchored(bs, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.75/2), 0.5, 0.5)
|
||||
titleimg = rendercard.Fillet(titlecard.Image(), 16)
|
||||
}()
|
||||
go func() {
|
||||
@@ -264,26 +298,34 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
basiccard.DrawRoundedRectangle(1, 1, float64(basiccard.W()-1*2), float64(basiccardh-1*2), 16)
|
||||
basiccard.SetLineWidth(3)
|
||||
basiccard.SetRGBA255(255, 255, 255, 100)
|
||||
basiccard.SetColor(colorswitch(100))
|
||||
basiccard.StrokePreserve()
|
||||
basiccard.SetRGBA255(255, 255, 255, 140)
|
||||
basiccard.SetColor(colorswitch(140))
|
||||
basiccard.Fill()
|
||||
|
||||
bslen := len(basicstate)
|
||||
for i, v := range basicstate {
|
||||
offset := float64(i) * ((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1) + 200)
|
||||
|
||||
basiccard.SetRGBA255(235, 235, 235, 255)
|
||||
basiccard.SetRGBA255(57, 57, 57, 255)
|
||||
if isday {
|
||||
basiccard.SetRGBA255(235, 235, 235, 255)
|
||||
}
|
||||
basiccard.DrawCircle((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 100)
|
||||
basiccard.Fill()
|
||||
|
||||
colors := darkcolor
|
||||
if isday {
|
||||
colors = lightcolor
|
||||
}
|
||||
|
||||
switch {
|
||||
case v.precent > 90:
|
||||
basiccard.SetRGBA255(255, 70, 0, 255)
|
||||
basiccard.SetColor(slice2color(colors[0]))
|
||||
case v.precent > 70:
|
||||
basiccard.SetRGBA255(255, 165, 0, 255)
|
||||
basiccard.SetColor(slice2color(colors[1]))
|
||||
default:
|
||||
basiccard.SetRGBA255(145, 240, 145, 255)
|
||||
basiccard.SetColor(slice2color(colors[2]))
|
||||
}
|
||||
|
||||
basiccard.NewSubPath()
|
||||
@@ -291,7 +333,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
basiccard.DrawEllipticalArc((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 100, 100, -0.5*math.Pi, -0.5*math.Pi+2*v.precent*0.01*math.Pi)
|
||||
basiccard.Fill()
|
||||
|
||||
basiccard.SetRGBA255(255, 255, 255, 255)
|
||||
basiccard.SetColor(colorswitch(255))
|
||||
basiccard.DrawCircle((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 80)
|
||||
basiccard.Fill()
|
||||
|
||||
@@ -303,7 +345,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
basiccard.SetRGBA255(213, 213, 213, 255)
|
||||
basiccard.DrawStringAnchored(strconv.FormatFloat(v.precent, 'f', 0, 64)+"%", (float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 0.5, 0.5)
|
||||
|
||||
basiccard.SetRGBA255(30, 30, 30, 255)
|
||||
basiccard.SetColor(fontcolorswitch())
|
||||
|
||||
_, fw := basiccard.MeasureString(v.name)
|
||||
basiccard.DrawStringAnchored(v.name, (float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200+15+basiccard.FontHeight()/2, 0.5, 0.5)
|
||||
|
||||
@@ -311,7 +354,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
basiccard.SetRGBA255(30, 30, 30, 180)
|
||||
basiccard.SetColor(fontcolorswitch())
|
||||
|
||||
textoffsety := basiccard.FontHeight() + 10
|
||||
for k, s := range v.text {
|
||||
@@ -328,9 +371,9 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
diskcard.DrawRoundedRectangle(1, 1, float64(diskcard.W()-1*2), float64(diskcardh-1*2), 16)
|
||||
diskcard.SetLineWidth(3)
|
||||
diskcard.SetRGBA255(255, 255, 255, 100)
|
||||
diskcard.SetColor(colorswitch(100))
|
||||
diskcard.StrokePreserve()
|
||||
diskcard.SetRGBA255(255, 255, 255, 140)
|
||||
diskcard.SetColor(colorswitch(140))
|
||||
diskcard.Fill()
|
||||
|
||||
err = diskcard.ParseFontFace(fontbyte, 32)
|
||||
@@ -340,24 +383,33 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
dslen := len(diskstate)
|
||||
if dslen == 1 {
|
||||
diskcard.SetRGBA255(192, 192, 192, 255)
|
||||
diskcard.SetRGBA255(57, 57, 57, 255)
|
||||
if isday {
|
||||
diskcard.SetRGBA255(192, 192, 192, 255)
|
||||
}
|
||||
diskcard.DrawRoundedRectangle(40, 40, float64(diskcard.W())-40-100, 50, 12)
|
||||
diskcard.ClipPreserve()
|
||||
diskcard.Fill()
|
||||
|
||||
colors := darkcolor
|
||||
if isday {
|
||||
colors = lightcolor
|
||||
}
|
||||
|
||||
switch {
|
||||
case diskstate[0].precent > 90:
|
||||
diskcard.SetRGBA255(255, 70, 0, 255)
|
||||
diskcard.SetColor(slice2color(colors[0]))
|
||||
case diskstate[0].precent > 70:
|
||||
diskcard.SetRGBA255(255, 165, 0, 255)
|
||||
diskcard.SetColor(slice2color(colors[1]))
|
||||
default:
|
||||
diskcard.SetRGBA255(145, 240, 145, 255)
|
||||
diskcard.SetColor(slice2color(colors[2]))
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
diskcard.SetColor(fontcolorswitch())
|
||||
|
||||
fw, _ := diskcard.MeasureString(diskstate[0].name)
|
||||
fw1, _ := diskcard.MeasureString(diskstate[0].text[0])
|
||||
@@ -369,23 +421,32 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
for i, v := range diskstate {
|
||||
offset := float64(i)*(50+20) - 20
|
||||
|
||||
diskcard.SetRGBA255(192, 192, 192, 255)
|
||||
diskcard.SetRGBA255(57, 57, 57, 255)
|
||||
if isday {
|
||||
diskcard.SetRGBA255(192, 192, 192, 255)
|
||||
}
|
||||
|
||||
diskcard.DrawRoundedRectangle(40, 40+(float64(diskcardh-40*2)-50*float64(dslen))/float64(dslen-1)+offset, float64(diskcard.W())-40-100, 50, 12)
|
||||
diskcard.Fill()
|
||||
|
||||
colors := darkcolor
|
||||
if isday {
|
||||
colors = lightcolor
|
||||
}
|
||||
|
||||
switch {
|
||||
case v.precent > 90:
|
||||
diskcard.SetRGBA255(255, 70, 0, 255)
|
||||
diskcard.SetColor(slice2color(colors[0]))
|
||||
case v.precent > 70:
|
||||
diskcard.SetRGBA255(255, 165, 0, 255)
|
||||
diskcard.SetColor(slice2color(colors[1]))
|
||||
default:
|
||||
diskcard.SetRGBA255(145, 240, 145, 255)
|
||||
diskcard.SetColor(slice2color(colors[2]))
|
||||
}
|
||||
|
||||
diskcard.DrawRoundedRectangle(40, 40+(float64(diskcardh-40*2)-50*float64(dslen))/float64(dslen-1)+offset, (float64(diskcard.W())-40-100)*v.precent*0.01, 50, 12)
|
||||
diskcard.Fill()
|
||||
|
||||
diskcard.SetRGBA255(30, 30, 30, 255)
|
||||
diskcard.SetColor(fontcolorswitch())
|
||||
|
||||
fw, _ := diskcard.MeasureString(v.name)
|
||||
fw1, _ := diskcard.MeasureString(v.text[0])
|
||||
@@ -405,9 +466,9 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
|
||||
moreinfocard.DrawRoundedRectangle(1, 1, float64(moreinfocard.W()-1*2), float64(moreinfocard.H()-1*2), 16)
|
||||
moreinfocard.SetLineWidth(3)
|
||||
moreinfocard.SetRGBA255(255, 255, 255, 100)
|
||||
moreinfocard.SetColor(colorswitch(100))
|
||||
moreinfocard.StrokePreserve()
|
||||
moreinfocard.SetRGBA255(255, 255, 255, 140)
|
||||
moreinfocard.SetColor(colorswitch(140))
|
||||
moreinfocard.Fill()
|
||||
|
||||
err = moreinfocard.ParseFontFace(fontbyte, 32)
|
||||
@@ -419,7 +480,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
for i, v := range moreinfo {
|
||||
offset := float64(i)*(20+moreinfocard.FontHeight()) - 20
|
||||
|
||||
moreinfocard.SetRGBA255(30, 30, 30, 255)
|
||||
moreinfocard.SetColor(fontcolorswitch())
|
||||
|
||||
fw, _ := moreinfocard.MeasureString(v.name)
|
||||
fw1, _ := moreinfocard.MeasureString(v.text[0])
|
||||
@@ -497,6 +558,8 @@ func botstatus() (string, error) {
|
||||
t.WriteString(runtime.Version())
|
||||
t.WriteString(" | ")
|
||||
t.WriteString(cases.Title(language.English).String(hostinfo.OS))
|
||||
t.WriteString(" ")
|
||||
t.WriteString(runtime.GOARCH)
|
||||
return t.String(), nil
|
||||
}
|
||||
|
||||
@@ -507,7 +570,7 @@ type status struct {
|
||||
}
|
||||
|
||||
func basicstate() (stateinfo [3]*status, err error) {
|
||||
percent, err := cpu.Percent(time.Second, false)
|
||||
percent, err := cpu.Percent(time.Second, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -515,7 +578,15 @@ func basicstate() (stateinfo [3]*status, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cores := strconv.Itoa(int(cpuinfo[0].Cores)) + " Core"
|
||||
cpucore, err := cpu.Counts(false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cputhread, err := cpu.Counts(true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cores := strconv.Itoa(cpucore) + "C" + strconv.Itoa(cputhread) + "T"
|
||||
times := "最大 " + strconv.FormatFloat(cpuinfo[0].Mhz/1000, 'f', 1, 64) + "Ghz"
|
||||
|
||||
stateinfo[0] = &status{
|
||||
@@ -595,6 +666,10 @@ func diskstate() (stateinfo []*status, err error) {
|
||||
}
|
||||
|
||||
func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) {
|
||||
var mems runtime.MemStats
|
||||
runtime.ReadMemStats(&mems)
|
||||
fmtmem := storagefmt(float64(mems.Sys))
|
||||
|
||||
hostinfo, err := host.Info()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -603,12 +678,32 @@ func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
count := len(m.Manager.M)
|
||||
stateinfo = []*status{
|
||||
{name: "OS", text: []string{hostinfo.Platform}},
|
||||
{name: "CPU", text: []string{cpuinfo[0].ModelName}},
|
||||
{name: "CPU", text: []string{strings.TrimSpace(cpuinfo[0].ModelName)}},
|
||||
{name: "Version", text: []string{hostinfo.PlatformVersion}},
|
||||
{name: "Plugin", text: []string{"共 " + strconv.Itoa(count) + " 个"}},
|
||||
{name: "Memory", text: []string{"已用 " + fmtmem}},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func colorswitch(a uint8) color.Color {
|
||||
if isday {
|
||||
return color.NRGBA{255, 255, 255, a}
|
||||
}
|
||||
return color.NRGBA{0, 0, 0, a}
|
||||
}
|
||||
|
||||
func fontcolorswitch() color.Color {
|
||||
if isday {
|
||||
return color.NRGBA{30, 30, 30, 255}
|
||||
}
|
||||
return color.NRGBA{235, 235, 235, 255}
|
||||
}
|
||||
|
||||
func slice2color(c [4]uint8) color.Color {
|
||||
return color.NRGBA{c[0], c[1], c[2], c[3]}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (r *result) String() string {
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aipaint", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "ai绘图",
|
||||
Help: "- [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx\n" +
|
||||
|
||||
@@ -17,7 +17,7 @@ const (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
control.Register("aiwife", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "ai随机生成老婆",
|
||||
Help: "- waifu | 随机waifu",
|
||||
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("alipayvoice", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "支付宝到账语音",
|
||||
Help: "- 支付宝到账 1",
|
||||
|
||||
@@ -38,7 +38,7 @@ func onDel(uid int64, _ struct{}) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.Register("antiabuse", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "违禁词检测",
|
||||
Help: "- /[添加|删除|查看]违禁词",
|
||||
|
||||
@@ -48,7 +48,7 @@ func isAtriSleeping(*zero.Ctx) bool {
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("atri", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "atri人格文本回复",
|
||||
Help: "本插件基于 ATRI ,为 Golang 移植版\n" +
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("autowithdraw", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "触发者撤回时也自动撤回",
|
||||
Help: "- 撤回一条消息\n",
|
||||
|
||||
@@ -4,6 +4,7 @@ package baidu
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
@@ -27,7 +28,7 @@ type result struct {
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "百科\n" +
|
||||
"- 百度/百科/维基/wiki[关键字]",
|
||||
@@ -37,9 +38,9 @@ func init() { // 主函数
|
||||
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])) // 将网站返回结果赋值
|
||||
es, err = web.GetData(fmt.Sprintf(duURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
|
||||
case "wiki", "维基":
|
||||
es, err = web.GetData(fmt.Sprintf(wikiURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值
|
||||
es, err = web.GetData(fmt.Sprintf(wikiURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
|
||||
@@ -34,7 +34,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("baiduaudit", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "百度内容审核",
|
||||
Help: "##该功能来自百度内容审核, 需购买相关服务, 并创建app##\n" +
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("base16384", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "base16384加解密",
|
||||
Help: "- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("base64gua", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "六十四卦加解密",
|
||||
Help: "- 六十四卦加密xxx\n- 六十四卦解密xxx\n- 六十四卦用yyy加密xxx\n- 六十四卦用yyy解密xxx",
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("baseamasiro", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "天城文加解密",
|
||||
Help: "- 天城文加密xxx\n- 天城文解密xxx\n- 天城文用yyy加密xxx\n- 天城文用yyy解密xxx",
|
||||
|
||||
@@ -48,7 +48,7 @@ var (
|
||||
|
||||
// 查成分的
|
||||
func init() {
|
||||
engine := control.Register("bilibili", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "b站查成分查弹幕",
|
||||
Help: "- >vup info [xxx]\n" +
|
||||
@@ -337,12 +337,12 @@ func init() {
|
||||
faceH := float64(510)
|
||||
|
||||
totalDanmuku := 0
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
totalDanmuku += len(danmaku.Data.Data[i].Danmakus) + 1
|
||||
for i := 0; i < len(danmaku.Data.Data.Records); i++ {
|
||||
totalDanmuku += len(danmaku.Data.Data.Records[i].Danmakus) + 1
|
||||
}
|
||||
cw := 3000
|
||||
mcw := float64(2000)
|
||||
ch := 550 + len(danmaku.Data.Data)*int(faceH) + totalDanmuku*int(danmuH)
|
||||
ch := 550 + len(danmaku.Data.Data.Records)*int(faceH) + totalDanmuku*int(danmuH)
|
||||
canvas = gg.NewContext(cw, ch)
|
||||
canvas.SetColor(color.White)
|
||||
canvas.Clear()
|
||||
@@ -372,9 +372,9 @@ func init() {
|
||||
canvas.DrawString("网页链接: "+fmt.Sprintf(bz.DanmakuURL, u.Mid), startWidth, 422.5)
|
||||
var channelStart float64
|
||||
channelStart = float64(550)
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
item := danmaku.Data.Data[i]
|
||||
facePath = cachePath + strconv.Itoa(int(item.Channel.UID)) + "vupFace" + path.Ext(item.Channel.FaceURL)
|
||||
for i := 0; i < len(danmaku.Data.Data.Records); i++ {
|
||||
item := danmaku.Data.Data.Records[i]
|
||||
facePath = cachePath + strconv.Itoa(item.Channel.UID) + "vupFace" + path.Ext(item.Channel.FaceURL)
|
||||
if path.Ext(item.Channel.FaceURL) != ".webp" {
|
||||
err = initFacePic(facePath, item.Channel.FaceURL)
|
||||
if err != nil {
|
||||
@@ -393,7 +393,7 @@ func init() {
|
||||
}
|
||||
canvas.SetRGB255(24, 144, 255)
|
||||
canvas.DrawString("标题: "+item.Live.Title, startWidth, channelStart+fontH)
|
||||
canvas.DrawString("主播: "+item.Channel.Name, startWidth, channelStart+fontH*2)
|
||||
canvas.DrawString("主播: "+item.Channel.UName, startWidth, channelStart+fontH*2)
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawString("开始时间: "+time.UnixMilli(item.Live.StartDate).Format("2006-01-02 15:04:05"), startWidth, channelStart+fontH*3)
|
||||
if item.Live.IsFinish {
|
||||
@@ -411,8 +411,8 @@ func init() {
|
||||
|
||||
canvas.DrawString("直播时长: "+strconv.FormatFloat(float64(time.Now().UnixMilli()-item.Live.StartDate)/3600000.0, 'f', 1, 64)+"小时", startWidth, channelStart+fontH*5)
|
||||
}
|
||||
canvas.DrawString("弹幕数量: "+strconv.Itoa(int(item.Live.DanmakusCount)), startWidth, channelStart+fontH*6)
|
||||
canvas.DrawString("观看次数: "+strconv.Itoa(int(item.Live.WatchCount)), startWidth, channelStart+fontH*7)
|
||||
canvas.DrawString("弹幕数量: "+strconv.Itoa(item.Live.DanmakusCount), startWidth, channelStart+fontH*6)
|
||||
canvas.DrawString("观看次数: "+strconv.Itoa(item.Live.WatchCount), startWidth, channelStart+fontH*7)
|
||||
|
||||
t := "收益:"
|
||||
l, _ := canvas.MeasureString(t)
|
||||
@@ -434,7 +434,7 @@ func init() {
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l + dz
|
||||
|
||||
t = danItem.Name
|
||||
t = danItem.UName
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.SetRGB255(24, 144, 255)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
|
||||
@@ -76,11 +76,17 @@ func handleVideo(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
summaryMsg, err := getVideoSummary(card)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
msg = append(msg, summaryMsg...)
|
||||
ctx.SendChain(msg...)
|
||||
}
|
||||
|
||||
func handleDynamic(ctx *zero.Ctx) {
|
||||
msg, err := dynamicDetail(ctx.State["regex_matched"].([]string)[2])
|
||||
msg, err := dynamicDetail(cfg, ctx.State["regex_matched"].([]string)[2])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
@@ -75,7 +75,7 @@ func updateVup() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gjson.Get(binary.BytesToString(data), "@this").ForEach(func(key, value gjson.Result) bool {
|
||||
gjson.Get(binary.BytesToString(data), "@this").ForEach(func(_, value gjson.Result) bool {
|
||||
mid := value.Get("mid").Int()
|
||||
uname := value.Get("uname").String()
|
||||
roomid := value.Get("roomid").Int()
|
||||
|
||||
@@ -3,16 +3,10 @@ package bilibili
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
bz "github.com/FloatTech/AnimeAPI/bilibili"
|
||||
@@ -21,38 +15,25 @@ import (
|
||||
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://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"
|
||||
infoURL = "https://api.bilibili.com/x/space/wbi/acc/info?mid=%v"
|
||||
)
|
||||
|
||||
// bdb bilibili推送数据库
|
||||
var bdb *bilibilipushdb
|
||||
|
||||
var (
|
||||
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{"!", "'", "(", ")", "*"}
|
||||
lastTime = map[int64]int64{}
|
||||
liveStatus = map[int64]int{}
|
||||
upMap = map[int64]string{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -64,8 +45,10 @@ func init() {
|
||||
"- 取消b站动态订阅[uid|name]\n" +
|
||||
"- 取消b站直播订阅[uid|name]\n" +
|
||||
"- b站推送列表\n" +
|
||||
"Tips: 需要配合job一起使用, 全局只需要设置一个, 无视响应状态推送, 下为例子\n" +
|
||||
"记录在\"@every 5m\"触发的指令)\n" +
|
||||
"- [开启|关闭]艾特全体\n" +
|
||||
"Tips: 需要先在 bilibili 插件中设置cookie\n" +
|
||||
"需要配合 job 插件一起使用, 全局只需要设置一个, 无视响应状态推送, 下为例子\n" +
|
||||
"记录在\"@every 5m\"触发的指令\n" +
|
||||
"拉取b站推送",
|
||||
PrivateDataFolder: "bilibilipush",
|
||||
})
|
||||
@@ -74,10 +57,27 @@ func init() {
|
||||
dbpath := en.DataFolder()
|
||||
dbfile := dbpath + "push.db"
|
||||
bdb = initializePush(dbfile)
|
||||
en.OnFullMatch(`开启艾特全体`, zero.UserOrGrpAdmin, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
if err := changeAtAll(gid, 1); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已开启艾特全体Oo"))
|
||||
})
|
||||
|
||||
en.OnFullMatch(`关闭艾特全体`, zero.UserOrGrpAdmin, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
if err := changeAtAll(gid, 0); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已关闭艾特全体Oo"))
|
||||
})
|
||||
|
||||
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)
|
||||
name, err := getName(buid, cfg)
|
||||
if err != nil || name == "" {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -92,9 +92,10 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
|
||||
})
|
||||
|
||||
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)
|
||||
name, err := getName(buid, cfg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -111,7 +112,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)
|
||||
name, err := getName(buid, cfg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -132,7 +133,7 @@ func init() {
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
name, err := getName(buid)
|
||||
name, err := getName(buid, cfg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -143,6 +144,7 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("已取消" + name + "的直播订阅"))
|
||||
})
|
||||
|
||||
en.OnRegex(`^[B|b]站推送列表$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
@@ -189,11 +191,27 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func changeAtAll(gid int64, b int) (err error) {
|
||||
bpMap := map[string]any{
|
||||
"group_id": gid,
|
||||
"at_all": b,
|
||||
}
|
||||
return bdb.updateAtAll(bpMap)
|
||||
}
|
||||
|
||||
// 取得uid的名字
|
||||
func getName(buid int64) (name string, err error) {
|
||||
func getName(buid int64, cookiecfg *bz.CookieConfig) (name string, err error) {
|
||||
var ok bool
|
||||
if name, ok = upMap[buid]; !ok {
|
||||
data, err := web.RequestDataWithHeaders(web.NewDefaultClient(), signURL(fmt.Sprintf(infoURL, buid)), "GET", func(r *http.Request) error {
|
||||
data, err := web.RequestDataWithHeaders(web.NewDefaultClient(), bz.SignURL(fmt.Sprintf(infoURL, buid)), "GET", func(r *http.Request) error {
|
||||
if cookiecfg != nil {
|
||||
cookie := ""
|
||||
cookie, err = cookiecfg.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Header.Add("Cookie", cookie)
|
||||
}
|
||||
r.Header.Set("User-Agent", ua)
|
||||
return nil
|
||||
}, nil)
|
||||
@@ -212,103 +230,6 @@ 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{
|
||||
@@ -349,8 +270,19 @@ func unsubscribeLive(buid, groupid int64) (err error) {
|
||||
return bdb.insertOrUpdateLiveAndDynamic(bpMap)
|
||||
}
|
||||
|
||||
func getUserDynamicCard(buid int64) (cardList []gjson.Result, err error) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(bz.SpaceHistoryURL, buid, 0), "GET", referer, ua, nil)
|
||||
func getUserDynamicCard(buid int64, cookiecfg *bz.CookieConfig) (cardList []gjson.Result, err error) {
|
||||
data, err := web.RequestDataWithHeaders(web.NewDefaultClient(), fmt.Sprintf(bz.SpaceHistoryURL, buid, 0), "GET", func(req *http.Request) error {
|
||||
if cookiecfg != nil {
|
||||
cookie := ""
|
||||
cookie, err = cookiecfg.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Add("Cookie", cookie)
|
||||
}
|
||||
req.Header.Add("User-Agent", ua)
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -376,7 +308,7 @@ func sendDynamic(ctx *zero.Ctx) error {
|
||||
uids := bdb.getAllBuidByDynamic()
|
||||
for _, buid := range uids {
|
||||
time.Sleep(2 * time.Second)
|
||||
cardList, err := getUserDynamicCard(buid)
|
||||
cardList, err := getUserDynamicCard(buid, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -466,6 +398,9 @@ func sendLive(ctx *zero.Ctx) error {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
switch {
|
||||
case gid > 0:
|
||||
if res := bdb.getAtAll(gid); res == 1 {
|
||||
msg = append([]message.MessageSegment{message.AtAll()}, msg...)
|
||||
}
|
||||
ctx.SendGroupMessage(gid, msg)
|
||||
case gid < 0:
|
||||
ctx.SendPrivateMessage(-gid, msg)
|
||||
|
||||
@@ -33,6 +33,15 @@ func (bilibiliup) TableName() string {
|
||||
return "bilibili_up"
|
||||
}
|
||||
|
||||
type bilibiliAt struct {
|
||||
GroupID int64 `gorm:"column:group_id;primary_key" json:"group_id"`
|
||||
AtAll int64 `gorm:"column:at_all;default:0" json:"at_all"`
|
||||
}
|
||||
|
||||
func (bilibiliAt) TableName() string {
|
||||
return "bilibili_at"
|
||||
}
|
||||
|
||||
// initializePush 初始化bilibilipushdb数据库
|
||||
func initializePush(dbpath string) *bilibilipushdb {
|
||||
var err error
|
||||
@@ -48,7 +57,7 @@ func initializePush(dbpath string) *bilibilipushdb {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gdb.AutoMigrate(&bilibilipush{}).AutoMigrate(&bilibiliup{})
|
||||
gdb.AutoMigrate(&bilibilipush{}).AutoMigrate(&bilibiliup{}).AutoMigrate(&bilibiliAt{})
|
||||
return (*bilibilipushdb)(gdb)
|
||||
}
|
||||
|
||||
@@ -130,6 +139,35 @@ func (bdb *bilibilipushdb) getAllPushByGroup(groupID int64) (bpl []bilibilipush)
|
||||
return
|
||||
}
|
||||
|
||||
func (bdb *bilibilipushdb) getAtAll(groupID int64) (res int64) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bpl bilibiliAt
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "group_id = ?", groupID)
|
||||
res = bpl.AtAll
|
||||
return
|
||||
}
|
||||
|
||||
func (bdb *bilibilipushdb) updateAtAll(bpMap map[string]any) (err error) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
bp := bilibiliAt{}
|
||||
data, err := json.Marshal(&bpMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &bp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = db.Model(&bilibiliAt{}).First(&bp, "group_id = ?", bp.GroupID).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Model(&bilibiliAt{}).Create(&bp).Error
|
||||
}
|
||||
} else {
|
||||
err = db.Model(&bilibiliAt{}).Where("group_id = ?", bp.GroupID).Update(bpMap).Error
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (bdb *bilibilipushdb) insertBilibiliUp(buid int64, name string) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
bu := bilibiliup{
|
||||
|
||||
@@ -2,10 +2,12 @@ package bilibili
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
bz "github.com/FloatTech/AnimeAPI/bilibili"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
@@ -253,8 +255,8 @@ func card2msg(dynamicCard *bz.DynamicCard, card *bz.Card, cType int) (msg []mess
|
||||
}
|
||||
|
||||
// dynamicDetail 用动态id查动态信息
|
||||
func dynamicDetail(dynamicIDStr string) (msg []message.MessageSegment, err error) {
|
||||
dyc, err := bz.GetDynamicDetail(dynamicIDStr)
|
||||
func dynamicDetail(cookiecfg *bz.CookieConfig, dynamicIDStr string) (msg []message.MessageSegment, err error) {
|
||||
dyc, err := bz.GetDynamicDetail(cookiecfg, dynamicIDStr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -321,6 +323,30 @@ func videoCard2msg(card bz.Card) (msg []message.MessageSegment, err error) {
|
||||
msg = append(msg, message.Image(card.Pic))
|
||||
msg = append(msg, message.Text("\n点赞: ", bz.HumanNum(card.Stat.Like), " 投币: ", bz.HumanNum(card.Stat.Coin), "\n",
|
||||
"收藏: ", bz.HumanNum(card.Stat.Favorite), " 分享: ", bz.HumanNum(card.Stat.Share), "\n",
|
||||
bz.VURL, card.BvID))
|
||||
bz.VURL, card.BvID, "\n\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// getVideoSummary AI视频总结
|
||||
func getVideoSummary(card bz.Card) (msg []message.MessageSegment, err error) {
|
||||
var (
|
||||
data []byte
|
||||
videoSummary bz.VideoSummary
|
||||
)
|
||||
data, err = web.GetData(bz.SignURL(fmt.Sprintf(bz.VideoSummaryURL, card.BvID, card.CID)))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &videoSummary)
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
msg = append(msg, message.Text("已为你生成视频总结\n\n"))
|
||||
msg = append(msg, message.Text(videoSummary.Data.ModelResult.Summary, "\n\n"))
|
||||
for _, v := range videoSummary.Data.ModelResult.Outline {
|
||||
msg = append(msg, message.Text("● ", v.Title, "\n"))
|
||||
for _, p := range v.PartOutline {
|
||||
msg = append(msg, message.Text(fmt.Sprintf("%d:%d %s\n", p.Timestamp/60, p.Timestamp%60, p.Content)))
|
||||
}
|
||||
msg = append(msg, message.Text("\n"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,35 +15,6 @@ func TestArticleInfo(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestDynamicDetail(t *testing.T) {
|
||||
t.Log("cType = 1")
|
||||
t.Log(dynamicDetail("642279068898689029"))
|
||||
|
||||
t.Log("cType = 2")
|
||||
t.Log(dynamicDetail("642470680290394121"))
|
||||
|
||||
t.Log("cType = 2048")
|
||||
t.Log(dynamicDetail("642277677329285174"))
|
||||
|
||||
t.Log("cType = 4")
|
||||
t.Log(dynamicDetail("642154347357011968"))
|
||||
|
||||
t.Log("cType = 8")
|
||||
t.Log(dynamicDetail("675892999274627104"))
|
||||
|
||||
t.Log("cType = 4308")
|
||||
t.Log(dynamicDetail("668598718656675844"))
|
||||
|
||||
t.Log("cType = 64")
|
||||
t.Log(dynamicDetail("675966082178088963"))
|
||||
|
||||
t.Log("cType = 256")
|
||||
t.Log(dynamicDetail("599253048535707632"))
|
||||
|
||||
t.Log("cType = 4,投票类型")
|
||||
t.Log(dynamicDetail("677231070435868704"))
|
||||
}
|
||||
|
||||
func TestMemberCard(t *testing.T) {
|
||||
card, err := bz.GetMemberCard(2)
|
||||
if err != nil {
|
||||
@@ -75,6 +46,14 @@ func TestVideoInfo(t *testing.T) {
|
||||
t.Log(videoCard2msg(card))
|
||||
}
|
||||
|
||||
func TestGetVideoSummary(t *testing.T) {
|
||||
card, err := bz.GetVideoInfo("BV1mF411j7iU")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(getVideoSummary(card))
|
||||
}
|
||||
|
||||
func TestLiveRoomInfo(t *testing.T) {
|
||||
card, err := bz.GetLiveRoomInfo("83171")
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("bookreview", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "哀伤雪刃推书书评",
|
||||
Help: "- 书评[xxx]\n- 随机书评",
|
||||
@@ -16,7 +16,7 @@ const throttle = 3 // 不可超过 9
|
||||
var sm syncx.Map[int64, string]
|
||||
|
||||
func init() {
|
||||
engine := control.Register("breakrepeat", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "打断复读",
|
||||
Help: "- 打断" + strconv.Itoa(throttle) + "次以上复读\n",
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("cangtoushi", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "藏头诗, 藏尾诗",
|
||||
Help: "- 藏头诗[xxx]\n- 藏尾诗[xxx]",
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
var (
|
||||
poke = rate.NewManager[int64](time.Minute*5, 8) // 戳一戳
|
||||
engine = control.Register("chat", &ctrl.Options[*zero.Ctx]{
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "基础反应, 群空调",
|
||||
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]",
|
||||
|
||||
183
plugin/chess/chess.go
Normal file
183
plugin/chess/chess.go
Normal file
@@ -0,0 +1,183 @@
|
||||
// Package chess 国际象棋
|
||||
package chess
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const helpString = `- 参与/创建一盘游戏:「下棋」(chess)
|
||||
- 参与/创建一盘盲棋:「盲棋」(blind)
|
||||
- 投降认输:「认输」 (resign)
|
||||
- 请求、接受和棋:「和棋」 (draw)
|
||||
- 走棋:!Nxf3 中英文感叹号均可,格式请参考“代数记谱法”(Algebraic notation)
|
||||
- 中断对局:「中断」 (abort)(仅群主/管理员有效)
|
||||
- 查看等级分排行榜:「排行榜」(ranking)
|
||||
- 查看自己的等级分:「等级分」(rate)
|
||||
- 清空等级分:「清空等级分 QQ号」(.clean.rate) (仅超管有效)`
|
||||
|
||||
var (
|
||||
limit = ctxext.NewLimiterManager(time.Microsecond*2500, 1)
|
||||
tempFileDir string
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "国际象棋",
|
||||
Help: helpString,
|
||||
PrivateDataFolder: "chess",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("有操作正在执行, 请稍后再试..."),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 初始化临时文件夹
|
||||
tempFileDir = path.Join(engine.DataFolder(), "temp")
|
||||
err := os.MkdirAll(tempFileDir, 0750)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 初始化数据库
|
||||
dbFilePath := engine.DataFolder() + "chess.db"
|
||||
initDatabase(dbFilePath)
|
||||
// 注册指令
|
||||
engine.OnFullMatchGroup([]string{"下棋", "chess"}, zero.OnlyGroup).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.Sender == nil {
|
||||
return
|
||||
}
|
||||
userUin := ctx.Event.UserID
|
||||
userName := ctx.Event.Sender.NickName
|
||||
groupCode := ctx.Event.GroupID
|
||||
replyMessage, err := game(groupCode, userUin, userName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"认输", "resign"}, zero.OnlyGroup).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
userUin := ctx.Event.UserID
|
||||
groupCode := ctx.Event.GroupID
|
||||
replyMessage, err := resign(groupCode, userUin)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"和棋", "draw"}, zero.OnlyGroup).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
userUin := ctx.Event.UserID
|
||||
groupCode := ctx.Event.GroupID
|
||||
replyMessage, err := draw(groupCode, userUin)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"中断", "abort"}, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
groupCode := ctx.Event.GroupID
|
||||
replyMessage, err := abort(groupCode)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"盲棋", "blind"}, zero.OnlyGroup).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.Sender == nil {
|
||||
return
|
||||
}
|
||||
userUin := ctx.Event.UserID
|
||||
userName := ctx.Event.Sender.NickName
|
||||
groupCode := ctx.Event.GroupID
|
||||
replyMessage, err := blindfold(groupCode, userUin, userName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnRegex("^[!|!]([0-8]|[R|N|B|Q|K|O|a-h|x]|[-|=|+])+$", zero.OnlyGroup).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
userUin := ctx.Event.UserID
|
||||
groupCode := ctx.Event.GroupID
|
||||
userMsgStr := ctx.State["regex_matched"].([]string)[0]
|
||||
moveStr := strings.TrimPrefix(strings.TrimPrefix(userMsgStr, "!"), "!")
|
||||
replyMessage, err := play(groupCode, userUin, moveStr)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"排行榜", "ranking"}).SetBlock(true).Limit(limit.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
replyMessage, err := getRanking()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnFullMatchGroup([]string{"等级分", "rate"}).SetBlock(true).Limit(limit.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.Sender == nil {
|
||||
return
|
||||
}
|
||||
userUin := ctx.Event.UserID
|
||||
userName := ctx.Event.Sender.NickName
|
||||
replyMessage, err := rate(userUin, userName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
|
||||
engine.OnPrefixGroup([]string{"清空等级分", ".clean.rate"}, zero.SuperUserPermission).SetBlock(true).
|
||||
Limit(limit.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
args := ctx.State["args"].(string)
|
||||
playerUin, err := strconv.ParseInt(strings.TrimSpace(args), 10, 64)
|
||||
if err != nil || playerUin <= 0 {
|
||||
ctx.Send(fmt.Sprintf("解析失败「%s」不是正确的 QQ 号。", args))
|
||||
return
|
||||
}
|
||||
replyMessage, err := cleanUserRate(playerUin)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(replyMessage)
|
||||
})
|
||||
}
|
||||
637
plugin/chess/core.go
Normal file
637
plugin/chess/core.go
Normal file
@@ -0,0 +1,637 @@
|
||||
package chess
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
|
||||
"github.com/RomiChan/syncx"
|
||||
"github.com/jinzhu/gorm"
|
||||
resvg "github.com/kanrichan/resvg-go"
|
||||
"github.com/notnil/chess"
|
||||
cimage "github.com/notnil/chess/image"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const eloDefault = 500
|
||||
|
||||
var (
|
||||
chessRoomMap syncx.Map[int64, *chessRoom]
|
||||
errNotExist = errors.New("对局不存在, 发送「下棋」或「chess」可创建对局。")
|
||||
)
|
||||
|
||||
type chessRoom struct {
|
||||
chessGame *chess.Game
|
||||
whitePlayer int64
|
||||
whiteName string
|
||||
blackPlayer int64
|
||||
blackName string
|
||||
drawPlayer int64
|
||||
lastMoveTime int64
|
||||
isBlindfold bool
|
||||
whiteErr bool // 违例记录(盲棋用)
|
||||
blackErr bool
|
||||
}
|
||||
|
||||
// game 下棋
|
||||
func game(groupCode, senderUin int64, senderName string) (message.Message, error) {
|
||||
return createGame(false, groupCode, senderUin, senderName)
|
||||
}
|
||||
|
||||
// blindfold 盲棋
|
||||
func blindfold(groupCode, senderUin int64, senderName string) (message.Message, error) {
|
||||
return createGame(true, groupCode, senderUin, senderName)
|
||||
}
|
||||
|
||||
// abort 中断对局
|
||||
func abort(groupCode int64) (message.Message, error) {
|
||||
if room, ok := chessRoomMap.Load(groupCode); ok {
|
||||
return abortGame(*room, groupCode, "对局已被管理员中断, 游戏结束。")
|
||||
}
|
||||
return nil, errNotExist
|
||||
}
|
||||
|
||||
// draw 和棋
|
||||
func draw(groupCode, senderUin int64) (msg message.Message, err error) {
|
||||
msg = message.Message{message.At(senderUin)}
|
||||
// 检查对局是否存在
|
||||
room, ok := chessRoomMap.Load(groupCode)
|
||||
if !ok {
|
||||
return nil, errNotExist
|
||||
}
|
||||
// 检查消息发送者是否为对局中的玩家
|
||||
if senderUin != room.whitePlayer && senderUin != room.blackPlayer {
|
||||
return
|
||||
}
|
||||
// 处理和棋逻辑
|
||||
room.lastMoveTime = time.Now().Unix()
|
||||
if room.drawPlayer == 0 {
|
||||
room.drawPlayer = senderUin
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
msg = append(msg, message.Text("请求和棋, 发送「和棋」或「draw」接受和棋。走棋视为拒绝和棋。"))
|
||||
return
|
||||
}
|
||||
if room.drawPlayer == senderUin {
|
||||
return
|
||||
}
|
||||
err = room.chessGame.Draw(chess.DrawOffer)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
chessString := getChessString(*room)
|
||||
eloString := ""
|
||||
if len(room.chessGame.Moves()) > 4 {
|
||||
// 若走子次数超过 4 认为是有效对局, 存入数据库
|
||||
dbService := newDBService()
|
||||
if err = dbService.createPGN(chessString, room.whitePlayer, room.blackPlayer, room.whiteName, room.blackName); err != nil {
|
||||
return
|
||||
}
|
||||
whiteScore, blackScore := 0.5, 0.5
|
||||
eloString, err = getELOString(*room, whiteScore, blackScore)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("接受和棋, 游戏结束。\n", eloString, chessString))
|
||||
chessRoomMap.Delete(groupCode)
|
||||
return
|
||||
}
|
||||
|
||||
// resign 认输
|
||||
func resign(groupCode, senderUin int64) (msg message.Message, err error) {
|
||||
msg = message.Message{message.At(senderUin)}
|
||||
// 检查对局是否存在
|
||||
room, ok := chessRoomMap.Load(groupCode)
|
||||
if !ok {
|
||||
return nil, errNotExist
|
||||
}
|
||||
// 检查是否是当前游戏玩家
|
||||
if senderUin != room.whitePlayer && senderUin != room.blackPlayer {
|
||||
return
|
||||
}
|
||||
// 如果对局未建立, 中断对局
|
||||
if room.whitePlayer == 0 || room.blackPlayer == 0 {
|
||||
chessRoomMap.Delete(groupCode)
|
||||
msg = append(msg, message.Text("对局结束"))
|
||||
return
|
||||
}
|
||||
// 计算认输方
|
||||
var resignColor chess.Color
|
||||
if senderUin == room.whitePlayer {
|
||||
resignColor = chess.White
|
||||
} else {
|
||||
resignColor = chess.Black
|
||||
}
|
||||
if isAprilFoolsDay() {
|
||||
if resignColor == chess.White {
|
||||
resignColor = chess.Black
|
||||
} else {
|
||||
resignColor = chess.White
|
||||
}
|
||||
}
|
||||
room.chessGame.Resign(resignColor)
|
||||
chessString := getChessString(*room)
|
||||
eloString := ""
|
||||
if len(room.chessGame.Moves()) > 4 {
|
||||
// 若走子次数超过 4 认为是有效对局, 存入数据库
|
||||
dbService := newDBService()
|
||||
if err = dbService.createPGN(chessString, room.whitePlayer, room.blackPlayer, room.whiteName, room.blackName); err != nil {
|
||||
return
|
||||
}
|
||||
whiteScore, blackScore := 1.0, 1.0
|
||||
if resignColor == chess.White {
|
||||
whiteScore = 0.0
|
||||
} else {
|
||||
blackScore = 0.0
|
||||
}
|
||||
eloString, err = getELOString(*room, whiteScore, blackScore)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("认输, 游戏结束。\n", eloString, chessString))
|
||||
if isAprilFoolsDay() {
|
||||
msg = append(msg, message.Text("对手认输, 游戏结束, 你胜利了。\n", eloString, chessString))
|
||||
}
|
||||
chessRoomMap.Delete(groupCode)
|
||||
return
|
||||
}
|
||||
|
||||
// play 走棋
|
||||
func play(groupCode, senderUin int64, moveStr string) (msg message.Message, err error) {
|
||||
msg = message.Message{message.At(senderUin)}
|
||||
// 检查对局是否存在
|
||||
room, ok := chessRoomMap.Load(groupCode)
|
||||
if !ok {
|
||||
return nil, errNotExist
|
||||
}
|
||||
// 不是对局中的玩家, 忽略消息
|
||||
if (senderUin != room.whitePlayer) && (senderUin != room.blackPlayer) && !isAprilFoolsDay() {
|
||||
return
|
||||
}
|
||||
// 对局未建立
|
||||
if (room.whitePlayer == 0) || (room.blackPlayer == 0) {
|
||||
msg = append(msg, message.Text("请等候其他玩家加入游戏。"))
|
||||
return
|
||||
}
|
||||
// 需要对手走棋
|
||||
if ((senderUin == room.whitePlayer) && (room.chessGame.Position().Turn() != chess.White)) || ((senderUin == room.blackPlayer) && (room.chessGame.Position().Turn() != chess.Black)) {
|
||||
msg = append(msg, message.Text("请等待对手走棋。"))
|
||||
return
|
||||
}
|
||||
room.lastMoveTime = time.Now().Unix()
|
||||
// 走棋
|
||||
if err = room.chessGame.MoveStr(moveStr); err != nil {
|
||||
// 指令错误时检查
|
||||
if !room.isBlindfold {
|
||||
// 未开启盲棋, 提示指令错误
|
||||
msg = append(msg, message.Text("移动「", moveStr, "」违规, 请检查, 格式请参考「代数记谱法」(Algebraic notation)。"))
|
||||
return
|
||||
}
|
||||
// 开启盲棋, 判断违例情况
|
||||
var currentPlayerColor chess.Color
|
||||
if senderUin == room.whitePlayer {
|
||||
currentPlayerColor = chess.White
|
||||
} else {
|
||||
currentPlayerColor = chess.Black
|
||||
}
|
||||
// 第一次违例, 提示
|
||||
_flag := false
|
||||
if (currentPlayerColor == chess.White) && !room.whiteErr {
|
||||
room.whiteErr = true
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
_flag = true
|
||||
}
|
||||
if (currentPlayerColor == chess.Black) && !room.blackErr {
|
||||
room.blackErr = true
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
_flag = true
|
||||
}
|
||||
if _flag {
|
||||
msg = append(msg, message.Text("移动「", moveStr, "」违规, 再次违规会立即判负。"))
|
||||
return
|
||||
}
|
||||
// 出现多次违例, 判负
|
||||
room.chessGame.Resign(currentPlayerColor)
|
||||
chessString := getChessString(*room)
|
||||
msg = append(msg, message.Text("违规两次,游戏结束。\n", chessString))
|
||||
|
||||
chessRoomMap.Delete(groupCode)
|
||||
return
|
||||
}
|
||||
// 走子之后, 视为拒绝和棋
|
||||
if room.drawPlayer != 0 {
|
||||
room.drawPlayer = 0
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
}
|
||||
// 生成棋盘图片
|
||||
var boardImgEle message.MessageSegment
|
||||
if !room.isBlindfold {
|
||||
boardImgEle, err = getBoardElement(groupCode)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 检查游戏是否结束
|
||||
if room.chessGame.Method() != chess.NoMethod {
|
||||
whiteScore, blackScore := 0.5, 0.5
|
||||
var msgBuilder strings.Builder
|
||||
msgBuilder.WriteString("游戏结束, ")
|
||||
switch room.chessGame.Method() {
|
||||
case chess.FivefoldRepetition:
|
||||
msgBuilder.WriteString("和棋, 因为五次重复走子。\n")
|
||||
case chess.SeventyFiveMoveRule:
|
||||
msgBuilder.WriteString("和棋, 因为七十五步规则。\n")
|
||||
case chess.InsufficientMaterial:
|
||||
msgBuilder.WriteString("和棋, 因为不可能将死。\n")
|
||||
case chess.Stalemate:
|
||||
msgBuilder.WriteString("和棋, 因为逼和(无子可动和棋)。\n")
|
||||
case chess.Checkmate:
|
||||
var winner string
|
||||
if room.chessGame.Position().Turn() == chess.White {
|
||||
whiteScore = 0.0
|
||||
blackScore = 1.0
|
||||
winner = "黑方"
|
||||
} else {
|
||||
whiteScore = 1.0
|
||||
blackScore = 0.0
|
||||
winner = "白方"
|
||||
}
|
||||
msgBuilder.WriteString(winner)
|
||||
msgBuilder.WriteString("胜利, 因为将杀。\n")
|
||||
case chess.NoMethod:
|
||||
case chess.Resignation:
|
||||
case chess.DrawOffer:
|
||||
case chess.ThreefoldRepetition:
|
||||
case chess.FiftyMoveRule:
|
||||
default:
|
||||
}
|
||||
chessString := getChessString(*room)
|
||||
eloString := ""
|
||||
if len(room.chessGame.Moves()) > 4 {
|
||||
// 若走子次数超过 4 认为是有效对局, 存入数据库
|
||||
dbService := newDBService()
|
||||
if err = dbService.createPGN(chessString, room.whitePlayer, room.blackPlayer, room.whiteName, room.blackName); err != nil {
|
||||
return
|
||||
}
|
||||
// 仅有效对局才会计算等级分
|
||||
eloString, err = getELOString(*room, whiteScore, blackScore)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
msgBuilder.WriteString(eloString)
|
||||
msgBuilder.WriteString(chessString)
|
||||
msg = append(msg, message.Text(msgBuilder.String()))
|
||||
if !room.isBlindfold {
|
||||
msg = append(msg, boardImgEle)
|
||||
}
|
||||
|
||||
chessRoomMap.Delete(groupCode)
|
||||
return
|
||||
}
|
||||
// 提示玩家继续游戏
|
||||
var currentPlayer int64
|
||||
if room.chessGame.Position().Turn() == chess.White {
|
||||
currentPlayer = room.whitePlayer
|
||||
} else {
|
||||
currentPlayer = room.blackPlayer
|
||||
}
|
||||
msg = message.Message{message.At(currentPlayer), message.Text("对手已走子, 游戏继续。"), boardImgEle}
|
||||
return
|
||||
}
|
||||
|
||||
// rate 获取等级分
|
||||
func rate(senderUin int64, senderName string) (msg message.Message, err error) {
|
||||
rate := 0
|
||||
dbService := newDBService()
|
||||
rate, err = dbService.getELORateByUin(senderUin)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
err = errors.New("无法获取等级分信息。")
|
||||
return
|
||||
}
|
||||
err = errors.New("没有查找到等级分信息, 请至少进行一局对局。")
|
||||
}
|
||||
msg = append(msg, message.Text("玩家「", senderName, "」目前的等级分: ", rate))
|
||||
return
|
||||
}
|
||||
|
||||
// cleanUserRate 清空用户等级分
|
||||
func cleanUserRate(senderUin int64) (msg message.Message, err error) {
|
||||
dbService := newDBService()
|
||||
err = dbService.cleanELOByUin(senderUin)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
err = errors.New("无法清空等级分。")
|
||||
return
|
||||
}
|
||||
err = errors.New("没有查找到等级分信息, 请检查用户 uid 是否正确。")
|
||||
}
|
||||
msg = append(msg, message.Text("已清空用户「", senderUin, "」的等级分。"))
|
||||
return
|
||||
}
|
||||
|
||||
// createGame 创建游戏
|
||||
func createGame(isBlindfold bool, groupCode, senderUin int64, senderName string) (msg message.Message, err error) {
|
||||
room, ok := chessRoomMap.Load(groupCode)
|
||||
if !ok {
|
||||
chessRoomMap.Store(groupCode, &chessRoom{
|
||||
chessGame: chess.NewGame(),
|
||||
whitePlayer: senderUin,
|
||||
whiteName: senderName,
|
||||
blackPlayer: 0,
|
||||
blackName: "",
|
||||
drawPlayer: 0,
|
||||
lastMoveTime: time.Now().Unix(),
|
||||
isBlindfold: isBlindfold,
|
||||
whiteErr: false,
|
||||
blackErr: false,
|
||||
})
|
||||
text := "已创建新的对局, 发送「下棋」或「chess」可加入对局。"
|
||||
if isBlindfold {
|
||||
text = "已创建新的盲棋对局, 发送「盲棋」或「blind」可加入对局。"
|
||||
}
|
||||
msg = append(msg, message.Text(text))
|
||||
return
|
||||
}
|
||||
msg = message.Message{message.At(senderUin)}
|
||||
if room.blackPlayer != 0 {
|
||||
// 检测对局是否已存在超过 6 小时
|
||||
if (time.Now().Unix() - room.lastMoveTime) > 21600 {
|
||||
msg, err = abortGame(*room, groupCode, "对局已存在超过 6 小时, 游戏结束。")
|
||||
msg = append(msg, message.Text("\n\n已有对局已被中断, 如需创建新对局请重新发送指令。"))
|
||||
msg = append(msg, message.At(senderUin))
|
||||
return
|
||||
}
|
||||
// 对局在进行
|
||||
msg = append(msg, message.Text("对局已在进行中, 无法创建或加入对局, 当前对局玩家为: "))
|
||||
if room.whitePlayer != 0 {
|
||||
msg = append(msg, message.At(room.whitePlayer))
|
||||
}
|
||||
if room.blackPlayer != 0 {
|
||||
msg = append(msg, message.At(room.blackPlayer))
|
||||
}
|
||||
msg = append(msg, message.Text(", 群主或管理员发送「中断」或「abort」可中断对局(自动判和)。"))
|
||||
return
|
||||
}
|
||||
if senderUin == room.whitePlayer {
|
||||
msg = append(msg, message.Text("请等候其他玩家加入游戏。"))
|
||||
return
|
||||
}
|
||||
if room.isBlindfold && !isBlindfold {
|
||||
msg = append(msg, message.Text("已创建盲棋对局, 请加入或等待盲棋对局结束之后创建普通对局。"))
|
||||
return
|
||||
}
|
||||
if !room.isBlindfold && isBlindfold {
|
||||
msg = append(msg, message.Text("已创建普通对局, 请加入或等待普通对局结束之后创建盲棋对局。"))
|
||||
return
|
||||
}
|
||||
room.blackPlayer = senderUin
|
||||
room.blackName = senderName
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
var boardImgEle message.MessageSegment
|
||||
if !room.isBlindfold {
|
||||
boardImgEle, err = getBoardElement(groupCode)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("黑棋已加入对局, 请白方下棋。"), message.At(room.whitePlayer))
|
||||
if !isBlindfold {
|
||||
msg = append(msg, boardImgEle)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// abortGame 中断游戏
|
||||
func abortGame(room chessRoom, groupCode int64, hint string) (message.Message, error) {
|
||||
var msg message.Message
|
||||
err := room.chessGame.Draw(chess.DrawOffer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chessString := getChessString(room)
|
||||
if len(room.chessGame.Moves()) > 4 {
|
||||
dbService := newDBService()
|
||||
if err := dbService.createPGN(chessString, room.whitePlayer, room.blackPlayer, room.whiteName, room.blackName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chessRoomMap.Delete(groupCode)
|
||||
msg = append(msg, message.Text(hint))
|
||||
if room.whitePlayer != 0 {
|
||||
msg = append(msg, message.At(room.whitePlayer))
|
||||
}
|
||||
if room.blackPlayer != 0 {
|
||||
msg = append(msg, message.At(room.blackPlayer))
|
||||
}
|
||||
msg = append(msg, message.Text("\n\n"+chessString))
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
// getBoardElement 获取棋盘图片的消息内容
|
||||
func getBoardElement(groupCode int64) (imgMsg message.MessageSegment, err error) {
|
||||
fontdata, err := file.GetLazyData(text.GNUUnifontFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
room, ok := chessRoomMap.Load(groupCode)
|
||||
if !ok {
|
||||
return imgMsg, errNotExist
|
||||
}
|
||||
// 获取高亮方块
|
||||
highlightSquare := make([]chess.Square, 0, 2)
|
||||
moves := room.chessGame.Moves()
|
||||
if len(moves) != 0 {
|
||||
lastMove := moves[len(moves)-1]
|
||||
highlightSquare = append(highlightSquare, lastMove.S1())
|
||||
highlightSquare = append(highlightSquare, lastMove.S2())
|
||||
}
|
||||
// 生成棋盘 svg 文件
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
fenStr := room.chessGame.FEN()
|
||||
gameTurn := room.chessGame.Position().Turn()
|
||||
pos := &chess.Position{}
|
||||
if err = pos.UnmarshalText(binary.StringToBytes(fenStr)); err != nil {
|
||||
return
|
||||
}
|
||||
yellow := color.RGBA{255, 255, 0, 1}
|
||||
mark := cimage.MarkSquares(yellow, highlightSquare...)
|
||||
board := pos.Board()
|
||||
fromBlack := cimage.Perspective(gameTurn)
|
||||
err = cimage.SVG(buf, board, fromBlack, mark)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
worker, err := resvg.NewDefaultWorker(context.Background())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer worker.Close()
|
||||
|
||||
tree, err := worker.NewTreeFromData(buf.Bytes(), &resvg.Options{
|
||||
Dpi: 96,
|
||||
FontFamily: "Unifont",
|
||||
FontSize: 24.0,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer tree.Close()
|
||||
|
||||
fontdb, err := worker.NewFontDBDefault()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer fontdb.Close()
|
||||
|
||||
err = fontdb.LoadFontData(fontdata)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = tree.ConvertText(fontdb)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
pixmap, err := worker.NewPixmap(720, 720)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer pixmap.Close()
|
||||
|
||||
err = tree.Render(resvg.TransformFromScale(2, 2), pixmap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
out, err := pixmap.EncodePNG()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
imgMsg = message.ImageBytes(out)
|
||||
return imgMsg, nil
|
||||
}
|
||||
|
||||
// getELOString 获得玩家等级分的文本内容
|
||||
func getELOString(room chessRoom, whiteScore, blackScore float64) (string, error) {
|
||||
if room.whitePlayer == 0 || room.blackPlayer == 0 {
|
||||
return "", nil
|
||||
}
|
||||
var msgBuilder strings.Builder
|
||||
msgBuilder.WriteString("玩家等级分: \n")
|
||||
dbService := newDBService()
|
||||
if err := updateELORate(room.whitePlayer, room.blackPlayer, room.whiteName, room.blackName, whiteScore, blackScore, dbService); err != nil {
|
||||
return "", err
|
||||
}
|
||||
whiteRate, blackRate, err := getELORate(room.whitePlayer, room.blackPlayer, dbService)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
msgBuilder.WriteString(room.whiteName)
|
||||
msgBuilder.WriteString(": ")
|
||||
msgBuilder.WriteString(strconv.Itoa(whiteRate))
|
||||
msgBuilder.WriteString("\n")
|
||||
msgBuilder.WriteString(room.blackName)
|
||||
msgBuilder.WriteString(": ")
|
||||
msgBuilder.WriteString(strconv.Itoa(blackRate))
|
||||
msgBuilder.WriteString("\n\n")
|
||||
return msgBuilder.String(), nil
|
||||
}
|
||||
|
||||
// getRankingString 获取等级分排行榜的文本内容
|
||||
func getRanking() (message.Message, error) {
|
||||
dbService := newDBService()
|
||||
eloList, err := dbService.getHighestRateList()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var msgBuilder strings.Builder
|
||||
msgBuilder.WriteString("当前等级分排行榜: \n\n")
|
||||
for _, elo := range eloList {
|
||||
msgBuilder.WriteString(elo.Name)
|
||||
msgBuilder.WriteString(": ")
|
||||
msgBuilder.WriteString(strconv.Itoa(elo.Rate))
|
||||
msgBuilder.WriteString("\n")
|
||||
}
|
||||
return message.Message{message.Text(msgBuilder.String())}, nil
|
||||
}
|
||||
|
||||
// updateELORate 更新 elo 等级分
|
||||
// 当数据库中没有玩家的等级分信息时, 自动新建一条记录
|
||||
func updateELORate(whiteUin, blackUin int64, whiteName, blackName string, whiteScore, blackScore float64, dbService *chessDBService) error {
|
||||
whiteRate, err := dbService.getELORateByUin(whiteUin)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
return err
|
||||
}
|
||||
// create white elo
|
||||
if err := dbService.createELO(whiteUin, whiteName, eloDefault); err != nil {
|
||||
return err
|
||||
}
|
||||
whiteRate = eloDefault
|
||||
}
|
||||
blackRate, err := dbService.getELORateByUin(blackUin)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
return err
|
||||
}
|
||||
// create black elo
|
||||
if err := dbService.createELO(blackUin, blackName, eloDefault); err != nil {
|
||||
return err
|
||||
}
|
||||
blackRate = eloDefault
|
||||
}
|
||||
whiteRate, blackRate = calculateNewRate(whiteRate, blackRate, whiteScore, blackScore)
|
||||
// 更新白棋玩家的 ELO 等级分
|
||||
if err := dbService.updateELOByUin(whiteUin, whiteName, whiteRate); err != nil {
|
||||
return err
|
||||
}
|
||||
// 更新黑棋玩家的 ELO 等级分
|
||||
return dbService.updateELOByUin(blackUin, blackName, blackRate)
|
||||
}
|
||||
|
||||
// getChessString 获取 PGN 字符串
|
||||
func getChessString(room chessRoom) string {
|
||||
game := room.chessGame
|
||||
dataString := fmt.Sprintf("[Date \"%s\"]\n", time.Now().Format("2006-01-02"))
|
||||
whiteString := fmt.Sprintf("[White \"%s\"]\n", room.whiteName)
|
||||
blackString := fmt.Sprintf("[Black \"%s\"]\n", room.blackName)
|
||||
chessString := game.String()
|
||||
|
||||
return dataString + whiteString + blackString + chessString
|
||||
}
|
||||
|
||||
// getELORate 获取玩家的 ELO 等级分
|
||||
func getELORate(whiteUin, blackUin int64, dbService *chessDBService) (whiteRate int, blackRate int, err error) {
|
||||
whiteRate, err = dbService.getELORateByUin(whiteUin)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
blackRate, err = dbService.getELORateByUin(blackUin)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// isAprilFoolsDay 判断当前时间是否为愚人节期间
|
||||
func isAprilFoolsDay() bool {
|
||||
now := time.Now()
|
||||
return now.Month() == 4 && now.Day() == 1
|
||||
}
|
||||
100
plugin/chess/db.go
Normal file
100
plugin/chess/db.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package chess
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
var chessDB *gorm.DB
|
||||
|
||||
// elo user elo info
|
||||
type elo struct {
|
||||
gorm.Model
|
||||
Uin int64 `gorm:"unique_index"`
|
||||
Name string
|
||||
Rate int
|
||||
}
|
||||
|
||||
// pgn chess pgn info
|
||||
type pgn struct {
|
||||
gorm.Model
|
||||
Data string
|
||||
WhiteUin int64
|
||||
BlackUin int64
|
||||
WhiteName string
|
||||
BlackName string
|
||||
}
|
||||
|
||||
// chessDBService 数据库服务
|
||||
type chessDBService struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// newDBService 创建数据库服务
|
||||
func newDBService() *chessDBService {
|
||||
return &chessDBService{
|
||||
db: chessDB,
|
||||
}
|
||||
}
|
||||
|
||||
// initDatabase init database
|
||||
func initDatabase(dbPath string) {
|
||||
var err error
|
||||
if _, err = os.Stat(dbPath); err != nil || os.IsNotExist(err) {
|
||||
f, err := os.Create(dbPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
}
|
||||
chessDB, err = gorm.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
chessDB.AutoMigrate(&elo{}, &pgn{})
|
||||
}
|
||||
|
||||
// createELO 创建 ELO
|
||||
func (s *chessDBService) createELO(uin int64, name string, rate int) error {
|
||||
return s.db.Create(&elo{
|
||||
Uin: uin,
|
||||
Name: name,
|
||||
Rate: rate,
|
||||
}).Error
|
||||
}
|
||||
|
||||
// getELORateByUin 获取 ELO 等级分
|
||||
func (s *chessDBService) getELORateByUin(uin int64) (int, error) {
|
||||
var elo elo
|
||||
err := s.db.Select("rate").Where("uin = ?", uin).First(&elo).Error
|
||||
return elo.Rate, err
|
||||
}
|
||||
|
||||
// getHighestRateList 获取最高的等级分列表
|
||||
func (s *chessDBService) getHighestRateList() ([]elo, error) {
|
||||
var eloList []elo
|
||||
err := s.db.Order("rate desc").Limit(10).Find(&eloList).Error
|
||||
return eloList, err
|
||||
}
|
||||
|
||||
// updateELOByUin 更新 ELO 等级分
|
||||
func (s *chessDBService) updateELOByUin(uin int64, name string, rate int) error {
|
||||
return s.db.Model(&elo{}).Where("uin = ?", uin).Update("name", name).Update("rate", rate).Error
|
||||
}
|
||||
|
||||
// cleanELOByUin 清空用户 ELO 等级分
|
||||
func (s *chessDBService) cleanELOByUin(uin int64) error {
|
||||
return s.db.Model(&elo{}).Where("uin = ?", uin).Update("rate", 100).Error
|
||||
}
|
||||
|
||||
// createPGN 创建 PGN
|
||||
func (s *chessDBService) createPGN(data string, whiteUin int64, blackUin int64, whiteName string, blackName string) error {
|
||||
return s.db.Create(&pgn{
|
||||
Data: data,
|
||||
WhiteUin: whiteUin,
|
||||
BlackUin: blackUin,
|
||||
WhiteName: whiteName,
|
||||
BlackName: blackName,
|
||||
}).Error
|
||||
}
|
||||
37
plugin/chess/elo.go
Normal file
37
plugin/chess/elo.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package chess
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
// calculateNewRate calculate new rate of the player
|
||||
func calculateNewRate(whiteRate, blackRate int, whiteScore, blackScore float64) (int, int) {
|
||||
k := getKFactor(whiteRate, blackRate)
|
||||
exceptionWhite := calculateException(whiteRate, blackRate)
|
||||
exceptionBlack := calculateException(blackRate, whiteRate)
|
||||
whiteRate = calculateRate(whiteRate, whiteScore, exceptionWhite, k)
|
||||
blackRate = calculateRate(blackRate, blackScore, exceptionBlack, k)
|
||||
return whiteRate, blackRate
|
||||
}
|
||||
|
||||
func calculateException(rate int, opponentRate int) float64 {
|
||||
return 1.0 / (1.0 + math.Pow(10.0, float64(opponentRate-rate)/400.0))
|
||||
}
|
||||
|
||||
func calculateRate(rate int, score float64, exception float64, k int) int {
|
||||
newRate := int(math.Round(float64(rate) + float64(k)*(score-exception)))
|
||||
if newRate < 1 {
|
||||
newRate = 1
|
||||
}
|
||||
return newRate
|
||||
}
|
||||
|
||||
func getKFactor(rateA, rateB int) int {
|
||||
if rateA > 2400 && rateB > 2400 {
|
||||
return 16
|
||||
}
|
||||
if rateA > 2100 && rateB > 2100 {
|
||||
return 24
|
||||
}
|
||||
return 32
|
||||
}
|
||||
80
plugin/chess/elo_test.go
Normal file
80
plugin/chess/elo_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package chess
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCalculateNewRate(t *testing.T) {
|
||||
type args struct {
|
||||
whiteRate int
|
||||
blackRate int
|
||||
whiteScore float64
|
||||
blackScore float64
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want int
|
||||
want1 int
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
args: args{
|
||||
whiteRate: 1613,
|
||||
blackRate: 1573,
|
||||
whiteScore: 0.5,
|
||||
blackScore: 0.5,
|
||||
},
|
||||
want: 1611,
|
||||
want1: 1575,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, got1 := calculateNewRate(tt.args.whiteRate, tt.args.blackRate, tt.args.whiteScore, tt.args.blackScore)
|
||||
if got != tt.want {
|
||||
t.Errorf("CalculateNewRate() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
if got1 != tt.want1 {
|
||||
t.Errorf("CalculateNewRate() got1 = %v, want %v", got1, tt.want1)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_calculateException(t *testing.T) {
|
||||
type args struct {
|
||||
rate int
|
||||
opponentRate int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want float64
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
args: args{
|
||||
rate: 1613,
|
||||
opponentRate: 1573,
|
||||
},
|
||||
want: 0.5573116,
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
args: args{
|
||||
rate: 1613,
|
||||
opponentRate: 1613,
|
||||
},
|
||||
want: 0.5,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := calculateException(tt.args.rate, tt.args.opponentRate); math.Abs(got-tt.want) > 0.0001 {
|
||||
t.Errorf("calculateException() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("choose", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "选择困难症帮手",
|
||||
Help: "例: 选择可口可乐还是百事可乐\n" +
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("chouxianghua", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "翻译为抽象话",
|
||||
Help: "- 抽象翻译xxx",
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
// 初始化engine
|
||||
engine := control.Register("chrev", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "英文字符翻转",
|
||||
Help: "例: 翻转 I love you",
|
||||
|
||||
@@ -53,7 +53,7 @@ func init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
control.Register("coser", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "三次元coser",
|
||||
Help: "- coser",
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("cpstory", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "cp短打", // 这里也许有更好的名字
|
||||
Help: "- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
|
||||
|
||||
@@ -21,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("curse", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Brief: "骂人反击",
|
||||
Help: "- 骂我\n- 大力骂我",
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
const api = "http://dwz.2xb.cn/zaob"
|
||||
|
||||
func init() {
|
||||
engine := control.Register("dailynews", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "今日早报",
|
||||
Help: "- 今日早报",
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("danbooru", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "二次元图片标签识别",
|
||||
Help: "- 鉴赏图片[图片]",
|
||||
|
||||
@@ -3,6 +3,7 @@ package deepdanbooru
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"net/url"
|
||||
@@ -59,8 +60,12 @@ func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(data) < 4 {
|
||||
err = errors.New("data too short")
|
||||
return
|
||||
}
|
||||
tags := make(map[string]float64)
|
||||
err = json.Unmarshal(data, &tags)
|
||||
err = json.Unmarshal(data[1:len(data)-1], &tags)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
|
||||
)
|
||||
|
||||
var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
|
||||
var engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "嘉然相关", // 也许使用常用功能当Brief更好
|
||||
Help: "- 小作文\n" +
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("dish", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "程序员做饭指南",
|
||||
Help: "-怎么做[xxx]|烹饪[xxx]|随机菜谱|随便做点菜",
|
||||
|
||||
@@ -40,7 +40,7 @@ var (
|
||||
}
|
||||
return lotsList
|
||||
}()
|
||||
en = control.Register("drawlots", &ctrl.Options[*zero.Ctx]{
|
||||
en = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "多功能抽签",
|
||||
Help: "支持图包文件夹和gif抽签\n" +
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("dress", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "女装",
|
||||
Help: "女装\n" +
|
||||
|
||||
@@ -33,7 +33,7 @@ var seaLocker sync.RWMutex
|
||||
// We need a container to inject what we need :(
|
||||
|
||||
func init() {
|
||||
en := control.Register("driftbottle", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "漂流瓶",
|
||||
Help: "- @bot pick" + "- @bot throw xxx (xxx为投递内容)",
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
const bed = "https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%x.png"
|
||||
|
||||
func init() {
|
||||
control.Register("emojimix", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "合成emoji",
|
||||
Help: "- [emoji][emoji]",
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("event", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "好友申请和群聊邀请事件处理",
|
||||
Help: "- [开启|关闭]自动同意[申请|邀请|主人]\n" +
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("font", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "渲染任意文字到图片",
|
||||
Help: "- (用[字体])渲染(抖动)文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|粗苹方体|未来荧黑体|Gugi体|八丸体|Impact体|猫啃体|苹方体]",
|
||||
|
||||
@@ -48,7 +48,7 @@ var (
|
||||
|
||||
func init() {
|
||||
// 插件主体
|
||||
en := control.Register("fortune", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "每日运势",
|
||||
Help: "- 运势 | 抽签\n" +
|
||||
|
||||
@@ -24,7 +24,7 @@ type joke struct {
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func init() {
|
||||
en := control.Register("funny", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "讲个笑话",
|
||||
Help: "- 讲个笑话[@xxx|qq号|人名] | 夸夸[@xxx|qq号|人名] ",
|
||||
|
||||
@@ -35,7 +35,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("genshin", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "原神模拟抽卡",
|
||||
Help: "- 原神十连\n- 切换原神卡池",
|
||||
|
||||
@@ -126,7 +126,7 @@ func init() { // 插件主体
|
||||
for k := range cmdMap {
|
||||
cmd = append(cmd, k)
|
||||
}
|
||||
en := control.Register("gif", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "制图",
|
||||
Help: "下为制图命令:\n" +
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
control.Register("github", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "GitHub仓库搜索",
|
||||
Help: "- >github [xxx]\n" +
|
||||
|
||||
@@ -11,16 +11,28 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/pkg/errors"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/liuzl/gocc"
|
||||
)
|
||||
|
||||
var cuttime = [...]string{"00:00:05", "00:00:30", "00:01:00"} // 音乐切割时间点,可自行调节时间(时:分:秒)
|
||||
var t2s *gocc.OpenCC
|
||||
|
||||
func init() {
|
||||
// 初始化简繁体转换变量
|
||||
var err1 error
|
||||
t2s, err1 = gocc.New("t2s")
|
||||
if err1 != nil {
|
||||
log.Infof("[guessmusic]:%s", err1)
|
||||
}
|
||||
|
||||
engine.OnRegex(`^(个人|团队)猜歌(-(.*))?$`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
mode := ctx.State["regex_matched"].([]string)[3]
|
||||
@@ -283,6 +295,11 @@ func cutMusic(musicName, pathOfMusic, outputPath string) (err error) {
|
||||
// 数据匹配(结果信息,答题次数,提示次数,是否结束游戏)
|
||||
func gameMatch(c *zero.Ctx, beginner int64, musicInfo []string, answerTimes, tickTimes int) (message.MessageSegment, int, int, bool) {
|
||||
answer := strings.Replace(c.Event.Message.String(), "-", "", 1)
|
||||
// 大小写,简繁体转换
|
||||
answer = ConvertText(answer)
|
||||
for i, element := range musicInfo {
|
||||
musicInfo[i] = ConvertText(element)
|
||||
}
|
||||
switch {
|
||||
case answer == "取消":
|
||||
if c.Event.UserID == beginner {
|
||||
@@ -314,3 +331,15 @@ func gameMatch(c *zero.Ctx, beginner int64, musicInfo []string, answerTimes, tic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ConvertText 将传入字符串中的英文转为小写,繁体中文转为简体中文
|
||||
func ConvertText(input string) string {
|
||||
// 将字符串中的英文转为小写
|
||||
toLower := strings.ToLower(input)
|
||||
toLower, err := t2s.Convert(toLower)
|
||||
if err != nil {
|
||||
message.Text("简繁转换失败")
|
||||
return toLower
|
||||
}
|
||||
return toLower
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ var (
|
||||
// 用户数据
|
||||
cfg config
|
||||
// 插件主体
|
||||
engine = control.Register("guessmusic", &ctrl.Options[*zero.Ctx]{
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "猜歌插件",
|
||||
Help: "------bot主人指令------\n" +
|
||||
|
||||
@@ -241,9 +241,9 @@ type listInfoOfAPI struct {
|
||||
PublishTime int64 `json:"publishTime"`
|
||||
Tns []string `json:"tns,omitempty"`
|
||||
} `json:"tracks"`
|
||||
VideoIds interface{} `json:"videoIds"`
|
||||
VideoIDs interface{} `json:"videoIds"`
|
||||
Videos interface{} `json:"videos"`
|
||||
TrackIds []struct {
|
||||
TrackIDs []struct {
|
||||
ID int `json:"id"`
|
||||
V int `json:"v"`
|
||||
T int `json:"t"`
|
||||
|
||||
@@ -66,7 +66,7 @@ func init() { // 插件主体
|
||||
panic(err)
|
||||
}
|
||||
|
||||
engine := control.Register("heisi", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "黑丝",
|
||||
Help: "- 来点黑丝\n- 来点白丝\n- 来点jk\n- 来点巨乳\n- 来点足控\n- 来点网红",
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("hitokoto", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "一言",
|
||||
Help: "- 一言[xxx]\n" +
|
||||
|
||||
@@ -41,7 +41,7 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("hs", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "炉石搜卡",
|
||||
Help: "- 搜卡[xxxx]\n" +
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const bed = "https://gitcode.net/u011570312/OguraHyakuninIsshu/-/raw/master/"
|
||||
const bed = "https://gitea.seku.su/fumiama/OguraHyakuninIsshu/raw/branch/master/"
|
||||
|
||||
type line struct {
|
||||
番号, 歌人, 上の句, 下の句, 上の句ひらがな, 下の句ひらがな string
|
||||
@@ -51,7 +51,7 @@ func (l *line) String() string {
|
||||
var lines [100]*line
|
||||
|
||||
func init() {
|
||||
engine := control.Register("hyaku", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "百人一首",
|
||||
Help: "- 百人一首(随机发一首)\n" +
|
||||
|
||||
@@ -62,7 +62,7 @@ type resultjson struct {
|
||||
var hrefre = regexp.MustCompile(`<a href=".*">`)
|
||||
|
||||
func init() {
|
||||
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "关键字搜图",
|
||||
Help: "- 来张 [xxx]",
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("inject", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "注入指令",
|
||||
Help: "- run[CQ码]",
|
||||
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("jandan", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "煎蛋网无聊图",
|
||||
Help: "- 来份[屌|弔|吊]图\n- 更新[屌|弔|吊]图\n",
|
||||
|
||||
@@ -25,7 +25,7 @@ type nmd struct { // struct解析格式大概是
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("jiami", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "兽语加解密",
|
||||
Help: "兽语加解密\n" +
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("jptingroom", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "日语听力学习材料",
|
||||
Help: "- 随机日语听力\n" +
|
||||
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("juejuezi", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "绝绝子生成器",
|
||||
Help: "例: 喝奶茶绝绝子\n绝绝子吃饭",
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
package kfccrazythursday
|
||||
|
||||
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 (
|
||||
crazyURL = "https://www.iculture.cc/demo/CrazyThursday/api/kfc.php"
|
||||
crazyURL = "https://api.jixs.cc/api/wenan-fkxqs/index.php"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("kfccrazythursday", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "疯狂星期四",
|
||||
Help: "疯狂星期四\n",
|
||||
@@ -26,6 +26,6 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.ParseBytes(data).Get("@this.0.content").String()))
|
||||
ctx.SendChain(message.Text(binary.BytesToString(data)))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("lolicon", &ctrl.Options[*zero.Ctx]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "随机图片",
|
||||
Help: "- 随机图片\n" +
|
||||
@@ -115,5 +115,5 @@ func getimgurl(url string) (string, error) {
|
||||
if imageurl = json.Get("data.0.urls.original").Str; imageurl == "" {
|
||||
return "", errors.New("未找到相关内容, 换个tag试试吧")
|
||||
}
|
||||
return strings.ReplaceAll(imageurl, "i.pixiv.cat", "i.pixiv.re"), nil
|
||||
return imageurl, nil
|
||||
}
|
||||
|
||||
112
plugin/lolimi/lolimi.go
Normal file
112
plugin/lolimi/lolimi.go
Normal file
@@ -0,0 +1,112 @@
|
||||
// Package lolimi 来源于 https://api.lolimi.cn/ 的接口
|
||||
package lolimi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tts/lolimi"
|
||||
"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/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
lolimiURL = "https://api.lolimi.cn"
|
||||
raoURL = lolimiURL + "/API/rao/api.php"
|
||||
yanURL = lolimiURL + "/API/yan/?url=%v"
|
||||
xjjURL = lolimiURL + "/API/tup/xjj.php"
|
||||
qingURL = lolimiURL + "/API/qing/api.php"
|
||||
fabingURL = lolimiURL + "/API/fabing/fb.php?name=%v"
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "桑帛云 API",
|
||||
Help: "- 让[嘉然|塔菲|东雪莲|懒羊羊|科比|孙笑川|陈泽|丁真|空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然]说我测尼玛\n- 随机绕口令\n- 颜值鉴定[图片]\n" +
|
||||
"- 随机妹子\n- 随机情话\n- 发病 嘉然\n\n说明: 颜值鉴定只能鉴定三次元图片",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("随机妹子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Image(xjjURL))
|
||||
})
|
||||
engine.OnFullMatch("随机绕口令").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(raoURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.Get(binary.BytesToString(data), "data.Msg").String()))
|
||||
})
|
||||
engine.OnFullMatch("随机情话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(qingURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(binary.BytesToString(data)))
|
||||
})
|
||||
engine.OnPrefix(`发病`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
name := ctx.NickName()
|
||||
data, err := web.GetData(fmt.Sprintf(fabingURL, url.QueryEscape(name)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.Get(binary.BytesToString(data), "data").String()))
|
||||
})
|
||||
engine.OnKeywordGroup([]string{"颜值鉴定"}, zero.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
list := ctx.State["image_url"].([]string)
|
||||
if len(list) > 0 {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
data, err := web.GetData(fmt.Sprintf(yanURL, url.QueryEscape(list[0])))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
assessment := gjson.Get(binary.BytesToString(data), "data.text").String()
|
||||
if assessment == "" {
|
||||
ctx.SendChain(message.Text("ERROR: 请输入正确的图片"))
|
||||
return
|
||||
}
|
||||
var text strings.Builder // 创建一个strings.Builder实例
|
||||
text.WriteString("评价: ")
|
||||
text.WriteString(assessment) // 添加评估信息
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
key := gjson.Get(binary.BytesToString(data), "data.grade.key"+strconv.Itoa(i)).String()
|
||||
score := gjson.Get(binary.BytesToString(data), "data.grade.score"+strconv.Itoa(i)).String()
|
||||
if key != "" {
|
||||
text.WriteString("\n")
|
||||
text.WriteString(key)
|
||||
text.WriteString(": ")
|
||||
text.WriteString(score)
|
||||
}
|
||||
}
|
||||
|
||||
ctx.SendChain(message.Text(text.String())) // 发送构建好的字符串
|
||||
}
|
||||
})
|
||||
engine.OnRegex("^让(嘉然|塔菲|东雪莲|懒羊羊|科比|孙笑川|陈泽|丁真|空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然)说([\\s\u4e00-\u9fa5\u3040-\u309F\u30A0-\u30FF\\w\\p{P}\u3000-\u303F\uFF00-\uFFEF]+)$").Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
|
||||
name := ctx.State["regex_matched"].([]string)[1]
|
||||
msg := ctx.State["regex_matched"].([]string)[2]
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
recordURL, err := lolimi.TTS(name, msg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record(recordURL))
|
||||
})
|
||||
}
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("magicprompt", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "MagicPrompt-Stable-Diffusion吟唱提示",
|
||||
Help: "- 吟唱提示 xxx",
|
||||
|
||||
@@ -47,6 +47,7 @@ const (
|
||||
"- 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 赞我\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}]\n" +
|
||||
"- 测试欢迎语\n" +
|
||||
"- 设置告别辞 参数同设置欢迎语\n" +
|
||||
@@ -64,7 +65,7 @@ var (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("manager", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "群管插件",
|
||||
Help: hint,
|
||||
@@ -384,6 +385,24 @@ func init() { // 插件主体
|
||||
),
|
||||
)
|
||||
})
|
||||
// 给好友点赞
|
||||
engine.OnFullMatch("赞我").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
list := ctx.GetFriendList().Array()
|
||||
flag := false
|
||||
for _, v := range list {
|
||||
if ctx.Event.UserID == v.Get("user_id").Int() {
|
||||
flag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("不加好友不给赞!"))
|
||||
return
|
||||
}
|
||||
ctx.SendLike(ctx.Event.UserID, 10)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("给你赞了10下哦,记得回我~"))
|
||||
})
|
||||
// 入群欢迎
|
||||
engine.OnNotice().SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -155,7 +155,7 @@ func (t *Timer) judgeHM() {
|
||||
if t.SelfID != 0 {
|
||||
t.sendmsg(t.GrpID, zero.GetBot(t.SelfID))
|
||||
} else {
|
||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) (_ bool) {
|
||||
zero.RangeBot(func(_ int64, ctx *zero.Ctx) (_ bool) {
|
||||
t.sendmsg(t.GrpID, ctx)
|
||||
return
|
||||
})
|
||||
|
||||
370
plugin/mcfish/fish.go
Normal file
370
plugin/mcfish/fish.go
Normal file
@@ -0,0 +1,370 @@
|
||||
// Package mcfish 钓鱼模拟器
|
||||
package mcfish
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnRegex(`^进行(([1-5]\d|[1-9])次)?钓鱼$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
numberOfPole, err := dbdata.getNumberFor(uid, "竿")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.3]:", err))
|
||||
return
|
||||
}
|
||||
if numberOfPole > 30 {
|
||||
ctx.SendChain(message.Text("你有", numberOfPole, "支鱼竿,大于30支的玩家不允许钓鱼"))
|
||||
return
|
||||
}
|
||||
fishNumber := 1
|
||||
info := ctx.State["regex_matched"].([]string)[2]
|
||||
if info != "" {
|
||||
number, err := strconv.Atoi(info)
|
||||
if err != nil || number > FishLimit {
|
||||
ctx.SendChain(message.Text("请输入正确的次数"))
|
||||
return
|
||||
}
|
||||
fishNumber = number
|
||||
}
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.2]:", err))
|
||||
return
|
||||
}
|
||||
if equipInfo == (equip{}) {
|
||||
ok, err := dbdata.checkEquipFor(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.2.1]:", err))
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
ctx.SendChain(message.At(uid), message.Text("请装备鱼竿后钓鱼", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你尚未装备鱼竿,是否花费100购买鱼竿?\n回答\"是\"或\"否\""))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(是|否)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
buy := false
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("等待超时,取消钓鱼")))
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "否" {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已取消购买")))
|
||||
return
|
||||
}
|
||||
money := wallet.GetWalletOf(uid)
|
||||
if money < 100 {
|
||||
ctx.SendChain(message.Text("你钱包当前只有", money, "ATRI币,无法完成支付"))
|
||||
return
|
||||
}
|
||||
err = wallet.InsertWalletOf(uid, -100)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.3]:", err))
|
||||
return
|
||||
}
|
||||
equipInfo = equip{
|
||||
ID: uid,
|
||||
Equip: "木竿",
|
||||
Durable: 30,
|
||||
}
|
||||
err = dbdata.updateUserEquip(equipInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.4]:", err))
|
||||
return
|
||||
}
|
||||
err = dbdata.setEquipFor(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.4]:", err))
|
||||
return
|
||||
}
|
||||
buy = true
|
||||
}
|
||||
if buy {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if equipInfo.Durable < fishNumber {
|
||||
fishNumber = equipInfo.Durable
|
||||
}
|
||||
residue, err := dbdata.updateFishInfo(uid, fishNumber)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.1]:", err))
|
||||
return
|
||||
}
|
||||
if residue == 0 {
|
||||
ctx.SendChain(message.Text("今天你已经进行", FishLimit, "次钓鱼了.\n游戏虽好,但请不要沉迷。"))
|
||||
return
|
||||
}
|
||||
fishNumber = residue
|
||||
msg := ""
|
||||
if equipInfo.Equip != "美西螈" {
|
||||
equipInfo.Durable -= fishNumber
|
||||
err = dbdata.updateUserEquip(equipInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5]:", err))
|
||||
return
|
||||
}
|
||||
if equipInfo.Durable < 10 && equipInfo.Durable > 0 {
|
||||
msg = "(你的鱼竿耐久仅剩" + strconv.Itoa(equipInfo.Durable) + ")"
|
||||
} else if equipInfo.Durable <= 0 {
|
||||
msg = "(你的鱼竿已销毁)"
|
||||
}
|
||||
if equipInfo.Equip == "三叉戟" {
|
||||
fishNumber *= 3
|
||||
}
|
||||
} else {
|
||||
fishNmaes, err := dbdata.pickFishFor(uid, fishNumber)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5.1]:", err))
|
||||
return
|
||||
}
|
||||
if len(fishNmaes) == 0 {
|
||||
equipInfo.Durable = 0
|
||||
err = dbdata.updateUserEquip(equipInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5]:", err))
|
||||
}
|
||||
ctx.SendChain(message.Text("美西螈因为没吃到鱼,钓鱼时一直没回来,你失去了美西螈"))
|
||||
return
|
||||
}
|
||||
msg = "(美西螈吃掉了"
|
||||
fishNumber = 0
|
||||
for name, number := range fishNmaes {
|
||||
fishNumber += number
|
||||
msg += strconv.Itoa(number) + name + "、"
|
||||
}
|
||||
msg += ")"
|
||||
fishNumber /= 2
|
||||
}
|
||||
waitTime := 120 / (equipInfo.Induce + 1)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你开始去钓鱼了,请耐心等待鱼上钩(预计要", time.Second*time.Duration(waitTime), ")"))
|
||||
timer := time.NewTimer(time.Second * time.Duration(rand.Intn(waitTime)+1))
|
||||
for {
|
||||
<-timer.C
|
||||
timer.Stop()
|
||||
break
|
||||
}
|
||||
// 钓到鱼的范围
|
||||
number, err := dbdata.getNumberFor(uid, "鱼")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5.1]:", err))
|
||||
return
|
||||
}
|
||||
number2, err := dbdata.getNumberFor(uid, "海豚")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5.1]:", err))
|
||||
return
|
||||
}
|
||||
if number > 100 || equipInfo.Equip == "美西螈" { // 放大概率
|
||||
probabilities["treasure"] = probabilityLimit{
|
||||
Min: 0,
|
||||
Max: 2,
|
||||
}
|
||||
probabilities["pole"] = probabilityLimit{
|
||||
Min: 2,
|
||||
Max: 10,
|
||||
}
|
||||
probabilities["fish"] = probabilityLimit{
|
||||
Min: 10,
|
||||
Max: 45,
|
||||
}
|
||||
probabilities["waste"] = probabilityLimit{
|
||||
Min: 45,
|
||||
Max: 90,
|
||||
}
|
||||
}
|
||||
if number2 != 0 {
|
||||
info := probabilities["waste"]
|
||||
info.Max = 100
|
||||
probabilities["waste"] = info
|
||||
}
|
||||
for name, info := range probabilities {
|
||||
switch name {
|
||||
case "treasure":
|
||||
info.Max += equipInfo.Favor
|
||||
probabilities[name] = info
|
||||
case "pole":
|
||||
info.Min += equipInfo.Favor
|
||||
info.Max += equipInfo.Favor * 2
|
||||
probabilities[name] = info
|
||||
case "fish":
|
||||
info.Min += equipInfo.Favor * 2
|
||||
info.Max += equipInfo.Favor * 3
|
||||
probabilities[name] = info
|
||||
case "waste":
|
||||
info.Min += equipInfo.Favor * 3
|
||||
probabilities[name] = info
|
||||
}
|
||||
}
|
||||
// 钓鱼结算
|
||||
picName := ""
|
||||
thingNameList := make(map[string]int)
|
||||
for i := fishNumber; i > 0; i-- {
|
||||
thingName := ""
|
||||
typeOfThing := ""
|
||||
number := 1
|
||||
dice := rand.Intn(100)
|
||||
switch {
|
||||
case dice >= probabilities["waste"].Min && dice < probabilities["waste"].Max: // 垃圾
|
||||
typeOfThing = "waste"
|
||||
thingName = wasteList[rand.Intn(len(wasteList))]
|
||||
picName = thingName
|
||||
case dice >= probabilities["treasure"].Min && dice < probabilities["treasure"].Max: // 宝藏
|
||||
dice = rand.Intn(100)
|
||||
switch {
|
||||
case dice >= probabilities["美西螈"].Min && dice < probabilities["美西螈"].Max:
|
||||
typeOfThing = "pole"
|
||||
picName = "美西螈"
|
||||
thingName = "美西螈"
|
||||
case dice >= probabilities["唱片"].Min && dice < probabilities["唱片"].Max:
|
||||
typeOfThing = "article"
|
||||
picName = "唱片"
|
||||
thingName = "唱片"
|
||||
case dice >= probabilities["海之眷顾"].Min && dice < probabilities["海之眷顾"].Max:
|
||||
typeOfThing = "article"
|
||||
picName = "book"
|
||||
thingName = "海之眷顾"
|
||||
case dice >= probabilities["净化书"].Min && dice < probabilities["净化书"].Max:
|
||||
typeOfThing = "article"
|
||||
picName = "book"
|
||||
thingName = "净化书"
|
||||
case dice >= probabilities["宝藏诅咒"].Min && dice < probabilities["宝藏诅咒"].Max:
|
||||
typeOfThing = "article"
|
||||
picName = "book"
|
||||
thingName = "宝藏诅咒"
|
||||
case dice >= probabilities["海豚"].Min && dice < probabilities["海豚"].Max:
|
||||
typeOfThing = "fish"
|
||||
picName = "海豚"
|
||||
thingName = "海豚"
|
||||
default:
|
||||
typeOfThing = "article"
|
||||
picName = "book"
|
||||
thingName = "诱钓"
|
||||
}
|
||||
case dice >= probabilities["pole"].Min && dice < probabilities["pole"].Max: // 宝藏
|
||||
typeOfThing = "pole"
|
||||
dice := rand.Intn(100)
|
||||
switch {
|
||||
case dice >= probabilities["铁竿"].Min && dice < probabilities["铁竿"].Max:
|
||||
thingName = "铁竿"
|
||||
case dice >= probabilities["金竿"].Min && dice < probabilities["金竿"].Max:
|
||||
thingName = "金竿"
|
||||
case dice >= probabilities["钻石竿"].Min && dice < probabilities["钻石竿"].Max:
|
||||
thingName = "钻石竿"
|
||||
case dice >= probabilities["下界合金竿竿竿"].Min && dice < probabilities["下界合金竿竿竿"].Max:
|
||||
thingName = "下界合金竿竿竿"
|
||||
default:
|
||||
thingName = "木竿"
|
||||
}
|
||||
picName = thingName
|
||||
case dice >= probabilities["fish"].Min && dice < probabilities["fish"].Max:
|
||||
typeOfThing = "fish"
|
||||
dice = rand.Intn(100)
|
||||
switch {
|
||||
case dice >= probabilities["墨鱼"].Min && dice < probabilities["墨鱼"].Max:
|
||||
thingName = "墨鱼"
|
||||
case dice >= probabilities["鳕鱼"].Min && dice < probabilities["鳕鱼"].Max:
|
||||
thingName = "鳕鱼"
|
||||
case dice >= probabilities["鲑鱼"].Min && dice < probabilities["鲑鱼"].Max:
|
||||
thingName = "鲑鱼"
|
||||
case dice >= probabilities["热带鱼"].Min && dice < probabilities["热带鱼"].Max:
|
||||
thingName = "热带鱼"
|
||||
case dice >= probabilities["河豚"].Min && dice < probabilities["河豚"].Max:
|
||||
thingName = "河豚"
|
||||
default:
|
||||
thingName = "鹦鹉螺"
|
||||
}
|
||||
picName = thingName
|
||||
default:
|
||||
thingNameList["赛博空气"]++
|
||||
}
|
||||
if thingName != "" {
|
||||
newThing := article{}
|
||||
if strings.Contains(thingName, "竿") {
|
||||
info := strconv.Itoa(rand.Intn(durationList[thingName])+1) +
|
||||
"/" + strconv.Itoa(rand.Intn(10)) + "/" +
|
||||
strconv.Itoa(rand.Intn(3)) + "/" + strconv.Itoa(rand.Intn(2))
|
||||
newThing = article{
|
||||
Duration: time.Now().Unix()*100 + int64(i),
|
||||
Type: typeOfThing,
|
||||
Name: thingName,
|
||||
Number: number,
|
||||
Other: info,
|
||||
}
|
||||
} else {
|
||||
thingInfo, err := dbdata.getUserThingInfo(uid, thingName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.6]:", err))
|
||||
return
|
||||
}
|
||||
if len(thingInfo) == 0 {
|
||||
newThing = article{
|
||||
Duration: time.Now().Unix()*100 + int64(i),
|
||||
Type: typeOfThing,
|
||||
Name: thingName,
|
||||
}
|
||||
} else {
|
||||
newThing = thingInfo[0]
|
||||
}
|
||||
if equipInfo.Equip == "美西螈" && thingName != "美西螈" {
|
||||
number += 2
|
||||
}
|
||||
newThing.Number += number
|
||||
}
|
||||
err = dbdata.updateUserThingInfo(uid, newThing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.7]:", err))
|
||||
return
|
||||
}
|
||||
thingNameList[thingName] += number
|
||||
}
|
||||
}
|
||||
err = dbdata.updateCurseFor(uid, "fish", fishNumber)
|
||||
if err != nil {
|
||||
logrus.Warnln(err)
|
||||
}
|
||||
if len(thingNameList) == 1 {
|
||||
thingName := ""
|
||||
numberOfFish := 0
|
||||
for name, number := range thingNameList {
|
||||
thingName = name
|
||||
numberOfFish = number
|
||||
}
|
||||
if picName != "" {
|
||||
pic, err := engine.GetLazyData(picName+".png", false)
|
||||
if err != nil {
|
||||
logrus.Warnln("[mcfish]error:", err)
|
||||
ctx.SendChain(message.At(uid), message.Text("恭喜你钓到了", numberOfFish, thingName, "\n", msg))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.At(uid), message.Text("恭喜你钓到了", numberOfFish, thingName, "\n", msg), message.ImageBytes(pic))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.At(uid), message.Text("恭喜你钓到了", numberOfFish, thingName, "\n", msg))
|
||||
return
|
||||
}
|
||||
msgInfo := make(message.Message, 0, 3+len(thingNameList))
|
||||
msgInfo = append(msgInfo, message.Reply(ctx.Event.MessageID), message.Text("你进行了", fishNumber, "次钓鱼,结果如下:\n"))
|
||||
for name, number := range thingNameList {
|
||||
msgInfo = append(msgInfo, message.Text(name, " : ", number, "\n"))
|
||||
}
|
||||
msgInfo = append(msgInfo, message.Text(msg))
|
||||
ctx.Send(msgInfo)
|
||||
})
|
||||
}
|
||||
776
plugin/mcfish/main.go
Normal file
776
plugin/mcfish/main.go
Normal file
@@ -0,0 +1,776 @@
|
||||
// Package mcfish 钓鱼模拟器
|
||||
package mcfish
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
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"
|
||||
)
|
||||
|
||||
type fishdb struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// FishLimit 钓鱼次数上限
|
||||
const FishLimit = 50
|
||||
|
||||
// version 规则版本号
|
||||
const version = "5.4.2"
|
||||
|
||||
// 各物品信息
|
||||
type jsonInfo struct {
|
||||
ZoneInfo []zoneInfo `json:"分类"` // 区域概率
|
||||
ArticleInfo []articleInfo `json:"物品"` // 物品信息
|
||||
}
|
||||
type zoneInfo struct {
|
||||
Name string `json:"类型"` // 类型
|
||||
Probability int `json:"概率[0-100)"` // 概率
|
||||
}
|
||||
type articleInfo struct {
|
||||
Name string `json:"名称"` // 名称
|
||||
Type string `json:"类型"` // 类型
|
||||
Probability int `json:"概率[0-100),omitempty"` // 概率
|
||||
Durable int `json:"耐久上限,omitempty"` // 耐久
|
||||
Price int `json:"价格"` // 价格
|
||||
}
|
||||
|
||||
type probabilityLimit struct {
|
||||
Min int
|
||||
Max int
|
||||
}
|
||||
|
||||
type equip struct {
|
||||
ID int64 // 用户
|
||||
Equip string // 装备名称
|
||||
Durable int // 耐久
|
||||
Maintenance int // 维修次数
|
||||
Induce int // 诱钓等级
|
||||
Favor int // 眷顾等级
|
||||
}
|
||||
|
||||
type article struct {
|
||||
Duration int64
|
||||
Name string
|
||||
Number int
|
||||
Other string // 耐久/维修次数/诱钓/眷顾
|
||||
Type string
|
||||
}
|
||||
|
||||
type store struct {
|
||||
Duration int64
|
||||
Name string
|
||||
Number int
|
||||
Price int
|
||||
Other string // 耐久/维修次数/诱钓/眷顾
|
||||
Type string
|
||||
}
|
||||
|
||||
type fishState struct {
|
||||
ID int64
|
||||
Duration int64
|
||||
Fish int
|
||||
Equip int
|
||||
Curse int // 功德--(x)
|
||||
Bless int // 功德++(x)
|
||||
}
|
||||
|
||||
type storeDiscount struct {
|
||||
Name string
|
||||
Discount int
|
||||
}
|
||||
|
||||
// buff状态记录
|
||||
// buff0: 优惠卷
|
||||
type buffInfo struct {
|
||||
ID int64
|
||||
Duration int64
|
||||
BuyTimes int `db:"Buff0"` // 购买次数
|
||||
Coupon int `db:"Buff1"` // 优惠卷
|
||||
SalesPole int `db:"Buff2"` // 卖鱼竿上限
|
||||
BuyTing int `db:"Buff3"` // 购买上限
|
||||
Buff4 int `db:"Buff4"` // 暂定
|
||||
Buff5 int `db:"Buff5"` // 暂定
|
||||
Buff6 int `db:"Buff6"` // 暂定
|
||||
Buff7 int `db:"Buff7"` // 暂定
|
||||
Buff8 int `db:"Buff8"` // 暂定
|
||||
Buff9 int `db:"Buff9"` // 暂定
|
||||
}
|
||||
|
||||
var (
|
||||
articlesInfo = jsonInfo{} // 物品信息
|
||||
thingList = make([]string, 0, 100) // 竿列表
|
||||
poleList = make([]string, 0, 10) // 竿列表
|
||||
fishList = make([]string, 0, 10) // 鱼列表
|
||||
treasureList = make([]string, 0, 10) // 鱼列表
|
||||
wasteList = make([]string, 0, 10) // 垃圾列表
|
||||
probabilities = make(map[string]probabilityLimit, 50) // 概率分布
|
||||
priceList = make(map[string]int, 50) // 价格分布
|
||||
durationList = make(map[string]int, 50) // 装备耐久分布
|
||||
discountList = make(map[string]int, 50) // 价格波动信息
|
||||
enchantLevel = []string{"0", "Ⅰ", "Ⅱ", "Ⅲ"}
|
||||
dbdata = &fishdb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "钓鱼",
|
||||
Help: "一款钓鱼模拟器\n----------指令----------\n" +
|
||||
"- 钓鱼看板/钓鱼商店\n- 购买xxx\n- 购买xxx [数量]\n- 出售xxx\n- 出售xxx [数量]\n" +
|
||||
"- 钓鱼背包\n- 装备[xx竿|三叉戟|美西螈]\n- 附魔[诱钓|海之眷顾]\n- 修复鱼竿\n- 合成[xx竿|三叉戟]\n- 消除[绑定|宝藏]诅咒\n- 消除[绑定|宝藏]诅咒 [数量]\n" +
|
||||
"- 进行钓鱼\n- 进行n次钓鱼\n- 当前装备概率明细\n" +
|
||||
"规则V" + version + ":\n" +
|
||||
"1.每日的商店价格是波动的!!如何最大化收益自己考虑一下喔\n" +
|
||||
"2.装备信息:\n-> 木竿 : 耐久上限:30 均价:100 上钩概率:0.7%\n-> 铁竿 : 耐久上限:50 均价:300 上钩概率:0.2%\n-> 金竿 : 耐久上限:70 均价700 上钩概率:0.06%\n" +
|
||||
"-> 钻石竿 : 耐久上限:100 均价1500 上钩概率:0.03%\n-> 下界合金竿 : 耐久上限:150 均价3100 上钩概率:0.01%\n-> 三叉戟 : 可使1次钓鱼视为3次钓鱼. 耐久上限:300 均价4000 只能合成、修复和交易\n" +
|
||||
"3.附魔书信息:\n-> 诱钓 : 减少上钩时间. 均价:1000, 上钩概率:0.25%\n-> 海之眷顾 : 增加宝藏上钩概率. 均价:2500, 上钩概率:0.10%\n" +
|
||||
"4.稀有物品:\n-> 唱片 : 出售物品时使用该物品使价格翻倍. 均价:3000, 上钩概率:0.01%\n" +
|
||||
"-> 美西螈 : 可装备,获得隐形[钓鱼佬]buff,并让钓到除鱼竿和美西螈外的物品数量变成3,无耐久上限.不可修复/附魔,每次钓鱼消耗两任意鱼类物品. 均价:3000, 上钩概率:0.01%\n" +
|
||||
"-> 海豚 : 使空竿概率变成垃圾概率. 均价:1000, 上钩概率:0.19%\n" +
|
||||
"-> 宝藏诅咒 : 无法交易,每一层就会增加购买时10%价格和减少出售时10%价格(超过10层会变为倒贴钱). 上钩概率:0.25%\n-> 净化书 : 用于消除宝藏诅咒. 均价:5000, 上钩概率:0.19%\n" +
|
||||
"5.鱼类信息:\n-> 鳕鱼 : 均价:10 上钩概率:0.69%\n-> 鲑鱼 : 均价:50 上钩概率:0.2%\n-> 热带鱼 : 均价:100 上钩概率:0.06%\n-> 河豚 : 均价:300 上钩概率:0.03%\n-> 鹦鹉螺 : 均价:500 上钩概率:0.01%\n-> 墨鱼 : 均价:500 上钩概率:0.01%\n" +
|
||||
"6.垃圾:\n-> 均价:10 上钩概率:30%\n" +
|
||||
"7.物品BUFF:\n-> 钓鱼佬 : 当背包名字含有'鱼'的物品数量超过100时激活,钓到物品概率提高至90%\n-> 修复大师 : 当背包鱼竿数量超过10时激活,修复物品时耐久百分百继承\n" +
|
||||
"8.合成:\n-> 铁竿 : 3x木竿\n-> 金竿 : 3x铁竿\n-> 钻石竿 : 3x金竿\n-> 下界合金竿 : 3x钻石竿\n-> 三叉戟 : 3x下界合金竿\n注:合成成功率90%,继承附魔等级合/3的等级\n" +
|
||||
"9.杂项:\n-> 无装备的情况下,每人最多可以购买3次100块钱的鱼竿\n-> 默认状态钓鱼上钩概率为60%(理论值!!!)\n-> 附魔的鱼竿会因附魔变得昂贵,每个附魔最高3级\n-> 三叉戟不算鱼竿,修复时可直接满耐久\n" +
|
||||
"-> 鱼竿数量大于50的不能买东西;\n 鱼竿数量大于30的不能钓鱼;\n 每购/售10次鱼竿获得1层宝藏诅咒;\n 每购买20次物品将获得3次价格减半福利;\n 每钓鱼75次获得1本净化书;\n" +
|
||||
" 每天最多只可出售5个鱼竿和购买15次物品;",
|
||||
PublicDataFolder: "McFish",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbdata.db.DBPath = engine.DataFolder() + "fishdata.db"
|
||||
err := dbdata.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at main.go.1]:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
// go func() {
|
||||
_, err := engine.GetLazyData("articlesInfo.json", false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
reader, err := os.Open(engine.DataFolder() + "articlesInfo.json")
|
||||
if err == nil {
|
||||
err = json.NewDecoder(reader).Decode(&articlesInfo)
|
||||
}
|
||||
if err == nil {
|
||||
err = reader.Close()
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
probableList := make([]int, 4)
|
||||
for _, info := range articlesInfo.ZoneInfo {
|
||||
switch info.Name {
|
||||
case "treasure":
|
||||
probableList[0] = info.Probability
|
||||
case "pole":
|
||||
probableList[1] = info.Probability
|
||||
case "fish":
|
||||
probableList[2] = info.Probability
|
||||
case "waste":
|
||||
probableList[3] = info.Probability
|
||||
}
|
||||
}
|
||||
probabilities["treasure"] = probabilityLimit{
|
||||
Min: 0,
|
||||
Max: probableList[0],
|
||||
}
|
||||
probabilities["pole"] = probabilityLimit{
|
||||
Min: probableList[0],
|
||||
Max: probableList[1],
|
||||
}
|
||||
probabilities["fish"] = probabilityLimit{
|
||||
Min: probableList[1],
|
||||
Max: probableList[2],
|
||||
}
|
||||
probabilities["waste"] = probabilityLimit{
|
||||
Min: probableList[2],
|
||||
Max: probableList[3],
|
||||
}
|
||||
min := make(map[string]int, 4)
|
||||
for _, info := range articlesInfo.ArticleInfo {
|
||||
switch {
|
||||
case info.Type == "pole" || info.Name == "美西螈":
|
||||
poleList = append(poleList, info.Name)
|
||||
case info.Type == "fish" || info.Name == "海豚":
|
||||
fishList = append(fishList, info.Name)
|
||||
case info.Type == "waste":
|
||||
wasteList = append(wasteList, info.Name)
|
||||
case info.Type == "treasure":
|
||||
treasureList = append(treasureList, info.Name)
|
||||
}
|
||||
if info.Name != "宝藏诅咒" {
|
||||
thingList = append(thingList, info.Name)
|
||||
priceList[info.Name] = info.Price
|
||||
}
|
||||
if info.Durable != 0 {
|
||||
durationList[info.Name] = info.Durable
|
||||
}
|
||||
probabilities[info.Name] = probabilityLimit{
|
||||
Min: min[info.Type],
|
||||
Max: min[info.Type] + info.Probability,
|
||||
}
|
||||
min[info.Type] += info.Probability
|
||||
}
|
||||
// }()
|
||||
}
|
||||
|
||||
// 更新上限信息
|
||||
func (sql *fishdb) updateFishInfo(uid int64, number int) (residue int, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := fishState{ID: uid}
|
||||
err = sql.db.Create("fishState", &userInfo)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if time.Unix(userInfo.Duration, 0).Day() != time.Now().Day() {
|
||||
userInfo.Fish = 0
|
||||
userInfo.Duration = time.Now().Unix()
|
||||
}
|
||||
if userInfo.Fish >= FishLimit {
|
||||
return 0, nil
|
||||
}
|
||||
residue = number
|
||||
if userInfo.Fish+number > FishLimit {
|
||||
residue = FishLimit - userInfo.Fish
|
||||
number = residue
|
||||
}
|
||||
userInfo.Fish += number
|
||||
err = sql.db.Insert("fishState", &userInfo)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新诅咒
|
||||
func (sql *fishdb) updateCurseFor(uid int64, info string, number int) (err error) {
|
||||
if number < 1 {
|
||||
return
|
||||
}
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := fishState{ID: uid}
|
||||
err = sql.db.Create("fishState", &userInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
changeCheck := false
|
||||
add := 0
|
||||
buffName := "宝藏诅咒"
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if info == "fish" {
|
||||
userInfo.Bless += number
|
||||
for userInfo.Bless >= 75 {
|
||||
add++
|
||||
changeCheck = true
|
||||
buffName = "净化书"
|
||||
userInfo.Bless -= 75
|
||||
}
|
||||
} else {
|
||||
userInfo.Curse += number
|
||||
for userInfo.Curse >= 10 {
|
||||
add++
|
||||
changeCheck = true
|
||||
userInfo.Curse -= 10
|
||||
}
|
||||
}
|
||||
err = sql.db.Insert("fishState", &userInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if changeCheck {
|
||||
table := strconv.FormatInt(uid, 10) + "Pack"
|
||||
thing := article{
|
||||
Duration: time.Now().Unix(),
|
||||
Name: buffName,
|
||||
Type: "treasure",
|
||||
}
|
||||
_ = sql.db.Find(table, &thing, "where Name = '"+buffName+"'")
|
||||
thing.Number += add
|
||||
return sql.db.Insert(table, &thing)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/************************装备相关函数***********************/
|
||||
/*********************************************************/
|
||||
|
||||
func (sql *fishdb) checkEquipFor(uid int64) (ok bool, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := fishState{ID: uid}
|
||||
err = sql.db.Create("fishState", &userInfo)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !sql.db.CanFind("fishState", "where ID = "+strconv.FormatInt(uid, 10)) {
|
||||
return true, nil
|
||||
}
|
||||
err = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if userInfo.Equip > 3 {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (sql *fishdb) setEquipFor(uid int64) (err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := fishState{ID: uid}
|
||||
err = sql.db.Create("fishState", &userInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfo.Equip++
|
||||
return sql.db.Insert("fishState", &userInfo)
|
||||
}
|
||||
|
||||
// 获取装备信息
|
||||
func (sql *fishdb) getUserEquip(uid int64) (userInfo equip, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("equips", &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind("equips", "where ID = "+strconv.FormatInt(uid, 10)) {
|
||||
return
|
||||
}
|
||||
err = sql.db.Find("equips", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
return
|
||||
}
|
||||
|
||||
// 更新装备信息
|
||||
func (sql *fishdb) updateUserEquip(userInfo equip) (err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("equips", &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if userInfo.Durable == 0 {
|
||||
return sql.db.Del("equips", "where ID = "+strconv.FormatInt(userInfo.ID, 10))
|
||||
}
|
||||
return sql.db.Insert("equips", &userInfo)
|
||||
}
|
||||
|
||||
func (sql *fishdb) pickFishFor(uid int64, number int) (fishNames map[string]int, err error) {
|
||||
fishNames = make(map[string]int, 6)
|
||||
name := strconv.FormatInt(uid, 10) + "Pack"
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := article{}
|
||||
err = sql.db.Create(name, &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Type is 'fish'") {
|
||||
return
|
||||
}
|
||||
fishInfo := article{}
|
||||
k := 0
|
||||
for i := number * 2; i > 0 && k < len(fishList); {
|
||||
_ = sql.db.Find(name, &fishInfo, "where Name is '"+fishList[k]+"'")
|
||||
if fishInfo.Number <= 0 {
|
||||
k++
|
||||
continue
|
||||
}
|
||||
if fishInfo.Number < i {
|
||||
k++
|
||||
fishInfo.Number = 0
|
||||
i -= fishInfo.Number
|
||||
fishNames[fishInfo.Name] += fishInfo.Number
|
||||
} else {
|
||||
fishNames[fishInfo.Name] += i
|
||||
fishInfo.Number -= i
|
||||
i = 0
|
||||
}
|
||||
if fishInfo.Number <= 0 {
|
||||
err = sql.db.Del(name, "where Duration = "+strconv.FormatInt(fishInfo.Duration, 10))
|
||||
} else {
|
||||
err = sql.db.Insert(name, &fishInfo)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/************************背包相关函数***********************/
|
||||
/*********************************************************/
|
||||
|
||||
// 获取用户背包信息
|
||||
func (sql *fishdb) getUserPack(uid int64) (thingInfos []article, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := article{}
|
||||
err = sql.db.Create(strconv.FormatInt(uid, 10)+"Pack", &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count(strconv.FormatInt(uid, 10) + "Pack")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor(strconv.FormatInt(uid, 10)+"Pack", &userInfo, "ORDER by Type, Name, Other ASC", func() error {
|
||||
thingInfos = append(thingInfos, userInfo)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户物品信息
|
||||
func (sql *fishdb) getUserThingInfo(uid int64, thing string) (thingInfos []article, err error) {
|
||||
name := strconv.FormatInt(uid, 10) + "Pack"
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := article{}
|
||||
err = sql.db.Create(name, &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Name = '"+thing+"'") {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor(name, &userInfo, "where Name = '"+thing+"'", func() error {
|
||||
thingInfos = append(thingInfos, userInfo)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 更新用户物品信息
|
||||
func (sql *fishdb) updateUserThingInfo(uid int64, userInfo article) (err error) {
|
||||
name := strconv.FormatInt(uid, 10) + "Pack"
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create(name, &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if userInfo.Number == 0 {
|
||||
return sql.db.Del(name, "where Duration = "+strconv.FormatInt(userInfo.Duration, 10))
|
||||
}
|
||||
return sql.db.Insert(name, &userInfo)
|
||||
}
|
||||
|
||||
// 获取某关键字的数量
|
||||
func (sql *fishdb) getNumberFor(uid int64, thing string) (number int, err error) {
|
||||
name := strconv.FormatInt(uid, 10) + "Pack"
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := article{}
|
||||
err = sql.db.Create(name, &userInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Name glob '*"+thing+"*'") {
|
||||
return
|
||||
}
|
||||
info := article{}
|
||||
err = sql.db.FindFor(name, &info, "where Name glob '*"+thing+"*'", func() error {
|
||||
number += info.Number
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/************************商店相关函数***********************/
|
||||
/*********************************************************/
|
||||
|
||||
// 刷新商店信息
|
||||
func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("stroeDiscount", &storeDiscount{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
lastTime := storeDiscount{}
|
||||
_ = sql.db.Find("stroeDiscount", &lastTime, "where Name = 'lastTime'")
|
||||
refresh := false
|
||||
timeNow := time.Now().Day()
|
||||
if timeNow != lastTime.Discount {
|
||||
lastTime = storeDiscount{
|
||||
Name: "lastTime",
|
||||
Discount: timeNow,
|
||||
}
|
||||
err = sql.db.Insert("stroeDiscount", &lastTime)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
refresh = true
|
||||
}
|
||||
for _, name := range thingList {
|
||||
thing := storeDiscount{}
|
||||
switch refresh {
|
||||
case true:
|
||||
thingDiscount := 50 + rand.Intn(150)
|
||||
thing = storeDiscount{
|
||||
Name: name,
|
||||
Discount: thingDiscount,
|
||||
}
|
||||
err = sql.db.Insert("stroeDiscount", &thing)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
default:
|
||||
_ = sql.db.Find("stroeDiscount", &thing, "where Name = '"+name+"'")
|
||||
}
|
||||
if thing.Discount != 0 {
|
||||
discountList[name] = thing.Discount
|
||||
} else {
|
||||
discountList[name] = 100
|
||||
}
|
||||
}
|
||||
thing := store{}
|
||||
oldThing := []store{}
|
||||
_ = sql.db.FindFor("stroeDiscount", &thing, "where type = 'pole'", func() error {
|
||||
if time.Since(time.Unix(thing.Duration, 0)) > 24 {
|
||||
oldThing = append(oldThing, thing)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
for _, info := range oldThing {
|
||||
_ = sql.db.Del("stroeDiscount", "where Duration = "+strconv.FormatInt(info.Duration, 10))
|
||||
}
|
||||
if refresh {
|
||||
err = sql.db.Create("store", &store{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 每天调控1种鱼
|
||||
fish := fishList[rand.Intn(len(fishList))]
|
||||
thingInfo := store{
|
||||
Duration: time.Now().Unix(),
|
||||
Name: fish,
|
||||
Type: "fish",
|
||||
Price: priceList[fish] * discountList[fish] / 100,
|
||||
}
|
||||
_ = sql.db.Find("store", &thingInfo, "where Name = '"+fish+"'")
|
||||
thingInfo.Number += (100 - discountList[fish])
|
||||
if thingInfo.Number < 1 {
|
||||
thingInfo.Number = 100
|
||||
}
|
||||
_ = sql.db.Insert("store", &thingInfo)
|
||||
// 每天上架20本净化书
|
||||
thingInfo = store{
|
||||
Duration: time.Now().Unix(),
|
||||
Name: "净化书",
|
||||
Type: "article",
|
||||
Price: priceList["净化书"] * discountList["净化书"] / 100,
|
||||
}
|
||||
_ = sql.db.Find("store", &thingInfo, "where Name = '净化书'")
|
||||
thingInfo.Number = 20
|
||||
_ = sql.db.Insert("store", &thingInfo)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 获取商店信息
|
||||
func (sql *fishdb) getStoreInfo() (thingInfos []store, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
thingInfo := store{}
|
||||
err = sql.db.Create("store", &thingInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count("store")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor("store", &thingInfo, "ORDER by Type, Name, Price ASC", func() error {
|
||||
thingInfos = append(thingInfos, thingInfo)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取商店物品信息
|
||||
func (sql *fishdb) getStoreThingInfo(thing string) (thingInfos []store, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
thingInfo := store{}
|
||||
err = sql.db.Create("store", &thingInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count("store")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind("store", "where Name = '"+thing+"'") {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor("store", &thingInfo, "where Name = '"+thing+"'", func() error {
|
||||
thingInfos = append(thingInfos, thingInfo)
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取商店物品信息
|
||||
func (sql *fishdb) checkStoreFor(thing store, number int) (ok bool, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("store", &thing)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
count, err := sql.db.Count("store")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
return false, nil
|
||||
}
|
||||
if !sql.db.CanFind("store", "where Duration = "+strconv.FormatInt(thing.Duration, 10)) {
|
||||
return false, nil
|
||||
}
|
||||
err = sql.db.Find("store", &thing, "where Duration = "+strconv.FormatInt(thing.Duration, 10))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if thing.Number < number {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 更新商店信息
|
||||
func (sql *fishdb) updateStoreInfo(thingInfo store) (err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("store", &thingInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if thingInfo.Number == 0 {
|
||||
return sql.db.Del("store", "where Duration = "+strconv.FormatInt(thingInfo.Duration, 10))
|
||||
}
|
||||
return sql.db.Insert("store", &thingInfo)
|
||||
}
|
||||
|
||||
// 更新购买次数
|
||||
func (sql *fishdb) updateBuyTimeFor(uid int64, add int) (err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := buffInfo{ID: uid}
|
||||
err = sql.db.Create("buff", &userInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
userInfo.BuyTimes += add
|
||||
if userInfo.BuyTimes > 20 {
|
||||
userInfo.BuyTimes -= 20
|
||||
userInfo.Coupon = 3
|
||||
}
|
||||
return sql.db.Insert("buff", &userInfo)
|
||||
}
|
||||
|
||||
// 使用优惠卷
|
||||
func (sql *fishdb) useCouponAt(uid int64, times int) (int, error) {
|
||||
useTimes := -1
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := buffInfo{ID: uid}
|
||||
err := sql.db.Create("buff", &userInfo)
|
||||
if err != nil {
|
||||
return useTimes, err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if userInfo.Coupon > 0 {
|
||||
useTimes = math.Min(userInfo.Coupon, times)
|
||||
userInfo.Coupon -= useTimes
|
||||
}
|
||||
return useTimes, sql.db.Insert("buff", &userInfo)
|
||||
}
|
||||
|
||||
// 检测上限
|
||||
func (sql *fishdb) checkCanSalesFor(uid int64, sales bool) (int, error) {
|
||||
residue := 0
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
userInfo := buffInfo{ID: uid}
|
||||
err := sql.db.Create("buff", &userInfo)
|
||||
if err != nil {
|
||||
return residue, err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
if time.Now().Day() != time.Unix(userInfo.Duration, 0).Day() {
|
||||
userInfo.SalesPole = 0
|
||||
userInfo.BuyTing = 0
|
||||
}
|
||||
if sales && userInfo.SalesPole < 5 {
|
||||
residue = 5 - userInfo.SalesPole
|
||||
userInfo.SalesPole++
|
||||
} else if userInfo.BuyTing < 15 {
|
||||
residue = 15 - userInfo.SalesPole
|
||||
userInfo.SalesPole++
|
||||
}
|
||||
return residue, sql.db.Insert("buff", &userInfo)
|
||||
}
|
||||
517
plugin/mcfish/pack.go
Normal file
517
plugin/mcfish/pack.go
Normal file
@@ -0,0 +1,517 @@
|
||||
// Package mcfish 钓鱼模拟器
|
||||
package mcfish
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"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.OnFullMatch("钓鱼背包", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pack.go.1]:", err))
|
||||
return
|
||||
}
|
||||
articles, err := dbdata.getUserPack(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pack.go.2]:", err))
|
||||
return
|
||||
}
|
||||
pic, err := drawPackImage(uid, equipInfo, articles)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pack.go.3]:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(pic))
|
||||
})
|
||||
engine.OnRegex(`^消除绑定诅咒(\d*)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
number, _ := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
|
||||
if number == 0 {
|
||||
number = 1
|
||||
}
|
||||
number1, err := dbdata.getNumberFor(uid, "宝藏诅咒")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.3.1]:", err))
|
||||
return
|
||||
}
|
||||
if number1 == 0 {
|
||||
ctx.SendChain(message.Text("你没有绑定任何诅咒"))
|
||||
return
|
||||
}
|
||||
if number1 < number {
|
||||
number = number1
|
||||
}
|
||||
number2, err := dbdata.getNumberFor(uid, "净化书")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.3.2]:", err))
|
||||
return
|
||||
}
|
||||
if number2 < number {
|
||||
ctx.SendChain(message.Text("你没有足够的解除诅咒的道具"))
|
||||
return
|
||||
}
|
||||
articles, err := dbdata.getUserThingInfo(uid, "净化书")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.3.3]:", err))
|
||||
return
|
||||
}
|
||||
articles[0].Number -= number
|
||||
err = dbdata.updateUserThingInfo(uid, articles[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.3.4]:", err))
|
||||
return
|
||||
}
|
||||
articles, err = dbdata.getUserThingInfo(uid, "宝藏诅咒")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("消除失败,净化书销毁了\n[ERROR at store.go.3.5]:", err))
|
||||
return
|
||||
}
|
||||
articles[0].Number -= number
|
||||
err = dbdata.updateUserThingInfo(uid, articles[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.3.5]:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("消除成功"))
|
||||
})
|
||||
engine.OnFullMatch("当前装备概率明细", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pack.go.1]:", err))
|
||||
return
|
||||
}
|
||||
number, err := dbdata.getNumberFor(uid, "鱼")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5.1]:", err))
|
||||
return
|
||||
}
|
||||
msg := make(message.Message, 0, 20+len(thingList))
|
||||
msg = append(msg, message.At(uid), message.Text("\n大类概率:\n"))
|
||||
probableList := make([]int, 4)
|
||||
for _, info := range articlesInfo.ZoneInfo {
|
||||
switch info.Name {
|
||||
case "treasure":
|
||||
probableList[0] = info.Probability
|
||||
case "pole":
|
||||
probableList[1] = info.Probability
|
||||
case "fish":
|
||||
probableList[2] = info.Probability
|
||||
case "waste":
|
||||
probableList[3] = info.Probability
|
||||
}
|
||||
}
|
||||
if number > 100 || equipInfo.Equip == "美西螈" { // 放大概率
|
||||
probableList = []int{2, 8, 35, 45}
|
||||
}
|
||||
if equipInfo.Favor > 0 {
|
||||
probableList[0] += equipInfo.Favor
|
||||
probableList[1] += equipInfo.Favor
|
||||
probableList[2] += equipInfo.Favor
|
||||
probableList[3] -= equipInfo.Favor * 3
|
||||
}
|
||||
probable := probableList[0]
|
||||
msg = append(msg, message.Text("宝藏 : ", probableList[0], "%\n"))
|
||||
probable += probableList[1]
|
||||
msg = append(msg, message.Text("鱼竿 : ", probableList[1], "%\n"))
|
||||
probable += probableList[2]
|
||||
msg = append(msg, message.Text("鱼类 : ", probableList[2], "%\n"))
|
||||
probable += probableList[3]
|
||||
msg = append(msg, message.Text("垃圾 : ", probableList[3], "%\n"))
|
||||
msg = append(msg, message.Text("合计 : ", probable, "%\n"))
|
||||
msg = append(msg, message.Text("-----------\n宝藏概率:\n"))
|
||||
for _, name := range treasureList {
|
||||
msg = append(msg, message.Text(name, " : ",
|
||||
strconv.FormatFloat(float64(probabilities[name].Max-probabilities[name].Min)*float64(probableList[0])/100, 'f', 2, 64),
|
||||
"%\n"))
|
||||
}
|
||||
msg = append(msg, message.Text("-----------\n鱼竿概率:\n"))
|
||||
for _, name := range poleList {
|
||||
if name != "美西螈" {
|
||||
msg = append(msg, message.Text(name, " : ",
|
||||
strconv.FormatFloat(float64(probabilities[name].Max-probabilities[name].Min)*float64(probableList[1])/100, 'f', 2, 64),
|
||||
"%\n"))
|
||||
} else if name == "美西螈" {
|
||||
msg = append(msg, message.Text(name, " : ",
|
||||
strconv.FormatFloat(float64(probabilities[name].Max-probabilities[name].Min)*float64(probableList[0])/100, 'f', 2, 64),
|
||||
"%\n"))
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("-----------\n鱼类概率:\n"))
|
||||
for _, name := range fishList {
|
||||
if name != "海豚" {
|
||||
msg = append(msg, message.Text(name, " : ",
|
||||
strconv.FormatFloat(float64(probabilities[name].Max-probabilities[name].Min)*float64(probableList[2])/100, 'f', 2, 64),
|
||||
"%\n"))
|
||||
} else if name == "海豚" {
|
||||
msg = append(msg, message.Text(name, " : ",
|
||||
strconv.FormatFloat(float64(probabilities[name].Max-probabilities[name].Min)*float64(probableList[0])/100, 'f', 2, 64),
|
||||
"%\n"))
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("-----------"))
|
||||
ctx.Send(msg)
|
||||
})
|
||||
}
|
||||
|
||||
func drawPackImage(uid int64, equipInfo equip, articles []article) (imagePicByte []byte, err error) {
|
||||
fontdata, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
equipBlock image.Image // 装备信息
|
||||
packBlock image.Image // 背包信息
|
||||
)
|
||||
wg.Add(1)
|
||||
// 绘制ID
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if equipInfo == (equip{}) {
|
||||
equipBlock, err = drawEquipEmptyBlock(fontdata)
|
||||
} else {
|
||||
equipBlock, err = drawEquipInfoBlock(equipInfo, fontdata)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
wg.Add(1)
|
||||
// 绘制基本信息
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if len(articles) == 0 {
|
||||
packBlock, err = drawArticleEmptyBlock(fontdata)
|
||||
} else {
|
||||
packBlock, err = drawArticleInfoBlock(uid, articles, fontdata)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
wg.Wait()
|
||||
if equipBlock == nil || packBlock == nil {
|
||||
err = errors.New("生成图片失败,数据缺失")
|
||||
return
|
||||
}
|
||||
// 计算图片高度
|
||||
backDX := 1020
|
||||
backDY := 10 + equipBlock.Bounds().Dy() + 10 + packBlock.Bounds().Dy() + 10
|
||||
canvas := gg.NewContext(backDX, backDY)
|
||||
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, float64(backDX), float64(backDY))
|
||||
canvas.SetRGBA255(150, 150, 150, 255)
|
||||
canvas.Fill()
|
||||
canvas.DrawRectangle(10, 10, float64(backDX-20), float64(backDY-20))
|
||||
canvas.SetRGBA255(255, 255, 255, 255)
|
||||
canvas.Fill()
|
||||
|
||||
canvas.DrawImage(equipBlock, 10, 10)
|
||||
canvas.DrawImage(packBlock, 10, 10+equipBlock.Bounds().Dy()+10)
|
||||
|
||||
return imgfactory.ToBytes(canvas.Image())
|
||||
}
|
||||
|
||||
// 绘制装备栏区域
|
||||
func drawEquipEmptyBlock(fontdata []byte) (image.Image, error) {
|
||||
canvas := gg.NewContext(1000, 300)
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetRGBA255(255, 255, 255, 150)
|
||||
canvas.Fill()
|
||||
// 边框框
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
canvas.SetColor(color.Black)
|
||||
err := canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textW, textH := canvas.MeasureString("装备信息")
|
||||
canvas.DrawString("装备信息", 10, 10+textH)
|
||||
canvas.DrawLine(10, textH*1.2, textW, textH*1.2)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
if err = canvas.ParseFontFace(fontdata, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawString("没有装备任何鱼竿", 50, 10+textH*2+50)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
func drawEquipInfoBlock(equipInfo equip, fontdata []byte) (image.Image, error) {
|
||||
canvas := gg.NewContext(1, 1)
|
||||
err := canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, titleH := canvas.MeasureString("装备信息")
|
||||
err = canvas.ParseFontFace(fontdata, 50)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, textH := canvas.MeasureString("装备信息")
|
||||
|
||||
backDY := math.Max(int(10+titleH*2+(textH*2)*4+10), 300)
|
||||
|
||||
canvas = gg.NewContext(1000, backDY)
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, 1000, float64(backDY))
|
||||
canvas.SetRGBA255(255, 255, 255, 150)
|
||||
canvas.Fill()
|
||||
// 边框框
|
||||
canvas.DrawRectangle(0, 0, 1000, float64(backDY))
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
getAvatar, err := engine.GetLazyData(equipInfo.Equip+".png", false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
equipPic, _, err := image.Decode(bytes.NewReader(getAvatar))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
picDy := float64(backDY) - 10 - titleH*2
|
||||
equipPic = imgfactory.Size(equipPic, int(picDy)-10, int(picDy)-10).Image()
|
||||
canvas.DrawImage(equipPic, 10, 10+int(titleH)*2)
|
||||
|
||||
// 放字
|
||||
canvas.SetColor(color.Black)
|
||||
if err = canvas.ParseFontFace(fontdata, 100); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
titleW, titleH := canvas.MeasureString("装备信息")
|
||||
canvas.DrawString("装备信息", 10, 10+titleH*1.2)
|
||||
canvas.DrawLine(10, titleH*1.6, titleW, titleH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
textDx := picDy + 10
|
||||
textDy := 10 + titleH*2
|
||||
if err = canvas.ParseFontFace(fontdata, 75); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textW, textH := canvas.MeasureString(equipInfo.Equip)
|
||||
canvas.DrawStringAnchored(equipInfo.Equip, textDx+textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
|
||||
textDy += textH * 1.5
|
||||
if err = canvas.ParseFontFace(fontdata, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textW, textH = canvas.MeasureString("维修次数")
|
||||
durable := strconv.Itoa(equipInfo.Durable)
|
||||
valueW, _ := canvas.MeasureString("100")
|
||||
barW := 1000 - textDx - textW - 10 - valueW - 10
|
||||
|
||||
canvas.DrawStringAnchored("装备耐久", textDx+textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawRectangle(textDx+textW+5, textDy, barW, textH*1.2)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
durableW := barW * float64(equipInfo.Durable) / float64(durationList[equipInfo.Equip])
|
||||
canvas.DrawRectangle(textDx+textW+5, textDy, durableW, textH*1.2)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
canvas.Fill()
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawStringAnchored(durable, textDx+textW+5+barW+5+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
|
||||
textDy += textH * 2
|
||||
maintenance := strconv.Itoa(equipInfo.Maintenance)
|
||||
canvas.DrawStringAnchored("维修次数", textDx+textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawRectangle(textDx+textW+5, textDy, barW, textH*1.2)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(textDx+textW+5, textDy, barW*float64(equipInfo.Maintenance)/10, textH*1.2)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
canvas.Fill()
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawStringAnchored(maintenance, textDx+textW+5+barW+5+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
|
||||
textDy += textH * 3
|
||||
canvas.DrawString(" 附魔: 诱钓"+enchantLevel[equipInfo.Induce]+" 海之眷顾"+enchantLevel[equipInfo.Favor], textDx, textDy)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
|
||||
// 绘制背包信息区域
|
||||
func drawArticleEmptyBlock(fontdata []byte) (image.Image, error) {
|
||||
canvas := gg.NewContext(1000, 300)
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetRGBA255(255, 255, 255, 150)
|
||||
canvas.Fill()
|
||||
// 边框框
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
canvas.SetColor(color.Black)
|
||||
err := canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textW, textH := canvas.MeasureString("背包信息")
|
||||
canvas.DrawString("背包信息", 10, 10+textH*1.2)
|
||||
canvas.DrawLine(10, textH*1.6, textW, textH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
if err = canvas.ParseFontFace(fontdata, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored("背包没有存放任何东西", 500, 10+textH*2+50, 0.5, 0)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
func drawArticleInfoBlock(uid int64, articles []article, fontdata []byte) (image.Image, error) {
|
||||
canvas := gg.NewContext(1, 1)
|
||||
err := canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
titleW, titleH := canvas.MeasureString("背包信息")
|
||||
front := 45.0
|
||||
err = canvas.ParseFontFace(fontdata, front)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, textH := canvas.MeasureString("高度")
|
||||
|
||||
nameWOfFiest := 0.0
|
||||
nameWOfSecond := 0.0
|
||||
for i, info := range articles {
|
||||
textW, _ := canvas.MeasureString(info.Name + "(" + info.Other + ")")
|
||||
if i%2 == 0 && textW > nameWOfFiest {
|
||||
nameWOfFiest = textW
|
||||
} else if textW > nameWOfSecond {
|
||||
nameWOfSecond = textW
|
||||
}
|
||||
}
|
||||
valueW, _ := canvas.MeasureString("10000")
|
||||
|
||||
if (10+nameWOfFiest+10+valueW+10)+(10+nameWOfSecond+10+valueW+10) > 980 {
|
||||
front = 32.0
|
||||
err = canvas.ParseFontFace(fontdata, front)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, textH = canvas.MeasureString("高度")
|
||||
|
||||
nameWOfFiest = 0
|
||||
nameWOfSecond = 0
|
||||
for i, info := range articles {
|
||||
textW, _ := canvas.MeasureString(info.Name + "(" + info.Other + ")")
|
||||
if i%2 == 0 && textW > nameWOfFiest {
|
||||
nameWOfFiest = textW
|
||||
} else if textW > nameWOfSecond {
|
||||
nameWOfSecond = textW
|
||||
}
|
||||
}
|
||||
valueW, _ = canvas.MeasureString("10000")
|
||||
}
|
||||
wallW := (980 - (10 + nameWOfFiest + 10 + valueW + 10) - (10 + nameWOfSecond + 10 + valueW + 10)) / 2
|
||||
backY := math.Max(10+int(titleH*1.6)+10+int(textH*2)*(math.Ceil(len(articles), 2)+1), 500)
|
||||
canvas = gg.NewContext(1000, backY)
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, 1000, float64(backY))
|
||||
canvas.SetRGBA255(255, 255, 255, 150)
|
||||
canvas.Fill()
|
||||
// 边框框
|
||||
canvas.DrawRectangle(0, 0, 1000, float64(backY))
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
// 放字
|
||||
canvas.SetColor(color.Black)
|
||||
err = canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawString("背包信息", 10, 10+titleH*1.2)
|
||||
canvas.DrawLine(10, titleH*1.6, titleW, titleH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
textDy := 10 + titleH*1.7
|
||||
if err = canvas.ParseFontFace(fontdata, front); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.SetColor(color.Black)
|
||||
numberOfFish := 0
|
||||
numberOfEquip := 0
|
||||
canvas.DrawStringAnchored("名称", wallW+20+nameWOfFiest/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("数量", wallW+20+nameWOfFiest+10+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("名称", wallW+20+nameWOfFiest+10+valueW+10+10+nameWOfSecond/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("数量", wallW+20+nameWOfFiest+10+valueW+10+10+nameWOfSecond+10+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
textDy += textH * 2
|
||||
for i, info := range articles {
|
||||
name := info.Name
|
||||
if info.Other != "" {
|
||||
if strings.Contains(info.Name, "竿") {
|
||||
numberOfEquip++
|
||||
}
|
||||
name += "(" + info.Other + ")"
|
||||
} else if strings.Contains(name, "鱼") {
|
||||
numberOfFish += info.Number
|
||||
}
|
||||
valueStr := strconv.Itoa(info.Number)
|
||||
if i%2 == 0 {
|
||||
if i != 0 {
|
||||
textDy += textH * 2
|
||||
}
|
||||
canvas.DrawStringAnchored(name, wallW+20+nameWOfFiest/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored(valueStr, wallW+20+nameWOfFiest+10+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
} else {
|
||||
canvas.DrawStringAnchored(name, wallW+20+nameWOfFiest+10+valueW+10+10+nameWOfSecond/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored(valueStr, wallW+20+nameWOfFiest+10+valueW+10+10+nameWOfSecond+10+valueW/2, textDy+textH/2, 0.5, 0.5)
|
||||
}
|
||||
}
|
||||
if err = canvas.ParseFontFace(fontdata, 30); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textDy = 10
|
||||
text := "钱包余额: " + strconv.Itoa(wallet.GetWalletOf(uid))
|
||||
textW, textH := canvas.MeasureString(text)
|
||||
w, _ := canvas.MeasureString("维修大师[已激活]")
|
||||
if w > textW {
|
||||
textW = w
|
||||
}
|
||||
canvas.DrawStringAnchored(text, 980-textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
textDy += textH * 1.5
|
||||
if numberOfFish > 100 {
|
||||
canvas.DrawStringAnchored("钓鱼佬[已激活]", 980-textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
textDy += textH * 1.5
|
||||
}
|
||||
if numberOfEquip > 10 {
|
||||
canvas.DrawStringAnchored("维修大师[已激活]", 980-textW/2, textDy+textH/2, 0.5, 0.5)
|
||||
}
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
485
plugin/mcfish/pole.go
Normal file
485
plugin/mcfish/pole.go
Normal file
@@ -0,0 +1,485 @@
|
||||
// Package mcfish 钓鱼模拟器
|
||||
package mcfish
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnRegex(`^装备(`+strings.Join(poleList, "|")+`)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.1]:", err))
|
||||
return
|
||||
}
|
||||
thingName := ctx.State["regex_matched"].([]string)[1]
|
||||
articles, err := dbdata.getUserThingInfo(uid, thingName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.2]:", err))
|
||||
return
|
||||
}
|
||||
if len(articles) == 0 {
|
||||
ctx.SendChain(message.Text("你的背包不存在该物品"))
|
||||
return
|
||||
}
|
||||
poles := make([]equip, 0, len(articles))
|
||||
if thingName != "美西螈" {
|
||||
for _, info := range articles {
|
||||
poleInfo := strings.Split(info.Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
poles = append(poles, equip{
|
||||
ID: uid,
|
||||
Equip: info.Name,
|
||||
Durable: durable,
|
||||
Maintenance: maintenance,
|
||||
Induce: induceLevel,
|
||||
Favor: favorLevel,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
poles = append(poles, equip{
|
||||
ID: uid,
|
||||
Equip: thingName,
|
||||
Durable: 999,
|
||||
})
|
||||
}
|
||||
check := false
|
||||
index := 0
|
||||
if len(poles) > 1 {
|
||||
msg := make(message.Message, 0, 3+len(articles))
|
||||
msg = append(msg, message.Reply(ctx.Event.MessageID), message.Text("找到以下鱼竿:\n"))
|
||||
for i, info := range poles {
|
||||
msg = append(msg, message.Text("[", i, "] ", info.Equip, " : 耐", info.Durable, "/修", info.Maintenance,
|
||||
"/诱", enchantLevel[info.Induce], "/眷顾", enchantLevel[info.Favor], "\n"))
|
||||
}
|
||||
msg = append(msg, message.Text("————————\n输入对应序号进行装备,或回复“取消”取消"))
|
||||
ctx.Send(msg)
|
||||
// 等待用户下一步选择
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("等待超时,取消装备"),
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "取消" {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("已取消装备"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
index, err = strconv.Atoi(nextcmd)
|
||||
if err != nil || index > len(articles)-1 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入正确的序号"))
|
||||
continue
|
||||
}
|
||||
check = true
|
||||
}
|
||||
if check {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
newEquipInfo := poles[index]
|
||||
packEquip := articles[index]
|
||||
packEquip.Number--
|
||||
err = dbdata.updateUserThingInfo(uid, packEquip)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.3]:", err))
|
||||
return
|
||||
}
|
||||
err = dbdata.updateUserEquip(newEquipInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.3.1]:", err))
|
||||
return
|
||||
}
|
||||
oldthing := article{}
|
||||
if equipInfo != (equip{}) && equipInfo.Equip != "美西螈" {
|
||||
oldthing = article{
|
||||
Duration: time.Now().Unix(),
|
||||
Type: "pole",
|
||||
Name: equipInfo.Equip,
|
||||
Number: 1,
|
||||
Other: strconv.Itoa(equipInfo.Durable) + "/" + strconv.Itoa(equipInfo.Maintenance) + "/" + strconv.Itoa(equipInfo.Induce) + "/" + strconv.Itoa(equipInfo.Favor),
|
||||
}
|
||||
} else if equipInfo.Equip == "美西螈" {
|
||||
articles, err = dbdata.getUserThingInfo(uid, "美西螈")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.3.2]:", err))
|
||||
return
|
||||
}
|
||||
if len(articles) == 0 {
|
||||
oldthing = article{
|
||||
Duration: time.Now().Unix(),
|
||||
Type: "pole",
|
||||
Name: equipInfo.Equip,
|
||||
Number: 1,
|
||||
}
|
||||
} else {
|
||||
oldthing = articles[0]
|
||||
oldthing.Number++
|
||||
}
|
||||
}
|
||||
err = dbdata.updateUserThingInfo(uid, oldthing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.4]:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("装备成功"),
|
||||
),
|
||||
)
|
||||
})
|
||||
engine.OnFullMatchGroup([]string{"修复鱼竿", "维修鱼竿"}, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.5]:", err))
|
||||
return
|
||||
}
|
||||
if equipInfo.Equip == "" || equipInfo.Equip == "美西螈" {
|
||||
ctx.SendChain(message.Text("仅能修复装备中的鱼竿"))
|
||||
return
|
||||
}
|
||||
if equipInfo.Maintenance >= 10 {
|
||||
ctx.SendChain(message.Text("装备的鱼竿已经达到修复上限"))
|
||||
return
|
||||
}
|
||||
articles, err := dbdata.getUserThingInfo(uid, equipInfo.Equip)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.6]:", err))
|
||||
return
|
||||
}
|
||||
if len(articles) == 0 {
|
||||
ctx.SendChain(message.Text("你的背包不存在相同鱼竿进行修复"))
|
||||
return
|
||||
}
|
||||
poles := make([]equip, 0, len(articles))
|
||||
for _, info := range articles {
|
||||
poleInfo := strings.Split(info.Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
poles = append(poles, equip{
|
||||
ID: uid,
|
||||
Equip: info.Name,
|
||||
Durable: durable,
|
||||
Maintenance: maintenance,
|
||||
Induce: induceLevel,
|
||||
Favor: favorLevel,
|
||||
})
|
||||
}
|
||||
index := 0
|
||||
check := false
|
||||
if len(articles) > 1 {
|
||||
msg := make(message.Message, 0, 3+len(articles))
|
||||
msg = append(msg, message.Text("找到以下鱼竿:\n"))
|
||||
for i, info := range poles {
|
||||
msg = append(msg, message.Text("[", i, "] ", info.Equip, " : 耐", info.Durable, "/修", info.Maintenance,
|
||||
"/诱", enchantLevel[info.Induce], "/眷顾", enchantLevel[info.Favor], "\n"))
|
||||
}
|
||||
msg = append(msg, message.Text("————————\n输入对应序号进行修复,或回复“取消”取消"))
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, msg...))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("等待超时,取消修复"),
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "取消" {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("已取消修复"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
index, err = strconv.Atoi(nextcmd)
|
||||
if err != nil || index > len(articles)-1 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入正确的序号"))
|
||||
continue
|
||||
}
|
||||
check = true
|
||||
}
|
||||
if check {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
newEquipInfo := poles[index]
|
||||
number, err := dbdata.getNumberFor(uid, "竿")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at fish.go.5.1]:", err))
|
||||
return
|
||||
}
|
||||
if number <= 10 {
|
||||
number = 8
|
||||
} else {
|
||||
number = 10
|
||||
}
|
||||
equipInfo.Durable += newEquipInfo.Durable * number / 10
|
||||
if equipInfo.Durable > durationList[equipInfo.Equip] || equipInfo.Equip == "三叉戟" {
|
||||
equipInfo.Durable = durationList[equipInfo.Equip]
|
||||
}
|
||||
msg := ""
|
||||
if newEquipInfo.Induce != 0 && rand.Intn(100) < 50 {
|
||||
equipInfo.Induce += newEquipInfo.Induce
|
||||
if equipInfo.Induce > 3 {
|
||||
equipInfo.Induce = 3
|
||||
}
|
||||
msg += ",诱钓等级提升至" + enchantLevel[equipInfo.Induce]
|
||||
}
|
||||
if newEquipInfo.Favor != 0 && rand.Intn(100) < 50 {
|
||||
equipInfo.Favor += newEquipInfo.Favor
|
||||
if equipInfo.Favor > 3 {
|
||||
equipInfo.Favor = 3
|
||||
}
|
||||
msg += ",海之眷顾等级提升至" + enchantLevel[equipInfo.Favor]
|
||||
}
|
||||
thingInfo := articles[index]
|
||||
thingInfo.Number = 0
|
||||
err = dbdata.updateUserThingInfo(uid, thingInfo)
|
||||
if err == nil {
|
||||
equipInfo.Maintenance++
|
||||
err = dbdata.updateUserEquip(equipInfo)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.7]:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("鱼竿修复成功,耐久提高至", equipInfo.Durable, msg),
|
||||
),
|
||||
)
|
||||
})
|
||||
engine.OnRegex(`^附魔(诱钓|海之眷顾)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
equipInfo, err := dbdata.getUserEquip(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.7]:", err))
|
||||
return
|
||||
}
|
||||
if equipInfo.Equip == "" || equipInfo.Equip == "美西螈" {
|
||||
ctx.SendChain(message.Text("仅可对装备中的进行附魔"))
|
||||
return
|
||||
}
|
||||
book := ctx.State["regex_matched"].([]string)[1]
|
||||
books, err := dbdata.getUserThingInfo(uid, book)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.8]:", err))
|
||||
return
|
||||
}
|
||||
if len(books) == 0 {
|
||||
ctx.SendChain(message.Text("你的背包不存在", book, "进行附魔"))
|
||||
return
|
||||
}
|
||||
bookInfo := books[0]
|
||||
bookInfo.Number--
|
||||
err = dbdata.updateUserThingInfo(uid, bookInfo)
|
||||
number := 0
|
||||
if err == nil {
|
||||
if rand.Intn(100) > 50 {
|
||||
ctx.SendChain(message.Text("附魔失败了"))
|
||||
return
|
||||
}
|
||||
switch book {
|
||||
case "诱钓":
|
||||
equipInfo.Induce++
|
||||
if equipInfo.Induce > 3 {
|
||||
equipInfo.Induce = 3
|
||||
}
|
||||
number = equipInfo.Induce
|
||||
case "海之眷顾":
|
||||
equipInfo.Favor++
|
||||
if equipInfo.Favor > 3 {
|
||||
equipInfo.Favor = 3
|
||||
}
|
||||
number = equipInfo.Favor
|
||||
default:
|
||||
ctx.SendChain(message.Text("附魔失败了"))
|
||||
return
|
||||
}
|
||||
err = dbdata.updateUserEquip(equipInfo)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.9]:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("附魔成功,", book, "等级提高至", enchantLevel[number]))
|
||||
})
|
||||
engine.OnRegex(`^合成(.+竿|三叉戟)$`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
thingList := []string{"木竿", "铁竿", "金竿", "钻石竿", "下界合金竿", "三叉戟"}
|
||||
thingName := ctx.State["regex_matched"].([]string)[1]
|
||||
indexOfMaterial := -1
|
||||
for i, name := range thingList {
|
||||
if thingName == name {
|
||||
indexOfMaterial = (i - 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
if indexOfMaterial < 0 {
|
||||
return
|
||||
}
|
||||
articles, err := dbdata.getUserThingInfo(uid, thingList[indexOfMaterial])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.10]:", err))
|
||||
return
|
||||
}
|
||||
max := len(articles)
|
||||
if max < 3 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你的合成材料不足"))
|
||||
return
|
||||
}
|
||||
poles := make([]equip, 0, max)
|
||||
for _, info := range articles {
|
||||
poleInfo := strings.Split(info.Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
poles = append(poles, equip{
|
||||
ID: uid,
|
||||
Equip: info.Name,
|
||||
Durable: durable,
|
||||
Maintenance: maintenance,
|
||||
Induce: induceLevel,
|
||||
Favor: favorLevel,
|
||||
})
|
||||
}
|
||||
list := []int{0, 1, 2}
|
||||
check := false
|
||||
if len(articles) > 3 {
|
||||
msg := make(message.Message, 0, 3+len(articles))
|
||||
msg = append(msg, message.Text("找到以下鱼竿:\n"))
|
||||
for i, info := range poles {
|
||||
msg = append(msg, message.Text("[", i, "] ", info.Equip, " : 耐", info.Durable, "/修", info.Maintenance,
|
||||
"/诱", enchantLevel[info.Induce], "/眷顾", enchantLevel[info.Favor], "\n"))
|
||||
}
|
||||
msg = append(msg, message.Text("————————\n输入3个序号进行合成(用空格分割),或回复“取消”取消"))
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, msg...))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+ \d+ \d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("等待超时,取消合成"),
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "取消" {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("已取消合成"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
chooseList := strings.Split(nextcmd, " ")
|
||||
first, err := strconv.Atoi(chooseList[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.11.1]:", err))
|
||||
return
|
||||
}
|
||||
second, err := strconv.Atoi(chooseList[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.11.2]:", err))
|
||||
return
|
||||
}
|
||||
third, err := strconv.Atoi(chooseList[2])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.11.3]:", err))
|
||||
return
|
||||
}
|
||||
list = []int{first, second, third}
|
||||
if first == second || first == third || second == third {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("[0]请输入正确的序号\n", list))
|
||||
continue
|
||||
}
|
||||
if first > max || second > max || third > max {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("[", max, "]请输入正确的序号\n", list))
|
||||
continue
|
||||
}
|
||||
check = true
|
||||
}
|
||||
if check {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
favorLevel := 0
|
||||
induceLevel := 0
|
||||
for _, index := range list {
|
||||
thingInfo := articles[index]
|
||||
thingInfo.Number = 0
|
||||
err = dbdata.updateUserThingInfo(uid, thingInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.12]:", err))
|
||||
return
|
||||
}
|
||||
favorLevel += poles[index].Favor
|
||||
induceLevel += poles[index].Induce
|
||||
}
|
||||
if rand.Intn(100) >= 90 {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("合成失败,材料已销毁"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
attribute := strconv.Itoa(durationList[thingName]) + "/0/" + strconv.Itoa(induceLevel/3) + "/" + strconv.Itoa(favorLevel/3)
|
||||
newthing := article{
|
||||
Duration: time.Now().Unix(),
|
||||
Type: "pole",
|
||||
Name: thingName,
|
||||
Number: 1,
|
||||
Other: attribute,
|
||||
}
|
||||
err = dbdata.updateUserThingInfo(uid, newthing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at pole.go.12]:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text(thingName, "合成成功", list, "\n属性: ", attribute),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
702
plugin/mcfish/store.go
Normal file
702
plugin/mcfish/store.go
Normal file
@@ -0,0 +1,702 @@
|
||||
// Package mcfish 钓鱼模拟器
|
||||
package mcfish
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
storeLimiter = rate.NewManager[int64](time.Second*3, 1)
|
||||
refresh = false
|
||||
timeNow = 0
|
||||
refreshFish = func(ctx *zero.Ctx) bool {
|
||||
if refresh && timeNow == time.Now().Day() {
|
||||
return true
|
||||
}
|
||||
refresh, err := dbdata.refreshStroeInfo()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.1]:", err))
|
||||
return refresh
|
||||
}
|
||||
timeNow = time.Now().Day()
|
||||
return refresh
|
||||
}
|
||||
)
|
||||
|
||||
func limitSet(ctx *zero.Ctx) *rate.Limiter {
|
||||
return storeLimiter.Load(ctx.Event.UserID)
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatchGroup([]string{"钓鱼看板", "钓鱼商店"}, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
|
||||
infos, err := dbdata.getStoreInfo()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.2]:", err))
|
||||
return
|
||||
}
|
||||
var picImage image.Image
|
||||
if len(infos) == 0 {
|
||||
picImage, err = drawStroeEmptyImage()
|
||||
} else {
|
||||
picImage, err = drawStroeInfoImage(infos)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.3]:", err))
|
||||
return
|
||||
}
|
||||
pic, err := imgfactory.ToBytes(picImage)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.4]:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(pic))
|
||||
})
|
||||
engine.OnRegex(`^出售(`+strings.Join(thingList, "|")+`)\s*(\d*)$`, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
thingName := ctx.State["regex_matched"].([]string)[1]
|
||||
if strings.Contains(thingName, "竿") {
|
||||
times, err := dbdata.checkCanSalesFor(uid, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.75]:", err))
|
||||
return
|
||||
}
|
||||
if times <= 0 {
|
||||
ctx.SendChain(message.Text("出售次数已达到上限,明天再来售卖吧"))
|
||||
return
|
||||
}
|
||||
}
|
||||
number, _ := strconv.Atoi(ctx.State["regex_matched"].([]string)[2])
|
||||
if number == 0 || strings.Contains(thingName, "竿") {
|
||||
number = 1
|
||||
}
|
||||
articles, err := dbdata.getUserThingInfo(uid, thingName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.5]:", err))
|
||||
return
|
||||
}
|
||||
if len(articles) == 0 {
|
||||
ctx.SendChain(message.Text("你的背包不存在该物品"))
|
||||
return
|
||||
}
|
||||
index := 0
|
||||
thing := article{}
|
||||
if len(articles) > 1 {
|
||||
msg := make(message.Message, 0, 3+len(articles))
|
||||
msg = append(msg, message.Reply(ctx.Event.MessageID), message.Text("找到以下物品:\n"))
|
||||
for i, info := range articles {
|
||||
if info.Other != "" && info.Name != "美西螈" {
|
||||
msg = append(msg, message.Text("[", i, "] ", info.Name, "(", info.Other, ")\n"))
|
||||
} else {
|
||||
msg = append(msg, message.Text(
|
||||
"[", i, "]", info.Name, " 数量: ", info.Number, "\n"))
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("————————\n输入对应序号进行装备,或回复“取消”取消"))
|
||||
ctx.Send(msg)
|
||||
// 等待用户下一步选择
|
||||
sell := false
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("等待超时,取消出售"),
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "取消" {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("已取消出售"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
index, err = strconv.Atoi(nextcmd)
|
||||
if err != nil || index > len(articles)-1 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入正确的序号"))
|
||||
continue
|
||||
}
|
||||
sell = true
|
||||
}
|
||||
if sell {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thing = articles[index]
|
||||
if thing.Number < number {
|
||||
number = thing.Number
|
||||
}
|
||||
|
||||
var pice int
|
||||
if strings.Contains(thingName, "竿") || thingName == "三叉戟" {
|
||||
poleInfo := strings.Split(articles[index].Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
pice = (priceList[thingName] - (durationList[thingName] - durable) - maintenance*2 + induceLevel*600 + favorLevel*1800) * discountList[thingName] / 100
|
||||
} else {
|
||||
pice = priceList[thingName] * discountList[thingName] / 100
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("是否接受商店将以", pice*number*8/10, "收购", number, "个", thingName, "?\n回答\"是\"或\"否\"")))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel1 := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(是|否)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel1()
|
||||
buy := false
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 60):
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("等待超时,取消钓鱼")))
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "否" {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已取消出售")))
|
||||
return
|
||||
}
|
||||
buy = true
|
||||
}
|
||||
if buy {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
records, err := dbdata.getUserThingInfo(uid, "唱片")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.1]:", err))
|
||||
return
|
||||
}
|
||||
if len(records) != 0 {
|
||||
recordInfo := records[0]
|
||||
numberOfRecord := recordInfo.Number
|
||||
if thingName == "唱片" {
|
||||
numberOfRecord -= number
|
||||
}
|
||||
if numberOfRecord > 0 {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("是否使用唱片让价格翻倍?\n回答\"是\"或\"否\"")))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel2 := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(是|否)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel2()
|
||||
use := false
|
||||
checkTime := false
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 60):
|
||||
checkTime = true
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "是" {
|
||||
use = true
|
||||
}
|
||||
checkTime = true
|
||||
}
|
||||
if checkTime {
|
||||
break
|
||||
}
|
||||
}
|
||||
if use {
|
||||
pice *= 2
|
||||
if thingName == "唱片" {
|
||||
thing.Number--
|
||||
}
|
||||
recordInfo.Number--
|
||||
err = dbdata.updateUserThingInfo(uid, recordInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.2]:", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
msg := ""
|
||||
curse, err := dbdata.getNumberFor(uid, "宝藏诅咒")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.3]:", err))
|
||||
return
|
||||
}
|
||||
if curse != 0 {
|
||||
msg = "\n(你身上绑定了" + strconv.Itoa(curse) + "层诅咒)"
|
||||
pice = pice * (100 - 10*curse) / 100
|
||||
}
|
||||
thing.Number -= number
|
||||
err = dbdata.updateUserThingInfo(uid, thing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.6]:", err))
|
||||
return
|
||||
}
|
||||
newCommodity := store{}
|
||||
if strings.Contains(thing.Name, "竿") || thing.Name == "三叉戟" {
|
||||
if pice >= priceList[thing.Name]*2 { // 无附魔的不要
|
||||
newCommodity = store{
|
||||
Duration: time.Now().Unix(),
|
||||
Type: "pole",
|
||||
Name: thing.Name,
|
||||
Number: 1,
|
||||
Price: pice,
|
||||
Other: thing.Other,
|
||||
}
|
||||
polelist, _ := dbdata.getStoreThingInfo(thing.Name)
|
||||
if len(polelist) > 5 { // 超出上限的不要
|
||||
newCommodity.Type = "waste"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
things, err1 := dbdata.getStoreThingInfo(thingName)
|
||||
if err1 != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.8]:", err1))
|
||||
return
|
||||
}
|
||||
if len(things) == 0 {
|
||||
things = append(things, store{
|
||||
Duration: time.Now().Unix(),
|
||||
Name: thing.Name,
|
||||
Price: pice,
|
||||
Type: thing.Type,
|
||||
})
|
||||
}
|
||||
newCommodity = things[0]
|
||||
if newCommodity.Number < 255 {
|
||||
newCommodity.Number += number
|
||||
if newCommodity.Number > 255 {
|
||||
newCommodity.Number = 255
|
||||
}
|
||||
}
|
||||
}
|
||||
if newCommodity != (store{}) && newCommodity.Type != "waste" { // 不收垃圾
|
||||
err = dbdata.updateStoreInfo(newCommodity)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9]:", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
pice = pice * 8 / 10
|
||||
err = wallet.InsertWalletOf(uid, pice*number)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.10]:", err))
|
||||
return
|
||||
}
|
||||
if strings.Contains(thingName, "竿") {
|
||||
err = dbdata.updateCurseFor(uid, "sell", 1)
|
||||
if err != nil {
|
||||
logrus.Warnln(err)
|
||||
}
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("出售成功,你赚到了", pice*number, msg)))
|
||||
})
|
||||
engine.OnRegex(`^购买(`+strings.Join(thingList, "|")+`)\s*(\d*)$`, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
numberOfPole, err := dbdata.getNumberFor(uid, "竿")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.3]:", err))
|
||||
return
|
||||
}
|
||||
if numberOfPole > 50 {
|
||||
ctx.SendChain(message.Text("你有", numberOfPole, "支鱼竿,大于50支的玩家不允许购买东西"))
|
||||
return
|
||||
}
|
||||
buytimes, err := dbdata.checkCanSalesFor(uid, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.75]:", err))
|
||||
return
|
||||
}
|
||||
if buytimes <= 0 {
|
||||
ctx.SendChain(message.Text("出售次数已达到上限,明天再来购买吧"))
|
||||
return
|
||||
}
|
||||
thingName := ctx.State["regex_matched"].([]string)[1]
|
||||
number, _ := strconv.Atoi(ctx.State["regex_matched"].([]string)[2])
|
||||
if number == 0 {
|
||||
number = 1
|
||||
}
|
||||
thingInfos, err := dbdata.getStoreThingInfo(thingName)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.11]:", err))
|
||||
return
|
||||
}
|
||||
if len(thingInfos) == 0 {
|
||||
ctx.SendChain(message.Text("当前商店并没有上架该物品"))
|
||||
return
|
||||
}
|
||||
if thingName == "净化书" {
|
||||
curse, err := dbdata.getNumberFor(uid, "宝藏诅咒")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.303]:", err))
|
||||
return
|
||||
}
|
||||
if curse == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你身上没有诅咒,不能购买该商品"))
|
||||
return
|
||||
}
|
||||
bless, err := dbdata.getNumberFor(uid, "净化书")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.303]:", err))
|
||||
return
|
||||
}
|
||||
if bless >= curse {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你身上净化书已足够,不能购买该商品"))
|
||||
return
|
||||
}
|
||||
if curse < number {
|
||||
number = curse
|
||||
}
|
||||
}
|
||||
index := 0
|
||||
pice := make([]int, 0, len(thingInfos))
|
||||
for _, info := range thingInfos {
|
||||
if strings.Contains(thingName, "竿") || thingName == "三叉戟" {
|
||||
poleInfo := strings.Split(info.Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
thingPice := (priceList[info.Name] - (durationList[info.Name] - durable) - maintenance*2 + induceLevel*600 + favorLevel*1800) * discountList[info.Name] / 100
|
||||
pice = append(pice, thingPice)
|
||||
} else {
|
||||
thingPice := priceList[info.Name] * discountList[info.Name] / 100
|
||||
pice = append(pice, thingPice)
|
||||
}
|
||||
}
|
||||
if len(thingInfos) > 1 {
|
||||
msg := make(message.Message, 0, 3+len(thingInfos))
|
||||
msg = append(msg, message.Text("找到以下物品:\n"))
|
||||
for i, info := range thingInfos {
|
||||
if strings.Contains(thingName, "竿") || thingName == "三叉戟" {
|
||||
msg = append(msg, message.Text(
|
||||
"[", i, "]", info.Name, "(", info.Other, ") 价格:", pice[i], "\n"))
|
||||
} else {
|
||||
msg = append(msg, message.Text(
|
||||
"[", i, "]", info.Name, " 数量:", info.Number, " 价格:", pice[i], "\n"))
|
||||
}
|
||||
}
|
||||
msg = append(msg, message.Text("————————\n输入对应序号进行装备,或回复“取消”取消"))
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, msg...))
|
||||
// 等待用户下一步选择
|
||||
sell := false
|
||||
recv, cancel := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(取消|\d+)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("等待超时,取消购买"),
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "取消" {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("已取消购买"),
|
||||
),
|
||||
)
|
||||
return
|
||||
}
|
||||
index, err = strconv.Atoi(nextcmd)
|
||||
if err != nil || index > len(thingInfos)-1 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入正确的序号"))
|
||||
continue
|
||||
}
|
||||
sell = true
|
||||
}
|
||||
if sell {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thing := thingInfos[index]
|
||||
if thing.Number < number {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("商店数量不足")))
|
||||
return
|
||||
}
|
||||
price := pice[index] * number
|
||||
|
||||
msg := ""
|
||||
times := math.Min(3, number)
|
||||
coupon, err := dbdata.useCouponAt(uid, times)
|
||||
if err != nil {
|
||||
logrus.Warnln(err)
|
||||
}
|
||||
if coupon != -1 {
|
||||
msg += "\n(半价福利还有" + strconv.Itoa(3-coupon) + "次)"
|
||||
price = pice[index]*(number-coupon) + (pice[index]/2)*coupon
|
||||
} else {
|
||||
err = dbdata.updateBuyTimeFor(uid, 1)
|
||||
if err != nil {
|
||||
logrus.Warnln(err)
|
||||
}
|
||||
}
|
||||
curse, err := dbdata.getNumberFor(uid, "宝藏诅咒")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.9.3]:", err))
|
||||
return
|
||||
}
|
||||
if curse != 0 {
|
||||
msg += "\n(你身上绑定了" + strconv.Itoa(curse) + "层诅咒)"
|
||||
price = price * (100 + 10*curse) / 100
|
||||
}
|
||||
|
||||
money := wallet.GetWalletOf(uid)
|
||||
if money < price {
|
||||
ctx.SendChain(message.Text("你身上的钱(", money, ")不够支付", msg))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你确定花费", price, "购买", number, "个", thingName, "?", msg, "\n回答\"是\"或\"否\"")))
|
||||
// 等待用户下一步选择
|
||||
recv, cancel1 := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^(是|否)$`), zero.CheckUser(ctx.Event.UserID)).Repeat()
|
||||
defer cancel1()
|
||||
buy := false
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 60):
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("等待超时,取消购买")))
|
||||
return
|
||||
case e := <-recv:
|
||||
nextcmd := e.Event.Message.String()
|
||||
if nextcmd == "否" {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已取消购买")))
|
||||
return
|
||||
}
|
||||
buy = true
|
||||
}
|
||||
if buy {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
ok, err := dbdata.checkStoreFor(thing, number)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.11]:", err))
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("你慢了一步,物品被别人买走了"))
|
||||
return
|
||||
}
|
||||
thing.Number -= number
|
||||
err = dbdata.updateStoreInfo(thing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.12]:", err))
|
||||
return
|
||||
}
|
||||
err = wallet.InsertWalletOf(uid, -price)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.13]:", err))
|
||||
return
|
||||
}
|
||||
newCommodity := article{}
|
||||
if strings.Contains(thingName, "竿") || thingName == "三叉戟" {
|
||||
newCommodity = article{
|
||||
Duration: time.Now().Unix(),
|
||||
Type: thing.Type,
|
||||
Name: thing.Name,
|
||||
Number: 1,
|
||||
Other: thing.Other,
|
||||
}
|
||||
} else {
|
||||
things, err1 := dbdata.getUserThingInfo(uid, thingName)
|
||||
if err1 != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.15]:", err1))
|
||||
return
|
||||
}
|
||||
if len(things) == 0 {
|
||||
things = append(things, article{
|
||||
Duration: time.Now().Unix(),
|
||||
Name: thing.Name,
|
||||
Type: thing.Type,
|
||||
})
|
||||
}
|
||||
newCommodity = things[0]
|
||||
newCommodity.Number += number
|
||||
}
|
||||
err = dbdata.updateUserThingInfo(uid, newCommodity)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at store.go.14]:", err))
|
||||
return
|
||||
}
|
||||
if strings.Contains(thingName, "竿") {
|
||||
err = dbdata.updateCurseFor(uid, "buy", 1)
|
||||
if err != nil {
|
||||
logrus.Warnln(err)
|
||||
}
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你用", price, "购买了", number, thingName)))
|
||||
})
|
||||
}
|
||||
|
||||
func drawStroeEmptyImage() (picImage image.Image, err error) {
|
||||
fontdata, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas := gg.NewContext(1000, 300)
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetRGBA255(255, 255, 255, 150)
|
||||
canvas.Fill()
|
||||
// 边框框
|
||||
canvas.DrawRectangle(0, 0, 1000, 300)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
canvas.SetColor(color.Black)
|
||||
err = canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textW, textH := canvas.MeasureString("价格信息")
|
||||
canvas.DrawString("价格信息", 10, 10+textH*1.2)
|
||||
canvas.DrawLine(10, textH*1.6, textW, textH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
if err = canvas.ParseFontFace(fontdata, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawStringAnchored("当前商店并没有上架任何物品", 500, 10+textH*2+50, 0.5, 0)
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
|
||||
func drawStroeInfoImage(stroeInfo []store) (picImage image.Image, err error) {
|
||||
fontdata, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas := gg.NewContext(1, 1)
|
||||
err = canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
titleW, titleH := canvas.MeasureString("价格信息")
|
||||
|
||||
err = canvas.ParseFontFace(fontdata, 50)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, textH := canvas.MeasureString("高度")
|
||||
nameW, _ := canvas.MeasureString("下界合金竿(100/100/0/0)")
|
||||
numberW, _ := canvas.MeasureString("10000")
|
||||
priceW, _ := canvas.MeasureString("10000")
|
||||
|
||||
bolckW := int(10 + nameW + 50 + numberW + 50 + priceW + 10)
|
||||
backY := 10 + int(titleH*2+10)*2 + 10 + (len(stroeInfo)+len(discountList)/2+2)*int(textH*2) + 10
|
||||
canvas = gg.NewContext(bolckW, math.Max(backY, 500))
|
||||
// 画底色
|
||||
canvas.DrawRectangle(0, 0, float64(bolckW), float64(backY))
|
||||
canvas.SetRGBA255(150, 150, 150, 255)
|
||||
canvas.Fill()
|
||||
|
||||
// 放字
|
||||
canvas.SetColor(color.Black)
|
||||
err = canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawString("今日波动", 10, 10+titleH*1.2)
|
||||
canvas.DrawLine(10, titleH*1.6, titleW, titleH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
textDy := 10 + titleH*1.7
|
||||
if err = canvas.ParseFontFace(fontdata, 35); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
textDx, textDh := canvas.MeasureString("下界合金竿(均价1000)")
|
||||
valueDx, _ := canvas.MeasureString("+100%")
|
||||
i := 0
|
||||
for _, name := range thingList {
|
||||
text := name + "(均价" + strconv.Itoa(priceList[name]) + ") "
|
||||
|
||||
if i == 2 {
|
||||
i = 0
|
||||
textDy += textDh * 2
|
||||
}
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawStringAnchored(text, 20+(textDx+valueDx+10)*float64(i)+10, textDy+textDh/2, 0, 0.5)
|
||||
if discountList[name]-100 > 0 {
|
||||
canvas.SetRGBA255(200, 50, 50, 255)
|
||||
text = "+" + strconv.Itoa(discountList[name]-100) + "%"
|
||||
} else {
|
||||
canvas.SetRGBA255(63, 133, 55, 255)
|
||||
text = strconv.Itoa(discountList[name]-100) + "%"
|
||||
}
|
||||
canvas.DrawStringAnchored(text, 20+(textDx+valueDx+10)*float64(i)+10+textDx+10, textDy+textDh/2, 0, 0.5)
|
||||
i++
|
||||
}
|
||||
canvas.SetColor(color.Black)
|
||||
textDy += textDh * 2
|
||||
canvas.DrawStringAnchored("注:出售商品将会额外扣除20%的税收,附魔鱼竿请按实际价格", 10, textDy+10+textDh/2, 0, 0.5)
|
||||
|
||||
textDy += textH * 2
|
||||
err = canvas.ParseFontFace(fontdata, 100)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canvas.DrawString("上架内容", 10, textDy+titleH*1.2)
|
||||
canvas.DrawLine(10, textDy+titleH*1.6, titleW, textDy+titleH*1.6)
|
||||
canvas.SetLineWidth(3)
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.Stroke()
|
||||
|
||||
textDy += 10 + titleH*1.7
|
||||
if err = canvas.ParseFontFace(fontdata, 50); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
canvas.DrawStringAnchored("名称", 10+nameW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("数量", 10+nameW+10+numberW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("价格", 10+nameW+10+numberW+50+priceW/2, textDy+textH/2, 0.5, 0.5)
|
||||
|
||||
for _, info := range stroeInfo {
|
||||
textDy += textH * 2
|
||||
name := info.Name
|
||||
if info.Other != "" && info.Name != "美西螈" {
|
||||
name += "(" + info.Other + ")"
|
||||
}
|
||||
numberStr := strconv.Itoa(info.Number)
|
||||
pice := 0
|
||||
if strings.Contains(name, "竿") {
|
||||
poleInfo := strings.Split(info.Other, "/")
|
||||
durable, _ := strconv.Atoi(poleInfo[0])
|
||||
maintenance, _ := strconv.Atoi(poleInfo[1])
|
||||
induceLevel, _ := strconv.Atoi(poleInfo[2])
|
||||
favorLevel, _ := strconv.Atoi(poleInfo[3])
|
||||
pice = (priceList[info.Name] - (durationList[info.Name] - durable) - maintenance*2 + induceLevel*600 + favorLevel*1800) * discountList[info.Name] / 100
|
||||
} else {
|
||||
pice = priceList[info.Name] * discountList[info.Name] / 100
|
||||
}
|
||||
|
||||
canvas.DrawStringAnchored(name, 10+nameW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored(numberStr, 10+nameW+10+numberW/2, textDy+textH/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored(strconv.Itoa(pice), 10+nameW+10+numberW+50+priceW/2, textDy+textH/2, 0.5, 0.5)
|
||||
}
|
||||
return canvas.Image(), nil
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("midicreate", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "midi音乐制作",
|
||||
Help: "- midi制作 CCGGAAGR FFEEDDCR GGFFEEDR GGFFEEDR CCGGAAGR FFEEDDCR\n" +
|
||||
|
||||
@@ -18,38 +18,14 @@ import (
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
)
|
||||
|
||||
const (
|
||||
jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d"
|
||||
krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d"
|
||||
)
|
||||
|
||||
var speakers = map[string]uint{
|
||||
"宁宁": 0, "爱瑠": 1, "芳乃": 2, "茉子": 3, "丛雨": 4, "小春": 5, "七海": 6,
|
||||
"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]{
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "日韩中 VITS 模型拟声",
|
||||
Help: "- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" +
|
||||
"- 让[空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝]说(中文)",
|
||||
Help: "- 让[空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝]说(中文)",
|
||||
}).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) {
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(jpapi, url.QueryEscape(text), id)))
|
||||
})
|
||||
en.OnRegex("^让(Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae)说([A-Za-z\\s\\d\u3131-\u3163\uac00-\ud7ff\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
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).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if 原.k == "" {
|
||||
|
||||
@@ -23,31 +23,31 @@ func TestSetHoliday(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = SetHoliday("元旦", 1, 2023, 1, 1)
|
||||
err = SetHoliday("元旦", 1, 2024, 1, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("春节", 7, 2023, 1, 21)
|
||||
err = SetHoliday("春节", 7, 2024, 2, 10)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("清明节", 1, 2023, 4, 5)
|
||||
err = SetHoliday("清明节", 1, 2024, 4, 5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("劳动节", 1, 2023, 5, 1)
|
||||
err = SetHoliday("劳动节", 1, 2024, 5, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("端午节", 1, 2023, 6, 22)
|
||||
err = SetHoliday("端午节", 1, 2023, 6, 10)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("中秋节", 1, 2023, 9, 29)
|
||||
err = SetHoliday("中秋节", 2, 2023, 9, 29)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("国庆节", 7, 2023, 10, 1)
|
||||
err = SetHoliday("国庆节", 6, 2023, 10, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
control.Register("moyu", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Brief: "摸鱼提醒",
|
||||
Help: "- /启用 moyu\n" +
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("moyucalendar", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Brief: "摸鱼人日历",
|
||||
Help: "- /启用 moyucalendar\n" +
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("music", &ctrl.Options[*zero.Ctx]{
|
||||
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "点歌",
|
||||
Help: "- 点歌[xxx]\n" +
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("nativesetu", &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "本地涩图",
|
||||
Help: "- 本地[xxx]\n" +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user