Compare commits

..

881 Commits

Author SHA1 Message Date
源文雨
68386910c4 🔖 v1.7.0 2023-03-20 12:28:19 +08:00
莲宝坏坏坏
1734f1f7d4 更换百度一下为百度百科 (#627) 2023-03-20 12:23:52 +08:00
DreamZero
86b87c2b4e fix slow aifalse (#631) 2023-03-20 11:59:03 +08:00
DreamZero
e9eb4c5602 Fix steam & lint (#630)
* fix

* make lint happy
2023-03-20 11:57:46 +08:00
方柳煜
6474b36ccd 修复底部出现黑条的问题 (#626) 2023-03-18 12:07:13 +08:00
github-actions[bot]
107149892c 🎨 改进代码样式 (#625)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-03-18 00:32:36 +08:00
DreamZero
f1dba97922 feat: steam plugin (#621) 2023-03-18 00:30:22 +08:00
莲宝坏坏坏
bc3c4303be fix jiami api (#624) 2023-03-18 00:28:31 +08:00
源文雨
f7a61ed0ee 🎨 edit README 2023-03-16 19:24:26 +08:00
源文雨
107b38e2f5 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2023-03-16 19:22:38 +08:00
源文雨
0d85fa04e1 🔖 v1.7.0-beta5 2023-03-16 19:22:30 +08:00
KoiParadise
1d8f5a7869 fix: unexpected misplaced name (#622) 2023-03-16 19:21:18 +08:00
源文雨
5e93368e57 fix #586: 以图搜图分开发找不到 url 2023-03-16 19:20:28 +08:00
源文雨
56e931665e fix: gif by @nekohouse09 2023-03-16 19:18:35 +08:00
方柳煜
e5b2b369e3 修改加签逻辑 (#620)
* Update main.go

* Update main.go

* Update main.go
2023-03-15 23:03:01 +08:00
苜蓿紫
58cf08fc39 fix typo (#619)
* fix typo

* fix typo
2023-03-14 19:57:10 +08:00
源文雨
c18f9b8b72 🔖 v1.7.0-beta4 2023-03-12 12:28:53 +08:00
源文雨
0df465e1c6 fix: saucenao panic 2023-03-12 12:27:29 +08:00
himawari
8b010321d5 添加一言 (#616)
*  添加一言

* 🎨 优化随机数

* 🎨 更新包

* 🎨 优化随机结构

* 🎨 修改随机算法

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2023-03-12 11:09:07 +08:00
Fox_white
e1591c44b6 Fix: Intn Panic when the len is 0 (#617) 2023-03-11 15:45:40 +08:00
源文雨
cc26eb1332 优化 ai_false diskstate 2023-03-11 11:48:40 +08:00
源文雨
366c7acb90 Update README.md 2023-03-10 22:26:33 +08:00
苜蓿紫
d8cb5206e8 update: drawlots (#613) 2023-03-09 22:14:26 +08:00
源文雨
90efebf02f 🔖 v1.7.0-beta3 2023-03-09 13:57:31 +08:00
源文雨
960cd3ad8b fix: drawlots 2023-03-09 13:56:51 +08:00
源文雨
09a3e807c9 🚑 默认不编译webui 2023-03-09 13:55:15 +08:00
苜蓿紫
fb2718b495 fix README.md (#612)
修正抽签readme
2023-03-09 13:29:31 +08:00
方柳煜
1550cb7fcc 新增多功能抽签插件 (#606) 2023-03-09 00:04:09 +08:00
源文雨
7b27bc8f7a update icon 2023-03-08 16:21:46 +08:00
github-actions[bot]
54598fbf54 🎨 改进代码样式 (#611)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-03-08 00:57:14 +08:00
himawari
bb844eaa40 Feature gui 20230219 (#597)
*  添加gui

* 🐛 添加位置

*  修改为0.0.0.0

*  添加webui说明

* 🎨 修改为本地

*  添加webui默认url

* 📝 修改readme

* 🎨 修改方法名

*  修改readme

* 🎨 修改命令

* 🎨 更新包

* 🎨 调整位置
2023-03-08 00:44:47 +08:00
源文雨
4ef6f584c9 Update README.md 2023-03-07 19:14:08 +08:00
源文雨
861b3cc82f 优化baiduaudit 2023-03-05 00:46:53 +08:00
源文雨
5226548cec 优化代码结构 2023-03-04 23:30:51 +08:00
github-actions[bot]
d41ae01f01 🎨 改进代码样式 (#609)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-03-04 19:57:35 +08:00
GenesisAN
e294059de4 fix 初始化未能获取数据的问题 (#602)
* fix 初始化未能获取数据的问题

* fix 添加读写锁

* fix lint

* fix lint

* change 改为全局锁
2023-03-04 19:54:56 +08:00
源文雨
84bc79eaa6 fix 2023-03-01 21:14:51 +08:00
源文雨
8f9a396821 fix: platform that fails to set vt100 2023-03-01 21:13:18 +08:00
源文雨
6f96c389c4 make ci happy 2023-03-01 16:21:18 +08:00
源文雨
c55e31ed6f 🔖 v1.7.0-beta1 2023-03-01 16:17:10 +08:00
源文雨
f3a0813fed edit README 2023-03-01 16:14:37 +08:00
源文雨
c1602c323d fix: md5 cat & add: updater cache 2023-03-01 16:10:24 +08:00
源文雨
1bceaa52ff fix winres 2023-03-01 14:49:34 +08:00
源文雨
86296a28df 优化 manifest 2023-03-01 14:35:13 +08:00
源文雨
fe9b5023f6 feat: add icon 2023-03-01 14:20:36 +08:00
源文雨
d68223f63d add winres 2023-03-01 12:45:35 +08:00
源文雨
1c274d6eb8 优化 banner 2023-03-01 12:22:14 +08:00
源文雨
0e52bbe0f7 fix: set title 2023-03-01 12:07:15 +08:00
源文雨
a177448315 fix: set title 2023-03-01 11:47:49 +08:00
源文雨
ca3ff1b522 fix: set title 2023-03-01 11:46:00 +08:00
源文雨
41f0b11469 fix: set title 2023-03-01 11:43:37 +08:00
源文雨
ba0e471a19 fix: set title 2023-03-01 11:39:47 +08:00
源文雨
84115a7316 优化 windows console 2023-03-01 11:26:21 +08:00
源文雨
4dc837854b fix windows console input 2023-03-01 11:11:01 +08:00
Fox_white
64f9e309ef Feat: Better Setup Console (#601)
* Feat: Better Setup Console

* Feat: Better Setup Console
2023-02-28 20:18:10 +08:00
源文雨
67a1050df6 make lint happy 2023-02-28 18:33:36 +08:00
源文雨
d85865825e 优化windows输出 2023-02-28 18:29:39 +08:00
源文雨
2704d3e7d4 优化color 2023-02-28 12:15:54 +08:00
源文雨
0944fc7854 优化arch 2023-02-28 11:45:03 +08:00
源文雨
611c275092 🔖 v1.6.2 2023-02-27 21:01:31 +08:00
莫思潋
e3e991e6ab fix: ent->enr (#600) 2023-02-27 19:45:17 +08:00
源文雨
f2cebcf95a edit help 2023-02-27 14:14:02 +08:00
源文雨
4aca16a393 make lint happy 2023-02-27 14:11:07 +08:00
源文雨
891bbb96aa make lint happy 2023-02-27 14:10:44 +08:00
源文雨
d60acd3a47 update to go1.20 2023-02-27 13:59:31 +08:00
源文雨
7dc6499127 edit readme 2023-02-27 13:54:18 +08:00
源文雨
f28e746652 aireply add chatgpt 2023-02-27 13:52:12 +08:00
源文雨
3c905d9061 moegoe 恢复原 API 2023-02-27 13:22:31 +08:00
himawari
091d3170fc Feature zbpp bilibilipush 20230224 (#599)
* 🔥 删除小鸡词典

*  添加新插件和修改bilibilipush问题

* 🎨 去掉多余结构

* 🎨 简化语句
2023-02-25 19:48:13 +08:00
源文雨
bdc4138d78 fix: fortune 2023-02-24 11:29:15 +08:00
源文雨
e231235ed1 fix: 自检 2023-02-19 20:05:03 +08:00
源文雨
1795b9196b fix: 自检 2023-02-19 20:03:33 +08:00
源文雨
d5d0563544 fix: 自检 2023-02-19 19:52:45 +08:00
源文雨
723b7a9857 fix: 自检 2023-02-19 19:40:17 +08:00
源文雨
6a0a16662e fix: slow 自检 2023-02-19 19:30:47 +08:00
github-actions[bot]
f82ba852ba 🎨 改进代码样式 (#588)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-02-17 13:07:21 +08:00
MoeMagicMango
180945670b feat:新设计的签到 (#587) 2023-02-17 13:03:44 +08:00
源文雨
56984ef7fb 🔖 v1.6.2-beta4 2023-02-15 17:27:52 +08:00
源文雨
ac4de84188 fix: render text 2023-02-15 17:27:29 +08:00
源文雨
591ad79201 🔖 v1.6.2-beta3 2023-02-10 15:00:18 +08:00
源文雨
2e51c9e9c3 🚀 优化字体加载 2023-02-10 14:59:27 +08:00
源文雨
ca89f01f7d update deps 2023-02-07 16:53:30 +08:00
lianhong2758
5dfc118f64 修复原神 vits api失效 (#582) 2023-02-07 16:50:09 +08:00
源文雨
2410a7b3ed make lint happy 2023-02-07 16:46:26 +08:00
源文雨
7e11924b3f update deps 2023-02-07 16:39:07 +08:00
lianhong2758
4f65900688 readme add kokomi (#579) 2023-02-07 12:20:21 +08:00
源文雨
20821827b3 🔖 v1.6.2-beta2 2023-02-06 21:47:25 +08:00
源文雨
3dd10169e3 update deps 2023-02-06 21:40:41 +08:00
DreamZero
8cd60a84d5 复制黏贴被发现了( (#578) 2023-02-06 16:49:55 +08:00
DreamZero
03a2f4c331 给aifalse加一点细节 (#575) 2023-02-05 12:59:50 +08:00
icarus-ai
cfc9b55fce 更新quic-go版本,以支持使用Go 1.20编译 (#577)
* 支持 Go 1.20

* fix workflows (≖_≖ )

* 回滚 workflows

* 回滚 workflows
2023-02-04 12:05:14 +08:00
苜蓿紫
fc99eb3e22 修正qq号大小比较 (#576) 2023-02-02 11:42:52 +08:00
源文雨
93625f9c4f 优化代码结构 2023-02-01 15:03:05 +08:00
苜蓿紫
b6ce9f7b2e 修正错别字&增加提示语 (#574)
* 修正错别字

* 修正错别字

* 增加整理提示语

代发方柳
2023-02-01 14:53:10 +08:00
github-actions[bot]
20642b3776 🎨 改进代码样式 (#573)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-02-01 11:52:42 +08:00
GenesisAN
16ab7c08f6 fix 初始化错误,改善阅读体验 (#572) 2023-02-01 11:47:04 +08:00
源文雨
7bce7f28dc make lint happy 2023-01-31 18:25:32 +08:00
源文雨
8c695c96d7 优化代码结构 2023-01-31 18:23:08 +08:00
源文雨
d4a057e21a 优化代码结构 2023-01-31 18:20:12 +08:00
github-actions[bot]
f18c809355 🎨 改进代码样式 (#571)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-31 16:30:11 +08:00
github-actions[bot]
0d9c8d9a43 🎨 改进代码样式 (#570)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-31 16:29:02 +08:00
github-actions[bot]
76e7f81a6c 🎨 改进代码样式 (#569)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-31 16:27:43 +08:00
方柳煜
faf00dfea7 优化好感度系统,修复重复人名问题 (#568) 2023-01-31 16:23:27 +08:00
GenesisAN
39af90e63d add WarframeAPI (#541) 2023-01-31 16:22:19 +08:00
源文雨
36b09b8e94 tts append 。 2023-01-30 18:36:47 +08:00
源文雨
7ec2b46d75 🔖 v1.6.2-beta1 2023-01-30 18:01:56 +08:00
源文雨
7cc5771a9a update deps 2023-01-30 18:00:14 +08:00
DreamZero
f96b5f8965 优化代码结构 (#565) 2023-01-30 17:42:53 +08:00
himawari
07e6f33b04 添加小说下载 (#553)
*  添加小说下载

* 🎨 修改readme

* 🎨 修lint

* 🎨 修改包

* 🎨 使用新版http封装

* 🎨 new line
2023-01-30 17:40:57 +08:00
源文雨
f1a33a1845 🔖 v1.6.1-fix1 2023-01-16 11:36:31 +08:00
源文雨
0a72566378 fix #561: render text black & shindan 2023-01-16 11:35:11 +08:00
lianhong2758
a029add486 权重查询美化 (#560) 2023-01-16 11:25:39 +08:00
源文雨
778b8749ea 🐛 修复pixiv无法获取original url 2023-01-13 16:28:17 +08:00
源文雨
7d5944fccf 🔖 v1.6.1 2023-01-13 00:51:00 +08:00
github-actions[bot]
3e16a24ab5 🎨 改进代码样式 (#559)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-12 18:21:06 +08:00
源文雨
ff682da3fe 🔥 remove atri sleep due to global latency 2023-01-12 18:17:12 +08:00
源文雨
a0120485de fix #551: atri 发图 2023-01-12 18:14:47 +08:00
源文雨
0c8e9198ee fix: atri & v1.6.1-beta5 2023-01-11 14:47:05 +08:00
源文雨
40da2481cc fix: setupool file uri 2023-01-10 14:25:24 +08:00
源文雨
a7ae56481b fix: setupool file uri 2023-01-10 14:08:00 +08:00
源文雨
f550d58ad7 fix: heisi 2023-01-10 11:02:49 +08:00
源文雨
f488b75ac6 del: heisi due to api fail 2023-01-09 22:58:04 +08:00
源文雨
4308e386b4 fix: setu 2023-01-09 22:06:14 +08:00
源文雨
df1c207d77 add plugin autowithdraw
触发者撤回时也自动撤回
2023-01-09 21:55:20 +08:00
源文雨
8ca71967b6 移除ChatGPT & 默认注释 thesaurus 2023-01-09 21:17:04 +08:00
源文雨
c99d09ea63 优化代码结构 2023-01-07 16:24:02 +08:00
方柳煜
9ce65de698 增加并发,解决FutureEvent超时问题 (#552) 2023-01-03 18:52:27 +08:00
源文雨
cc7953c486 update 服务 2022-12-30 19:36:15 +08:00
源文雨
d50f330ccf update win32 dl 2022-12-29 14:28:12 +08:00
himawari
36f2a23aa1 🐛 修复moegoe (#546) 2022-12-27 16:01:43 +08:00
Stardust·减
14b98d4006 Update moegoe,add VITS cn interface (#544)
* Update main.go

* Update main.go

* Update main.go
2022-12-26 18:50:44 +08:00
源文雨
d401136966 🔖 1.6.1-beta3 2022-12-26 13:45:24 +08:00
源文雨
d0610b152f update downloadto 2022-12-26 13:27:28 +08:00
源文雨
fa8428ae8b edit README 2022-12-26 13:12:20 +08:00
源文雨
7d1a4b4005 edit README 2022-12-26 13:11:38 +08:00
源文雨
19e3688499 fix tts 2022-12-18 10:12:55 +08:00
github-actions[bot]
b8da6f8cfd 🎨 改进代码样式 (#536)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-16 18:04:09 +08:00
太好听了吧
58631c5b19 ️update music (#535)
* ️update music

添加咪咕点歌

* ️update music

添加咪咕点歌功能
2022-12-16 18:02:43 +08:00
github-actions[bot]
e994768318 🎨 改进代码样式 (#534)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-15 22:16:01 +08:00
太好听了吧
c304d72d77 music 音乐自定义分享 (#533)
1. 酷我音乐音乐直链url和参数修改,添加音乐卡片自定义参数。
2. 酷狗音乐添加音乐卡片自定义参数。
2022-12-15 22:12:55 +08:00
DreamZero
a1f1016fb9 独立wallet插件 (#531) 2022-12-15 01:28:33 +08:00
源文雨
913f01d69f 🔖 1.6.1-beta2 2022-12-14 21:39:27 +08:00
源文雨
f56929c852 简化设置原神vits key流程 2022-12-14 21:38:55 +08:00
源文雨
e9e0498b34 fix tts 2022-12-14 20:26:37 +08:00
源文雨
b6026ee76a fix pull ci 2022-12-14 16:56:09 +08:00
源文雨
8fdc358cc5 🔖 1.6.1-beta1 2022-12-14 16:52:59 +08:00
源文雨
fef0ac6049 fix genshin tts 2022-12-14 16:52:17 +08:00
源文雨
e144db9205 fix: aireply nil 2022-12-13 20:49:34 +08:00
源文雨
825a5a0d43 🎨 edit README 2022-12-12 18:59:42 +08:00
源文雨
6dccfc862c 🎨 edit README 2022-12-12 18:58:28 +08:00
源文雨
771f93f9af fix #527:
在设置群回复模式的时候没有生效
2022-12-12 18:50:41 +08:00
源文雨
7893fc9ebe revert 2022-12-12 16:03:42 +08:00
源文雨
9b4363dda8 fix #525: chatgpt add UA/CF config 2022-12-12 16:02:17 +08:00
源文雨
257263bfa2 ✏️ edit README 2022-12-11 15:39:47 +08:00
源文雨
8f009bb4ee config.json supports wss 2022-12-11 15:38:01 +08:00
源文雨
34a3cf82e7 🎨 edit README 2022-12-11 14:34:16 +08:00
源文雨
cd927ec2c4 🎨 优化chatgpt reset 2022-12-11 14:11:38 +08:00
源文雨
1266b2378a 🎨 优化tts 2022-12-11 14:10:35 +08:00
源文雨
575d158d5a Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-12-10 14:35:32 +08:00
源文雨
a008faf805 🐛 fix push 2022-12-10 14:35:28 +08:00
github-actions[bot]
9a2081de0a 🎨 改进代码样式 (#521)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-10 14:29:55 +08:00
源文雨
9550b817c5 add Create Pull Request 2022-12-10 14:28:42 +08:00
源文雨
ee895e7dc4 reintroduce Commit back 2022-12-10 14:19:04 +08:00
源文雨
7aa2996540 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-12-10 14:16:35 +08:00
源文雨
725aa5b180 💩👌 make lint happy 2022-12-10 14:16:30 +08:00
jinyunboss
f96f14052e feat: 群聊中撤回消息 (#520) 2022-12-10 14:11:26 +08:00
源文雨
adfa9f9e0f 💩👌 make lint happy 2022-12-10 14:11:09 +08:00
源文雨
d8bc336006 🔖 1.6.0 2022-12-10 13:57:30 +08:00
源文雨
b69bd3d640 fix: chatgpt " 2022-12-10 13:32:49 +08:00
莫思潋
5d9ac50106 fix: aireply: ent->enr & update README & optimize bilibili match (#519) 2022-12-09 23:23:56 +08:00
源文雨
df83ffc8b0 add reset 2022-12-07 21:08:54 +08:00
源文雨
e49b568d6d add ChatGPT 2022-12-07 20:36:23 +08:00
源文雨
8399e49072 aireply supports ChatGPT 2022-12-07 19:38:23 +08:00
源文雨
d76a65ec07 fix tts 2022-12-07 11:52:16 +08:00
himawari
ed7cef7566 添加随机女装 (#514) 2022-12-05 11:34:31 +08:00
源文雨
3349ec7694 edit help 2022-12-03 17:23:06 +08:00
源文雨
11f358bcbf fix gs tts 2022-12-03 17:16:45 +08:00
源文雨
82608d01bb genshin vits add api key 2022-12-03 16:35:14 +08:00
源文雨
a93f4f68b4 🔖 1.6.0-beta3 2022-12-03 13:43:00 +08:00
源文雨
6f8c576a44 🐛 fix ttr 2022-12-03 13:40:03 +08:00
源文雨
e75fc83412 🐛 fix ttr 2022-12-03 13:31:59 +08:00
方柳煜
2e538e3905 ygo: 优化指令 (#513) 2022-12-03 12:28:57 +08:00
源文雨
a69399fa58 🔖 1.6.0-beta2 2022-12-03 12:18:27 +08:00
源文雨
3e94d27e6a update deps 2022-12-03 12:11:48 +08:00
源文雨
20293b35f8 优化simai 2022-12-03 12:10:21 +08:00
源文雨
b768e48a74 add succ hint 2022-12-02 20:35:47 +08:00
源文雨
6a64c1ffd6 增加处理{name}和{segment} 2022-12-02 20:28:18 +08:00
源文雨
3b1ad2250f 词库增加设置概率功能 2022-12-02 20:24:44 +08:00
源文雨
83778afd51 fix 2022-12-02 18:59:10 +08:00
源文雨
cbbae11fcd update deps 2022-12-02 17:54:11 +08:00
源文雨
11c01af9da thetharus 增加 傲娇 可爱 词库 2022-12-02 16:50:12 +08:00
源文雨
7547b33f65 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-12-02 14:12:43 +08:00
源文雨
4305f589df edit readme 2022-12-02 14:12:36 +08:00
方柳煜
c8684f74a8 修复重置花名册会报错问题 (#511) 2022-12-01 14:04:40 +08:00
方柳煜
7cdc92c142 Update qqwife plugin (#510) 2022-11-30 16:53:32 +08:00
lianhong2758
a7ccf302f2 更新权重查询api地址 (#509) 2022-11-28 22:16:01 +08:00
方柳煜
f4b41efc75 优化qqwife代码,增加代码可读性 (#508) 2022-11-28 11:13:26 +08:00
方柳煜
ac18d3df96 新增一些游戏王相关的插件 (#507) 2022-11-28 11:12:19 +08:00
源文雨
daff47d912 fix nsetu 2022-11-25 15:23:16 +08:00
方柳煜
27d04cbae2 Update README.md (#505) 2022-11-24 10:36:35 +08:00
方柳煜
8eef7718ee qqwife新增好感度列表功能 (#504) 2022-11-23 16:39:32 +08:00
源文雨
fb4259b696 fix 2022-11-22 17:11:11 +08:00
源文雨
eb378ea45a 🍱 更新setu数据库 2022-11-22 17:05:48 +08:00
源文雨
02992271a1 ️ update reg 2022-11-21 23:18:29 +08:00
源文雨
72b11c2717 📄 使用 AGPL v3 2022-11-21 18:45:12 +08:00
方柳煜
a55f28c006 优化代码 (#501) 2022-11-17 12:08:12 +08:00
lianhong2758
9f37962d22 QQ权重查询 (#500) 2022-11-16 23:17:53 +08:00
源文雨
8d001122e2 sync data 2022-11-15 11:50:00 +08:00
源文雨
960aa2231c 🔖 v1.6.0-beta1 2022-11-15 11:14:28 +08:00
源文雨
e55a133f00 🎨 新服务列表 2022-11-15 11:13:25 +08:00
himawari
4075c92e53 添加qq空间表白墙 (#489) 2022-11-13 18:03:15 +08:00
方柳煜
743e5509a2 全新的guessmusic插件 (#499) 2022-11-13 18:01:15 +08:00
lianhong2758
1c93611a16 更正插件名称 (#497) 2022-11-13 17:58:18 +08:00
GenesisAN
df8a320fbe fix baiduaudit的正则错误 (#495)
修复一个正则错误,导致不能正确解析第二个ApiKey的问题
2022-11-12 11:16:31 +08:00
莫思潋
8e8464d727 调整以图绘图 (#493) 2022-11-10 18:30:27 +08:00
源文雨
356d1dfe4d 🐛 ms5 cat panic 2022-11-10 15:15:11 +08:00
源文雨
d185de0f3d fix: 设精 2022-11-10 10:26:15 +08:00
源文雨
644a6cdcc2 fix: 设精 2022-11-09 23:28:08 +08:00
源文雨
85f5fb2d87 🔖 v1.5.2 2022-11-09 15:15:22 +08:00
源文雨
8674c14754 🔖 v1.5.2 2022-11-09 14:54:52 +08:00
DreamZero
6c2fc1b4c2 恢复注册方式 (#491) 2022-11-09 13:29:07 +08:00
源文雨
5d94980e7c 优化设精 2022-11-07 12:26:13 +08:00
源文雨
9bed71a99f feat: job drop limit due to 事件环 2022-11-07 11:04:09 +08:00
方柳煜
6faa2b65e2 添加设精功能 (#488) 2022-11-06 10:42:04 +08:00
lianhong2758
98812b103e 第三次提交兽语加密 (#486) 2022-11-05 22:15:34 +08:00
himawari
deb655de36 Feature huggingface (#478) 2022-11-05 17:32:31 +08:00
方柳煜
8d1c18cb4a Update command.go (#487) 2022-11-05 11:10:36 +08:00
DreamZero
88824126f7 add: 添加Brief (#482)
* add brief

* fix: README中插件位置
2022-11-04 12:12:47 +08:00
喵酱
68a9ecf995 修改了两处错误的文案 (#481) 2022-11-03 22:26:43 +08:00
方柳煜
57404b2dcd 优化签到插件,qqwife插件添加礼物系统 (#480) 2022-11-03 16:38:48 +08:00
源文雨
29705c63c9 doc: 添加项目趋势图 2022-11-02 13:19:57 +08:00
源文雨
5a854d9715 options add brief & banner 2022-11-01 11:30:05 +08:00
源文雨
eb1cbeae3f 🎨 优化事件环 2022-10-30 00:07:17 +08:00
weigui404
b6246cfee6 Update README.md (#479)
2022-10-30 00:03:32 +08:00
源文雨
0619000f9a 🎨 优化事件环 2022-10-29 20:16:02 +08:00
源文雨
01361781c8 🎨 增加最大处理时间 2022-10-29 11:25:50 +08:00
源文雨
3c03a308b3 fix #421: 增加全局响应延迟与处理不及消息的丢弃 2022-10-28 17:41:28 +08:00
源文雨
7895e48420 update zb: 事件环 2022-10-28 16:18:03 +08:00
源文雨
ba15713b99 update zb: 事件环 2022-10-28 15:27:29 +08:00
源文雨
bd98fa3aed update zb: 事件环 2022-10-28 14:44:32 +08:00
源文雨
fce75a9475 🔖 v1.5.2-beta2 2022-10-28 12:50:16 +08:00
源文雨
7616d5759f fix nsetu 循环触发 2022-10-28 11:40:58 +08:00
源文雨
ea2c81a9c7 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-10-28 11:35:18 +08:00
源文雨
37cff9ff31 update reg 2022-10-28 11:35:11 +08:00
MoeMagicMango
b8d3d6af9b 修改漂流瓶的帮助 (#477) 2022-10-28 10:50:51 +08:00
MoeMagicMango
fdf90a72cc feat: 全局漂流瓶 (#474)
* feat: remove driftbottle and push bottle global plugin.

* Reverse name

* change by requests
2022-10-28 00:24:57 +08:00
DreamZero
ba0c05a774 change: 新的缓存池key (#476) 2022-10-28 00:20:19 +08:00
DreamZero
3250ec14ac fix: tarot (#475)
* fix tarot get img

* change: use sendtoslef check cache

但是好像过慢

* change: use imgpool

* fix

感觉改不好了

* fix: 修改变量赋值顺序
2022-10-28 00:00:43 +08:00
源文雨
ce2f390361 update md5 2022-10-27 16:57:16 +08:00
方柳煜
71434232fe 修复help显示问题 (#473)
* 修复help显示问题

* Update command.go

* Update wenxinAI.go

* Update README.md
2022-10-27 11:04:10 +08:00
GenesisAN
852629fa2e add:百度内容审核插件 (#468) 2022-10-25 18:43:58 +08:00
源文雨
f10676d16d 🔖 v1.5.2-beta1 2022-10-24 23:46:59 +08:00
方柳煜
d43ea7df1d 扩增文心AI的功能,修复猜歌的权限问题 (#471) 2022-10-24 23:36:28 +08:00
方柳煜
21712c6299 扩展aipaint指令 (#472) 2022-10-24 23:35:43 +08:00
himawari
2fc47a38fa 🎨 优化aipaint撤回,nihongo搜索 (#470) 2022-10-23 16:50:47 +08:00
源文雨
cbb4408668 fix tarot 2022-10-22 12:12:46 +08:00
源文雨
a0df41b859 fix tarot 2022-10-22 12:01:45 +08:00
DreamZero
494c1b33b4 fix: 因为gitcode反爬导致tarot插件图片获取失败 (#465)
* fix tarot get img

* change: use sendtoslef check cache

但是好像过慢

* change: use imgpool

* fix

感觉改不好了
2022-10-22 11:53:46 +08:00
DreamZero
2034d91912 fix: 以图搜图合并转发 (#467) 2022-10-20 00:17:00 +08:00
源文雨
235ced0b78 🔖 v1.5.1 2022-10-16 12:59:24 +08:00
源文雨
3339b6a16f fix runcode 2022-10-15 14:12:36 +08:00
weigui404
c08e3dfe4a Update setu_geter.go (#452) 2022-10-15 10:23:24 +08:00
himawari
894cf41d37 🎨 优化鉴赏图片, 文本重用 (#451) 2022-10-14 20:47:34 +08:00
源文雨
55aa869b1a update deps 2022-10-14 14:30:05 +08:00
himawari
42b18619c3 Feature jptingroom (#448) 2022-10-14 13:58:52 +08:00
himawari
b0c57dfec5 Feature aipaint (#450) 2022-10-14 13:57:42 +08:00
himawari
bdbcf2a5f8 Feature alipayvoice (#449)
*  添加支付宝到账

*  添加readme
2022-10-14 13:53:20 +08:00
源文雨
7807e68519 add plugin Heisi 2022-10-13 11:13:43 +08:00
方柳煜
4cd81cb2e9 更新QQ音乐点歌API,修复猜歌panic (#444) 2022-10-12 23:45:31 +08:00
方柳煜
dc34a33346 修复tts默认语音设置不成功问题 (#445)
* Update main.go

* Update ai_tts.go
2022-10-12 23:43:52 +08:00
方柳煜
2922854f96 百度文心AI画图插件 (#442) 2022-10-12 16:44:05 +08:00
源文雨
29c85442ff update deps 2022-10-11 23:43:21 +08:00
源文雨
048cbf51ca update deps 2022-10-11 13:56:25 +08:00
方柳煜
467dd2ea65 猜歌插件更改为本地猜歌 (#439) 2022-10-11 00:06:50 +08:00
源文雨
aef678be5c Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-10-10 10:12:35 +08:00
源文雨
77f7567b29 fix: nwife dup slash & genshin vits 2022-10-10 10:12:23 +08:00
MoeMagicMango
c3c0685d3a fix:换成网易云官方的api (#440) 2022-10-09 23:12:09 +08:00
源文雨
c4c3f79c8c 💩👌 make lint happy 2022-10-08 10:57:01 +08:00
源文雨
9cb54a34da 🎨 优化bilibili 2022-10-07 12:21:20 +08:00
源文雨
519ae62760 fix breakrepeat shuffle 2022-10-07 10:49:55 +08:00
方柳煜
6971da1abc fix #433 修复重置之后第一个人娶群友不登记问题 (#435)
* Update command.go

* Update function.go

* Update command.go

* Update function.go
2022-10-07 10:26:23 +08:00
源文雨
5f3054d344 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-10-05 17:19:47 +08:00
源文雨
5b586a7402 💩👌 make lint happy 2022-10-05 17:18:51 +08:00
方柳煜
f2ff66ec1d 修复qqwife bug,优化程序 (#432)
* Update command.go

* Update function.go

* Update command.go
2022-10-05 17:18:02 +08:00
源文雨
92b9bab76a edit README 2022-10-05 12:23:29 +08:00
源文雨
4609985b79 优化代码结构 2022-10-05 12:09:09 +08:00
源文雨
6cf14fc7dd 🔖 v1.5.1-beta5 2022-10-04 22:19:11 +08:00
源文雨
053363f781 优化代码结构 2022-10-04 22:18:20 +08:00
源文雨
e319bd61f1 fix baseamasiro 2022-10-04 21:15:54 +08:00
源文雨
baad83172f fix gitcode 图床 2022-10-04 17:54:43 +08:00
源文雨
4b288a59b9 🐛 hyaku 2022-10-04 16:39:18 +08:00
源文雨
a2ada0b67e 🔥🐛 fix lazy data & add base天城文 2022-10-03 23:22:40 +08:00
莫思潋
97fea6a93a fix: []message.MessageSegment->message.Message (#429) 2022-10-03 19:54:39 +08:00
源文雨
145a9fb0b1 fix 64gua 2022-10-02 11:11:05 +08:00
源文雨
202d5e41a1 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-10-01 23:46:37 +08:00
源文雨
a64bead5e6 base64卦加解密 2022-10-01 23:46:28 +08:00
DreamZero
f9b84f8cb1 fix lolicon panic and more plugin use forward (#426)
* fix lolicon panic and more plugin use forward

* add back lolicon imgpool

* 带tag不使用缓存
2022-09-26 18:07:56 +08:00
方柳煜
76e0c13f89 好感度需发“重置所有花名册”才能使用 (#423)
* Update function.go

* Update command.go
2022-09-23 11:11:19 +08:00
源文雨
f9319c2a27 优化 breakrepeat 2022-09-22 11:14:24 +08:00
源文雨
295c50a0ae 调整 breakrepeat 优先级为最低 2022-09-22 10:55:44 +08:00
源文雨
942f5abbe4 🔖 v1.5.1-beta4 2022-09-22 10:49:59 +08:00
源文雨
965df40476 ⬆️ update deps 2022-09-22 10:47:11 +08:00
方柳煜
11f7f07009 扩展插件功能 (#422) 2022-09-22 10:40:26 +08:00
源文雨
76cd2afbd3 🔥 优化服务图片,删除服务详情 2022-09-21 13:55:52 +08:00
源文雨
00d07cb7af fix 2022-09-21 12:50:58 +08:00
源文雨
3234c18718 fix tts 2022-09-21 11:49:30 +08:00
源文雨
d48285c450 job 支持分群打印触发指令 2022-09-21 10:07:12 +08:00
源文雨
98ea387254 job cron 增加别名 2022-09-19 23:18:12 +08:00
源文雨
fb80ff3b74 🐛 优化 ban 2022-09-19 20:57:03 +08:00
源文雨
41e0cf8424 🐛 fix ban 2022-09-19 20:12:57 +08:00
源文雨
1bcd321477 🐛 fix ban 2022-09-19 19:49:29 +08:00
源文雨
b0482ee84b fix go.sum 2022-09-17 20:59:55 +08:00
源文雨
404f4041a9 🐛 fix b14 panic on some platform 2022-09-17 20:49:53 +08:00
源文雨
f6d6375667 🐛 fix b14 panic on some platform 2022-09-17 20:44:15 +08:00
源文雨
04acf4af49 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-09-17 18:04:09 +08:00
源文雨
df6957cfb6 🔖 v1.5.1-beta3 2022-09-17 18:03:50 +08:00
himawari
d3ab1e1560 Refactor image (#419) 2022-09-17 14:53:25 +08:00
源文雨
598a255e34 make lint happy 2022-09-17 14:50:29 +08:00
源文雨
b4418fda55 🐛 fix 2022-09-17 14:42:26 +08:00
源文雨
3f26dde791 fix: /ban 2022-09-17 14:36:55 +08:00
MoeMagicMango
14d81411b1 Optimize: 更换经常出问题的iw233接口为MoeHu (#412) 2022-09-17 13:43:38 +08:00
莫思潋
4b667835f9 fix: 小鸡词典 (#410)
* - 调整触发器符合说明
- 减少查不到信息的情况
- 增加图片

* typo: imgURL

* - 改用foreach
- 增加被jikipedia封禁的提示

* 对于bilibili,在readme种引入了一键获取cookie工具

* 顺lint心意
2022-09-16 10:10:21 +08:00
莫思潋
002f971882 feat: 小鸡词典查梗 (#408) 2022-09-12 20:04:35 +08:00
源文雨
99a8fcd73a disable commit back 2022-09-12 20:02:39 +08:00
源文雨
3705da38b7 update deps 2022-09-12 19:58:46 +08:00
源文雨
32afee62c5 🐛 ban 人有时失灵 2022-09-12 19:21:46 +08:00
方柳煜
a5ecb4bf7d 修改tts指令使用权限,防止泛用滥用 (#400)
* 修改指令权限,防止泛用

* Update ai_tts.go

* Update ai_tts.go

* Update ai_tts.go
2022-09-12 18:53:53 +08:00
源文雨
1a424ebcd0 优化显示 2022-09-11 22:43:56 +08:00
源文雨
6a44331edd 🔖 v1.5.1-beta2 2022-09-11 10:32:35 +08:00
源文雨
4e78f43649 优化 2022-09-10 13:29:04 +08:00
源文雨
ca7ac08808 优化输出 2022-09-10 13:24:15 +08:00
源文雨
3351450d88 优化显示 2022-09-10 13:21:17 +08:00
源文雨
fa82bdec79 event master check default off 2022-09-10 13:14:43 +08:00
源文雨
0860a105ed 优化代码结构 2022-09-10 11:58:48 +08:00
Jiang-Red
b834307178 新插件event, 好友申请群聊邀请事件处理 (#403) 2022-09-10 11:01:24 +08:00
源文雨
fafe24f1e4 💩👌 make lint happy 2022-09-09 09:54:33 +08:00
源文雨
6f1ec04ac8 Revert "修正moegoe节之Readme (#402)" (#404)
This reverts commit 263278d71d.
2022-09-09 09:49:13 +08:00
Stardust·减
263278d71d 修正moegoe节之Readme (#402)
* Update README.md
2022-09-08 00:04:51 +08:00
源文雨
9ee5b044b4 🐛 fix engine hook 2022-09-07 00:35:08 +08:00
源文雨
21bfa14b55 更改 ban 时间为 10 分 2022-09-06 21:35:31 +08:00
源文雨
0e2d717aa6 添加ban人记忆 2022-09-06 21:24:49 +08:00
源文雨
f5d2bd78b9 添加ban人记忆 2022-09-06 21:24:19 +08:00
源文雨
ef9f764fa0 添加ban人记忆 2022-09-06 21:20:32 +08:00
源文雨
3cfe1a6960 format 2022-09-06 20:33:05 +08:00
源文雨
9387a48b5b format 2022-09-06 20:32:50 +08:00
源文雨
3812150669 edit help 2022-09-06 20:30:50 +08:00
源文雨
4ca100b0bf fix 2022-09-06 20:27:37 +08:00
源文雨
43dee54678 fix 2022-09-06 20:26:21 +08:00
源文雨
14786a94bf 优化 2022-09-06 20:11:40 +08:00
源文雨
98a652f440 优化 2022-09-06 20:02:14 +08:00
源文雨
a004ed8064 优化 2022-09-06 20:00:59 +08:00
源文雨
37b0edde38 add help 2022-09-06 19:51:11 +08:00
源文雨
fd9f19562f 优化 2022-09-06 19:47:26 +08:00
源文雨
acb7b42ded fix 2022-09-06 19:38:16 +08:00
源文雨
f1e4a523ce 优化显示 2022-09-06 19:35:03 +08:00
源文雨
676ea312a3 精简代码 2022-09-06 19:31:01 +08:00
源文雨
6acd930455 优化代码结构 & fix job regex 2022-09-06 19:19:04 +08:00
AkiraXie
340db0c644 improve antiabuse and add testcase (#398)
* improve antiabuse and add testcase

* fix managers link and add managers_test

* make linter happy

* add ttl.cache
2022-09-05 21:44:22 +08:00
方柳煜
f3d66b6abb 重构了qqwife的逻辑 (#395)
* Update and rename qqmapwife.go to command.go

* Add files via upload

* Update command.go

* Update command.go
2022-09-05 18:52:22 +08:00
源文雨
6b8ae2e864 🔖 v1.5.1-beta1 2022-09-01 21:29:49 +08:00
AkiraXie
664cb2f2f9 antiabuse only to me (#393) 2022-08-30 14:21:57 +08:00
AkiraXie
486292434e add anti_abuse plugin (#392)
add anti_abuse plugin
2022-08-30 11:08:00 +08:00
himawari
e5f186ace1 Feature danmakusuki (#388)
*  添加查弹幕

* 🎨 添加注释

* 🎨 优化代码

* 🎨 修lint

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-08-27 12:13:15 +08:00
himawari
0c637d4c8e 添加ahsai和breakrepeat (#384)
*  添加repeatbreak和ahsai

* 📝 添加readme说明
2022-08-27 12:09:28 +08:00
方柳煜
0943023a19 维护guessmusic和qqwife插件 (#385)
* 优化error输出,新增猜歌结束后分享歌曲

* 添加反并发,防止被多娶

* Update main.go
2022-08-26 18:44:47 +08:00
莫思潋
941d6d2884 feat: 抽塔罗牌附加解析 (#383) 2022-08-22 15:33:25 +08:00
fumiama
169af4ccce Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-08-22 13:35:40 +08:00
fumiama
6f1d0f8c02 fix gif panic 2022-08-22 11:53:52 +08:00
方柳煜
dd970b9a91 更换tts的语音api至原神语音api (#382) 2022-08-21 13:38:35 +08:00
fumiama
b997cb650e 🎨 优化 moegoe regex 2022-08-20 10:53:20 +08:00
fumiama
dd3ccf1d2f 🐛 moegoe Chinese 2022-08-20 09:26:15 +08:00
Stardust·减
52a7977461 新增VITS中文支持 (#378) 2022-08-20 09:20:39 +08:00
fumiama
70713c0719 🎨 优化 ERROR 格式 2022-08-16 15:15:29 +08:00
fumiama
b4d6e1ef04 🎨 update deps 2022-08-16 14:01:32 +08:00
fumiama
5295701541 fix aireply help 2022-08-16 11:51:01 +08:00
fumiama
43b9cea801 🔖 v1.5.0 2022-08-16 11:16:52 +08:00
fumiama
926d48af81 revert 2022-08-16 10:42:41 +08:00
尐酱油
962c48ca36 gif系列,新增,更新旧的素材 (#373) 2022-08-16 10:40:28 +08:00
fumiama
03fc569f87 更新 /用法 2022-08-16 10:38:16 +08:00
fumiama
e5b712ff39 🎨 优化 moegoe KR 2022-08-16 10:35:32 +08:00
fumiama
c7f7d0409e 优化 moegoe regex 2022-08-15 10:31:24 +08:00
fumiama
e4ec7ea5bb 🐛 moegoe regex 2022-08-14 20:45:53 +08:00
fumiama
4bf734778b edit README 2022-08-14 20:11:43 +08:00
fumiama
461325c8ca add plugin moegoe 2022-08-14 19:33:07 +08:00
源文雨
efa2ec6aac Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-08-11 19:23:12 +08:00
源文雨
eb8be40f77 fix: non-win /用法 (#370) 2022-08-11 19:22:58 +08:00
himawari
ae7e3c9c89 添加bilibilipush和完善gif文档 (#369)
*  添加bilibilipush和完善gif文档

* 🎨 修lint

* 🎨 日语语法标签匹配日文

* 🎨 优化发送逻辑和命令

* 🎨 错误处理

* 🎨 错误处理
2022-08-11 13:08:42 +08:00
莫思潋
4d68cc9fce fix: ImgFactory->Factory (#367)
* 🎨 改进代码样式

* fix: ImgFactory->Factory

* 🎨 改进代码样式

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-08-06 21:48:55 +08:00
源文雨
0226e2739a 优化 /服务列表 2022-08-06 15:48:22 +08:00
尐酱油
caa163a879 增加gif制图,菜单没写 (#363)
* Update context.go

* Update gif.go

* 🎨 改进代码样式

* Update png.go

* Update run.go

* 🎨 改进代码样式

* 修正素材地址

* Update run.go

* 呃,,,没改完整

* 继续修!!!

* Update png.go

* 🎨 改进代码样式

* Update gif.go

* 🎨 改进代码样式

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-08-06 00:06:16 +08:00
莫思潋
0e29010897 feat:将牌阵结果解析纳入转发列表 (#359) 2022-08-04 13:40:53 +08:00
源文雨
e9a8b99f4f 💩👌 make lint happy 2022-08-03 22:41:00 +08:00
莫思潋
27c637ba66 feat:小阿卡纳塔罗牌 (#346) 2022-07-29 15:26:04 +08:00
源文雨
305db3395c fix: 限速后使用功能直接导致插件崩溃 (#344) 2022-07-28 13:26:25 +08:00
himawari
3da37f0a3e Feature nihongo (#339)
*  添加日语语法学习

* 🎨 添加err
2022-07-24 23:28:30 +08:00
方柳煜
c30c9192f4 修复猜歌已知问题 (#340)
* Update main.go

* Update struct.go

* Update main.go

* Update main.go
2022-07-24 12:22:05 +08:00
源文雨
ceb3df513d 🔖 v1.5.0-beta5 2022-07-22 15:39:51 +08:00
WhitePaper
83372c4209 新增英文字符翻转插件 (#336)
*  新增英文字符翻转插件

* 🎨 代码规范优化

* 🎨 优化代码规范
2022-07-22 15:32:09 +08:00
himawari
20d5e014b7 🐛 支持json卡片 (#335)
Co-authored-by: xiaoguofan <1776620359@qq.com>
2022-07-22 11:50:38 +08:00
himawari
1c9a7eb158 🎨 修改bilibili,bilibiliparse插件结构,添加bilibili动态直播专栏解析 (#319)
* 🎨 修改bilibili,bilibiliparse插件结构,添加bilibili动态直播专栏解析

* 💩 修改大小写

* 🎨 正则全局,错误处理

* 🎨 使用json.NewDecoder()

* 💚 空使用

* 💚 修lint
2022-07-21 12:54:52 +08:00
方柳煜
31555cbf2f 修复群老婆闹离婚成功但实际没离问题 (#330) 2022-07-20 14:34:43 +08:00
方柳煜
4a1d4644ed 取消多个API依赖以提高稳定性,优化用户本地/API歌单可读性和自定义性 (#315) 2022-07-19 11:28:05 +08:00
源文雨
9182d214af ⬆️ update zb 2022-07-15 12:38:02 +08:00
源文雨
45e3383031 🔖 v1.5.0-beta4 2022-07-13 12:24:43 +08:00
himawari
fc91b69b55 添加新表情包 (#306)
*  添加新表情包

* 🐛 处理正则冲突

* 🎨 去掉反射
2022-07-12 12:25:45 +08:00
源文雨
13b6614dc2 🔖 v1.5.0-beta3 2022-07-08 21:40:51 +08:00
源文雨
fec5e4d73f 🐛 all sil 2022-07-08 21:34:23 +08:00
源文雨
585add29fc 🎨 edit README 2022-07-08 21:27:48 +08:00
源文雨
1e48e59cb7 #2: 全局启用、沉默 2022-07-08 21:20:24 +08:00
源文雨
41911af09a 🐛 b14 encode panic 2022-07-07 00:26:46 +08:00
源文雨
37b95e9559 🐛 edit README 2022-07-06 16:02:54 +08:00
源文雨
a7901745e8 🐛 response condition 2022-07-06 15:57:00 +08:00
源文雨
da9f085a50 🐛 create db panic 2022-07-06 14:59:03 +08:00
方柳煜
192c2a8bd6 修复网易云点歌API失效(405)问题 (#303)
* Update main.go

* Update selecter.go

* Update struct.go

* Update main.go
2022-07-06 13:44:24 +08:00
源文雨
e6c00e9b68 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-07-05 13:45:46 +08:00
源文雨
1faa5aa5d8 control 增加 /响应 /沉默 2022-07-05 13:45:39 +08:00
源文雨
7e7191536a 🔖 v1.5.0-beta2 2022-07-03 18:28:18 +08:00
时雨◎星空
16ff1975ff 修复猜歌插件创建config.json错误 (#296) 2022-07-03 18:20:04 +08:00
源文雨
b32c86863e edit main 2022-07-03 10:24:33 +08:00
源文雨
d9b361f765 🔖 v1.5.0-beta1 2022-07-03 09:52:01 +08:00
Fox_white
5b2810e6c5 为猜歌插件添加config (#285)
*  猜歌添加config

* 📚 猜歌帮助信息更新

* 📚 猜歌帮助信息更新

*  猜歌错误信息继承

*  错误处理

*  错误处理ep2

* 🐛 猜歌插件bug修正和命名修改

*  猜歌插件不再使用gjson

* Update struct.go

* 修复-动漫2无法下载歌曲问题

* 🐛 Resolve Compilation error

* 🐛 Resolve Lint

* 🐛 Resolve Lint

Co-authored-by: 方柳煜 <101934327+fangliuyu@users.noreply.github.com>
2022-07-03 09:25:14 +08:00
github-actions[bot]
15a5b347e8 🎨 改进代码样式 2022-06-29 12:58:24 +00:00
方柳煜
477ffa825b 优化qqwife插件,新增猜歌插件 (#283)
* 猜歌插件

* 猜歌插件

* 猜歌插件

* 优化重置花名册指令

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update main.go

* Update README.md
2022-06-29 20:57:58 +08:00
Jiang-Red
84363b1513 删除无法使用的zaobao (#278)
* drop zaobao

* edit readme

* drop zaobao
2022-06-24 21:00:55 +08:00
方柳煜
01bf6f049b 修复存在误解的文案 (#272)
* 修复存在误解的文案

* Update qqmapwife.go
2022-06-19 20:51:47 +08:00
莫思潋
a8d93de000 feat:塔罗牌阵 (#268)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版

* - 调整funny
- 补回readme中bilibili_push的注释说明

* - 简化funny说明

* - 用暴力的办法使抽多张塔罗牌不重复
- 逆位的图片现在可以倒过来了

* - 解塔罗牌

* - 修改readme

* 大幅减少全局变量,简化抽塔罗牌输出

* - 更新了塔罗牌阵

* - 顺lint心意
- 添加判断避免重复装填

* 调整塔罗牌阵消息
- 用图片说明牌阵信息避免被封

* 调整DoOnceOnSuccess,减少冗余

* 🎨 改进代码样式

* 调整发送牌阵信息

* 🎨 改进代码样式

* 改回base64

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-06-18 16:51:11 +08:00
github-actions[bot]
2da5de3743 🎨 改进代码样式 2022-06-18 04:06:33 +00:00
方柳煜
bf6bac7be6 修复花名册会显示单身贵族的问题 (#269)
* 修复花名册会显示单身贵族的问题

* Update qqmapwife.go

* Update qqmapwife.go
2022-06-18 12:06:07 +08:00
源文雨
394d2e4a08 edit README 2022-06-17 11:59:26 +08:00
himawari
0dd447e270 添加txt转midi,优化midi转txt (#267)
* 🐛 长字符串发文件

*  添加txt转midi

*  音色自定义

*  添加windows脚本说明

* 🐛 修复某些midi读取不了的问题

*  多音轨转换

Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
2022-06-17 11:46:09 +08:00
源文雨
92c913e3eb 🔖 1.4.1 2022-06-16 13:31:33 +08:00
github-actions[bot]
5dea461963 🎨 改进代码样式 2022-06-16 05:29:07 +00:00
方柳煜
f768081849 优化花名册名字切片报错问题 (#263) 2022-06-16 13:27:47 +08:00
himawari
668418c48a 添加mid2txt接口 (#264)
Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
2022-06-16 13:27:23 +08:00
github-actions[bot]
2bf387a57c 🎨 改进代码样式 2022-06-15 04:24:49 +00:00
方柳煜
42a4726985 修复checkupdate报错问题 (#262)
* 修复checkupdate报错问题

* Update qqmapwife.go

* Update qqmapwife.go
2022-06-15 12:24:19 +08:00
源文雨
5c4b5359e0 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-06-13 13:05:42 +08:00
源文雨
8e3f56a3a2 move info 2022-06-13 13:05:21 +08:00
github-actions[bot]
91a837477a 🎨 改进代码样式 2022-06-13 04:32:42 +00:00
源文雨
a2dfc54068 🐛 fix: b14 decode 2022-06-13 12:32:09 +08:00
github-actions[bot]
7ded2fe13a 🎨 改进代码样式 2022-06-13 04:09:52 +00:00
方柳煜
b6f1b27a81 Update qqmapwife.go (#261) 2022-06-13 12:09:22 +08:00
源文雨
621fd614ea 💩👌 make lint happy 2022-06-11 21:06:08 +08:00
源文雨
be3e7c892c fix b14 2022-06-11 18:27:26 +08:00
源文雨
1f640b7644 drop webgui 2022-06-11 17:00:22 +08:00
源文雨
987b505d32 fix regex 2022-06-11 16:27:09 +08:00
源文雨
4b2f23f093 优化正则 2022-06-11 16:13:26 +08:00
源文雨
1d52d0bafc 优化 parse 2022-06-11 16:04:57 +08:00
源文雨
e73db14976 运势 add ASoul 2022-06-11 14:27:03 +08:00
源文雨
fe8a677541 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-06-11 14:16:36 +08:00
源文雨
926cba8197 运势 add ASoul 2022-06-11 14:16:22 +08:00
Jiang-Red
ee6e5db0a6 Update bilibili_parse.go (#259)
修复 粉丝数据获取出错
优化 简化数据显示
优化 不返回无效链接的错误
2022-06-11 11:53:19 +08:00
源文雨
0c62d8dd07 fix: imgfinder format 2022-06-10 23:34:05 +08:00
源文雨
d6e352b3b4 fix: imgfinder format 2022-06-10 23:28:12 +08:00
源文雨
59e46be262 fix: imgfinder format 2022-06-10 23:24:14 +08:00
源文雨
746c048550 优化代码结构 2022-06-10 19:00:27 +08:00
himawari
a92c584997 添加简易midi制作 (#257)
*  添加简易midi制作

* 🐛 修lint

Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
2022-06-10 18:55:28 +08:00
源文雨
7f4c6eb4ac 🔖 1.4.1-beta6 2022-06-10 15:48:33 +08:00
源文雨
fbeb048c44 ⬆️ update sqlite 2022-06-10 15:47:47 +08:00
源文雨
9f748a8119 imgfinder add more info 2022-06-10 13:42:03 +08:00
源文雨
b9fd590095 fix #256: 关键字搜图无法使用 2022-06-10 13:21:31 +08:00
源文雨
430e210b3c update deps 2022-06-10 13:04:16 +08:00
Jiang-Red
706d54db76 更换api版bilibiliparse (#255)
* Update bilibili_parse.go

* make lint happy

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

* Update sign_in.go

* 🎨 改进代码样式

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

*  添加马丁路德骂人语录

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

* 更改源酱提出的问题

* Update qqmapwife.go

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

* 🚨 错误输出

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

更换API方式

* Update calendar.go

* 更换API

修复BUG

* 🎨 改进代码样式

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

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

* 🎨 查成分增加可选择查uid
2022-05-06 20:02:36 +08:00
源文雨
3b277b0eb0 搜图 drop yandex 2022-05-06 18:54:39 +08:00
源文雨
5e0991681f 抽n张塔罗牌 2022-05-05 14:19:52 +08:00
源文雨
354fbb7cdd 抽n张塔罗牌 2022-05-05 14:19:33 +08:00
源文雨
a166d06096 抽n张塔罗牌 2022-05-05 14:19:12 +08:00
源文雨
b8a6e07095 优化每日随机 2022-05-05 13:50:54 +08:00
源文雨
a8fba6e7b5 优化GetLazyData 2022-05-05 13:31:22 +08:00
源文雨
17a8c10f8c 🎨 modify badge 2022-05-04 23:40:37 +08:00
源文雨
7ccd29faac 🎨 modify badge 2022-05-04 23:40:01 +08:00
源文雨
d432e48cce 🔖 1.4.0-beta4 2022-05-04 23:21:50 +08:00
莫思潋
19091319cc feat:抽塔罗牌 (#213)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版

* - 调整funny
- 补回readme中bilibili_push的注释说明

* - 简化funny说明

* feat:抽塔罗牌

* 🎨 改进代码样式

* 加上一个换行符

* 🎨 改进代码样式

* - At用户

* 🎨 改进代码样式

* -改进抽塔罗牌

* typo: 小写struct名

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-04 23:19:21 +08:00
源文雨
d29e12a92c fortune add plugin 夏日口袋 by @XHLin-gamer 2022-05-04 21:23:54 +08:00
himawari
5db03b0441 查成分新增字段注册日期 (#212)
*  查成分添加注册日期信息

* 🐛 修复头像是webp图片使用不了的问题
2022-05-03 14:42:58 +08:00
源文雨
f8c7e2bf6d 🔖 1.4.0-beta3 2022-05-02 10:56:49 +08:00
源文雨
a7fdc6a88f 🐛 服务列表不显示名称 2022-05-02 10:55:17 +08:00
莫思潋
4aaf5b0779 调整讲个笑话 (#210) 2022-05-02 10:46:53 +08:00
源文雨
6150e4c736 add playground instruction 2022-04-30 00:37:12 +08:00
源文雨
9a3b4b3ecb 🔖 1.4.0-beta2 2022-04-29 20:41:57 +08:00
源文雨
cbaeb4d5f2 🐛 无法在job中移除匹配触发器 2022-04-29 20:40:37 +08:00
源文雨
592c306aa0 加速word count 2022-04-28 23:29:48 +08:00
源文雨
136e6bddf4 加速word count 2022-04-28 23:15:27 +08:00
源文雨
0e8bef0541 sync data 2022-04-28 22:26:00 +08:00
fumiama
9d8c52303e update deps 2022-04-28 22:19:53 +08:00
fumiama
e6ae7df546 🔖 1.4.0-beta1 2022-04-28 19:58:22 +08:00
fumiama
5b57a759be update deps 2022-04-28 19:56:37 +08:00
MSCxar#0293
cc96eeae32 🐛README.md查缺补漏 (#208) 2022-04-28 17:38:30 +08:00
himawari
484fef1228 🎨 优化vtb插件代码,更换shadiao的api (#206)
* 🎨 优化vtb插件代码,更换shadiao的api

* 🎨 正则全局变量

Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
2022-04-28 17:37:57 +08:00
Coloured-glaze
ba4ca11c83 🎨增加文字回复 (#205)
* 🎨增加文字回复

* 🎨增加文字回复

* 🎨增加文字回复

* 🎨增加文字回复(fix)

* 🎨small letter=>

* Update ys.go

* Update ys.go

* Update ys.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-04-27 14:11:23 +08:00
Mayuri
9372902348 🐛fix : setutime regex (#203) 2022-04-25 09:33:53 +08:00
源文雨
0cc9420570 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-04-22 09:24:29 +08:00
源文雨
18fa48d283 🔖 1.3.3-fix1 2022-04-22 09:24:15 +08:00
源文雨
9034fedbd0 lolicon add custom rand api 2022-04-22 09:23:31 +08:00
源文雨
ec3b6ec5fa 🔥 remove plugin acgimage 2022-04-22 09:13:43 +08:00
Mayuri
8cc2a4174e 🐛 更新签到背景图API (#202) 2022-04-21 21:36:23 +08:00
Yiwen-Chan
8a0014928d 🐛 更新疫情API 2022-04-21 12:59:01 +08:00
github-actions[bot]
228ca7f9c0 🎨 改进代码样式 2022-04-20 04:50:42 +00:00
MoeMagicMango
c0fa7efb27 简单修了下网易点歌 (#200) 2022-04-20 12:49:24 +08:00
himawari
3553683bb1 🐛 兼容linux和windows文件换行不同 (#199) 2022-04-19 23:00:01 +08:00
源文雨
ccb58e0a6c 🎨 edit README 2022-04-19 13:02:13 +08:00
源文雨
93253e2188 🎨 edit README 2022-04-19 12:59:47 +08:00
MSCxar#0293
e34bcc9bbd [水pr]整理README.md (#198)
* 整理 README.md
2022-04-19 12:39:45 +08:00
源文雨
72169e3a4d 🔖 1.3.3 2022-04-18 23:07:49 +08:00
源文雨
41c499840f fix #197: 猜单词出现空指针报警 2022-04-18 22:59:33 +08:00
himawari
f5cef170f0 🚑️ 修复查看其他群聊热词的问题 (#195) 2022-04-18 16:31:09 +08:00
源文雨
d7922a7c9b ️ 优化pool 2022-04-18 16:29:09 +08:00
github-actions[bot]
23fc77e8e1 🎨 改进代码样式 2022-04-17 13:25:27 +00:00
himawari
51f3eda09a 👍 添加聊天热词 (#192)
*  添加聊天热词

*  添加聊天热词

*  添加聊天热词

* 🚨 修lint

* 🚨 修lint
2022-04-17 21:24:07 +08:00
源文雨
6ec08a5227 🐛 reg 时序 2022-04-17 21:22:08 +08:00
源文雨
4855f694cb 🎨 edit README 2022-04-17 00:11:54 +08:00
源文雨
eaef37a831 Update README.md 2022-04-16 19:10:06 +08:00
源文雨
b182ff36bb 🔖 1.3.3-beta6 2022-04-16 00:35:05 +08:00
源文雨
c4e543449c 使用真正lazy的资源下载方式 2022-04-16 00:33:50 +08:00
源文雨
c76d9d4461 🔥 remove debug info in gorm 2022-04-16 00:04:07 +08:00
源文雨
dfd184724b 使用真正lazy的资源下载方式 2022-04-16 00:02:41 +08:00
源文雨
fef254031e ️ banmap 使用 ttl 2022-04-15 19:02:06 +08:00
源文雨
89c4e59bf1 🔖 1.3.3-beta5 2022-04-15 15:29:45 +08:00
源文雨
2e9acd3276 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-04-15 15:28:02 +08:00
源文雨
5cab59c93f 🐛 戳一戳失效 2022-04-15 15:27:47 +08:00
Mayuri
ebfb5878a1 更新用法和README.md (#189)
* update help manual

* Update README.md
2022-04-15 09:25:25 +08:00
源文雨
de6b11aa22 🔖 1.3.3-beta4 2022-04-14 17:18:01 +08:00
源文雨
9e7e7159e8 🔖 1.3.3-beta3 2022-04-14 17:11:00 +08:00
源文雨
00c909271b 🔖 1.3.3-beta3 2022-04-14 17:10:21 +08:00
源文雨
7401a0cbec 🎨 优化代码结构 2022-04-14 17:09:28 +08:00
源文雨
a9327d1774 🐛 reg close 2022-04-10 16:33:34 +08:00
Mayuri
9e99ef1348 新增 {gid} {groupname} (#186)
* modified:   plugin/manager/manager.go

* use message.UnescapeCQCodeText instead
2022-04-10 11:46:50 +08:00
源文雨
5b4b9fdb01 🔖 1.3.3-beta2 2022-04-06 11:17:02 +08:00
源文雨
d2998c4908 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-04-06 11:15:27 +08:00
源文雨
4ab968d563 🎨 优化代码结构 2022-04-06 11:15:24 +08:00
himawari
9b26eea754 增加查看签到排名 (#180)
*  增加查看签到排名

* 🚨 修lint

* 🚨 修lint
2022-04-06 10:59:56 +08:00
源文雨
a6bd717971 🔥 精简 log 输出 2022-04-05 23:18:13 +08:00
Kanri
f2914adb65 Update README.md 2022-04-05 20:52:25 +08:00
Kanri
aa5a426aac 📄 更换 README 图片 2022-04-05 20:50:40 +08:00
Kanri
fef8144187 📄 change title picture 2022-04-05 20:48:32 +08:00
源文雨
d8a429d3b3 🚧 move tag & nsfw to azfun 2022-04-05 15:52:06 +08:00
github-actions[bot]
56e53b75a5 🎨 改进代码样式 2022-04-04 14:55:00 +00:00
himawari
f89b6f5feb ️wordle逻辑优化,bilibilipush、translate添加信息 (#179)
* :sparkles:添加查成分功能

* :rotating_light:修lint

* :rotating_light:减少空格

* :bug:修改网址

* :bug:修改vup数量错误问题

* :bug:图片读取不了,就不读了

* 🐛 固定头像大小,bilibilipush调公有库

* 🎨 修改json转换

*  bilibilipush添加新类型,同时修改命令正则,wordle添加时间提醒,和单词语义,translate充实信息

* ️使用公用的翻译函数

* 🚨 添加return和stop

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-04-04 22:53:37 +08:00
源文雨
ec513e8893 🐛 job 指令触发可能失败 2022-04-04 14:36:25 +08:00
源文雨
35d6792d2e 🐛 job 指令触发可能失败 2022-04-04 13:28:50 +08:00
源文雨
74387aae2d 🔖 1.3.3-beta1 2022-04-03 18:53:06 +08:00
源文雨
959043962d Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-04-03 18:51:25 +08:00
源文雨
4efb71bafb 🍱 运势 增加底图 奇异恩典 2022-04-03 18:51:06 +08:00
TZMSky
6fd0bc0445 删除Onebot-YAYA (#177) 2022-04-02 22:53:10 +08:00
源文雨
176a2eb392 🔥 精简Register 2022-04-02 22:45:21 +08:00
源文雨
1a85deb36e 🎨 优化代码结构 2022-04-02 22:40:31 +08:00
源文雨
5b409ff3de 🐛 pixiv dns 2022-04-02 13:31:54 +08:00
源文雨
a9e13d3a92 🎨 优化代码结构 2022-03-31 19:50:34 +08:00
莫思潋
0698d8e3b1 fix:修复了枝网查重无法使用的问题 (#175)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版

* 小调整

- 考虑到屌字既难打又有碍观瞻,改为正则匹配`[屌|弔|吊]图`
- 增加了退群提醒的定制

* - 修复退群提醒本身忘记修改了的问题

* fix:修复了枝网查重无法使用的问题

* readme适配上次的欢迎语修改

* 删去调试语句

* Update setu_geter.go

* Update zhiwang.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-03-31 19:36:29 +08:00
源文雨
8e4c496b54 🐛 MustProvicePicture goroutine 泄漏 2022-03-30 13:23:52 +08:00
源文雨
27054b9722 🐛 MustProvicePicture goroutine 泄漏 2022-03-30 13:17:37 +08:00
源文雨
bcad2c4998 🎨 优化代码结构 2022-03-29 16:29:29 +08:00
github-actions[bot]
aae2bd4884 🎨 改进代码样式 2022-03-29 05:05:36 +00:00
himawari
006ef6f672 👍 添加查成分功能,修改bilibili插件的正则 (#171)
* :sparkles:添加查成分功能

* :rotating_light:修lint

* :rotating_light:减少空格

* :bug:修改网址

* :bug:修改vup数量错误问题

* :bug:图片读取不了,就不读了

* 🐛 固定头像大小,bilibilipush调公有库

* 🎨 修改json转换

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-03-29 13:03:46 +08:00
源文雨
7be1a61347 🎨 优化代码结构 2022-03-28 23:13:53 +08:00
源文雨
1ef48f6cd6 🎨 优化代码结构 2022-03-28 23:06:04 +08:00
源文雨
a9a061a4bb 🎨 优化代码结构 2022-03-28 23:01:36 +08:00
源文雨
14ed8b7af7 🐛 reg 2022-03-28 17:23:54 +08:00
源文雨
d17b8fa720 📝 edit readme 2022-03-28 17:14:39 +08:00
源文雨
68980a69b5 🐛 增加百人一首 修复Lazy不关闭 2022-03-28 17:11:44 +08:00
源文雨
636f14c450 🐛 md5 只能连接一次 2022-03-27 14:35:48 +08:00
源文雨
b066bc37b3 #150 缩减coser发图数 2022-03-27 14:26:28 +08:00
源文雨
9ac43fecf8 fix #151 2022-03-27 14:22:34 +08:00
源文雨
d6ff14167d add plugin 渲染任意文字到图片 2022-03-27 14:00:21 +08:00
源文雨
5837a765f1 add plugin 渲染任意文字到图片 2022-03-27 13:54:26 +08:00
源文雨
1bfb76a4b3 📝 edit readme 2022-03-27 12:59:08 +08:00
源文雨
2a78a602e2 shindan add 黄油角色 2022-03-27 12:56:57 +08:00
源文雨
884b0e4226 💩👌 make lint happy 2022-03-27 12:48:12 +08:00
源文雨
4e819eb5d9 fix ci 2022-03-27 12:44:02 +08:00
源文雨
e3a50cc014 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-03-27 00:24:56 +08:00
源文雨
25ab8c9234 fix: FutureEvent 2022-03-27 00:24:46 +08:00
github-actions[bot]
901e680fa4 🎨 改进代码样式 2022-03-26 14:03:46 +00:00
源文雨
82768fff59 fix b14 & cd 2022-03-26 22:01:50 +08:00
莫思潋
87e3297904 定制退群提醒+调整煎蛋网无聊图触发 (#166)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版

* 小调整

- 考虑到屌字既难打又有碍观瞻,改为正则匹配`[屌|弔|吊]图`
- 增加了退群提醒的定制

* - 修复退群提醒本身忘记修改了的问题
2022-03-22 12:31:44 +08:00
Jiang-Red
81a4297eb1 添加更多数据,修改发送排版 (#167) 2022-03-21 18:18:29 +08:00
源文雨
17f5b52931 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-03-20 18:49:31 +08:00
源文雨
2250adf854 fix #161 2022-03-20 18:49:20 +08:00
GenesisAN
5cd46b3926 从url正则中去除用字 (#160)
从url正则中去除用字,以防止url中包含用字前缀导致图片显示失败
2022-03-20 14:43:55 +08:00
源文雨
6e2b10b788 fix lint 2022-03-20 14:40:47 +08:00
源文雨
5e301ccaaf fix lint 2022-03-20 14:33:43 +08:00
源文雨
206a38efab fix #154: 优化代码结构 2022-03-20 14:20:37 +08:00
Coloured-glaze
cdf844be52 🎨原神抽卡 (#156)
* Add files via upload

* 原神抽卡

* 🎨原神抽卡
2022-03-20 10:59:11 +08:00
源文雨
70cc28c191 fix ci 2022-03-19 19:58:16 +08:00
源文雨
35282fba6c update data 2022-03-19 19:52:54 +08:00
源文雨
e43f8e594d Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-03-19 19:51:59 +08:00
源文雨
21988fab76 ⬆️ update to go 1.18 2022-03-19 19:51:45 +08:00
himawari
2f3823abe2 feat:添加舔狗日记和修复睡眠管理的问题 (#152)
* feat:添加舔狗日记和修复睡眠管理的问题

* fix:修lint

* fix:修改铅笔小说网址

* fix:修改铅笔小说网址
2022-03-19 11:29:31 +08:00
源文雨
2c545e7b7f 🎨 优化pool 2022-03-18 16:50:07 +08:00
源文雨
22f2200778 🐛 b14 panic 2022-03-15 22:50:38 +08:00
源文雨
2f63253ec0 🎨 优化代码结构 2022-03-14 12:50:50 +08:00
源文雨
be7e8134f9 🎨 优化代码结构 2022-03-14 12:46:54 +08:00
源文雨
b85408e3e5 pixiv add backend dns result 2022-03-13 22:43:41 +08:00
源文雨
4828451f9e 🔖 v1.3.2 2022-03-13 13:21:52 +08:00
源文雨
b3b50e1353 🐛 搜图 有时无法下载图片 2022-03-13 13:14:01 +08:00
源文雨
95e8bf2f55 📝 edit readme 2022-03-12 20:22:28 +08:00
源文雨
cde7669c0b 优化代码结构 2022-03-12 11:35:20 +08:00
源文雨
ff4a33c51c edit readme 2022-03-12 11:05:19 +08:00
源文雨
06cf6f84aa edit readme 2022-03-12 00:27:27 +08:00
源文雨
556f6f134f edit readme 2022-03-12 00:27:15 +08:00
源文雨
b1ab7ef118 edit readme 2022-03-12 00:25:59 +08:00
源文雨
e5fd108a9c edit readme 2022-03-12 00:25:21 +08:00
源文雨
5a67bf2417 🐛 每天刷新 2022-03-12 00:18:26 +08:00
源文雨
cb020c1bbd 🐛 每天刷新 2022-03-12 00:17:33 +08:00
源文雨
bf75b29e33 🐛 每天刷新 2022-03-12 00:16:04 +08:00
源文雨
d730fd9cab 优化代码结构 2022-03-12 00:05:41 +08:00
Jiang-Red
a862e5be7c 添加 早报插件及设置欢迎语增加更多自定义 (#147)
* 添加 早报插件

* 添加 早报插件

* 添加 早报插件

* 添加 设置欢迎语更多自定义

* 添加 help说明

* 添加 manager设置欢迎语说明

* 怪

* 🎨 改进代码样式

* Update zaobao.go

* Update zaobao.go

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-03-11 23:47:39 +08:00
源文雨
ebca124c86 🐛 修复 run 2022-03-11 23:02:08 +08:00
源文雨
3b7803a81b 优化代码结构 2022-03-11 16:34:26 +08:00
源文雨
b7b9d92148 优化代码结构 2022-03-11 16:18:11 +08:00
Rainy
44575fb19e 增加城市疫情查询 (#146)
* 增加城市疫情查询

* 增加城市疫情查询

* 增加城市疫情查询

* 增加城市疫情查询

* 增加查询城市疫情

* 增加城市查询疫情

* 增加城市疫情查询

* Update epidemic.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-03-11 16:10:14 +08:00
源文雨
f181a4b9cd 🎨 可自行编辑json 2022-03-11 11:40:51 +08:00
源文雨
77e5d8b0c2 ⬆️ update deps 2022-03-11 11:36:55 +08:00
源文雨
edd9feb8f8 🔥 drop ioutil 2022-03-11 11:32:13 +08:00
源文雨
81d6a06dbe 🎨 ascii2d color -> bovw 2022-03-11 10:46:01 +08:00
源文雨
8afbc67bf7 💩👌 make lint happy 2022-03-11 10:26:29 +08:00
源文雨
a27132f907 job可获取网页信息,可代表执行 2022-03-09 12:14:20 +08:00
源文雨
183be05d82 job可编程 2022-03-08 23:18:31 +08:00
源文雨
bccf789714 job增加执行指令 2022-03-08 20:39:02 +08:00
源文雨
55944dddb3 job增加参数读取 2022-03-08 18:14:41 +08:00
源文雨
f67932cc56 job增加参数读取 2022-03-08 18:11:24 +08:00
源文雨
6d633fac6a 🐛 edit readme 2022-03-08 18:10:01 +08:00
源文雨
86fc5c51c8 job增加参数读取 2022-03-08 18:07:59 +08:00
源文雨
156e9f07ad 🐛 job禁止递归触发&增加README 2022-03-08 13:04:44 +08:00
源文雨
1ba4722fc7 💩👌 make lint happy 2022-03-07 23:27:11 +08:00
源文雨
54c9857219 🎉 job增加注入指令结果 2022-03-07 22:49:19 +08:00
源文雨
ea56c7d0d2 🐛 panic: sync: WaitGroup is reused 2022-03-07 14:43:25 +08:00
源文雨
0cbe43df97 🐛 panic: sync: WaitGroup is reused 2022-03-07 14:08:23 +08:00
源文雨
1f941d883a 🐛 panic: sync: WaitGroup is reused 2022-03-07 14:01:15 +08:00
源文雨
f5b3e423fb 🐛 panic: sync: WaitGroup is reused 2022-03-07 13:56:05 +08:00
源文雨
6c7f81ca55 🔖 1.3.1 2022-03-07 13:41:23 +08:00
源文雨
3911b5ed82 🎨 优化初始化逻辑 2022-03-07 13:40:32 +08:00
源文雨
f38f3ab69c 🐛 定时指令触发器插件增加查看 2022-03-07 13:15:26 +08:00
源文雨
846db6f063 📝 edit README 2022-03-06 22:53:59 +08:00
源文雨
ff068a05b0 🐛 定时指令触发器插件增加限速器 2022-03-06 22:52:38 +08:00
源文雨
051b7dd182 🐛 定时指令触发器插件允许非管理私聊使用 2022-03-06 22:46:12 +08:00
源文雨
11870aeed6 🐛 定时指令触发器插件在某些bot失效 2022-03-06 22:37:35 +08:00
源文雨
9bcff82d9c Update main.go 2022-03-06 21:27:19 +08:00
源文雨
309efe8cd8 增加定时指令触发器插件 2022-03-06 21:21:28 +08:00
源文雨
bf54789f0f 🎨 优化pixiv下载 2022-03-05 23:01:28 +08:00
Kanri
01e527abdb 增加六阶七阶猜单词 (#140) 2022-03-05 10:36:01 +08:00
fumiama
db6b558c75 ⬆️ update deps 2022-03-04 12:17:58 +08:00
fumiama
9a792eb144 🍱 运势增加底图 东方归言录 by @KafCoppelia 2022-03-02 22:37:41 +08:00
fumiama
44e99664a3 🎨 关键字搜图改用云函数反代 2022-03-01 23:10:10 +08:00
fumiama
9f3dd37bf0 🎨 关键字搜图改用云函数反代 2022-03-01 23:02:22 +08:00
fumiama
f5936d9cb7 🎨 某些发图应用合并转发 2022-03-01 19:47:25 +08:00
fumiama
27e69ef022 yandex与ascii2d并行 2022-03-01 17:30:59 +08:00
fumiama
6262aab6bd 替换CustomNode为ctxext的封装 2022-03-01 17:29:19 +08:00
fumiama
4781bc8eb7 sync 2022-02-27 19:34:47 +08:00
fumiama
b233c4b638 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-02-27 19:32:29 +08:00
fumiama
0a0cc807dc fix #139 2022-02-27 19:31:53 +08:00
github-actions[bot]
feeeb63e52 🎨 改进代码样式 2022-02-27 10:59:03 +00:00
himawari
5c620d6268 feat:添加月幕galgame网站图 (#138)
* feat:添加月幕galgame网站图

* fix:修lint

* fix:不重复更新

* fix:增加命令提醒语

* fix:增加日语匹配

* fix:换位置加锁

* fix:隐式声明

* fix:copy数组

* Update ai_tts.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-02-27 18:57:52 +08:00
fumiama
a469000d7a 🔖 v1.3.0 2022-02-27 15:04:09 +08:00
fumiama
0e15ac78b2 修复pixiv下载 2022-02-27 14:17:29 +08:00
fumiama
d9e195ccd0 💩👌 make lint happy 2022-02-26 23:22:37 +08:00
fumiama
cf52997279 fix: 图片缓存池 2022-02-26 23:20:08 +08:00
fumiama
88318a7151 增加插件 百度一下 2022-02-26 22:28:37 +08:00
fumiama
91f522b666 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-02-26 22:09:55 +08:00
fumiama
1895f8815e fix: gif 爬 撕 2022-02-26 22:09:37 +08:00
Kanri
7be5f52be4 ✏️ 修复抓不到日历的碧油鸡 (#137)
* ✏️ 修复抓不到日历的碧油鸡

* ✏️ 小修改
2022-02-26 21:58:29 +08:00
fumiama
0cfb2e4e06 🎨 优化目录结构 2022-02-25 22:15:14 +08:00
fumiama
5ccf753af3 🎨 优化目录结构 2022-02-25 22:06:30 +08:00
fumiama
bfcf3cac91 删除插件 minecraft 2022-02-25 22:01:37 +08:00
fumiama
bc3d7bc278 删除插件 minecraft 2022-02-25 22:00:03 +08:00
fumiama
7cf767f344 🐛 fix: 摸鱼日历&插件控制 2022-02-25 13:24:21 +08:00
fumiama
7aed9a2c89 fix: reg panic 2022-02-24 21:34:06 +08:00
fumiama
454196a462 sync 2022-02-24 20:02:02 +08:00
fumiama
1597ba7128 💩👌 make lint happy 2022-02-24 19:55:28 +08:00
fumiama
480523ff27 🎨 🔥 ️ feat: pack pooled img sending 2022-02-24 19:54:48 +08:00
Kanri
7ec7ab8682 ✏️ 修复一下碧油鸡 (#136) 2022-02-24 18:06:23 +08:00
Kanri
ba2d011d48 ✏️ 修复获取公众号链接错误的问题 (#135) 2022-02-24 16:56:50 +08:00
fumiama
504e6cd1cc fix(#134): 两个群同时猜单词会互相干扰 2022-02-23 17:10:33 +08:00
github-actions[bot]
b8f3700fe4 🎨 改进代码样式 2022-02-23 08:58:01 +00:00
Jiang-Red
b2cff862bb Update manager.go (#132)
* Update manager.go

修改 自定义欢迎语可带图
添加 修改名片/修改头衔/申请头衔字数限制

* Update manager.go

* Update manager.go

添加 测试欢迎语

* Update manager.go

* Update manager.go

* Update manager.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-02-23 16:57:06 +08:00
fumiama
dc348f8500 🔥 🎨 统一 cron 2022-02-23 16:52:40 +08:00
Kanri
8c40293fed 新增插件 摸鱼人日历 (#133)
*  新增插件 摸鱼人日历

*  新增插件 摸鱼人日历

* ✏️ 优化插件 摸鱼人日历
2022-02-23 16:36:23 +08:00
fumiama
48deaf3aca 🔥 🎨 tts 2022-02-23 11:38:00 +08:00
fumiama
6932643788 🔥 🎨 tts 2022-02-23 11:35:43 +08:00
fumiama
7f972e3d68 🐛 fix: wordle 2022-02-23 11:32:26 +08:00
github-actions[bot]
edb0880999 🎨 改进代码样式 2022-02-23 03:17:02 +00:00
himawari
45f0f5cd6c 将mockingbird统一到tts (#131)
* fix:处理回复文本

* feat:将以mockingbird统一到tts里

* fix:修lint

* fix:换一个正则函数

* fix:去掉ok

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-02-23 11:15:42 +08:00
fumiama
e468ac1933 apply new api ImageBytes 2022-02-22 22:16:49 +08:00
fumiama
55b6b40acf fix: use Send instead of SendChain 2022-02-22 21:55:25 +08:00
fumiama
5f1190f72e feat: use single instead of sync.Map 2022-02-22 21:52:06 +08:00
Kanri
b0fbd6507d 发布插件猜单词 2022-02-22 19:48:13 +08:00
fumiama
598a664d30 🐛 修正放大图片 2022-02-22 13:13:04 +08:00
fumiama
211f0a667d 🐛 修正放大图片 2022-02-22 13:10:48 +08:00
fumiama
28fb788778 🎨 shrink imgpool hash 2022-02-21 22:24:29 +08:00
fumiama
628830fbf5 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-02-20 16:57:17 +08:00
fumiama
7d235d0077 🎨 scale 更改为 云函数 2022-02-20 16:57:01 +08:00
himawari
861b0b6cef fix:修改vtb语录存为本地路径,去掉bilibilipush缓存 (#130)
* fix:修改vtb语录存为本地路径,去掉bilibilipush缓存

* fix:bilibiliparse添加up和粉丝数,修改bilibilipush的时间

* Update bilibili_parse.go

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-02-19 23:54:17 +08:00
fumiama
9986c57727 fix: 缓存池有时无法发出图片 2022-02-19 23:50:39 +08:00
fumiama
f1c9e2331c fix: 缓存池有时无法发出图片 2022-02-19 23:41:11 +08:00
fumiama
7c1ddc6ab1 💩👌 make lint happy 2022-02-19 18:03:35 +08:00
fumiama
44ad78761b 🎨 🔥 update sqlite 2022-02-19 16:16:48 +08:00
fumiama
bd6925f2f1 🎨 🔥 统一 seed 2022-02-18 20:20:25 +08:00
fumiama
3838d74cb8 🎨 🔥 优化代码结构 2022-02-18 20:15:07 +08:00
Kanri
eaad8beb7b 增加插件 猜单词 (#129)
*  增加插件 猜单词

* Update wordle.go

* Update wordle.go

* Update wordle.go

* Update wordle.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-02-18 19:08:02 +08:00
fumiama
14acdfdbc3 🎨 ️ control 增加数据库查询缓存 & log 采用 CQ 码打印 2022-02-16 21:57:14 +08:00
fumiama
a5fe7a5b40 scale 增加图片过大保护 2022-02-16 13:55:17 +08:00
fumiama
61df3c55b5 scale 增加图片过大保护 2022-02-16 13:50:12 +08:00
fumiama
eb0059c1a3 fix: writer endian 2022-02-16 12:29:49 +08:00
fumiama
4ca5038ae9 🎨 🔥 优化代码结构 2022-02-15 20:50:49 +08:00
fumiama
121403231a fix: acgimage block 2022-02-15 16:17:40 +08:00
fumiama
b945338a8d 🔥 update go-registry 2022-02-15 13:38:45 +08:00
fumiama
ae5ea542a0 🔥 update go-registry 2022-02-15 00:42:39 +08:00
fumiama
fe95dc8201 🐛 fix: image finder 2022-02-14 17:08:20 +08:00
fumiama
1eefb4e610 🐛 fix: image finder 2022-02-14 17:07:45 +08:00
fumiama
8660d8d990 🐛 fix: image finder 2022-02-14 17:06:54 +08:00
fumiama
37033fe48d 搜图增加 yandex 2022-02-14 16:34:46 +08:00
fumiama
30665ad8c6 💩👌 make lint happy 2022-02-14 14:50:42 +08:00
fumiama
f9e4b8db76 📝 edit README 2022-02-14 14:49:12 +08:00
fumiama
c486a210e4 增加插件 漂流瓶 #2 2022-02-14 14:46:33 +08:00
fumiama
0cd01959a0 ⬆️ update kimoi #126 2022-02-14 13:03:37 +08:00
fumiama
d5ac9f7920 💩👌 make lint happy 2022-02-13 21:27:43 +08:00
fumiama
6b2dd112a6 dd add image size limit 2022-02-13 12:08:50 +08:00
fumiama
01abfab133 🚀 update moyu 春节 to 2023 2022-02-13 11:51:41 +08:00
fumiama
e2a56872dc 🐛 fix: 防止自触发 2022-02-13 11:43:36 +08:00
fumiama
6f22a9c4bc fix: chat call name 2022-02-13 11:35:42 +08:00
fumiama
a2426de70c Squashed commit of the following:
commit 3e4b0216b9f952b800e9be880acd744af3afe593
Merge: 970cb14 aaf832e
Author: fumiama <s862105088@gmail.com>
Date:   Sat Feb 12 23:23:51 2022 +0800

    Merge branch 'master' of https://github.com/MoYoez/ZeroBot-Plugin into MoYoez-master

commit 970cb142256d4575b3e5170b9dfb9370f5802da5
Author: fumiama <s862105088@gmail.com>
Date:   Sat Feb 12 23:18:23 2022 +0800

     🐛 🔥 🎨 fix: gif panic

commit aaf832e3b5
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 21:06:21 2022 +0800

    Update chat.go

commit fae3458bcf
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sat Feb 12 13:05:37 2022 +0000

    🎨 改进代码样式

commit 610cae5229
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 21:05:08 2022 +0800

    Update chat.go

commit c445c61da5
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:58:57 2022 +0800

    Delete data.go

commit 70172f4d8b
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:53:10 2022 +0800

    换了个网易云音乐热评的API

commit c8b4827e91
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sat Feb 12 12:50:57 2022 +0000

    🎨 改进代码样式

commit a233586dfe
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:50:21 2022 +0800

    Update chat.go

commit 87501f6011
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:49:08 2022 +0800

    Update data.go

commit ecf6419065
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:48:14 2022 +0800

    Update chat.go

commit c3550503f0
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:47:47 2022 +0800

    Delete plugin_purechat directory

commit 1da3486d00
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:46:34 2022 +0800

    Add files via upload

commit 34ed8c89fd
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:38:46 2022 +0800

    Update main.go

commit aa08eb0120
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:38:19 2022 +0800

    修改过的回复 删掉了一些ex的词汇

commit faf198289f
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:29:59 2022 +0800

    Update main.go

commit 5ac3b7a790
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:28:48 2022 +0800

    Update chat.go

commit b046d45435
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:25:23 2022 +0800

    Rename purechat.go to chat.go

commit 6bbcdfcd58
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:24:54 2022 +0800

    Add files via upload

commit e7630b5904
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:24:32 2022 +0800

    Update purechat.go

commit 36c903bece
Author: MoeMagicMango <i@himoyo.cn>
Date:   Sat Feb 12 20:23:01 2022 +0800

    Create purechat.go
2022-02-12 23:38:45 +08:00
MoeMagicMango
ed7bbf54a7 Update chat.go 2022-02-12 23:36:58 +08:00
fumiama
69394377d0 fix: emojimix logical error 2022-02-12 14:48:12 +08:00
fumiama
8f20487a15 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-02-12 14:20:21 +08:00
fumiama
fae24db2df 💩👌 make lint happy 2022-02-12 14:20:10 +08:00
github-actions[bot]
f8fb791d8f 🎨 改进代码样式 2022-02-12 06:19:04 +00:00
Kanri
f320d9e1e5 增加插件 emojimix (#121)
*  增加插件 emojimix

* 🎨✏️ 优化代码格式

*  增加 qqface 支持

* Update main.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-02-12 14:18:05 +08:00
fumiama
18bd34fad2 fix(#122): 避免图片过大导致内存占用过多 2022-02-12 13:37:06 +08:00
fumiama
cf72d0b36a fix(#122): 避免图片过大导致内存占用过多 2022-02-12 13:32:26 +08:00
fumiama
c3722b0a6c ️ perf: 每次匹配仅检查一次 ban 2022-02-11 00:39:50 +08:00
fumiama
3af701e803 🎉 🎨 ️ 优化 base64 图片 log 体验 & 减少 ban 遍历 2022-02-10 23:47:39 +08:00
fumiama
bc4b2e89db 🎉 base14支持所有平台 2022-02-10 14:15:49 +08:00
fumiama
3cbb589d2c 💩👌 make lint happy 2022-02-09 21:00:42 +08:00
github-actions[bot]
63ef93a9f9 🎨 改进代码样式 2022-02-09 07:44:23 +00:00
fumiama
8c943d2c01 🔥 🎨 优化代码结构 2022-02-09 15:43:14 +08:00
fumiama
806b77acce 🔥 🎨 优化代码结构 2022-02-08 19:39:19 +08:00
github-actions[bot]
3df0414621 🎨 改进代码样式 2022-02-08 07:43:30 +00:00
fumiama
04f70b0499 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-02-08 15:42:09 +08:00
fumiama
0b20087e61 🎨 🔥 优化 jandan 2022-02-08 15:40:31 +08:00
github-actions[bot]
5c82600972 🎨 改进代码样式 2022-02-08 07:06:57 +00:00
himawari
45edd86cb8 feat:增加煎蛋网无聊图 (#115)
* feat:添加煎蛋网无聊图

* fix:修lint

* fix:修改model和名称

* fix:删除不要的驱动

* fix:修改日志错误的地方

* fix:修改权限

* fix:去掉数据库

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-02-08 15:05:58 +08:00
fumiama
8f6b3fa00d 🎨 🔥 增加反并发 2022-02-08 14:58:47 +08:00
fumiama
a16bcda7da 🎨 🔥 统一限速器 2022-02-08 14:46:35 +08:00
fumiama
259b29f6e3 🐛 🔥 ascii2d返回多结果&修复合并转发 2022-02-07 20:39:49 +08:00
fumiama
477868c601 🐛 fix: imgpool fallback panic 2022-02-07 15:29:29 +08:00
莫思潋
92de963c0c 优化了更多插件中使用空格的体验 (#114)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版
2022-02-03 13:41:10 +08:00
fumiama
a7c56d9e77 💩👌 make lint happy 2022-02-03 13:40:00 +08:00
fumiama
4fe64eeb44 🐛 nsfw 防止风控 2022-02-01 18:38:01 +08:00
fumiama
fc0d020a04 新增叔叔的放大图片 2022-02-01 18:30:01 +08:00
fumiama
617e2c9885 🐛 添加封禁命令,修复 sql 2022-02-01 14:28:40 +08:00
github-actions[bot]
bb1130490b 🎨 改进代码样式 2022-01-30 16:40:38 +00:00
fumiama
ca18a323e3 增加初始化等待 2022-01-31 00:39:39 +08:00
fumiama
0770c6e4a1 fix plugin nsfw 2022-01-30 23:13:11 +08:00
fumiama
e1dbfe8f6a 🐛 fix nil ptr 2022-01-30 23:05:13 +08:00
fumiama
a2854069ac add plugin nsfw 2022-01-30 23:00:23 +08:00
fumiama
9f0efc2bda 🔖 v1.2.5 2022-01-30 20:06:19 +08:00
fumiama
ec5798f264 ️ 优化 rule.FirstValueInList 2022-01-30 20:05:39 +08:00
github-actions[bot]
ded20441fa 🎨 改进代码样式 2022-01-30 11:04:49 +00:00
himawari
47064dbcec b站视频链接解析 (#113)
* feat:b站视频链接解析

* fix:修lint

* fix:block改为true

* fix:不加视频链接,以免两个机器人在同一个群疯狂触发

* fix:链接换成bv号

* fix:修改为send方法

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-01-30 19:04:00 +08:00
莫思潋
2cda7ecb04 优化在两个命令中使用空格分隔的体验 (#112)
* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim
2022-01-29 13:48:01 +08:00
fumiama
b372892a20 🐛 adjust prio 2022-01-28 20:02:00 +08:00
fumiama
fabf62059e 💩👌 make lint happy 2022-01-28 19:59:31 +08:00
fumiama
c524c68809 🐛 fix setutime mkdir 2022-01-27 23:06:04 +08:00
fumiama
876fd425e4 ⬆️ update zb 2022-01-27 16:43:11 +08:00
fumiama
72ed1293f6 🔥 优化 setutime 2022-01-27 16:29:19 +08:00
fumiama
fa973a9231 🐛 fix saucenao relative path 2022-01-27 15:50:08 +08:00
fumiama
e245a8f124 🎨 ️ pixiv 图片缓存集中到 data/pixiv 2022-01-27 14:32:13 +08:00
fumiama
aa71fa7cb8 🐛 fix acgimage 2022-01-27 00:14:26 +08:00
fumiama
da5aab3ee6 🔥 use new imgpool 2022-01-26 23:52:37 +08:00
fumiama
e0317d1fe1 ️ 优化代码结构 2022-01-26 11:01:33 +08:00
fumiama
3557a0ebc1 ⬆️ update deps 2022-01-25 13:54:05 +08:00
fumiama
ddd0cc4538 ⬆️ update deps 2022-01-25 13:50:15 +08:00
fumiama
0212ec51cc 🔖 v1.2.4 2022-01-25 13:34:44 +08:00
fumiama
7109e30d93 🎨 🔥 modify wyy 2022-01-24 21:48:21 +08:00
MoeMagicMango
6990819d5c feat:添加来自ovooa的网易云热评API (#111)
* Create readme.md

* 调用网易云热评API

* Update main.go

* Delete readme.md

* Delete main.go

* Create main.go

* Add files via upload

* Update prio.go

* Add files via upload

* Add files via upload

* Update prio.go

* Add files via upload

* Update prio.go

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* revert main

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2022-01-24 21:40:52 +08:00
fumiama
b4ff754934 🐛 修正 imgpool 2022-01-24 18:23:33 +08:00
fumiama
6ece644a7b 🐛 修正 imgpool 2022-01-24 18:17:53 +08:00
fumiama
f826b4d0bc 🐛 防止风控 2022-01-24 14:28:43 +08:00
fumiama
aa1f82d46f 增加 pixiv 多线程下载与图片缓存 2022-01-24 14:01:30 +08:00
fumiama
f7c6d67428 🐛 fix fortune 2022-01-23 13:48:45 +08:00
fumiama
cd30d6df31 🐛 fix fortune 2022-01-23 13:43:42 +08:00
fumiama
7463792de7 🐛 fix fortune 2022-01-23 13:38:56 +08:00
fumiama
80f49c47c6 🐛 fix fortune 2022-01-23 13:22:31 +08:00
fumiama
4baead3490 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-23 00:28:16 +08:00
fumiama
2d0c69344a 🐛 fix get&del msg in zb 2022-01-23 00:28:05 +08:00
github-actions[bot]
a94ea2b332 🎨 改进代码样式 2022-01-22 15:44:30 +00:00
fumiama
4ee50a6582 add image pool 2022-01-22 23:43:38 +08:00
fumiama
b21021bd6b Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-22 12:39:51 +08:00
fumiama
7238fe0b6b 🍱 add fortune 赛马娘 2022-01-22 12:38:22 +08:00
Kanri
e1b5c176c3 ✏️ 修复 pixiv.cat 2022-01-22 10:54:38 +08:00
Mayuri
3aabc089d8 Make Help manual legible (#110) 2022-01-19 13:28:37 +08:00
fumiama
db5177027f add rough guild support 2022-01-18 15:07:34 +08:00
fumiama
0e2da1b983 add rough guild support 2022-01-17 23:44:47 +08:00
fumiama
1583006018 🔥 💩 disable bilibilipush by default 2022-01-17 23:20:26 +08:00
fumiama
6b49c2842c 💩👌 make lint happy 2022-01-17 23:06:31 +08:00
fumiama
9c4a5dc818 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-17 23:05:30 +08:00
fumiama
8256658ac2 add rough guild support 2022-01-17 23:04:32 +08:00
himawari
4b11ff495d fix:去掉chromedp,分类型处理json字符串 (#109)
* fix:新动态处理

* fix:使用正确的变量cOrigType

* fix:单小说的时候不用渲染图片

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-01-17 20:43:02 +08:00
fumiama
461dc925af add rough guild support 2022-01-16 20:48:45 +08:00
fumiama
1233b1d11c 💩👌 make lint happy 2022-01-16 20:37:47 +08:00
fumiama
6dbc0b3891 💩👌 make lint happy 2022-01-15 20:25:07 +08:00
github-actions[bot]
db3cef9bb6 🎨 改进代码样式 2022-01-15 12:18:59 +00:00
fumiama
3de009727e 💩👌 make lint happy 2022-01-15 20:17:56 +08:00
github-actions[bot]
8d35515497 🎨 改进代码样式 2022-01-15 12:15:39 +00:00
fumiama
4519dd5eb8 💫 ♻️ 🎉 ️ 强制使用优先级 2022-01-15 20:14:34 +08:00
257 changed files with 26879 additions and 6483 deletions

BIN
.github/hua_nobg_512.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

View File

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

View File

@@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: 1.17
go-version: '1.20'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master
@@ -28,9 +28,6 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the action will use pre-installed Go.
skip-go-installation: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

View File

@@ -6,24 +6,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: 1.17
go-version: '1.20'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master
with:
version: latest
args: --issues-exit-code=0
skip-go-installation: true
- name: Commit back
if: ${{ !github.head_ref }}
continue-on-error: true
run: |
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 push
- name: Create Pull Request
if: ${{ !github.head_ref }}
continue-on-error: true
uses: peter-evans/create-pull-request@v4

View File

@@ -9,19 +9,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@master
with:
go-version: '1.17'
go-version: '1.20'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@master
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

BIN
.github/yaya.jpg vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ plugins/*.dll
go-zero*
nohup.out
zerobot
ZeroBot-Plugin*
*.syso

View File

@@ -1,15 +1,11 @@
linters-settings:
errcheck:
ignore: fmt:.*,io/ioutil:^Read.*
ignore: fmt:.*
ignoretests: true
goimports:
local-prefixes: github.com/FloatTech/ZeroBot-Plugin
gocritic:
disabled-checks:
- exitAfterDefer
forbidigo:
# Forbid the following identifiers
forbid:
@@ -22,7 +18,6 @@ linters:
fast: false
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
@@ -43,13 +38,11 @@ linters:
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- prealloc
- predeclared
@@ -64,6 +57,9 @@ run:
deadline: 5m
issues-exit-code: 1
tests: false
skip-dirs:
- order
go: '1.20'
# output configuration options
output:
@@ -78,3 +74,4 @@ issues:
exclude-use-default: false
exclude:
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"
- 'identifier ".*" contain non-ASCII character: U\+.*'

View File

@@ -4,6 +4,8 @@ env:
before:
hooks:
- go mod tidy
- go install github.com/tc-hib/go-winres@latest
- go-winres make
builds:
- id: nowin
env:

143
LICENSE
View File

@@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@@ -7,17 +7,15 @@
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

1797
README.md

File diff suppressed because it is too large Load Diff

14
console/console_ansi.go Normal file
View File

@@ -0,0 +1,14 @@
//go:build !windows
// Package console sets console's behavior on init
package console
import (
"fmt"
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
)
func init() {
fmt.Print("\033]0;ZeroBot-Blugin " + banner.Version + " " + banner.Copyright + "\007")
}

144
console/console_windows.go Normal file
View File

@@ -0,0 +1,144 @@
// Package console sets console's behavior on init
package console
import (
"bytes"
"os"
"strings"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
"github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
)
var (
//go:linkname modkernel32 golang.org/x/sys/windows.modkernel32
modkernel32 *windows.LazyDLL
procSetConsoleTitle = modkernel32.NewProc("SetConsoleTitleW")
)
//go:linkname errnoErr golang.org/x/sys/windows.errnoErr
func errnoErr(e syscall.Errno) error
func setConsoleTitle(title string) (err error) {
var p0 *uint16
p0, err = syscall.UTF16PtrFromString(title)
if err != nil {
return
}
r1, _, e1 := syscall.Syscall(procSetConsoleTitle.Addr(), 1, uintptr(unsafe.Pointer(p0)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func init() {
stdin := windows.Handle(os.Stdin.Fd())
var mode uint32
err := windows.GetConsoleMode(stdin, &mode)
if err != nil {
panic(err)
}
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志
mode &^= windows.ENABLE_MOUSE_INPUT // 禁用鼠标输入
mode |= windows.ENABLE_PROCESSED_INPUT // 启用控制输入
mode &^= windows.ENABLE_INSERT_MODE // 禁用插入模式
mode |= windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT // 启用输入回显&逐行输入
mode &^= windows.ENABLE_WINDOW_INPUT // 禁用窗口输入
mode &^= windows.ENABLE_VIRTUAL_TERMINAL_INPUT // 禁用虚拟终端输入
err = windows.SetConsoleMode(stdin, mode)
if err != nil {
panic(err)
}
stdout := windows.Handle(os.Stdout.Fd())
err = windows.GetConsoleMode(stdout, &mode)
if err != nil {
panic(err)
}
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING // 启用虚拟终端处理
mode |= windows.ENABLE_PROCESSED_OUTPUT // 启用处理后的输出
err = windows.SetConsoleMode(stdout, mode)
// windows 带颜色 log 自定义格式
logrus.SetFormatter(&logFormat{hasColor: err == nil})
if err != nil {
logrus.Warnln("VT100设置失败, 将以无色模式输出")
}
err = setConsoleTitle("ZeroBot-Blugin " + banner.Version + " " + banner.Copyright)
if err != nil {
panic(err)
}
}
const (
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
colorReset = "\x1b[0m"
)
// logFormat specialize for zbp
type logFormat struct {
hasColor bool
}
// Format implements logrus.Formatter
func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) {
buf := new(bytes.Buffer)
buf.WriteByte('[')
if f.hasColor {
buf.WriteString(getLogLevelColorCode(entry.Level))
}
buf.WriteString(strings.ToUpper(entry.Level.String()))
if f.hasColor {
buf.WriteString(colorReset)
}
buf.WriteString("] ")
buf.WriteString(entry.Message)
buf.WriteString(" \n")
return buf.Bytes(), nil
}
// getLogLevelColorCode 获取日志等级对应色彩code
func getLogLevelColorCode(level logrus.Level) string {
switch level {
case logrus.PanicLevel:
return colorCodePanic
case logrus.FatalLevel:
return colorCodeFatal
case logrus.ErrorLevel:
return colorCodeError
case logrus.WarnLevel:
return colorCodeWarn
case logrus.InfoLevel:
return colorCodeInfo
case logrus.DebugLevel:
return colorCodeDebug
case logrus.TraceLevel:
return colorCodeTrace
default:
return colorCodeInfo
}
}

2
data

Submodule data updated: 522acbf5e3...b9848c9a4e

127
go.mod
View File

@@ -1,73 +1,100 @@
module github.com/FloatTech/ZeroBot-Plugin
go 1.17
go 1.20
require (
github.com/FloatTech/AnimeAPI v1.2.4-beta1
github.com/FloatTech/zbputils v1.2.4-beta1
github.com/antchfx/htmlquery v1.2.4
github.com/chromedp/chromedp v0.7.6
github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0
github.com/Baidu-AIP/golang-sdk v1.1.1
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc
github.com/FloatTech/gg v1.1.2
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
github.com/FloatTech/sqlite v1.5.7
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3
github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04
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
github.com/corona10/goimagehash v1.1.0
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3
github.com/disintegration/imaging v1.6.2
github.com/fumiama/ahsai v0.1.0
github.com/fumiama/cron v1.3.0
github.com/fumiama/go-base16384 v1.2.1
github.com/fumiama/go-registry v0.0.2
github.com/fumiama/gofastTEA v0.0.6
github.com/fumiama/go-base16384 v1.6.4
github.com/fumiama/go-registry v0.2.6
github.com/fumiama/gotracemoe v0.0.3
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/jinzhu/gorm v1.9.16
github.com/logoove/sqlite v1.13.0
github.com/mroth/weightedrand v0.4.1
github.com/shirou/gopsutil/v3 v3.21.12
github.com/sirupsen/logrus v1.8.1
github.com/tidwall/gjson v1.12.1
github.com/wdvxdr1123/ZeroBot v1.4.1
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
github.com/jozsefsallai/gophersauce v1.0.1
github.com/lithammer/fuzzysearch v1.1.5
github.com/mroth/weightedrand v1.0.0
github.com/pkg/errors v0.9.1
github.com/quic-go/quic-go v0.32.0
github.com/shirou/gopsutil/v3 v3.23.1
github.com/sirupsen/logrus v1.9.0
github.com/tidwall/gjson v1.14.4
github.com/wcharczuk/go-chart/v2 v2.1.0
github.com/wdvxdr1123/ZeroBot v1.6.11
gitlab.com/gomidi/midi/v2 v2.0.25
golang.org/x/image v0.3.0
golang.org/x/sys v0.4.0
golang.org/x/text v0.6.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/antchfx/xpath v1.2.0 // indirect
github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/disintegration/imaging v1.6.2 // 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
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
github.com/fumiama/gofastTEA v0.0.10 // indirect
github.com/fumiama/imgsz v0.0.2 // indirect
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hajimehoshi/oto v0.7.1 // indirect
github.com/jfreymuth/oggvorbis v1.0.1 // indirect
github.com/jfreymuth/vorbis v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/onsi/ginkgo/v2 v2.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pkumza/numcn v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.8 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.35.22 // indirect
modernc.org/ccgo/v3 v3.14.0 // indirect
modernc.org/libc v1.13.2 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.0.5 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/sqlite v1.14.4 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/exp/shiny v0.0.0-20221126150942-6ab00d035af9 // indirect
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/tools v0.2.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
modernc.org/libc v1.21.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.4.0 // indirect
modernc.org/sqlite v1.20.0 // indirect
)
replace modernc.org/sqlite => github.com/fumiama/sqlite3 v1.20.0-with-win386
replace github.com/remyoudompheng/bigfft => github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b

507
go.sum
View File

@@ -1,68 +1,95 @@
github.com/FloatTech/AnimeAPI v1.2.4-beta1 h1:Ff+721UgTSXCRiod83wlUCY0C1nE4wWa7+NCgYjF/Ew=
github.com/FloatTech/AnimeAPI v1.2.4-beta1/go.mod h1:tQNIP/1fbQzEi3U9v9PsdPOr2OURMx9S8WH+w1oco4I=
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
github.com/FloatTech/zbputils v1.2.4-beta1 h1:WT85o9Y6MAJtmQaMD5h0l1mJ/7qBcjRQdNlCsB5pAPY=
github.com/FloatTech/zbputils v1.2.4-beta1/go.mod h1:ZIuQP4tuhn7jiowEy+PALiHmr4zzPQBj4VdjEyd5/Es=
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhvrx4cw=
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.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY=
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc h1:1yentlIEJImE0rla5xE7o73ZW37eS/byFhPEwx9WYEs=
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI=
github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88=
github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 h1:IzZLuM/fgKclyMaU/Qb1qlLdGrs2FTietkqOWhh07Gw=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9/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.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk=
github.com/FloatTech/sqlite v1.5.7/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.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMNaI2bNA1Gu/B4F5MnfGaTaJClgR6+rhdA=
github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g=
github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 h1:ovL+7SAPTBCXy6XNRSdJhNvHtbueWCwEb/jtztmizAc=
github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo=
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/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
github.com/antchfx/htmlquery v1.2.4 h1:qLteofCMe/KGovBI6SQgmou2QNyedFUW+pE+BpeZ494=
github.com/antchfx/htmlquery v1.2.4/go.mod h1:2xO6iu3EVWs7R2JYqBbp8YzG50gj/ofqs5/0VZoDZLc=
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8=
github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77 h1:Et/9YcQRCsaZVT74sy6AHwWy/FcbYqm39jNprlfXF7c=
github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/chromedp v0.7.6 h1:2juGaktzjwULlsn+DnvIZXFUckEp5xs+GOBroaea+jA=
github.com/chromedp/chromedp v0.7.6/go.mod h1:ayT4YU/MGAALNfOg9gNrpGSAdnU51PMx+FCeuT1iXzo=
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/corona10/goimagehash v1.0.3 h1:NZM518aKLmoNluluhfHGxT3LGOnrojrxhGn63DR/CZA=
github.com/corona10/goimagehash v1.0.3/go.mod h1:VkvE0mLn84L4aF8vCb6mafVajEb6QYMHl2ZJLn0mOGI=
github.com/antchfx/htmlquery v1.2.5 h1:1lXnx46/1wtv1E/kzmH8vrfMuUKYgkdDBA9pIdMJnk4=
github.com/antchfx/htmlquery v1.2.5/go.mod h1:2MCVBzYVafPBmKbrmwB9F5xdd+IEgRY61ci2oOsOQVw=
github.com/antchfx/xpath v1.2.1 h1:qhp4EW6aCOVr5XIkT+l6LJ9ck/JsUH/yyauNgTQkBF8=
github.com/antchfx/xpath v1.2.1/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/corona10/goimagehash v1.1.0 h1:teNMX/1e+Wn/AYSbLHX8mj+mF9r60R1kBeqE9MkoYwI=
github.com/corona10/goimagehash v1.1.0/go.mod h1:VkvE0mLn84L4aF8vCb6mafVajEb6QYMHl2ZJLn0mOGI=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3 h1:qshMBFxVjYjzI+kwvWvgoByF3uMCvnJiaK8KslWAbr8=
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3/go.mod h1:M9fx6rAdHSYLKxXPgUXGgblb586CA7ceNrpu4DEc2No=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+JlV/f7JstZ4pitd4tHhpN+w+6I+LyOS7B4fyU=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/faiface/beep v1.1.0 h1:A2gWP6xf5Rh7RG/p9/VAW2jRSDEGQm5sbOb38sf5d4c=
github.com/faiface/beep v1.1.0/go.mod h1:6I8p6kK2q4opL/eWb+kAkk38ehnTunWeToJB+s51sT4=
github.com/fumiama/ahsai v0.1.0 h1:LXD61Kaj6kJHa3AEGsLIfKNzcgaVxg7JB72OR4yNNZ4=
github.com/fumiama/ahsai v0.1.0/go.mod h1:fFeNnqgo44i8FIaguK659aQryuZeFy+4klYLQu/rfdk=
github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b h1:Zt3pFQditAdWTHCOVkiloc9ZauBoWrb37guFV4iIRvE=
github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
github.com/fumiama/go-base16384 v1.2.1 h1:6OGprW8g/95m2ocmryHi8mipZ7bx9StFMZDKEqLvMiA=
github.com/fumiama/go-base16384 v1.2.1/go.mod h1:1HTC0QFL7BjS0DuO5Qm+fBYKQkHqmAapLbRpCxrhPXQ=
github.com/fumiama/go-registry v0.0.2 h1:2EoZwZpqI7YhkQ1FnuAPvALYPpvUtbsCqk879+r7ehs=
github.com/fumiama/go-registry v0.0.2/go.mod h1:QkcmmHuw1y6y/w7/HiH1c9yjBw5Zt+6EER6YJKl9xh8=
github.com/fumiama/gofastTEA v0.0.6 h1:Yni3MXDbJVa/c4CecgdZDgCJK+fLdvGph+OBqY2mtiI=
github.com/fumiama/gofastTEA v0.0.6/go.mod h1:+sBZ05nCA2skZkursHNvyr8kULlEetrYTM2y5kA4rQc=
github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o=
github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
github.com/fumiama/go-registry v0.2.6 h1:+vEeBUwa1+GC87ujW3Km42fi8O/H7QcpVJWu1iuGNh0=
github.com/fumiama/go-registry v0.2.6/go.mod h1:HjYagPZXzR2xCCxaSQerqX7JRzC0yiv2kslDdBiTq/g=
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
github.com/fumiama/gofastTEA v0.0.10/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6/Jc=
github.com/fumiama/gotracemoe v0.0.3/go.mod h1:tyqahdUzHf0bQIAVY/GYmDWvYYe5ik1ZbhnGYh+zl40=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak=
github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4=
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 h1:sQuR2+N5HurnvsZhiKdEg+Ig354TaqgCQRxd/0KgIOQ=
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565/go.mod h1:UUEvyLTJ7yoOA/viKG4wEis4ERydM7+Ny6gZUWgkS80=
github.com/fumiama/sqlite3 v1.20.0-with-win386 h1:ZR1AXGBEtkfq9GAXehOVcwn+aaCG8itrkgEsz4ggx5k=
github.com/fumiama/sqlite3 v1.20.0-with-win386/go.mod h1:Os58MHwYCcYZCy2PGChBrQtBAw5/LS1ZZOkfc+C/I7s=
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 h1:XL4SnagpaVHYybnnj6whQxmt8Ps9/kaG6sCNn4X1GGA=
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430/go.mod h1:lEaZsT4FRSqcjnQ5q8y+mkenkzR/r1D3BJmfdp0vqDg=
github.com/gabriel-vasile/mimetype v1.0.4 h1:uBejfH8l3/2f+5vjl1e4xIaSyNEhRBZ5N/ij7ohpNd8=
github.com/gabriel-vasile/mimetype v1.0.4/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA=
github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
@@ -70,306 +97,218 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/hajimehoshi/oto v0.7.1 h1:I7maFPz5MBCwiutOrz++DLdbr4rTzBsbBuV2VpgU9kk=
github.com/hajimehoshi/oto v0.7.1/go.mod h1:wovJ8WWMfFKvP587mhHgot/MBr4DnNy9m6EepeVGnos=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
github.com/jfreymuth/oggvorbis v1.0.1 h1:NT0eXBgE2WHzu6RT/6zcb2H10Kxj6Fm3PccT0LE6bqw=
github.com/jfreymuth/oggvorbis v1.0.1/go.mod h1:NqS+K+UXKje0FUYUPosyQ+XTVvjmVjps1aEZH1sumIk=
github.com/jfreymuth/vorbis v1.0.0 h1:SmDf783s82lIjGZi8EGUUaS7YxPHgRj4ZXW/h7rUi7U=
github.com/jfreymuth/vorbis v1.0.0/go.mod h1:8zy3lUAm9K/rJJk223RKy6vjCZTWC61NA2QD06bfOE0=
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/jozsefsallai/gophersauce v1.0.1 h1:BA3ovtQRrAb1qYU9JoRLbDHpxnDunlNcEkEfhCvDDCM=
github.com/jozsefsallai/gophersauce v1.0.1/go.mod h1:YVEI7djliMTmZ1Vh01YPF8bUHi+oKhe3yXgKf1T49vg=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/logoove/sqlite v1.13.0 h1:XM7QKK9R3tm8o7bI75R3zmwYBFQ5S3Jqg+XCaqsAMQQ=
github.com/logoove/sqlite v1.13.0/go.mod h1:MRpE/o3qQhT7AgfIdnBue5c63+//xT+KXV0gHeVAUAg=
github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c=
github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
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=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mroth/weightedrand v0.4.1 h1:rHcbUBopmi/3x4nnrvwGJBhX9d0vk+KgoLUZeDP6YyI=
github.com/mroth/weightedrand v0.4.1/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE=
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2/go.mod h1:3E2FUC/qYUfM8+r9zAwpeHJzqRVVMIYnpzD/clwWxyA=
github.com/mroth/weightedrand v1.0.0 h1:V8JeHChvl2MP1sAoXq4brElOcza+jxLkRuwvtQu8L3E=
github.com/mroth/weightedrand v1.0.0/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5 h1:1SoBaSPudixRecmlHXb/GxmaD3fLMtHIDN13QujwQuc=
github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI=
github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkumza/numcn v1.0.0 h1:ZT5cf9IJkUZgRgEtCiNNykk0RwsrKXSTsvDHOwUTzgE=
github.com/pkumza/numcn v1.0.0/go.mod h1:QSeH+al9dWCd8di5HZM/ZqHqhZmUKfph572e9Ev/ETc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/shirou/gopsutil/v3 v3.21.12 h1:VoGxEW2hpmz0Vt3wUvHIl9fquzYLNpVpgNNB7pGJimA=
github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U=
github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc=
github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4nttk=
github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI=
github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA=
github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/shirou/gopsutil/v3 v3.23.1 h1:a9KKO+kGLKEvcPIs4W62v0nu3sciVDOOOPUD0Hz7z/4=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/gjson v1.11.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo=
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
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=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI=
github.com/wdvxdr1123/ZeroBot v1.4.1 h1:fk/8RH2D1gB3YeC1eI/SZi/kG31Rh7Z8lAiDc60VZFM=
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
github.com/wdvxdr1123/ZeroBot v1.6.11 h1:44Wr6CsCtWlFensK5IhuVCWkosdRw0rA8SygVD8DgoI=
github.com/wdvxdr1123/ZeroBot v1.6.11/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=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
gitlab.com/gomidi/midi/v2 v2.0.25 h1:dkzVBqbaFHjyWwP71MrQNX7IeRUIDonddmHbPpO/Ucg=
gitlab.com/gomidi/midi/v2 v2.0.25/go.mod h1:quTyMKSQ4Klevxu6gY4gy2USbeZra0fV5SalndmPfsY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp/shiny v0.0.0-20221126150942-6ab00d035af9 h1:tLxpBz7qD8qFkRDC159unetNbxKp4zeqsqw2rLwvdxc=
golang.org/x/exp/shiny v0.0.0-20221126150942-6ab00d035af9/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8=
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.3.0 h1:HTDXbdK9bjfSWkPzDJIw89W8CAtfFGduujWs33NLLsg=
golang.org/x/image v0.3.0/go.mod h1:fXd9211C/0VTlYuAcOhW8dY/RtEJqODXOWBDpmYBf+A=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f h1:kgfVkAEEQXXQ0qc6dH7n6y37NAYmTFmz0YRwrRjgxKw=
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s=
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.34.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.4/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.5/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.8/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.20/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.22 h1:BzShpwCAP7TWzFppM4k2t03RhXhgYqaibROWkrWq7lE=
modernc.org/cc/v3 v3.35.22/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
modernc.org/ccgo/v3 v3.11.1/go.mod h1:lWHxfsn13L3f7hgGsGlU28D9eUOf6y3ZYHKoPaKU0ag=
modernc.org/ccgo/v3 v3.11.3/go.mod h1:0oHunRBMBiXOKdaglfMlRPBALQqsfrCKXgw9okQ3GEw=
modernc.org/ccgo/v3 v3.12.4/go.mod h1:Bk+m6m2tsooJchP/Yk5ji56cClmN6R1cqc9o/YtbgBQ=
modernc.org/ccgo/v3 v3.12.6/go.mod h1:0Ji3ruvpFPpz+yu+1m0wk68pdr/LENABhTrDkMDWH6c=
modernc.org/ccgo/v3 v3.12.8/go.mod h1:Hq9keM4ZfjCDuDXxaHptpv9N24JhgBZmUG5q60iLgUo=
modernc.org/ccgo/v3 v3.12.11/go.mod h1:0jVcmyDwDKDGWbcrzQ+xwJjbhZruHtouiBEvDfoIsdg=
modernc.org/ccgo/v3 v3.12.14/go.mod h1:GhTu1k0YCpJSuWwtRAEHAol5W7g1/RRfS4/9hc9vF5I=
modernc.org/ccgo/v3 v3.12.18/go.mod h1:jvg/xVdWWmZACSgOiAhpWpwHWylbJaSzayCqNOJKIhs=
modernc.org/ccgo/v3 v3.12.20/go.mod h1:aKEdssiu7gVgSy/jjMastnv/q6wWGRbszbheXgWRHc8=
modernc.org/ccgo/v3 v3.12.21/go.mod h1:ydgg2tEprnyMn159ZO/N4pLBqpL7NOkJ88GT5zNU2dE=
modernc.org/ccgo/v3 v3.12.22/go.mod h1:nyDVFMmMWhMsgQw+5JH6B6o4MnZ+UQNw1pp52XYFPRk=
modernc.org/ccgo/v3 v3.12.25/go.mod h1:UaLyWI26TwyIT4+ZFNjkyTbsPsY3plAEB6E7L/vZV3w=
modernc.org/ccgo/v3 v3.12.29/go.mod h1:FXVjG7YLf9FetsS2OOYcwNhcdOLGt8S9bQ48+OP75cE=
modernc.org/ccgo/v3 v3.12.36/go.mod h1:uP3/Fiezp/Ga8onfvMLpREq+KUjUmYMxXPO8tETHtA8=
modernc.org/ccgo/v3 v3.12.38/go.mod h1:93O0G7baRST1vNj4wnZ49b1kLxt0xCW5Hsa2qRaZPqc=
modernc.org/ccgo/v3 v3.12.43/go.mod h1:k+DqGXd3o7W+inNujK15S5ZYuPoWYLpF5PYougCmthU=
modernc.org/ccgo/v3 v3.12.46/go.mod h1:UZe6EvMSqOxaJ4sznY7b23/k13R8XNlyWsO5bAmSgOE=
modernc.org/ccgo/v3 v3.12.47/go.mod h1:m8d6p0zNps187fhBwzY/ii6gxfjob1VxWb919Nk1HUk=
modernc.org/ccgo/v3 v3.12.50/go.mod h1:bu9YIwtg+HXQxBhsRDE+cJjQRuINuT9PUK4orOco/JI=
modernc.org/ccgo/v3 v3.12.51/go.mod h1:gaIIlx4YpmGO2bLye04/yeblmvWEmE4BBBls4aJXFiE=
modernc.org/ccgo/v3 v3.12.53/go.mod h1:8xWGGTFkdFEWBEsUmi+DBjwu/WLy3SSOrqEmKUjMeEg=
modernc.org/ccgo/v3 v3.12.54/go.mod h1:yANKFTm9llTFVX1FqNKHE0aMcQb1fuPJx6p8AcUx+74=
modernc.org/ccgo/v3 v3.12.55/go.mod h1:rsXiIyJi9psOwiBkplOaHye5L4MOOaCjHg1Fxkj7IeU=
modernc.org/ccgo/v3 v3.12.56/go.mod h1:ljeFks3faDseCkr60JMpeDb2GSO3TKAmrzm7q9YOcMU=
modernc.org/ccgo/v3 v3.12.57/go.mod h1:hNSF4DNVgBl8wYHpMvPqQWDQx8luqxDnNGCMM4NFNMc=
modernc.org/ccgo/v3 v3.12.60/go.mod h1:k/Nn0zdO1xHVWjPYVshDeWKqbRWIfif5dtsIOCUVMqM=
modernc.org/ccgo/v3 v3.12.66/go.mod h1:jUuxlCFZTUZLMV08s7B1ekHX5+LIAurKTTaugUr/EhQ=
modernc.org/ccgo/v3 v3.12.67/go.mod h1:Bll3KwKvGROizP2Xj17GEGOTrlvB1XcVaBrC90ORO84=
modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3cQ=
modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
modernc.org/ccgo/v3 v3.12.84/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w=
modernc.org/ccgo/v3 v3.12.86/go.mod h1:dN7S26DLTgVSni1PVA3KxxHTcykyDurf3OgUzNqTSrU=
modernc.org/ccgo/v3 v3.12.90/go.mod h1:obhSc3CdivCRpYZmrvO88TXlW0NvoSVvdh/ccRjJYko=
modernc.org/ccgo/v3 v3.12.92/go.mod h1:5yDdN7ti9KWPi5bRVWPl8UNhpEAtCjuEE7ayQnzzqHA=
modernc.org/ccgo/v3 v3.13.1/go.mod h1:aBYVOUfIlcSnrsRVU8VRS35y2DIfpgkmVkYZ0tpIXi4=
modernc.org/ccgo/v3 v3.14.0 h1:Zr1Ny9+7r5yAiXpBdgp8XiXqkNA4ARrRphHGHVXeAp0=
modernc.org/ccgo/v3 v3.14.0/go.mod h1:hBrkiBlUwvr5vV/ZH9YzXIp982jKE8Ek8tR1ytoAL6Q=
modernc.org/ccorpus v1.11.1 h1:K0qPfpVG1MJh5BYazccnmhywH4zHuOgJXgbjzyp6dWA=
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
modernc.org/libc v1.11.0/go.mod h1:2lOfPmj7cz+g1MrPNmX65QCzVxgNq2C5o0jdLY2gAYg=
modernc.org/libc v1.11.2/go.mod h1:ioIyrl3ETkugDO3SGZ+6EOKvlP3zSOycUETe4XM4n8M=
modernc.org/libc v1.11.5/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
modernc.org/libc v1.11.6/go.mod h1:ddqmzR6p5i4jIGK1d/EiSw97LBcE3dK24QEwCFvgNgE=
modernc.org/libc v1.11.11/go.mod h1:lXEp9QOOk4qAYOtL3BmMve99S5Owz7Qyowzvg6LiZso=
modernc.org/libc v1.11.13/go.mod h1:ZYawJWlXIzXy2Pzghaf7YfM8OKacP3eZQI81PDLFdY8=
modernc.org/libc v1.11.16/go.mod h1:+DJquzYi+DMRUtWI1YNxrlQO6TcA5+dRRiq8HWBWRC8=
modernc.org/libc v1.11.19/go.mod h1:e0dgEame6mkydy19KKaVPBeEnyJB4LGNb0bBH1EtQ3I=
modernc.org/libc v1.11.24/go.mod h1:FOSzE0UwookyT1TtCJrRkvsOrX2k38HoInhw+cSCUGk=
modernc.org/libc v1.11.26/go.mod h1:SFjnYi9OSd2W7f4ct622o/PAYqk7KHv6GS8NZULIjKY=
modernc.org/libc v1.11.27/go.mod h1:zmWm6kcFXt/jpzeCgfvUNswM0qke8qVwxqZrnddlDiE=
modernc.org/libc v1.11.28/go.mod h1:Ii4V0fTFcbq3qrv3CNn+OGHAvzqMBvC7dBNyC4vHZlg=
modernc.org/libc v1.11.31/go.mod h1:FpBncUkEAtopRNJj8aRo29qUiyx5AvAlAxzlx9GNaVM=
modernc.org/libc v1.11.34/go.mod h1:+Tzc4hnb1iaX/SKAutJmfzES6awxfU1BPvrrJO0pYLg=
modernc.org/libc v1.11.37/go.mod h1:dCQebOwoO1046yTrfUE5nX1f3YpGZQKNcITUYWlrAWo=
modernc.org/libc v1.11.39/go.mod h1:mV8lJMo2S5A31uD0k1cMu7vrJbSA3J3waQJxpV4iqx8=
modernc.org/libc v1.11.42/go.mod h1:yzrLDU+sSjLE+D4bIhS7q1L5UwXDOw99PLSX0BlZvSQ=
modernc.org/libc v1.11.44/go.mod h1:KFq33jsma7F5WXiYelU8quMJasCCTnHK0mkri4yPHgA=
modernc.org/libc v1.11.45/go.mod h1:Y192orvfVQQYFzCNsn+Xt0Hxt4DiO4USpLNXBlXg/tM=
modernc.org/libc v1.11.47/go.mod h1:tPkE4PzCTW27E6AIKIR5IwHAQKCAtudEIeAV1/SiyBg=
modernc.org/libc v1.11.49/go.mod h1:9JrJuK5WTtoTWIFQ7QjX2Mb/bagYdZdscI3xrvHbXjE=
modernc.org/libc v1.11.51/go.mod h1:R9I8u9TS+meaWLdbfQhq2kFknTW0O3aw3kEMqDDxMaM=
modernc.org/libc v1.11.53/go.mod h1:5ip5vWYPAoMulkQ5XlSJTy12Sz5U6blOQiYasilVPsU=
modernc.org/libc v1.11.54/go.mod h1:S/FVnskbzVUrjfBqlGFIPA5m7UwB3n9fojHhCNfSsnw=
modernc.org/libc v1.11.55/go.mod h1:j2A5YBRm6HjNkoSs/fzZrSxCuwWqcMYTDPLNx0URn3M=
modernc.org/libc v1.11.56/go.mod h1:pakHkg5JdMLt2OgRadpPOTnyRXm/uzu+Yyg/LSLdi18=
modernc.org/libc v1.11.58/go.mod h1:ns94Rxv0OWyoQrDqMFfWwka2BcaF6/61CqJRK9LP7S8=
modernc.org/libc v1.11.71/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw=
modernc.org/libc v1.11.75/go.mod h1:dGRVugT6edz361wmD9gk6ax1AbDSe0x5vji0dGJiPT0=
modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI=
modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE=
modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY=
modernc.org/libc v1.11.88/go.mod h1:h3oIVe8dxmTcchcFuCcJ4nAWaoiwzKCdv82MM0oiIdQ=
modernc.org/libc v1.11.98/go.mod h1:ynK5sbjsU77AP+nn61+k+wxUGRx9rOFcIqWYYMaDZ4c=
modernc.org/libc v1.11.101/go.mod h1:wLLYgEiY2D17NbBOEp+mIJJJBGSiy7fLL4ZrGGZ+8jI=
modernc.org/libc v1.12.0/go.mod h1:2MH3DaF/gCU8i/UBiVE1VFRos4o523M7zipmwH8SIgQ=
modernc.org/libc v1.13.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk=
modernc.org/libc v1.13.2 h1:GCFjY9bmwDZ/TJC4OZOUWaNgxIxwb104C/QZrqpcVEA=
modernc.org/libc v1.13.2/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8=
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.14.4 h1:F3DRiVZKnCLqIQ0LhEGqBLnw9LcdADciCwCIHQ8bD5g=
modernc.org/sqlite v1.14.4/go.mod h1:LWtcO8JtBrt29KKmTqNNXDjAn36vHa/3nHvOYoVIAjc=
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
modernc.org/tcl v1.10.0/go.mod h1:WzWapmP/7dHVhFoyPpEaNSVTL8xtewhouN/cqSJ5A2s=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.2.21/go.mod h1:uXrObx4pGqXWIMliC5MiKuwAyMrltzwpteOFUP1PWCc=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.21.5 h1:xBkU9fnHV+hvZuPSRszN0AXDG4M7nwPLwTWwkYcvLCI=
modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk=
modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=

15
kanban/banner/banner.go Normal file
View File

@@ -0,0 +1,15 @@
// Code generated by kanban/gen. DO NOT EDIT.
package banner
// Version ...
var Version = "v1.7.0"
// Copyright ...
var Copyright = "© 2020 - 2023 FloatTech"
// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - 2023-03-20 12:27:42 +0800 CST\n" +
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"

51
kanban/gen/banner.go Normal file
View File

@@ -0,0 +1,51 @@
// Package main generates banner.go
package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"strings"
"time"
)
const banner = `// Code generated by kanban/gen. DO NOT EDIT.
package banner
// Version ...
var Version = "%s"
// Copyright ...
var Copyright = "© 2020 - %d FloatTech"
// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - %s\n" +
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
`
const timeformat = `2006-01-02 15:04:05 +0800 CST`
func main() {
f, err := os.Create("banner/banner.go")
if err != nil {
panic(err)
}
defer f.Close()
vartag := bytes.NewBuffer(nil)
vartagcmd := exec.Command("git", "tag", "--sort=committerdate")
vartagcmd.Stdout = vartag
err = vartagcmd.Run()
if err != nil {
panic(err)
}
s := strings.Split(vartag.String(), "\n")
now := time.Now()
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Year(), now.Format(timeformat))
if err != nil {
panic(err)
}
}

44
kanban/init.go Normal file
View File

@@ -0,0 +1,44 @@
// Package kanban 打印版本信息
package kanban
import (
"fmt"
"github.com/FloatTech/zbputils/control"
"github.com/fumiama/go-registry"
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
)
//go:generate go run github.com/FloatTech/ZeroBot-Plugin/kanban/gen
func init() {
PrintBanner()
}
var reg = registry.NewRegReader("reilia.fumiama.top:32664", control.Md5File, "fumiama")
// PrintBanner ...
func PrintBanner() {
fmt.Print(
"\n======================[ZeroBot-Plugin]======================",
"\n", banner.Banner, "\n",
"----------------------[ZeroBot-公告栏]----------------------",
"\n", Kanban(), "\n",
"============================================================\n\n",
)
}
// Kanban ...
func Kanban() string {
err := reg.Connect()
if err != nil {
return err.Error()
}
defer reg.Close()
text, err := reg.Get("ZeroBot-Plugin/kanban")
if err != nil {
return err.Error()
}
return text
}

395
main.go
View File

@@ -1,174 +1,321 @@
// Package main ZeroBot-Plugin main file
package main
import (
"encoding/json"
"flag"
"fmt"
"math/rand"
"os"
"runtime"
"strconv"
"strings"
"time"
// 注:以下插件均可通过前面加 // 注释,注释后停用并不加载插件
// 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用
_ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性
// 插件控制
// webctrl "github.com/FloatTech/zbputils/control/web" // web 后端控制
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 打印 banner
// 词库类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
// ----------------------插件优先级按顺序从高到低---------------------- //
// //
// //
// //
// //
// //
// ----------------------------高优先级区---------------------------- //
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv高优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
// vvvvvvvvvvvvvv高优先级区vvvvvvvvvvvvvv //
// vvvvvvv高优先级区vvvvvvv //
// vvvvvvvvvvvvvv //
// vvvv //
// 实用类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_b14" // base16384加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_github" // 搜索GitHub仓库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_manager" // 群管
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nbnhhsh" // 拼音首字母缩写释义工具
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode" // 在线运行代码
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage" // 统计睡眠时间
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_translation" // 翻译
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/antiabuse" // 违禁词
// 娱乐类
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wtf" // 鬼东西
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi" // 藏头诗
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua" // 说抽象话
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory" // cp短打
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse" // 骂人
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif" // 制图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_score" // 分数
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat" // 基础词库
// b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push" // b站推送需要安装chrome浏览器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana" // 嘉心糖发病
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage" // 统计睡眠时间
// 二次元图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru" // DeepDanbooru二次元图标签识别
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativesetu" // 本地涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativewife" // 本地老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao" // 以图搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_setutime" // 来份涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe" // 搜番
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation" // vtb语录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/atri" // ATRI词库
// 以下为内置依赖,勿动
"github.com/fumiama/go-registry"
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/manager" // 群管
_ "github.com/FloatTech/zbputils/job" // 定时指令触发器
// ^^^^ //
// ^^^^^^^^^^^^^^ //
// ^^^^^^^高优先级区^^^^^^^ //
// ^^^^^^^^^^^^^^高优先级区^^^^^^^^^^^^^^ //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^高优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// ----------------------------高优先级区---------------------------- //
// //
// //
// //
// //
// //
// ----------------------------中优先级区---------------------------- //
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv中优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
// vvvvvvvvvvvvvv中优先级区vvvvvvvvvvvvvv //
// vvvvvvv中优先级区vvvvvvv //
// vvvvvvvvvvvvvv //
// vvvv //
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews" // 今日早报
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drawlots" // 多功能抽签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/github" // 搜索GitHub仓库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/guessmusic" // 猜歌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/heisi" // 黑丝
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hitokoto" // 一言
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hyaku" // 百人一首
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday" // 疯狂星期四
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo" // 日语语法学习
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" // 铅笔小说网搜索
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/quan" // QQ权重查询
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam" // steam相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic" // vtb点歌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
// ^^^^ //
// ^^^^^^^^^^^^^^ //
// ^^^^^^^中优先级区^^^^^^^ //
// ^^^^^^^^^^^^^^中优先级区^^^^^^^^^^^^^^ //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^中优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// ----------------------------中优先级区---------------------------- //
// //
// //
// //
// //
// //
// ----------------------------低优先级区---------------------------- //
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv低优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
// vvvvvvvvvvvvvv低优先级区vvvvvvvvvvvvvv //
// vvvvvvv低优先级区vvvvvvv //
// vvvvvvvvvvvvvv //
// vvvv //
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/curse" // 骂人
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply" // 人工智能回复
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读
// ^^^^ //
// ^^^^^^^^^^^^^^ //
// ^^^^^^^低优先级区^^^^^^^ //
// ^^^^^^^^^^^^^^低优先级区^^^^^^^^^^^^^^ //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^低优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// ----------------------------低优先级区---------------------------- //
// //
// //
// //
// //
// //
// -----------------------以下为内置依赖,勿动------------------------ //
"github.com/FloatTech/floatbox/process"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/driver"
"github.com/wdvxdr1123/ZeroBot/message"
// webctrl "github.com/FloatTech/zbputils/control/web"
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
// -----------------------以上为内置依赖,勿动------------------------ //
)
var (
contents = []string{
"* OneBot + ZeroBot + Golang",
"* Version 1.2.4 - 2022-01-14 20:05:43 +0800 CST",
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
banner = strings.Join(contents, "\n")
token *string
url *string
adana *string
prefix *string
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
)
type zbpcfg struct {
Z zero.Config `json:"zero"`
W []*driver.WSClient `json:"ws"`
S []*driver.WSServer `json:"wss"`
}
var config zbpcfg
func init() {
sus := make([]int64, 0, 16)
// 解析命令行参数
d := flag.Bool("d", false, "Enable debug level log and higher.")
w := flag.Bool("w", false, "Enable warning level log and higher.")
h := flag.Bool("h", false, "Display this help.")
// 解析命令行参数,输入 `-g 监听地址:端口` 指定 gui 访问地址,默认 127.0.0.1:3000
// g := flag.String("g", "127.0.0.1:3000", "Set web gui listening address.")
// g := flag.String("g", "127.0.0.1:3000", "Set webui url.")
// 直接写死 AccessToken 时,请更改下面第二个参数
token = flag.String("t", "", "Set AccessToken of WSClient.")
token := flag.String("t", "", "Set AccessToken of WSClient.")
// 直接写死 URL 时,请更改下面第二个参数
url = flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
url := flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
// 默认昵称
adana = flag.String("n", "椛椛", "Set default nickname.")
prefix = flag.String("p", "/", "Set command prefix.")
adana := flag.String("n", "椛椛", "Set default nickname.")
prefix := flag.String("p", "/", "Set command prefix.")
runcfg := flag.String("c", "", "Run from config file.")
save := flag.String("s", "", "Save default config to file and exit.")
late := flag.Uint("l", 233, "Response latency (ms).")
rsz := flag.Uint("r", 4096, "Receiving buffer ring size.")
maxpt := flag.Uint("x", 4, "Max process time (min).")
flag.Parse()
if *h {
printBanner()
fmt.Println("Usage:")
flag.PrintDefaults()
os.Exit(0)
} else {
if *d && !*w {
logrus.SetLevel(logrus.DebugLevel)
}
if *w {
logrus.SetLevel(logrus.WarnLevel)
}
}
// 启用 gui
// webctrl.InitGui(*g)
}
if *d && !*w {
logrus.SetLevel(logrus.DebugLevel)
}
if *w {
logrus.SetLevel(logrus.WarnLevel)
}
func printBanner() {
fmt.Print(
"\n======================[ZeroBot-Plugin]======================",
"\n", banner, "\n",
"----------------------[ZeroBot-公告栏]----------------------",
"\n", getKanban(), "\n",
"============================================================\n",
)
}
for _, s := range flag.Args() {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
continue
}
sus = append(sus, i)
}
func getKanban() string {
err := reg.Connect()
if err != nil {
return err.Error()
// 通过代码写死的方式添加主人账号
// sus = append(sus, 12345678)
// sus = append(sus, 87654321)
if *runcfg != "" {
f, err := os.Open(*runcfg)
if err != nil {
panic(err)
}
config.W = make([]*driver.WSClient, 0, 2)
err = json.NewDecoder(f).Decode(&config)
f.Close()
if err != nil {
panic(err)
}
config.Z.Driver = make([]zero.Driver, len(config.W)+len(config.S))
for i, w := range config.W {
config.Z.Driver[i] = w
}
for i, s := range config.S {
config.Z.Driver[i+len(config.W)] = s
}
logrus.Infoln("[main] 从", *runcfg, "读取配置文件")
return
}
defer reg.Close()
text, err := reg.Get("ZeroBot-Plugin/kanban")
if err != nil {
return err.Error()
config.W = []*driver.WSClient{driver.NewWebSocketClient(*url, *token)}
config.Z = zero.Config{
NickName: append([]string{*adana}, "ATRI", "atri", "亚托莉", "アトリ"),
CommandPrefix: *prefix,
SuperUsers: sus,
RingLen: *rsz,
Latency: time.Duration(*late) * time.Millisecond,
MaxProcessTime: time.Duration(*maxpt) * time.Minute,
Driver: []zero.Driver{config.W[0]},
}
return text
if *save != "" {
f, err := os.Create(*save)
if err != nil {
panic(err)
}
err = json.NewEncoder(f).Encode(&config)
f.Close()
if err != nil {
panic(err)
}
logrus.Infoln("[main] 配置文件已保存到", *save)
os.Exit(0)
}
// 启用 webui
// go webctrl.RunGui(*g)
}
func main() {
printBanner()
if !strings.Contains(runtime.Version(), "go1.2") { // go1.20之前版本需要全局 seed其他插件无需再 seed
rand.Seed(time.Now().UnixNano()) //nolint: staticcheck
}
// 帮助
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(banner, "\n发送\"/服务列表\"查看 bot 功能"))
ctx.SendChain(message.Text(banner.Banner, "\n管理发送\"/服务列表\"查看 bot 功能\n发送\"/用法name\"查看功能用法"))
})
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).FirstPriority().
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(getKanban()))
ctx.SendChain(message.Text(strings.ReplaceAll(kanban.Kanban(), "\t", "")))
})
zero.RunAndBlock(
zero.Config{
NickName: append([]string{*adana}, nicks...),
CommandPrefix: *prefix,
// SuperUsers 某些功能需要主人权限,可通过以下两种方式修改
// SuperUsers: []string{"12345678", "87654321"}, // 通过代码写死的方式添加主人账号
SuperUsers: flag.Args(), // 通过命令行参数的方式添加主人账号
Driver: []zero.Driver{driver.NewWebSocketClient(*url, *token)},
},
)
zero.RunAndBlock(&config.Z, process.GlobalInitMutex.Unlock)
}

View File

@@ -1,70 +0,0 @@
//go:build windows
// +build windows
package main
import (
"bytes"
"strings"
"github.com/sirupsen/logrus"
)
func init() {
// windows 带颜色 log 自定义格式
logrus.SetFormatter(&LogFormat{})
}
const (
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
colorReset = "\x1b[0m"
)
// LogFormat specialize for zbp
type LogFormat struct{}
// Format implements logrus.Formatter
func (f LogFormat) Format(entry *logrus.Entry) ([]byte, error) {
buf := new(bytes.Buffer)
buf.WriteString(getLogLevelColorCode(entry.Level))
buf.WriteByte('[')
buf.WriteString(strings.ToUpper(entry.Level.String()))
buf.WriteString("] ")
buf.WriteString(entry.Message)
buf.WriteString(" \n")
buf.WriteString(colorReset)
return buf.Bytes(), nil
}
// getLogLevelColorCode 获取日志等级对应色彩code
func getLogLevelColorCode(level logrus.Level) string {
switch level {
case logrus.PanicLevel:
return colorCodePanic
case logrus.FatalLevel:
return colorCodeFatal
case logrus.ErrorLevel:
return colorCodeError
case logrus.WarnLevel:
return colorCodeWarn
case logrus.InfoLevel:
return colorCodeInfo
case logrus.DebugLevel:
return colorCodeDebug
case logrus.TraceLevel:
return colorCodeTrace
default:
return colorCodeInfo
}
}

97
plugin/ahsai/ahsai.go Normal file
View File

@@ -0,0 +1,97 @@
// Package ahsai AH Soft フリーテキスト音声合成 demo API
package ahsai
import (
"fmt"
"math/rand"
"os"
"sort"
"strconv"
"time"
"github.com/FloatTech/floatbox/file"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
ahsaitts "github.com/fumiama/ahsai"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
namelist = [...]string{"伊織弓鶴", "紲星あかり", "結月ゆかり", "京町セイカ", "東北きりたん", "東北イタコ", "ついなちゃん標準語", "ついなちゃん関西弁", "音街ウナ", "琴葉茜", "吉田くん", "民安ともえ", "桜乃そら", "月読アイ", "琴葉葵", "東北ずん子", "月読ショウタ", "水奈瀬コウ"}
namesort = func() []string {
nl := namelist[:]
sort.Strings(nl)
return nl
}()
)
func init() {
engine := control.Register("ahsai", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "フリーテキスト音声合成",
Help: "- 使[伊織弓鶴|紲星あかり|結月ゆかり|京町セイカ|東北きりたん|東北イタコ|ついなちゃん標準語|ついなちゃん関西弁|音街ウナ|琴葉茜|吉田くん|民安ともえ|桜乃そら|月読アイ|琴葉葵|東北ずん子|月読ショウタ|水奈瀬コウ]说(日语)",
PrivateDataFolder: "ahsai",
})
cachePath := engine.DataFolder() + "cache/"
_ = os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
engine.OnRegex("^使(.{0,10})说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$", selectName).SetBlock(true).Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
uid := ctx.Event.UserID
today := time.Now().Format("20060102150405")
ahsaiFile := cachePath + strconv.FormatInt(uid, 10) + today + "ahsai.wav"
s := ahsaitts.NewSpeaker()
err := s.SetName(ctx.State["ahsainame"].(string))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
u, err := s.Speak(ctx.State["ahsaitext"].(string))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
err = ahsaitts.SaveOggToFile(u, ahsaiFile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + ahsaiFile))
})
}
func selectName(ctx *zero.Ctx) bool {
regexMatched := ctx.State["regex_matched"].([]string)
ctx.State["ahsaitext"] = regexMatched[2]
name := regexMatched[1]
index := sort.SearchStrings(namesort, name)
if index < len(namelist) && namesort[index] == name {
ctx.State["ahsainame"] = name
return true
}
speaktext := ""
for i, v := range namelist {
speaktext += fmt.Sprintf("%d. %s\n", i, v)
}
ctx.SendChain(message.Text("输入的音源为空, 请输入音源序号\n", speaktext))
next, cancel := zero.NewFutureEvent("message", 999, false, ctx.CheckSession(), zero.RegexRule(`\d{0,2}`)).Repeat()
defer cancel()
for {
select {
case <-time.After(time.Second * 10):
ctx.State["ahsainame"] = namelist[rand.Intn(len(namelist))]
ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择", ctx.State["ahsainame"]))
return true
case c := <-next:
msg := c.Event.Message.ExtractPlainText()
num, _ := strconv.Atoi(msg)
if num < 0 || num >= len(namelist) {
ctx.SendChain(message.Text("序号非法!"))
continue
}
ctx.State["ahsainame"] = namelist[num]
return true
}
}
}

614
plugin/ai_false/ai_false.go Normal file
View File

@@ -0,0 +1,614 @@
// Package aifalse 暂时只有服务器监控
package aifalse
import (
"bytes"
"errors"
"image"
"math"
"runtime"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
"unsafe"
"github.com/FloatTech/AnimeAPI/bilibili"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/gg"
"github.com/FloatTech/imgfactory"
"github.com/FloatTech/rendercard"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
"github.com/disintegration/imaging"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/host"
"github.com/shirou/gopsutil/v3/mem"
"github.com/sirupsen/logrus"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const (
backgroundURL = "https://iw233.cn/api.php?sort=mp"
referer = "https://weibo.com/"
)
var (
boottime = time.Now()
bgdata *[]byte
bgcount uintptr
)
func init() { // 插件主体
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "自检, 全局限速",
Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" +
"- 设置默认限速为每 m [分钟 | 秒] n 次触发",
})
c, ok := control.Lookup("aifalse")
if !ok {
panic("register aifalse error")
}
m := c.GetData(0)
n := (m >> 16) & 0xffff
m &= 0xffff
if m != 0 || n != 0 {
ctxext.SetDefaultLimiterManagerParam(time.Duration(m)*time.Second, int(n))
logrus.Infoln("设置默认限速为每", m, "秒触发", n, "次")
}
engine.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
sendimg, err := imgfactory.ToBytes(img)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if id := ctx.SendChain(message.ImageBytes(sendimg)); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("ERROR: no such plugin"))
return
}
m, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if ctx.State["regex_matched"].([]string)[2] == "分钟" {
m *= 60
}
if m >= 65536 || m <= 0 {
ctx.SendChain(message.Text("ERROR: interval too big"))
return
}
n, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[3], 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if n >= 65536 || n <= 0 {
ctx.SendChain(message.Text("ERROR: burst too big"))
return
}
ctxext.SetDefaultLimiterManagerParam(time.Duration(m)*time.Second, int(n))
err = c.SetData(0, (m&0xffff)|((n<<16)&0xffff0000))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("设置默认限速为每", m, "秒触发", n, "次"))
})
}
func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg image.Image, err error) {
diskstate, err := diskstate()
if err != nil {
return
}
diskcardh := 40 + (20+50)*len(diskstate) + 40 - 20
moreinfo, err := moreinfo(m)
if err != nil {
return
}
moreinfocardh := 30 + (20+32*72/96)*len(moreinfo) + 30 - 20
basicstate, err := basicstate()
if err != nil {
return
}
dldata := (*[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata))))
if dldata == (*[]byte)(nil) || uintptr(time.Since(boottime).Hours()/24) >= atomic.LoadUintptr(&bgcount) {
url, err1 := bilibili.GetRealURL(backgroundURL)
if err1 != nil {
return nil, err1
}
data, err1 := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
if err1 != nil {
return nil, err1
}
atomic.AddUintptr(&bgcount, 1)
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)), unsafe.Pointer(&data))
dldata = &data
}
data := *dldata
back, _, err := image.Decode(bytes.NewReader(data))
if err != nil {
return
}
data, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640")
if err != nil {
return
}
avatar, _, err := image.Decode(bytes.NewReader(data))
if err != nil {
return
}
avatarf := imgfactory.Size(avatar, 200, 200)
fontbyte, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, true)
if err != nil {
return
}
canvas := gg.NewContext(1280, 70+250+40+380+diskcardh+40+moreinfocardh+40+70)
bh, bw, ch, cw := float64(back.Bounds().Dy()), float64(back.Bounds().Dx()), float64(canvas.H()), float64(canvas.W())
if bh/bw < ch/cw {
back = imgfactory.Size(back, int(bw*ch/bh), int(bh*ch/bh)).Image()
canvas.DrawImageAnchored(back, canvas.W()/2, canvas.H()/2, 0.5, 0.5)
} else {
back = imgfactory.Size(back, int(bw*cw/bw), int(bh*cw/bw)).Image()
canvas.DrawImage(back, 0, 0)
}
var blurback image.Image
bwg := &sync.WaitGroup{}
bwg.Add(1)
go func() {
defer bwg.Done()
blurback = imaging.Blur(canvas.Image(), 8)
}()
wg := &sync.WaitGroup{}
wg.Add(5)
cardw := canvas.W() - 70 - 70
titlecardh := 250
basiccardh := 380
var titleimg, basicimg, diskimg, moreinfoimg, shadowimg image.Image
go func() {
defer wg.Done()
titlecard := gg.NewContext(cardw, titlecardh)
bwg.Wait()
titlecard.DrawImage(blurback, -70, -70)
titlecard.DrawRoundedRectangle(1, 1, float64(titlecard.W()-1*2), float64(titlecardh-1*2), 16)
titlecard.SetLineWidth(3)
titlecard.SetRGBA255(255, 255, 255, 100)
titlecard.StrokePreserve()
titlecard.SetRGBA255(255, 255, 255, 140)
titlecard.Fill()
titlecard.DrawImage(avatarf.Circle(0).Image(), (titlecardh-avatarf.H())/2, (titlecardh-avatarf.H())/2)
err = titlecard.ParseFontFace(fontbyte, 72)
if err != nil {
return
}
fw, _ := titlecard.MeasureString(botname)
titlecard.SetRGBA255(30, 30, 30, 255)
titlecard.DrawStringAnchored(botname, float64(titlecardh)+fw/2, float64(titlecardh)*0.5/2, 0.5, 0.5)
err = titlecard.ParseFontFace(fontbyte, 24)
if err != nil {
return
}
titlecard.SetRGBA255(30, 30, 30, 180)
titlecard.NewSubPath()
titlecard.MoveTo(float64(titlecardh), float64(titlecardh)/2)
titlecard.LineTo(float64(titlecard.W()-titlecardh), float64(titlecardh)/2)
titlecard.Stroke()
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)
bs, err := botstatus()
if err != nil {
return
}
fw, _ = titlecard.MeasureString(bs)
titlecard.DrawStringAnchored(bs, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.5/2), 0.5, 0.5)
titleimg = rendercard.Fillet(titlecard.Image(), 16)
}()
go func() {
defer wg.Done()
basiccard := gg.NewContext(cardw, basiccardh)
bwg.Wait()
basiccard.DrawImage(blurback, -70, -70-titlecardh-40)
basiccard.DrawRoundedRectangle(1, 1, float64(basiccard.W()-1*2), float64(basiccardh-1*2), 16)
basiccard.SetLineWidth(3)
basiccard.SetRGBA255(255, 255, 255, 100)
basiccard.StrokePreserve()
basiccard.SetRGBA255(255, 255, 255, 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.DrawCircle((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 100)
basiccard.Fill()
switch {
case v.precent > 90:
basiccard.SetRGBA255(255, 70, 0, 255)
case v.precent > 70:
basiccard.SetRGBA255(255, 165, 0, 255)
default:
basiccard.SetRGBA255(145, 240, 145, 255)
}
basiccard.NewSubPath()
basiccard.MoveTo((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2)
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.DrawCircle((float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200/2, 80)
basiccard.Fill()
err = basiccard.ParseFontFace(fontbyte, 42)
if err != nil {
return
}
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)
_, 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)
err = basiccard.ParseFontFace(fontbyte, 20)
if err != nil {
return
}
basiccard.SetRGBA255(30, 30, 30, 180)
textoffsety := basiccard.FontHeight() + 10
for k, s := range v.text {
basiccard.DrawStringAnchored(s, (float64(basiccard.W())-200*float64(bslen))/float64(bslen+1)+200/2+offset, 20+200+15+fw+15+basiccard.FontHeight()/2+float64(k)*textoffsety, 0.5, 0.5)
}
}
basicimg = rendercard.Fillet(basiccard.Image(), 16)
}()
go func() {
defer wg.Done()
diskcard := gg.NewContext(cardw, diskcardh)
bwg.Wait()
diskcard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40)
diskcard.DrawRoundedRectangle(1, 1, float64(diskcard.W()-1*2), float64(diskcardh-1*2), 16)
diskcard.SetLineWidth(3)
diskcard.SetRGBA255(255, 255, 255, 100)
diskcard.StrokePreserve()
diskcard.SetRGBA255(255, 255, 255, 140)
diskcard.Fill()
err = diskcard.ParseFontFace(fontbyte, 32)
if err != nil {
return
}
dslen := len(diskstate)
if dslen == 1 {
diskcard.SetRGBA255(192, 192, 192, 255)
diskcard.DrawRoundedRectangle(40, 40, float64(diskcard.W())-40-100, 50, 12)
diskcard.ClipPreserve()
diskcard.Fill()
switch {
case diskstate[0].precent > 90:
diskcard.SetRGBA255(255, 70, 0, 255)
case diskstate[0].precent > 70:
diskcard.SetRGBA255(255, 165, 0, 255)
default:
diskcard.SetRGBA255(145, 240, 145, 255)
}
diskcard.DrawRoundedRectangle(40, 40, (float64(diskcard.W())-40-100)*diskstate[0].precent*0.01, 50, 12)
diskcard.Fill()
diskcard.ResetClip()
diskcard.SetRGBA255(30, 30, 30, 255)
fw, _ := diskcard.MeasureString(diskstate[0].name)
fw1, _ := diskcard.MeasureString(diskstate[0].text[0])
diskcard.DrawStringAnchored(diskstate[0].name, 40+10+fw/2, 40+50/2, 0.5, 0.5)
diskcard.DrawStringAnchored(diskstate[0].text[0], (float64(diskcard.W())-100-10)-fw1/2, 40+50/2, 0.5, 0.5)
diskcard.DrawStringAnchored(strconv.FormatFloat(diskstate[0].precent, 'f', 0, 64)+"%", float64(diskcard.W())-100/2, 40+50/2, 0.5, 0.5)
} else {
for i, v := range diskstate {
offset := float64(i)*(50+20) - 20
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()
switch {
case v.precent > 90:
diskcard.SetRGBA255(255, 70, 0, 255)
case v.precent > 70:
diskcard.SetRGBA255(255, 165, 0, 255)
default:
diskcard.SetRGBA255(145, 240, 145, 255)
}
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)
fw, _ := diskcard.MeasureString(v.name)
fw1, _ := diskcard.MeasureString(v.text[0])
diskcard.DrawStringAnchored(v.name, 40+10+fw/2, 40+(float64(diskcardh-40*2)-50*float64(dslen))/float64(dslen-1)+50/2+offset, 0.5, 0.5)
diskcard.DrawStringAnchored(v.text[0], (float64(diskcard.W())-100-10)-fw1/2, 40+(float64(diskcardh-40*2)-50*float64(dslen))/float64(dslen-1)+50/2+offset, 0.5, 0.5)
diskcard.DrawStringAnchored(strconv.FormatFloat(v.precent, 'f', 0, 64)+"%", float64(diskcard.W())-100/2, 40+(float64(diskcardh-40*2)-50*float64(dslen))/float64(dslen-1)+50/2+offset, 0.5, 0.5)
}
}
diskimg = rendercard.Fillet(diskcard.Image(), 16)
}()
go func() {
defer wg.Done()
moreinfocard := gg.NewContext(cardw, moreinfocardh)
bwg.Wait()
moreinfocard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40-diskcardh-40)
moreinfocard.DrawRoundedRectangle(1, 1, float64(moreinfocard.W()-1*2), float64(moreinfocard.H()-1*2), 16)
moreinfocard.SetLineWidth(3)
moreinfocard.SetRGBA255(255, 255, 255, 100)
moreinfocard.StrokePreserve()
moreinfocard.SetRGBA255(255, 255, 255, 140)
moreinfocard.Fill()
err = moreinfocard.ParseFontFace(fontbyte, 32)
if err != nil {
return
}
milen := len(moreinfo)
for i, v := range moreinfo {
offset := float64(i)*(20+moreinfocard.FontHeight()) - 20
moreinfocard.SetRGBA255(30, 30, 30, 255)
fw, _ := moreinfocard.MeasureString(v.name)
fw1, _ := moreinfocard.MeasureString(v.text[0])
moreinfocard.DrawStringAnchored(v.name, 20+fw/2, 30+(float64(moreinfocardh-30*2)-moreinfocard.FontHeight()*float64(milen))/float64(milen-1)+moreinfocard.FontHeight()/2+offset, 0.5, 0.5)
moreinfocard.DrawStringAnchored(v.text[0], float64(moreinfocard.W())-20-fw1/2, 30+(float64(moreinfocardh-30*2)-moreinfocard.FontHeight()*float64(milen))/float64(milen-1)+moreinfocard.FontHeight()/2+offset, 0.5, 0.5)
}
moreinfoimg = rendercard.Fillet(moreinfocard.Image(), 16)
}()
go func() {
defer wg.Done()
shadow := gg.NewContext(canvas.W(), canvas.H())
shadow.SetRGBA255(0, 0, 0, 100)
shadow.SetLineWidth(12)
shadow.DrawRoundedRectangle(70, 70, float64(cardw), float64(titlecardh), 16)
shadow.Stroke()
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40), float64(cardw), float64(basiccardh), 16)
shadow.Stroke()
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40), float64(cardw), float64(diskcardh), 16)
shadow.Stroke()
shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40+diskcardh+40), float64(cardw), float64(moreinfocardh), 16)
shadow.Stroke()
shadowimg = imaging.Blur(shadow.Image(), 24)
}()
wg.Wait()
if shadowimg == nil || titleimg == nil || basicimg == nil || diskimg == nil || moreinfoimg == nil {
err = errors.New("图片渲染失败")
return
}
canvas.DrawImage(shadowimg, 0, 0)
canvas.DrawImage(titleimg, 70, 70)
canvas.DrawImage(basicimg, 70, 70+titlecardh+40)
canvas.DrawImage(diskimg, 70, 70+titlecardh+40+basiccardh+40)
canvas.DrawImage(moreinfoimg, 70, 70+titlecardh+40+basiccardh+40+diskcardh+40)
err = canvas.ParseFontFace(fontbyte, 28)
if err != nil {
return
}
canvas.SetRGBA255(0, 0, 0, 255)
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2+3, float64(canvas.H())-70/2+3, 0.5, 0.5)
canvas.SetRGBA255(255, 255, 255, 255)
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2, float64(canvas.H())-70/2, 0.5, 0.5)
sendimg = canvas.Image()
return
}
func botruntime() (string, error) {
hostinfo, err := host.Info()
if err != nil {
return "", err
}
t := &strings.Builder{}
t.WriteString("ZeroBot-Plugin 已运行 ")
t.WriteString(strconv.FormatInt((time.Now().Unix()-boottime.Unix())/86400, 10))
t.WriteString(" 天 ")
t.WriteString(time.Unix(time.Now().Unix()-boottime.Unix(), 0).UTC().Format("15:04:05"))
t.WriteString(" | 系统运行 ")
t.WriteString(strconv.FormatInt(int64(hostinfo.Uptime)/86400, 10))
t.WriteString(" 天 ")
t.WriteString(time.Unix(int64(hostinfo.Uptime), 0).UTC().Format("15:04:05"))
return t.String(), nil
}
func botstatus() (string, error) {
hostinfo, err := host.Info()
if err != nil {
return "", err
}
t := &strings.Builder{}
t.WriteString(time.Now().Format("2006-01-02 15:04:05"))
t.WriteString(" | Compiled by ")
t.WriteString(runtime.Version())
t.WriteString(" | ")
t.WriteString(cases.Title(language.English).String(hostinfo.OS))
return t.String(), nil
}
type status struct {
precent float64
name string
text []string
}
func basicstate() (stateinfo [3]*status, err error) {
percent, err := cpu.Percent(time.Second, false)
if err != nil {
return
}
cpuinfo, err := cpu.Info()
if err != nil {
return
}
cores := strconv.Itoa(int(cpuinfo[0].Cores)) + " Core"
times := "最大 " + strconv.FormatFloat(cpuinfo[0].Mhz/1000, 'f', 1, 64) + "Ghz"
stateinfo[0] = &status{
precent: math.Round(percent[0]),
name: "CPU",
text: []string{cores, times},
}
raminfo, err := mem.VirtualMemory()
if err != nil {
return
}
total := "总共 " + storagefmt(float64(raminfo.Total))
used := "已用 " + storagefmt(float64(raminfo.Used))
free := "剩余 " + storagefmt(float64(raminfo.Free))
stateinfo[1] = &status{
precent: math.Round(raminfo.UsedPercent),
name: "RAM",
text: []string{total, used, free},
}
swapinfo, err := mem.SwapMemory()
if err != nil {
return
}
total = "总共 " + storagefmt(float64(swapinfo.Total))
used = "已用 " + storagefmt(float64(swapinfo.Used))
free = "剩余 " + storagefmt(float64(swapinfo.Free))
stateinfo[2] = &status{
precent: math.Round(swapinfo.UsedPercent),
name: "SWAP",
text: []string{total, used, free},
}
return
}
func storagefmt(num float64) string {
if num /= 1024; num < 1 {
return strconv.FormatFloat(num*1024, 'f', 2, 64) + "B"
}
if num /= 1024; num < 1 {
return strconv.FormatFloat(num*1024, 'f', 2, 64) + "KB"
}
if num /= 1024; num < 1 {
return strconv.FormatFloat(num*1024, 'f', 2, 64) + "MB"
}
if num /= 1024; num < 1 {
return strconv.FormatFloat(num*1024, 'f', 2, 64) + "GB"
}
return strconv.FormatFloat(num, 'f', 2, 64) + "TB"
}
func diskstate() (stateinfo []*status, err error) {
parts, err := disk.Partitions(false)
if err != nil {
return
}
stateinfo = make([]*status, 0, len(parts))
for _, v := range parts {
mp := v.Mountpoint
if strings.HasPrefix(mp, "/snap/") || strings.HasPrefix(mp, "/apex/") {
continue
}
diskusage, err := disk.Usage(mp)
if err != nil {
continue
}
stateinfo = append(stateinfo, &status{
precent: math.Round(diskusage.UsedPercent),
name: mp,
text: []string{storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))},
})
}
return stateinfo, nil
}
func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) {
hostinfo, err := host.Info()
if err != nil {
return
}
cpuinfo, err := cpu.Info()
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: "Version", text: []string{hostinfo.PlatformVersion}},
{name: "Plugin", text: []string{"共 " + strconv.Itoa(count) + " 个"}},
}
return
}

282
plugin/ai_reply/ai_tts.go Normal file
View File

@@ -0,0 +1,282 @@
package aireply
import (
"errors"
"net/url"
"github.com/RomiChan/syncx"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/FloatTech/AnimeAPI/aireply"
"github.com/FloatTech/AnimeAPI/tts"
"github.com/FloatTech/AnimeAPI/tts/baidutts"
"github.com/FloatTech/AnimeAPI/tts/genshin"
"github.com/FloatTech/AnimeAPI/tts/mockingbird"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
)
// 数据结构: [4 bits] [4 bits] [8 bits] [8 bits]
// [拟声鸟模式] [百度模式] [tts模式] [回复模式]
// defaultttsindexkey
// 数据结构: [4 bits] [4 bits] [8 bits]
// [拟声鸟模式] [百度模式] [tts模式]
// [tts模式]: 0~63 genshin 64 baidu 65 mockingbird
const (
lastgsttsindex = 63 + iota
baiduttsindex
mockingbirdttsindex
)
// extrattsname is the tts other than genshin vits
var extrattsname = []string{"百度", "拟声鸟"}
const (
defaultttsindexkey = -2905
gsapikeyextragrp = -1
chatgptapikeyextragrp = -2
)
type replymode struct {
APIKey string // APIKey is for chatgpt
replyModes []string `json:"-"`
}
func (r *replymode) setReplyMode(ctx *zero.Ctx, name string) error {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
var ok bool
var index int64
for i, s := range r.replyModes {
if s == name {
ok = true
index = int64(i)
break
}
}
if !ok {
return errors.New("no such mode")
}
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
return errors.New("no such plugin")
}
return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff))
}
func (r *replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
switch m.GetData(gid) & 0xff {
case 0:
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
case 1:
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
case 2:
k := r.getAPIKey(ctx)
if k != "" {
return aireply.NewChatGPT(aireply.ChatGPTURL, k)
}
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
}
}
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
}
func (r *replymode) getAPIKey(ctx *zero.Ctx) string {
if r.APIKey == "" {
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
_ = m.Manager.GetExtra(chatgptapikeyextragrp, &r)
logrus.Debugln("[tts] get api key:", r.APIKey)
}
return r.APIKey
}
func (r *replymode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
r.APIKey = key
_ = m.Manager.Response(chatgptapikeyextragrp)
return m.Manager.SetExtra(chatgptapikeyextragrp, r)
}
var ttsins = func() map[string]tts.TTS {
m := make(map[string]tts.TTS, 128)
for _, mode := range append(genshin.SoundList[:], extrattsname...) {
m[mode] = nil
}
return m
}()
var ttsModes = func() []string {
s := append(genshin.SoundList[:], make([]string, 64-len(genshin.SoundList))...) // 0-63
s = append(s, extrattsname...) // 64 65 ...
return s
}()
type ttsmode struct {
APIKey string // APIKey is for genshin vits
mode syncx.Map[int64, int64] `json:"-"` // mode grp index
}
func list(list []string, num int) string {
s := ""
for i, value := range list {
s += value
if (i+1)%num == 0 {
s += "\n"
} else {
s += " | "
}
}
return s
}
func newttsmode() *ttsmode {
t := &ttsmode{}
m, ok := control.Lookup("tts")
t.mode = syncx.Map[int64, int64]{}
t.mode.Store(defaultttsindexkey, 0)
if ok {
index := m.GetData(defaultttsindexkey)
msk := index & 0xff
if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == mockingbirdttsindex) {
t.mode.Store(defaultttsindexkey, index)
}
}
return t
}
func (t *ttsmode) getAPIKey(ctx *zero.Ctx) string {
if t.APIKey == "" {
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
_ = m.Manager.GetExtra(gsapikeyextragrp, &t)
logrus.Debugln("[tts] get api key:", t.APIKey)
}
return url.QueryEscape(t.APIKey)
}
func (t *ttsmode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
t.APIKey = key
_ = m.Manager.Response(gsapikeyextragrp)
return m.Manager.SetExtra(gsapikeyextragrp, t)
}
func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt int) error {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
_, ok := ttsins[name]
if !ok {
return errors.New("不支持设置语音人物" + name)
}
var index = int64(-1)
for i, s := range genshin.SoundList {
if s == name {
index = int64(i)
break
}
}
if index == -1 {
switch name {
case extrattsname[0]:
index = baiduttsindex
case extrattsname[1]:
index = mockingbirdttsindex
default:
return errors.New("语音人物" + name + "未注册index")
}
}
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
t.mode.Store(gid, index)
return m.SetData(gid, (m.GetData(gid)&^0xffff00)|((index<<8)&0xff00)|((int64(baiduper)<<16)&0x0f0000)|((int64(mockingsynt)<<20)&0xf00000))
}
func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
i, ok := t.mode.Load(gid)
if !ok {
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
i = m.GetData(gid) >> 8
}
m := i & 0xff
if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != mockingbirdttsindex) {
i, _ = t.mode.Load(defaultttsindexkey)
m = i & 0xff
}
mode := ttsModes[m]
ins, ok := ttsins[mode]
if !ok || ins == nil {
switch mode {
case extrattsname[0]:
ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8)
case extrattsname[1]:
var err error
ins, err = mockingbird.NewMockingBirdTTS(int(i&0xf000) >> 12)
if err != nil {
return nil, err
}
default: // 原神
k := t.getAPIKey(ctx)
if k != "" {
ins = genshin.NewGenshin(int(m), t.getAPIKey(ctx))
ttsins[mode] = ins
} else {
return nil, errors.New("no valid speaker")
}
}
}
return ins, nil
}
func (t *ttsmode) resetSoundMode(ctx *zero.Ctx) error {
gid := ctx.Event.GroupID
if gid == 0 {
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)) // 重置数据
}
func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) error {
_, ok := ttsins[name]
if !ok {
return errors.New("不支持设置语音人物" + name)
}
index := int64(-1)
for i, s := range genshin.SoundList {
if s == name {
index = int64(i)
break
}
}
if index == -1 {
switch name {
case extrattsname[0]:
index = baiduttsindex
case extrattsname[1]:
index = mockingbirdttsindex
default:
return errors.New("语音人物" + name + "未注册index")
}
}
m, ok := control.Lookup("tts")
if !ok {
return errors.New("[tts] service not found")
}
t.mode.Store(defaultttsindexkey, index)
return m.SetData(defaultttsindexkey, (index&0xff)|((int64(baiduper)<<8)&0x0f00)|((int64(mockingsynt)<<12)&0xf000))
}

193
plugin/ai_reply/main.go Normal file
View File

@@ -0,0 +1,193 @@
// Package aireply AI 回复
package aireply
import (
"regexp"
"strconv"
"time"
"github.com/FloatTech/AnimeAPI/tts/genshin"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var replmd = replymode{
replyModes: []string{"青云客", "小爱", "ChatGPT"},
}
var ttsmd = newttsmode()
func init() { // 插件主体
ent := control.Register("tts", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Brief: "人工智能语音回复",
Help: "- @Bot 任意文本(任意一句话回复)\n" +
"- 设置语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" +
"- 设置默认语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" +
"- 恢复成默认语音模式\n" +
"- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
"当前适用的原神人物含有以下:\n" + list(genshin.SoundList[:], 5),
})
enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "人工智能回复",
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱|ChatGPT]\n- 设置 ChatGPT api key xxx",
PrivateDataFolder: "aireply",
})
enr.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
aireply := replmd.getReplyMode(ctx)
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
}
ctx.Send(reply)
})
enr.OnPrefix("设置回复模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
err := replmd.setReplyMode(ctx, param)
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
})
enr.OnRegex(`^设置\s*ChatGPT\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
err := replmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("设置成功"))
})
endpre := regexp.MustCompile(`\pP$`)
ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
// 获取回复模式
r := replmd.getReplyMode(ctx)
// 获取回复的文本
reply := r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0])
// 获取语音
speaker, err := ttsmd.getSoundMode(ctx)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
rec, err := speaker.Speak(ctx.Event.UserID, func() string {
if !endpre.MatchString(reply) {
return reply + "。"
}
return reply
})
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
return
}
// 发送语音
if id := ctx.SendChain(message.Record(rec)); id.ID() == 0 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
}
})
ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s*(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
param := ctx.State["regex_matched"].([]string)[1]
num := ctx.State["regex_matched"].([]string)[2]
n := 0
var err error
if num != "" {
n, err = strconv.Atoi(num)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}
// 保存设置
logrus.Debugln("[tts] t.setSoundMode( ctx", param, n, n, ")")
err = ttsmd.setSoundMode(ctx, param, n, n)
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
return
}
if banner, ok := genshin.TestRecord[param]; ok {
logrus.Debugln("[tts] banner:", banner, "get sound mode...")
// 设置验证
speaker, err := ttsmd.getSoundMode(ctx)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
logrus.Debugln("[tts] got sound mode, speaking...")
rec, err := speaker.Speak(ctx.Event.UserID, func() string { return banner })
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
return
}
logrus.Debugln("[tts] sending...")
if id := ctx.SendChain(message.Record(rec).Add("cache", 0)); id.ID() == 0 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。"))
return
}
time.Sleep(time.Second * 2)
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功"))
})
ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s*(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
param := ctx.State["regex_matched"].([]string)[1]
num := ctx.State["regex_matched"].([]string)[2]
n := 0
var err error
if num != "" {
n, err = strconv.Atoi(num)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}
// 保存设置
err = ttsmd.setDefaultSoundMode(param, n, n)
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功"))
})
ent.OnFullMatch("恢复成默认语音模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
err := ttsmd.resetSoundMode(ctx)
if err != nil {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
return
}
// 设置验证
speaker, err := ttsmd.getSoundMode(ctx)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前为", speaker))
})
ent.OnRegex(`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
err := ttsmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("设置成功"))
})
}

224
plugin/aipaint/aipaint.go Normal file
View File

@@ -0,0 +1,224 @@
// Package aipaint ai绘图
package aipaint
import (
"encoding/base64"
"encoding/json"
"fmt"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"time"
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
datapath string
predictRe = regexp.MustCompile(`{"steps".+?}`)
// 参考host http://91.217.139.190:5010 http://91.216.169.75:5010
aipaintTxt2ImgURL = "/got_image?token=%v&tags=%v"
aipaintImg2ImgURL = "/got_image2image?token=%v&tags=%v"
cfg = newServerConfig("data/aipaint/config.json")
)
type result struct {
Steps int `json:"steps"`
Sampler string `json:"sampler"`
Seed int `json:"seed"`
Strength float64 `json:"strength"`
Noise float64 `json:"noise"`
Scale float64 `json:"scale"`
Uc string `json:"uc"`
}
func (r *result) String() string {
return fmt.Sprintf("steps: %v\nsampler: %v\nseed: %v\nstrength: %v\nnoise: %v\nscale: %v\nuc: %v\n", r.Steps, r.Sampler, r.Seed, r.Strength, r.Noise, r.Scale, r.Uc)
}
func init() { // 插件主体
engine := control.Register("aipaint", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "ai绘图",
Help: "- [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx\n" +
"- [ ai高级绘图 | 高级生成色图 | 高级生成涩图 | ai高级画图 ] [prompt]\n" +
"- 设置ai绘图配置 [server] [token]\n" +
"- 设置ai绘图撤回时间90s\n" +
"- 查看ai绘图配置\n" +
"Tips: 使用前请先前往 http://91.217.139.190:5010/token 按提示获取token" +
"设置token示例(请确保是主人并且响应): 设置ai绘图配置 http://91.217.139.190:5010 [token] (中括号无需输入)\n" +
"参考服务器 http://91.217.139.190:5010, http://91.216.169.75:5010, http://185.80.202.180:5010\n" +
"[prompt]参数如下\n" +
"tags:tag词条\nntags:ntag词条\nshape:[Portrait|Landscape|Square]\nscale:[6:20]\nseed:种子\nstrength:[0-1] 建议0-0.7\nnoise:[0-1] 建议0-0.15" +
"参数与参数内容用:连接,每个参数之间用回车分割",
PrivateDataFolder: "aipaint",
})
datapath = file.BOTPATH + "/" + engine.DataFolder()
if file.IsNotExist(cfg.file) {
s := serverConfig{}
data, err := json.Marshal(s)
if err != nil {
panic(err)
}
err = os.WriteFile(cfg.file, data, 0666)
if err != nil {
panic(err)
}
}
engine.OnPrefixGroup([]string{`ai绘图`, `生成色图`, `生成涩图`, `ai画图`}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("少女祈祷中..."))
args := ctx.State["args"].(string)
data, err := web.GetData(cfg.BaseURL + fmt.Sprintf(aipaintTxt2ImgURL, cfg.Token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20")))))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
sendAiImg(ctx, data, cfg.Interval)
})
engine.OnPrefixGroup([]string{`ai高级绘图`, `高级生成色图`, `高级生成涩图`, `ai高级画图`}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
tags := make(map[string]string)
args := strings.Split(ctx.State["args"].(string), "\n")
if len(args) < 1 {
ctx.SendChain(message.Text("ERROR: 请输入正确的参数"))
return
}
for _, info := range args {
value := strings.Split(info, ":")
if len(value) > 1 {
if value[0] == "R18" && value[1] == "1" {
value[1] = "0"
ctx.SendChain(message.Text("不准涩涩! 已将R18设置为0. "))
}
tags[value[0]] = strings.Join(value[1:], ":")
}
}
ctx.SendChain(message.Text("少女祈祷中..."))
apiurl := "/got_image?token=" + cfg.Token
if _, ok := tags["tags"]; ok {
apiurl += "&tags=" + url.QueryEscape(strings.ReplaceAll(strings.TrimSpace(tags["tags"]), " ", "%20"))
}
if _, ok := tags["ntags"]; ok {
apiurl += "&ntags=" + url.QueryEscape(strings.ReplaceAll(strings.TrimSpace(tags["ntags"]), " ", "%20"))
}
if _, ok := tags["R18"]; ok {
apiurl += "&R18=" + url.QueryEscape(strings.TrimSpace(tags["R18"]))
}
if _, ok := tags["shape"]; ok {
apiurl += "&shape=" + url.QueryEscape(strings.TrimSpace(tags["shape"]))
}
if _, ok := tags["scale"]; ok {
apiurl += "&scale=" + url.QueryEscape(strings.TrimSpace(tags["scale"]))
}
if _, ok := tags["seed"]; ok {
apiurl += "&seed=" + url.QueryEscape(strings.TrimSpace(tags["seed"]))
}
if _, ok := tags["strength"]; ok {
apiurl += "&strength=" + url.QueryEscape(strings.TrimSpace(tags["strength"]))
}
if _, ok := tags["noise"]; ok {
apiurl += "&noise=" + url.QueryEscape(strings.TrimSpace(tags["noise"]))
}
data, err := web.GetData(cfg.BaseURL + apiurl)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
sendAiImg(ctx, data, cfg.Interval)
})
engine.OnRegex(`^设置ai绘图配置\s(.*[^\s$])\s(.+)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
regexMatched := ctx.State["regex_matched"].([]string)
err := cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
err = cfg.update(regexMatched[1], regexMatched[2], cfg.Interval)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功设置\nbase_url: ", cfg.BaseURL, "\ntoken: ", cfg.Token, "\ninterval: ", cfg.Interval))
})
engine.OnRegex(`^设置ai绘图撤回时间(\d{1,3})s$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
regexMatched := ctx.State["regex_matched"].([]string)
interval, err := strconv.Atoi(regexMatched[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
err = cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
err = cfg.update(cfg.BaseURL, cfg.Token, interval)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功设置撤回时间为", cfg.Interval, "s"))
})
engine.OnFullMatch(`查看ai绘图配置`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("base_url: ", cfg.BaseURL, "\ntoken: ", cfg.Token, "\ninterval: ", cfg.Interval))
})
}
func sendAiImg(ctx *zero.Ctx, data []byte, interval int) {
var loadData string
if predictRe.MatchString(binary.BytesToString(data)) {
loadData = predictRe.FindStringSubmatch(binary.BytesToString(data))[0]
}
var r result
if loadData != "" {
err := json.Unmarshal(binary.StringToBytes(loadData), &r)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
r.Uc, err = url.QueryUnescape(r.Uc)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}
encodeStr := base64.StdEncoding.EncodeToString(data)
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("base64://"+encodeStr))}
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(r.String())))
if mid := ctx.Send(m); mid.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
} else if interval > 0 {
go func(i message.MessageID) {
time.Sleep(time.Duration(interval) * time.Second)
ctx.DeleteMessage(i)
}(mid)
}
}

56
plugin/aipaint/config.go Normal file
View File

@@ -0,0 +1,56 @@
package aipaint
import (
"encoding/json"
"errors"
"os"
"github.com/FloatTech/floatbox/file"
)
// 配置结构体
type serverConfig struct {
BaseURL string `json:"base_url"`
Token string `json:"token"`
Interval int `json:"interval"`
file string
}
func newServerConfig(file string) *serverConfig {
return &serverConfig{
file: file,
}
}
func (cfg *serverConfig) update(baseURL, token string, interval int) (err error) {
if baseURL != "" {
cfg.BaseURL = baseURL
}
if token != "" {
cfg.Token = token
}
cfg.Interval = interval
reader, err := os.Create(cfg.file)
if err != nil {
return err
}
defer reader.Close()
return json.NewEncoder(reader).Encode(cfg)
}
func (cfg *serverConfig) load() (err error) {
if cfg.BaseURL != "" && cfg.Token != "" && cfg.Interval != 0 {
return
}
if file.IsNotExist(cfg.file) {
err = errors.New("no server config")
return
}
reader, err := os.Open(cfg.file)
if err != nil {
return
}
defer reader.Close()
err = json.NewDecoder(reader).Decode(cfg)
return
}

41
plugin/aipaint/context.go Normal file
View File

@@ -0,0 +1,41 @@
package aipaint
import (
"os"
"strconv"
"strings"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/process"
)
type context struct {
usrdir string
headimgsdir []string
}
func newContext(user int64) *context {
c := new(context)
c.usrdir = datapath + "users/" + strconv.FormatInt(user, 10) + `/`
_ = os.MkdirAll(c.usrdir, 0755)
c.headimgsdir = make([]string, 2)
c.headimgsdir[0] = c.usrdir + "0.gif"
c.headimgsdir[1] = c.usrdir + "1.gif"
return c
}
func (cc *context) prepareLogos(s ...string) error {
for i, v := range s {
_, err := strconv.Atoi(v)
if err != nil {
err = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.usrdir+strconv.Itoa(i)+".gif")
} else {
err = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.usrdir+strconv.Itoa(i)+".gif")
}
if err != nil {
return err
}
process.SleepAbout1sTo2s()
}
return nil
}

88
plugin/aipaint/img2img.go Normal file
View File

@@ -0,0 +1,88 @@
// Package aipaint ai绘图
package aipaint
import (
"bytes"
"fmt"
"image"
"net/url"
"os"
"strconv"
"strings"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/imgfactory"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
engine := control.Register("img2img", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Brief: "以图绘图",
Help: "- [ 以图绘图 | 以图生图 | 以图画图 ] xxx [图片]|@xxx|[qq号]\n" +
"- 官方以图绘图api已失效 需要自建api 其他配置参数同ai绘图",
PrivateDataFolder: "img2img",
})
datapath = file.BOTPATH + "/" + engine.DataFolder()
engine.OnRegex(`^(以图绘图|以图生图|以图画图)[\s\S]*?(\[CQ:(image\,file=([0-9a-zA-Z]{32}).*|at.+?(\d{5,11}))\].*|(\d+))$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := cfg.load()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
c := newContext(ctx.Event.UserID)
list := ctx.State["regex_matched"].([]string)
err = c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
args := strings.TrimSuffix(strings.TrimPrefix(list[0], list[1]), list[2])
if args == "" {
ctx.SendChain(message.Text("ERROR: 以图绘图必须添加tag"))
return
}
ctx.SendChain(message.Text("少女祈祷中..."))
postURL := cfg.BaseURL + fmt.Sprintf(aipaintImg2ImgURL, cfg.Token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20"))))
f, err := os.Open(c.headimgsdir[0])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
defer f.Close()
img, _, err := image.Decode(f)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
imageShape := ""
switch {
case img.Bounds().Dx() > img.Bounds().Dy():
imageShape = "Landscape"
case img.Bounds().Dx() == img.Bounds().Dy():
imageShape = "Square"
default:
imageShape = "Portrait"
}
// 图片转base64
base64Bytes, err := imgfactory.ToBase64(img)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
data, err := web.PostData(postURL+"&shape="+imageShape, "text/plain", bytes.NewReader(base64Bytes))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
sendAiImg(ctx, data, cfg.Interval)
})
}

View File

@@ -4,9 +4,10 @@ package aiwife
import (
"fmt"
"math/rand"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
@@ -16,14 +17,11 @@ const (
)
func init() { // 插件主体
// TODO: 1.17 特性暂不增加
// rand.Seed(time.Now().UnixMicro())
rand.Seed(time.Now().UnixNano())
control.Register("aiwife", &control.Options{
control.Register("aiwife", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "AIWife\n" +
"- waifu|随机waifu",
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).SetBlock(true).
Brief: "ai随机生成老婆",
Help: "- waifu | 随机waifu",
}).ApplySingle(ctxext.DefaultSingle).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
miku := rand.Intn(100000) + 1
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))

View File

@@ -0,0 +1,32 @@
// Package alipayvoice 支付宝到账语音
package alipayvoice
import (
"fmt"
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const (
alipayvoiceURL = "https://mm.cqu.cc/share/zhifubaodaozhang/mp3/%v.mp3"
)
func init() { // 插件主体
engine := control.Register("alipayvoice", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "支付宝到账语音",
Help: "- 支付宝到账 1",
PrivateDataFolder: "alipayvoice",
})
// 开启
engine.OnPrefix(`支付宝到账`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
args := ctx.State["args"].(string)
ctx.SendChain(message.Record(fmt.Sprintf(alipayvoiceURL, strings.TrimSpace(args))))
})
}

124
plugin/antiabuse/anti.go Normal file
View File

@@ -0,0 +1,124 @@
// Package antiabuse defines antiabuse plugin ,support abuse words check and add/remove abuse words
package antiabuse
import (
"strconv"
"strings"
"time"
"github.com/FloatTech/floatbox/binary"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/ttl"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const bandur time.Duration = time.Minute * 10
var (
managers *ctrl.Manager[*zero.Ctx] // managers lazy load
cache = ttl.NewCacheOn(bandur, [4]func(int64, struct{}){nil, nil, onDel, nil})
db *antidb
)
func onDel(uid int64, _ struct{}) {
if managers == nil {
return
}
if err := managers.DoUnblock(uid); err != nil {
logrus.Errorln("[antiabuse.onDel] unblock:", err)
}
if err := db.Del("__bantime__", "WHERE id="+strconv.FormatInt(uid, 10)); err != nil {
logrus.Errorln("[antiabuse.onDel] db:", err)
}
}
func init() {
engine := control.Register("antiabuse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "违禁词检测",
Help: "- /[添加|删除|查看]违禁词",
PrivateDataFolder: "anti_abuse",
})
onceRule := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
managers = ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager
var err error
db, err = newantidb(engine.DataFolder() + "anti_abuse.db")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
return true
})
engine.OnMessage(onceRule, zero.OnlyGroup, func(ctx *zero.Ctx) bool {
if !ctx.Event.IsToMe {
return true
}
uid := ctx.Event.UserID
gid := ctx.Event.GroupID
msg := strings.ReplaceAll(ctx.MessageString(), "\n", "")
msg = strings.ReplaceAll(msg, "\r", "")
msg = strings.ReplaceAll(msg, "\t", "")
msg = strings.ReplaceAll(msg, ";", "")
if db.isInAntiList(gid, msg) {
if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil {
t := time.Now().Unix()
cache.Set(uid, struct{}{})
ctx.SetGroupBan(gid, uid, int64(bandur.Minutes()))
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur))
db.Lock()
defer db.Unlock()
err := db.Create("__bantime__", nilbt)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Insert("__bantime__", &banTime{ID: uid, Time: t})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
} else {
ctx.SendChain(message.Text("ERROR: block user: ", err))
}
return false
}
return true
})
engine.OnCommand("添加违禁词", zero.OnlyGroup, zero.AdminPermission, onceRule).Handle(
func(ctx *zero.Ctx) {
args := ctx.State["args"].(string)
if err := db.insertWord(ctx.Event.GroupID, args); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
} else {
ctx.SendChain(message.Text("成功"))
}
})
engine.OnCommand("删除违禁词", zero.OnlyGroup, zero.AdminPermission, onceRule).Handle(
func(ctx *zero.Ctx) {
args := ctx.State["args"].(string)
if err := db.deleteWord(ctx.Event.GroupID, args); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
} else {
ctx.SendChain(message.Text("成功"))
}
})
engine.OnCommand("查看违禁词", zero.OnlyGroup, onceRule).Handle(
func(ctx *zero.Ctx) {
b, err := text.RenderToBase64(db.listWords(ctx.Event.GroupID), text.FontFile, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("本群违禁词有\n"), message.Image("base64://"+binary.BytesToString(b)))
})
}

102
plugin/antiabuse/db.go Normal file
View File

@@ -0,0 +1,102 @@
package antiabuse
import (
"errors"
"strconv"
"strings"
"sync"
"time"
sqlite "github.com/FloatTech/sqlite"
)
type antidb struct {
sync.RWMutex
sqlite.Sqlite
}
type banWord struct {
Word string `db:"word"`
}
type banTime struct {
ID int64 `db:"id"`
Time int64 `db:"time"`
}
var (
nilban = &banWord{}
nilbt = &banTime{}
)
func newantidb(path string) (*antidb, error) {
db := &antidb{Sqlite: sqlite.Sqlite{DBPath: path}}
err := db.Open(bandur)
if err != nil {
return nil, err
}
_ = db.FindFor("__bantime__", nilbt, "", func() error {
t := time.Unix(nilbt.Time, 0)
ttl := time.Until(t.Add(bandur))
if ttl < time.Minute {
_ = managers.DoUnblock(nilbt.ID)
return nil
}
cache.Set(nilbt.ID, struct{}{})
cache.Touch(nilbt.ID, -time.Since(t))
return nil
})
_ = db.Del("__bantime__", "WHERE time<="+strconv.FormatInt(time.Now().Add(time.Minute-bandur).Unix(), 10))
return db, nil
}
func (db *antidb) isInAntiList(gid int64, msg string) bool {
grp := strconv.FormatInt(gid, 36)
db.RLock()
defer db.RUnlock()
return db.CanFind(grp, "WHERE instr('"+msg+"', word)>0")
}
func (db *antidb) insertWord(gid int64, word string) error {
grp := strconv.FormatInt(gid, 36)
db.Lock()
defer db.Unlock()
err := db.Create(grp, nilban)
if err != nil {
return err
}
return db.Insert(grp, &banWord{Word: word})
}
func (db *antidb) deleteWord(gid int64, word string) error {
grp := strconv.FormatInt(gid, 36)
db.Lock()
defer db.Unlock()
if n, _ := db.Count(grp); n == 0 {
return errors.New("本群还没有违禁词~")
}
return db.Del(grp, "WHERE word='"+word+"'")
}
func (db *antidb) listWords(gid int64) string {
grp := strconv.FormatInt(gid, 36)
word := &banWord{}
sb := strings.Builder{}
sb.WriteByte('[')
i := 0
db.RLock()
defer db.RUnlock()
_ = db.FindFor(grp, word, "", func() error {
if i > 0 {
sb.WriteString(" | ")
}
sb.WriteString(word.Word)
i++
return nil
})
if sb.Len() <= 4 {
return "[]"
}
sb.WriteByte(']')
return sb.String()
}

View File

@@ -6,77 +6,87 @@ Package atri 本文件基于 https://github.com/Kyomotoi/ATRI
package atri
import (
"encoding/base64"
"math/rand"
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/process"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
)
const (
// 服务名
servicename = "atri"
// ATRI 所有命令的优先级
prio = 15
// ATRI 表情的 codechina 镜像
res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/"
)
type datagetter func(string, bool) ([]byte, error)
func (dgtr datagetter) randImage(file ...string) message.MessageSegment {
data, err := dgtr(file[rand.Intn(len(file))], true)
if err != nil {
return message.Text("ERROR: ", err)
}
return message.ImageBytes(data)
}
func (dgtr datagetter) randRecord(file ...string) message.MessageSegment {
data, err := dgtr(file[rand.Intn(len(file))], true)
if err != nil {
return message.Text("ERROR: ", err)
}
return message.Record("base64://" + base64.StdEncoding.EncodeToString(data))
}
func randText(text ...string) message.MessageSegment {
return message.Text(text[rand.Intn(len(text))])
}
// isAtriSleeping 凌晨0点到6点ATRI 在睡觉,不回应任何请求
func isAtriSleeping(*zero.Ctx) bool {
if now := time.Now().Hour(); now >= 1 && now < 6 {
return false
}
return true
}
func init() { // 插件主体
engine := control.Register(servicename, &control.Options{
engine := control.Register("atri", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "atri人格文本回复",
Help: "本插件基于 ATRI ,为 Golang 移植版\n" +
"- ATRI醒醒\n- ATRI睡吧\n- 萝卜子\n- 喜欢|爱你|爱|suki|daisuki|すき|好き|贴贴|老婆|亲一个|mua\n" +
"- 草你妈|操你妈|脑瘫|废柴|fw|废物|战斗|爬|爪巴|sb|SB|傻B\n- 早安|早哇|早上好|ohayo|哦哈哟|お早う|早好|早|早早早\n" +
"- 中午好|午安|午好\n- 晚安|oyasuminasai|おやすみなさい|晚好|晚上好\n- 高性能|太棒了|すごい|sugoi|斯国一|よかった\n" +
"- 没事|没关系|大丈夫|还好|不要紧|没出大问题|没伤到哪\n- 好吗|是吗|行不行|能不能|可不可以\n- 啊这\n- 我好了\n- |?|¿\n" +
"- ATRI醒醒\n- ATRI睡吧\n- 萝卜子\n- 喜欢 | 爱你 | 爱 | suki | daisuki | すき | 好き | 贴贴 | 老婆 | 亲一个 | mua\n" +
"- 草你妈 | 操你妈 | 脑瘫 | 废柴 | fw | 废物 | 战斗 | 爬 | 爪巴 | sb | SB | 傻B\n- 早安 | 早哇 | 早上好 | ohayo | 哦哈哟 | お早う | 早好 | 早 | 早早早\n" +
"- 中午好 | 午安 | 午好\n- 晚安 | oyasuminasai | おやすみなさい | 晚好 | 晚上好\n- 高性能 | 太棒了 | すごい | sugoi | 斯国一 | よかった\n" +
"- 没事 | 没关系 | 大丈夫 | 还好 | 不要紧 | 没出大问题 | 没伤到哪\n- 好吗 | 是吗 | 行不行 | 能不能 | 可不可以\n- 啊这\n- 我好了\n- | ? | ¿\n" +
"- 离谱\n- 答应我",
PublicDataFolder: "Atri",
OnEnable: func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("嗯呜呜……夏生先生……?"))
},
OnDisable: func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("Zzz……Zzz……"))
},
})
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio).
engine.UsePreHandler(isAtriSleeping)
var dgtr datagetter = engine.GetLazyData
engine.OnFullMatch("萝卜子").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup(servicename)
if ok && !c.IsEnabledIn(ctx.Event.GroupID) {
c.Enable(ctx.Event.GroupID)
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("嗯呜呜……夏生先生……?"))
}
})
engine.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup(servicename)
if ok && c.IsEnabledIn(ctx.Event.GroupID) {
c.Disable(ctx.Event.GroupID)
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("Zzz……Zzz……"))
}
})
engine.OnFullMatch("萝卜子", atriSleep).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
switch rand.Intn(2) {
case 0:
ctx.SendChain(randText("萝卜子是对机器人的蔑称!", "是亚托莉......萝卜子可是对机器人的蔑称"))
case 1:
ctx.SendChain(randRecord("RocketPunch.amr"))
ctx.SendChain(dgtr.randRecord("RocketPunch.amr"))
}
})
engine.OnFullMatchGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
ctx.SendChain(dgtr.randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
})
engine.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1).
engine.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randImage("FN.jpg", "WQ.jpg", "WQ1.jpg"))
ctx.SendChain(dgtr.randImage("FN.jpg", "WQ.jpg", "WQ1.jpg"))
})
engine.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う", "早好", "早", "早早早"}).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う", "早好", "早", "早早早"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
process.SleepAbout1sTo2s()
switch {
case now < 6: // 凌晨
ctx.SendChain(message.Reply(ctx.Event.MessageID), randText(
@@ -113,11 +123,10 @@ func init() { // 插件主体
))
}
})
engine.OnFullMatchGroup([]string{"中午好", "午安", "午好"}).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"中午好", "午安", "午好"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
if now > 11 && now < 15 { // 中午
process.SleepAbout1sTo2s()
ctx.SendChain(message.Reply(ctx.Event.MessageID), randText(
"午安w",
"午觉要好好睡哦ATRI会陪伴在你身旁的w",
@@ -126,10 +135,9 @@ func init() { // 插件主体
))
}
})
engine.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい", "晚好", "晚上好"}).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい", "晚好", "晚上好"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
process.SleepAbout1sTo2s()
switch {
case now < 6: // 凌晨
ctx.SendChain(message.Reply(ctx.Event.MessageID), randText(
@@ -169,9 +177,8 @@ func init() { // 插件主体
))
}
})
engine.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText(
"当然,我是高性能的嘛~",
"小事一桩,我是高性能的嘛",
@@ -190,9 +197,8 @@ func init() { // 插件主体
"呣......我的高性能,毫无遗憾地施展出来了......",
))
})
engine.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText(
"当然,我是高性能的嘛~",
"没事没事,因为我是高性能的嘛!嗯哼!",
@@ -205,67 +211,42 @@ func init() { // 插件主体
))
})
engine.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("YES.png", "NO.jpg"))
ctx.SendChain(dgtr.randImage("YES.png", "NO.jpg"))
}
})
engine.OnKeywordGroup([]string{"啊这"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"啊这"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg"))
ctx.SendChain(dgtr.randImage("AZ.jpg", "AZ1.jpg"))
}
})
engine.OnKeywordGroup([]string{"我好了"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"我好了"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(message.Reply(ctx.Event.MessageID), randText("不许好!", "憋回去!"))
})
engine.OnFullMatchGroup([]string{"", "?", "¿"}, atriSleep).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
switch rand.Intn(5) {
case 0:
ctx.SendChain(randText("?", "", "嗯?", "(。´・ω・)ん?", "ん?"))
case 1, 2:
ctx.SendChain(randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
}
})
engine.OnKeyword("离谱", atriSleep).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"", "?", "¿"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(5) {
case 0:
ctx.SendChain(randText("?", "", "嗯?", "(。´・ω・)ん?", "ん?"))
case 1, 2:
ctx.SendChain(randImage("WH.jpg"))
ctx.SendChain(dgtr.randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
}
})
engine.OnKeyword("答应我", atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeyword("离谱").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(5) {
case 0:
ctx.SendChain(randText("?", "", "嗯?", "(。´・ω・)ん?", "ん?"))
case 1, 2:
ctx.SendChain(dgtr.randImage("WH.jpg"))
}
})
engine.OnKeyword("答应我", zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText("我无法回应你的请求"))
})
}
func randText(text ...string) message.MessageSegment {
return message.Text(text[rand.Intn(len(text))])
}
func randImage(file ...string) message.MessageSegment {
return message.Image(res + file[rand.Intn(len(file))])
}
func randRecord(file ...string) message.MessageSegment {
return message.Record(res + file[rand.Intn(len(file))])
}
// atriSleep 凌晨0点到6点ATRI 在睡觉,不回应任何请求
func atriSleep(ctx *zero.Ctx) bool {
if now := time.Now().Hour(); now >= 1 && now < 6 {
return false
}
return true
}

View File

@@ -0,0 +1,29 @@
// Package autowithdraw 触发者撤回时也自动撤回
package autowithdraw
import (
"github.com/FloatTech/floatbox/process"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
control.Register("autowithdraw", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "触发者撤回时也自动撤回",
Help: "- 撤回一条消息\n",
}).OnNotice(func(ctx *zero.Ctx) bool {
return ctx.Event.NoticeType == "group_recall" || ctx.Event.NoticeType == "friend_recall"
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
id, ok := ctx.Event.MessageID.(int64)
if !ok {
return
}
for _, msg := range zero.GetTriggeredMessages(message.NewMessageIDFromInteger(id)) {
process.SleepAbout1sTo2s()
ctx.DeleteMessage(msg)
}
})
}

62
plugin/b14/main.go Normal file
View File

@@ -0,0 +1,62 @@
// Package b14coder base16384 与 tea 加解密
package b14coder
import (
"github.com/FloatTech/floatbox/crypto"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
base14 "github.com/fumiama/go-base16384"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
func init() {
en := control.Register("base16384", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "base16384加解密",
Help: "- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
})
en.OnRegex(`^加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := base14.EncodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^解密\s*([一-踀]+[㴁-㴆]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := base14.DecodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
en.OnRegex(`^用(.+)加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := base14.UTF16BE2UTF8(base14.Encode(t.Encrypt(helper.StringToBytes(str))))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(es)))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^用(.+)解密\s*([一-踀]+[㴁-㴆]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := base14.UTF82UTF16BE(helper.StringToBytes(str))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(t.Decrypt(base14.Decode(es)))))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
}

51
plugin/baidu/search.go Normal file
View File

@@ -0,0 +1,51 @@
// Package baidu 百度百科
package baidu
import (
"encoding/json"
"fmt"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const (
api = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址
)
type result struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data []struct {
Content string `json:"content"`
} `json:"data"`
}
func init() { // 主函数
en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "百度百科\n" +
"- 百度/百科[关键字]",
})
en.OnRegex(`^[百度|百科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
es, err := web.GetData(fmt.Sprintf(api, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值
if err != nil {
ctx.SendChain(message.Text("出现错误捏:", err))
return
}
var r result // r数组
err = json.Unmarshal(es, &r) // 填api返回结果struct地址
if err != nil {
ctx.SendChain(message.Text("出现错误捏:", err))
return
}
if r.Code == 0 && len(r.Data) > 0 {
ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果
} else {
ctx.SendChain(message.Text("API访问错误"))
}
})
}

292
plugin/baiduaudit/audit.go Normal file
View File

@@ -0,0 +1,292 @@
// Package baiduaudit 百度内容审核
package baiduaudit
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/Baidu-AIP/golang-sdk/aip/censor"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/floatbox/binary"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
)
var (
bdcli *censor.ContentCensorClient // 百度云审核服务Client
txttyp = [...]string{
0: "默认违禁词库",
1: "违禁违规",
2: "文本色情",
3: "敏感信息",
4: "恶意推广",
5: "低俗辱骂",
6: "恶意推广-联系方式",
7: "恶意推广-软文推广",
} // 文本类型
config = newconfig() // 插件配置
)
func init() {
engine := control.Register("baiduaudit", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "百度内容审核",
Help: "##该功能来自百度内容审核, 需购买相关服务, 并创建app##\n" +
"- 获取BDAKey\n" +
"- 配置BDAKey [API key] [Secret Key]\n" +
"- 开启/关闭内容审核\n" +
"- 开启/关闭撤回提示\n" +
"- 开启/关闭详细提示\n" +
"- 开启/关闭撤回禁言\n" +
"##禁言时间设置## 禁言时间计算方式为:禁言次数*每次禁言累加时间,当达到最大禁言时间时, 再次触发按最大禁言时间计算\n" +
"- 开启/关闭禁言累加\n" +
"- 设置撤回禁言时间[分钟, 默认:1]\n" +
"- 设置最大禁言时间[分钟, 默认:60,最大43200]\n" +
"- 设置每次累加时间[分钟, 默认:1]\n" +
"##检测类型设置## 类型编号列表:[1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广]\n" +
"- 查看检测类型\n" +
"- 查看检测配置\n" +
"- 设置检测类型[类型编号]\n" +
"- 设置不检测类型[类型编号]\n" +
"- 开启/关闭文本检测\n" +
"- 开启/关闭图像检测\n" +
"##测试功能##\n" +
"- ^文本检测[文本内容]\n" +
"- ^图像检测[图片]\n",
PrivateDataFolder: "baiduaudit",
})
configpath := engine.DataFolder() + "config.json"
err := config.load(configpath)
if err != nil {
logrus.Warnln("[baiduaudit] 加载配置错误:", err)
} else if config.Key1 != "" && config.Key2 != "" {
bdcli = censor.NewClient(config.Key1, config.Key2)
}
engine.OnFullMatch("获取BDAKey", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("接口key创建网址:\n" +
"https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index\n" +
"免费8w次数领取地址:\n" +
"https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/resource/getFree"))
})
engine.OnRegex("^查看检测(类型|配置)$", zero.AdminPermission, hasinit).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 获取群配置
group := config.groupof(ctx.Event.GroupID)
msg := ""
k1 := ctx.State["regex_matched"].([]string)[1]
if k1 == "类型" {
sb := strings.Builder{}
sb.WriteString("本群检测类型:")
found := false
// 遍历群检测类型名单
for i, v := range group.copyWhiteListType() {
if !v {
found = true
sb.WriteByte('\n')
sb.WriteString(strconv.Itoa(i))
sb.WriteByte('.')
sb.WriteString(txttyp[i])
}
}
if !found {
sb.WriteString("无")
}
msg = sb.String()
} else {
// 生成配置文本
msg = fmt.Sprintf("本群配置:\n"+
"内容审核:%s\n"+
"-文本:%s\n"+
"-图像:%s\n"+
"撤回提示:%s\n"+
"-详细提示:%s\n"+
"撤回禁言:%s\n"+
"-禁言累加:%s\n"+
"-撤回禁言时间:%v分钟\n"+
"-每次累加时间:%v分钟\n"+
"-最大禁言时间:%v分钟", group.Enable, group.TextAudit, group.ImageAudit, group.DMRemind, group.MoreRemind, group.DMBAN, group.BANTimeAddEnable, group.BANTime, group.BANTimeAddTime, group.MaxBANTimeAddRange)
}
b, err := text.RenderToBase64(msg, text.FontFile, 300, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
})
engine.OnRegex("^设置(不)?检测类型([0-7])$", zero.AdminPermission, hasinit).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
k1 := ctx.State["regex_matched"].([]string)[1]
k2 := ctx.State["regex_matched"].([]string)[2]
group := config.groupof(ctx.Event.GroupID)
inputType, _ := strconv.Atoi(k2)
group.setWhiteListType(inputType, k1 == "不")
err := config.saveto(configpath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群将%s检测%s类型内容", k1, txttyp[inputType])))
})
engine.OnRegex("^设置(最大|每次|撤回)(累加|禁言)时间(\\d{1,5})$", zero.AdminPermission, hasinit).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
k1 := ctx.State["regex_matched"].([]string)[1]
k3 := ctx.State["regex_matched"].([]string)[3]
time, _ := strconv.ParseInt(k1, 10, 64)
config.groupof(ctx.Event.GroupID).set(func(g *group) {
switch k1 {
case "最大":
g.MaxBANTimeAddRange = time
case "每次":
g.BANTimeAddTime = time
case "撤回":
g.BANTime = time
}
})
err := config.saveto(configpath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s禁言累加时间已设置为%s", k3, k1)))
})
engine.OnRegex("^(开启|关闭)(内容审核|撤回提示|撤回禁言|禁言累加|详细提示|文本检测|图像检测)$", zero.AdminPermission, hasinit).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
k1 := ctx.State["regex_matched"].([]string)[1]
k2 := ctx.State["regex_matched"].([]string)[2]
isEnable := mark(k1 == "开启")
config.groupof(ctx.Event.GroupID).set(func(g *group) {
switch k2 {
case "内容审核":
g.Enable = isEnable
case "撤回提示":
g.DMRemind = isEnable
case "撤回禁言":
g.DMBAN = isEnable
case "禁言累加":
g.BANTimeAddEnable = isEnable
case "详细提示":
g.MoreRemind = isEnable
case "文本检测":
g.TextAudit = isEnable
case "图像检测":
g.ImageAudit = isEnable
}
})
err := config.saveto(configpath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s已%s", k2, k1)))
})
engine.OnRegex(`^配置BDAKey\s(.*)\s(.*)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
k1 := ctx.State["regex_matched"].([]string)[1]
k2 := ctx.State["regex_matched"].([]string)[2]
bdcli = censor.NewClient(k1, k2)
config.setkey(k1, k2)
if bdcli != nil {
err := config.saveto(configpath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("配置成功"))
}
})
engine.OnMessage(config.isgroupexist).SetBlock(false).Handle(func(ctx *zero.Ctx) {
group := config.groupof(ctx.Event.GroupID)
if !bool(group.Enable) {
return
}
var bdres baiduRes
var err error
for _, elem := range ctx.Event.Message {
switch elem.Type {
case "image":
if !group.ImageAudit || elem.Data["url"] == "" {
continue
}
res := bdcli.ImgCensorUrl(elem.Data["url"], nil)
bdres, err = parse2BaiduRes(res)
if err != nil {
continue
}
case "text":
if !group.TextAudit || elem.Data["text"] == "" {
continue
}
bdres, err = parse2BaiduRes(bdcli.TextCensor(elem.Data["text"]))
if err != nil {
continue
}
default:
continue
}
}
bdres.audit(ctx, configpath)
})
engine.OnPrefix("^文本检测", hasinit).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
args := ctx.ExtractPlainText()
res := bdcli.TextCensor(args)
bdres, err := parse2BaiduRes(res)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
return
}
ctx.Send(config.groupof(ctx.Event.GroupID).reply(&bdres))
})
engine.OnPrefix("^图像检测", hasinit).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
var urls []string
for _, elem := range ctx.Event.Message {
if elem.Type == "image" {
if elem.Data["url"] != "" {
urls = append(urls, elem.Data["url"])
}
}
}
if len(urls) == 0 {
return
}
res := bdcli.ImgCensorUrl(urls[0], nil)
bdres, err := parse2BaiduRes(res)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
return
}
ctx.Send(config.groupof(ctx.Event.GroupID).reply(&bdres))
})
}
// 客户端是否初始化检测
func hasinit(ctx *zero.Ctx) bool {
if bdcli == nil {
ctx.SendChain(message.Text("Key未配置"))
return false
}
return true
}
func parse2BaiduRes(resjson string) (bdres baiduRes, err error) {
err = json.Unmarshal(binary.StringToBytes(resjson), &bdres)
return
}

271
plugin/baiduaudit/model.go Normal file
View File

@@ -0,0 +1,271 @@
package baiduaudit
import (
"encoding/json"
"os"
"sync"
"sync/atomic"
"github.com/FloatTech/floatbox/file"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
// 服务网址:https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index
// 返回参数说明https://cloud.baidu.com/doc/ANTIPORN/s/Nk3h6xbb2
type baiduRes struct {
mu sync.Mutex `json:"-"`
// LogID int `json:"log_id"` // 请求唯一id
Conclusion string `json:"conclusion"` // 审核结果, 可取值:合规、不合规、疑似、审核失败
ConclusionType int `json:"conclusionType"` // 审核结果类型, 可取值1.合规, 2.不合规, 3.疑似, 4.审核失败
Data []*auditData `json:"data"`
ErrorCode int `json:"error_code"` // 错误提示码, 失败才返回, 成功不返回
ErrorMsg string `json:"error_msg"` // 错误提示信息, 失败才返回, 成功不返回
}
// 禁言检测
func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) {
bdres.mu.Lock()
defer bdres.mu.Unlock()
// 如果返回类型为2不合规, 0为合规, 3为疑似
if bdres.ConclusionType != 2 {
return
}
// 创建消息ID
mid := message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64))
// 获取群配置
group := config.groupof(ctx.Event.GroupID)
// 检测群配置里的不检测类型白名单, 忽略掉不检测的违规类型
for i, b := range group.copyWhiteListType() {
if i == bdres.Data[0].SubType && b {
return
}
}
// 生成回复文本
res := group.reply(bdres)
// 撤回消息
ctx.DeleteMessage(mid)
// 查看是否启用撤回后禁言
if group.DMBAN {
// 从历史违规记录中获取指定用户
user := group.historyof(ctx.Event.UserID)
// 用户违规次数自增
atomic.AddInt64(&user.Count, 1)
user.mu.Lock()
// 用户违规原因记录
user.ResList = append(user.ResList, bdres)
user.mu.Unlock()
// 保存到json
err := config.saveto(configpath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
var bantime int64
// 查看是否开启禁言累加功能, 并计算禁言时间
if group.BANTimeAddEnable {
bantime = atomic.LoadInt64(&user.Count) * group.BANTimeAddTime * 60
} else {
bantime = group.BANTime * 60
}
// 执行禁言
ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime)
}
// 查看是否开启撤回提示
if group.DMRemind {
res = append(res, message.At(ctx.Event.Sender.ID))
ctx.Send(res)
}
}
type auditData struct {
// Type int `json:"type"` // 审核主类型, 11百度官方违禁词库、12文本反作弊、13:自定义文本黑名单、14:自定义文本白名单
SubType int `json:"subType"` // 审核子类型, 0:含多种类型, 具体看官方链接, 1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
// Conclusion string `json:"conclusion"` // 审核结果, 可取值:合规、不合规、疑似、审核失败
// ConclusionType int `json:"conclusionType"` // 审核结果类型, 可取值1.合规, 2.不合规, 3.疑似, 4.审核失败
Msg string `json:"msg"` // 不合规项描述信息
Hits []*hit `json:"hits"`
} // 不合规/疑似/命中白名单项详细信息.响应成功并且conclusion为疑似或不合规或命中白名单时才返回, 响应失败或conclusion为合规且未命中白名单时不返回.
type auditHistory struct {
mu sync.Mutex `json:"-"`
Count int64 `json:"key2"` // 被禁次数
ResList []*baiduRes `json:"reslist"` // 禁言原因
}
type hit struct {
// DatasetName string `json:"datasetName"` // 违规项目所属数据集名称
Words []string `json:"words"` // 送检文本命中词库的关键词备注建议参考新字段“wordHitPositions”, 包含信息更丰富:关键词以及对应的位置及标签信息)
// Probability float64 `json:"probability,omitempty"` // 不合规项置信度
} // 送检文本违规原因的详细信息
type keyConfig struct {
mu sync.Mutex `json:"-"`
Key1 string `json:"key1"` // 百度云服务内容审核key存储
Key2 string `json:"key2"` // 百度云服务内容审核key存储
Groups map[int64]*group `json:"groups"` // 群配置存储
}
func newconfig() (kc keyConfig) {
kc.Groups = make(map[int64]*group, 64)
return
}
func (kc *keyConfig) setkey(k1, k2 string) {
kc.mu.Lock()
defer kc.mu.Unlock()
kc.Key1 = k1
kc.Key2 = k2
}
// 加载JSON配置文件
func (kc *keyConfig) load(filename string) error {
if file.IsNotExist(filename) {
return nil
}
f, err := os.Open(filename)
if err != nil {
return err
}
kc.mu.Lock()
defer kc.mu.Unlock()
return json.NewDecoder(f).Decode(kc)
}
func (kc *keyConfig) isgroupexist(ctx *zero.Ctx) (ok bool) {
kc.mu.Lock()
defer kc.mu.Unlock()
_, ok = kc.Groups[ctx.Event.GroupID]
return
}
// 获取群配置
func (kc *keyConfig) groupof(groupID int64) *group {
kc.mu.Lock()
defer kc.mu.Unlock()
g, ok := kc.Groups[groupID]
if ok {
return g
}
g = &group{
TextAudit: true,
ImageAudit: true,
BANTime: 1,
MaxBANTimeAddRange: 60,
BANTimeAddTime: 1,
AuditHistory: map[int64]*auditHistory{},
}
kc.Groups[groupID] = g
return g
}
// 保存配置文件
func (kc *keyConfig) saveto(filename string) error {
kc.mu.Lock()
defer kc.mu.Unlock()
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
return json.NewEncoder(f).Encode(kc)
}
type group struct {
mu sync.Mutex
Enable mark // 是否启用内容审核
TextAudit mark // 文本检测
ImageAudit mark // 图像检测
DMRemind mark // 撤回提示
MoreRemind mark // 详细违规提示
DMBAN mark // 撤回后禁言
BANTimeAddEnable mark // 禁言累加
BANTime int64 // 标准禁言时间, 禁用累加, 但开启禁言的的情况下采用该值
MaxBANTimeAddRange int64 // 最大禁言时间累加范围, 最高禁言时间
BANTimeAddTime int64 // 禁言累加时间, 该值是开启禁累加功能后, 再次触发时, 根据被禁次数X该值计算出的禁言时间
WhiteListType [8]bool // 类型白名单, 处于白名单类型的违规, 不会被触发 0:含多种类型, 具体看官方链接, 1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
AuditHistory map[int64]*auditHistory // 被封禁用户列表
}
func (g *group) set(f func(g *group)) {
g.mu.Lock()
f(g)
g.mu.Unlock()
}
func (g *group) setWhiteListType(typ int, ok bool) {
g.mu.Lock()
defer g.mu.Unlock()
g.WhiteListType[typ] = ok
}
func (g *group) copyWhiteListType() [8]bool {
g.mu.Lock()
defer g.mu.Unlock()
return g.WhiteListType
}
// 从群历史违规记录中获取用户
func (g *group) historyof(userID int64) *auditHistory {
g.mu.Lock()
defer g.mu.Unlock()
audit, ok := g.AuditHistory[userID]
if ok {
return audit
}
// 如果没有用户, 则创建一个并返回
if g.AuditHistory == nil {
g.AuditHistory = make(map[int64]*auditHistory)
}
audit = &auditHistory{}
g.AuditHistory[userID] = audit
return audit
}
// 生成回复文本
func (g *group) reply(bdres *baiduRes) message.Message {
g.mu.Lock()
defer g.mu.Unlock()
// 建立消息段
msgs := make([]message.MessageSegment, 0, 8)
// 生成简略审核结果回复
msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
// 查看是否开启详细审核内容提示, 并确定审核内容值为疑似, 或者不合规
if !g.MoreRemind {
return msgs
}
// 遍历返回的不合规数据, 生成详细违规内容
for i, datum := range bdres.Data {
msgs = append(msgs, message.Text("[", i, "]:", datum.Msg, "\n"))
// 检查命中词条是否大于0
if len(datum.Hits) == 0 {
return msgs
}
// 遍历打印命中的违规词条
for _, hit := range datum.Hits {
if len(datum.Hits) == 0 {
return msgs
}
msgs = append(msgs, message.Text("("))
for i4, i3 := range hit.Words {
// 检查是否是最后一个要打印的词条, 如果是则不加上逗号
if i4 != len(hit.Words)-1 {
msgs = append(msgs, message.Text(i3, ","))
} else {
msgs = append(msgs, message.Text(i3))
}
}
msgs = append(msgs, message.Text(")"))
}
}
return msgs
}
type mark bool
// String 打印启用状态
func (em mark) String() string {
if em {
return "开启"
}
return "关闭"
}

62
plugin/base64gua/main.go Normal file
View File

@@ -0,0 +1,62 @@
// Package base64gua base64卦 与 tea 加解密
package base64gua
import (
"github.com/FloatTech/floatbox/crypto"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/fumiama/unibase2n"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
func init() {
en := control.Register("base64gua", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "六十四卦加解密",
Help: "- 六十四卦加密xxx\n- 六十四卦解密xxx\n- 六十四卦用yyy加密xxx\n- 六十四卦用yyy解密xxx",
})
en.OnRegex(`^六十四卦加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := unibase2n.Base64Gua.EncodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^六十四卦解密\s*([䷀-䷿]+[☰☱]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := unibase2n.Base64Gua.DecodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
en.OnRegex(`^六十四卦用(.+)加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := unibase2n.UTF16BE2UTF8(unibase2n.Base64Gua.Encode(t.Encrypt(helper.StringToBytes(str))))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(es)))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^六十四卦用(.+)解密\s*([䷀-䷿]+[☰☱]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := unibase2n.UTF82UTF16BE(helper.StringToBytes(str))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(t.Decrypt(unibase2n.Base64Gua.Decode(es)))))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
}

View File

@@ -0,0 +1,62 @@
// Package baseamasiro base天城文 与 tea 加解密
package baseamasiro
import (
"github.com/FloatTech/floatbox/crypto"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/fumiama/unibase2n"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
func init() {
en := control.Register("baseamasiro", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "天城文加解密",
Help: "- 天城文加密xxx\n- 天城文解密xxx\n- 天城文用yyy加密xxx\n- 天城文用yyy解密xxx",
})
en.OnRegex(`^天城文加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := unibase2n.BaseDevanagari.EncodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^天城文解密\s*([ऀ-ॿ]+[-৫]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es := unibase2n.BaseDevanagari.DecodeString(str)
if es != "" {
ctx.SendChain(message.Text(es))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
en.OnRegex(`^天城文用(.+)加密\s*(.+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := unibase2n.UTF16BE2UTF8(unibase2n.BaseDevanagari.Encode(t.Encrypt(helper.StringToBytes(str))))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(es)))
} else {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex(`^天城文用(.+)解密\s*([ऀ-ॿ]+[-৫]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
key, str := ctx.State["regex_matched"].([]string)[1], ctx.State["regex_matched"].([]string)[2]
t := crypto.GetTEA(key)
es, err := unibase2n.UTF82UTF16BE(helper.StringToBytes(str))
if err == nil {
ctx.SendChain(message.Text(helper.BytesToString(t.Decrypt(unibase2n.BaseDevanagari.Decode(es)))))
} else {
ctx.SendChain(message.Text("解密失败!"))
}
})
}

632
plugin/bilibili/bilibili.go Normal file
View File

@@ -0,0 +1,632 @@
// Package bilibili 查询b站用户信息
package bilibili
import (
"crypto/tls"
"encoding/binary"
"encoding/json"
"fmt"
"image"
"image/color"
"net/http"
"os"
"path"
"regexp"
"sort"
"strconv"
"time"
bz "github.com/FloatTech/AnimeAPI/bilibili"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/gg"
"github.com/FloatTech/imgfactory"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
re = regexp.MustCompile(`^\d+$`)
danmakuTypeMap = map[int64]string{
0: "普通消息",
1: "礼物",
2: "上舰",
3: "Superchat",
4: "进入直播间",
5: "标题变动",
6: "分区变动",
7: "直播中止",
8: "直播继续",
}
cfg = bz.NewCookieConfig("data/Bilibili/config.json")
)
// 查成分的
func init() {
engine := control.Register("bilibili", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "b站查成分查弹幕",
Help: "- >vup info [xxx]\n" +
"- >user info [xxx]\n" +
"- 查成分 [xxx]\n" +
"- 查弹幕 [xxx]\n" +
"- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" +
"- 更新vup\n" +
"Tips: (412就是拦截的意思,建议私聊把cookie设全)\n",
PublicDataFolder: "Bilibili",
})
cachePath := engine.DataFolder() + "cache/"
_ = os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
var getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
var err error
_, _ = engine.GetLazyData("bilibili.db", false)
vdb, err = initializeVup(engine.DataFolder() + "bilibili.db")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
return true
})
engine.OnRegex(`^>user info\s?(.{1,25})$`, getPara).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
id := ctx.State["uid"].(string)
card, err := bz.GetMemberCard(id)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text(
"uid: ", card.Mid, "\n",
"name: ", card.Name, "\n",
"sex: ", card.Sex, "\n",
"sign: ", card.Sign, "\n",
"level: ", card.LevelInfo.CurrentLevel, "\n",
"birthday: ", card.Birthday,
))
})
engine.OnRegex(`^>vup info\s?(.{1,25})$`, getPara).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
id := ctx.State["uid"].(string)
// 获取详情
fo, err := bz.GetVtbDetail(id)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text(
"b站id: ", fo.Mid, "\n",
"名字: ", fo.Uname, "\n",
"当前粉丝数: ", fo.Follower, "\n",
"24h涨粉数: ", fo.Rise, "\n",
"视频投稿数: ", fo.Video, "\n",
"直播间id: ", fo.Roomid, "\n",
"舰队: ", fo.GuardNum, "\n",
"直播总排名: ", fo.AreaRank, "\n",
"数据来源: ", "https://vtbs.moe/detail/", fo.Mid, "\n",
"数据获取时间: ", time.Now().Format("2006-01-02 15:04:05"),
))
})
engine.OnRegex(`^查成分\s?(.{1,25})$`, getPara, getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
id := ctx.State["uid"].(string)
today := time.Now().Format("20060102")
drawedFile := cachePath + id + today + "vupLike.png"
if file.IsExist(drawedFile) {
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
return
}
u, err := bz.GetMemberCard(id)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
vups, err := vdb.filterVup(u.Attentions)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
vupLen := len(vups)
medals, err := bz.GetMedalWall(cfg, id)
sort.Sort(bz.MedalSorter(medals))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
frontVups := make([]vup, 0)
medalMap := make(map[int64]bz.Medal)
for _, v := range medals {
up := vup{
Mid: v.Mid,
Uname: v.Uname,
}
frontVups = append(frontVups, up)
medalMap[v.Mid] = v
}
vups = append(vups, frontVups...)
copy(vups[len(frontVups):], vups)
copy(vups, frontVups)
for i := len(frontVups); i < len(vups); i++ {
if _, ok := medalMap[vups[i].Mid]; ok {
vups = append(vups[:i], vups[i+1:]...)
i--
}
}
facePath := cachePath + id + "vupFace" + path.Ext(u.Face)
backX := 500
backY := 500
var back image.Image
if path.Ext(u.Face) != ".webp" {
err = initFacePic(facePath, u.Face)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back, err = gg.LoadImage(facePath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back = imgfactory.Size(back, backX, backY).Image()
}
if len(vups) > 50 {
ctx.SendChain(message.Text(u.Name + "关注的up主太多了, 只展示前50个up"))
vups = vups[:50]
}
canvas := gg.NewContext(1500, int(500*(1.1+float64(len(vups))/3)))
fontSize := 50.0
canvas.SetColor(color.White)
canvas.Clear()
if back != nil {
canvas.DrawImage(back, 0, 0)
}
canvas.SetColor(color.Black)
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
if err = canvas.ParseFontFace(data, fontSize); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
sl, _ := canvas.MeasureString("好")
length, h := canvas.MeasureString(u.Mid)
n, _ := canvas.MeasureString(u.Name)
canvas.DrawString(u.Name, 550, 160-h)
canvas.DrawRoundedRectangle(600+n-length*0.1, 160-h*2.5, length*1.2, h*2, fontSize*0.2)
canvas.SetRGB255(221, 221, 221)
canvas.Fill()
canvas.SetColor(color.Black)
canvas.DrawString(u.Mid, 600+n, 160-h)
canvas.DrawString(fmt.Sprintf("粉丝:%d", u.Fans), 550, 240-h)
canvas.DrawString(fmt.Sprintf("关注:%d", len(u.Attentions)), 1000, 240-h)
canvas.DrawString(fmt.Sprintf("管人痴成分:%.2f%%%d/%d", float64(vupLen)/float64(len(u.Attentions))*100, vupLen, len(u.Attentions)), 550, 320-h)
regtime := time.Unix(u.Regtime, 0).Format("2006-01-02 15:04:05")
canvas.DrawString("注册日期:"+regtime, 550, 400-h)
canvas.DrawString("查询日期:"+time.Now().Format("2006-01-02"), 550, 480-h)
for i, v := range vups {
if i%2 == 1 {
canvas.SetRGB255(245, 245, 245)
canvas.DrawRectangle(0, float64(backY)*1.1+float64(i)*float64(backY)/3, float64(backX*3), float64(backY)/3)
canvas.Fill()
}
canvas.SetColor(color.Black)
nl, _ := canvas.MeasureString(v.Uname)
canvas.DrawString(v.Uname, float64(backX)*0.1, float64(backY)*1.1+float64(i+1)*float64(backY)/3-2*h)
ml, _ := canvas.MeasureString(strconv.FormatInt(v.Mid, 10))
canvas.DrawRoundedRectangle(nl-0.1*ml+float64(backX)*0.2, float64(backY)*1.1+float64(i+1)*float64(backY)/3-h*3.5, ml*1.2, h*2, fontSize*0.2)
canvas.SetRGB255(221, 221, 221)
canvas.Fill()
canvas.SetColor(color.Black)
canvas.DrawString(strconv.FormatInt(v.Mid, 10), nl+float64(backX)*0.2, float64(backY)*1.1+float64(i+1)*float64(backY)/3-2*h)
if m, ok := medalMap[v.Mid]; ok {
mnl, _ := canvas.MeasureString(m.MedalName)
grad := gg.NewLinearGradient(nl+ml-sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-3.5*h, nl+ml+mnl+sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-1.5*h)
r, g, b := int2rbg(m.MedalColorStart)
grad.AddColorStop(0, color.RGBA{R: uint8(r), G: uint8(g), B: uint8(b), A: 255})
r, g, b = int2rbg(m.MedalColorEnd)
grad.AddColorStop(1, color.RGBA{R: uint8(r), G: uint8(g), B: uint8(b), A: 255})
canvas.SetFillStyle(grad)
canvas.SetLineWidth(4)
canvas.MoveTo(nl+ml-sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-3.5*h)
canvas.LineTo(nl+ml+mnl+sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-3.5*h)
canvas.LineTo(nl+ml+mnl+sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-1.5*h)
canvas.LineTo(nl+ml-sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-1.5*h)
canvas.ClosePath()
canvas.Fill()
canvas.SetColor(color.White)
canvas.DrawString(m.MedalName, nl+ml+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-2*h)
r, g, b = int2rbg(m.MedalColorBorder)
canvas.SetRGB255(int(r), int(g), int(b))
canvas.DrawString(strconv.FormatInt(m.Level, 10), nl+ml+mnl+sl+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-2*h)
mll, _ := canvas.MeasureString(strconv.FormatInt(m.Level, 10))
canvas.SetLineWidth(4)
canvas.MoveTo(nl+ml-sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-3.5*h)
canvas.LineTo(nl+ml+mnl+mll+sl/2+float64(backX)*0.5, float64(backY)*1.1+float64(i+1)*float64(backY)/3-3.5*h)
canvas.LineTo(nl+ml+mnl+mll+sl/2+float64(backX)*0.5, float64(backY)*1.1+float64(i+1)*float64(backY)/3-1.5*h)
canvas.LineTo(nl+ml-sl/2+float64(backX)*0.4, float64(backY)*1.1+float64(i+1)*float64(backY)/3-1.5*h)
canvas.ClosePath()
canvas.Stroke()
}
}
f, err := os.Create(drawedFile)
if err != nil {
log.Errorln("[bilibili]", err)
data, err := imgfactory.ToBytes(canvas.Image())
if err != nil {
log.Errorln("[bilibili]", err)
return
}
ctx.SendChain(message.ImageBytes(data))
return
}
_, err = imgfactory.WriteTo(canvas.Image(), f)
_ = f.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
})
engine.OnRegex(`^查弹幕\s?(\S{1,25})\s?(\d*)$`, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
id := ctx.State["uid"].(string)
pagenum := ctx.State["regex_matched"].([]string)[2]
if pagenum == "" {
pagenum = "0"
}
u, err := bz.GetMemberCard(id)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
var danmaku bz.Danmakusuki
tr := &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
data, err := web.RequestDataWith(client, fmt.Sprintf(bz.DanmakuAPI, id, pagenum), "GET", "", web.RandUA(), nil)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
err = json.Unmarshal(data, &danmaku)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
today := time.Now().Format("20060102150415")
drawedFile := cachePath + id + today + "vupLike.png"
facePath := cachePath + id + "vupFace" + path.Ext(u.Face)
backX := 500
backY := 500
var back image.Image
if path.Ext(u.Face) != ".webp" {
err = initFacePic(facePath, u.Face)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back, err = gg.LoadImage(facePath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back = imgfactory.Size(back, backX, backY).Image()
}
canvas := gg.NewContext(100, 100)
fontSize := 50.0
data, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
if err = canvas.ParseFontFace(data, fontSize); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
dz, h := canvas.MeasureString("好")
danmuH := h * 2
faceH := float64(510)
totalDanmuku := 0
for i := 0; i < len(danmaku.Data.Data); i++ {
totalDanmuku += len(danmaku.Data.Data[i].Danmakus) + 1
}
cw := 3000
mcw := float64(2000)
ch := 550 + len(danmaku.Data.Data)*int(faceH) + totalDanmuku*int(danmuH)
canvas = gg.NewContext(cw, ch)
canvas.SetColor(color.White)
canvas.Clear()
canvas.SetColor(color.Black)
if err = canvas.ParseFontFace(data, fontSize); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
facestart := 100
fontH := h * 1.6
startWidth := float64(700)
startWidth2 := float64(20)
if back != nil {
canvas.DrawImage(back, facestart, 0)
}
length, _ := canvas.MeasureString(u.Mid)
n, _ := canvas.MeasureString(u.Name)
canvas.DrawString(u.Name, startWidth, 122.5)
canvas.DrawRoundedRectangle(900+n-length*0.1, 66, length*1.2, 75, fontSize*0.2)
canvas.SetRGB255(221, 221, 221)
canvas.Fill()
canvas.SetColor(color.Black)
canvas.DrawString(u.Mid, 900+n, 122.5)
canvas.DrawString(fmt.Sprintf("粉丝:%d 关注:%d", u.Fans, u.Attention), startWidth, 222.5)
canvas.DrawString(fmt.Sprintf("页码:[%d/%d]", danmaku.Data.PageNum, (danmaku.Data.Total-1)/5), startWidth, 322.5)
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)
if path.Ext(item.Channel.FaceURL) != ".webp" {
err = initFacePic(facePath, item.Channel.FaceURL)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back, err = gg.LoadImage(facePath)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
back = imgfactory.Size(back, backX, backY).Image()
}
if back != nil {
canvas.DrawImage(back, facestart, int(channelStart))
}
canvas.SetRGB255(24, 144, 255)
canvas.DrawString("标题: "+item.Live.Title, startWidth, channelStart+fontH)
canvas.DrawString("主播: "+item.Channel.Name, 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 {
canvas.DrawString("结束时间: "+time.UnixMilli(item.Live.StopDate).Format("2006-01-02 15:04:05"), startWidth, channelStart+fontH*4)
canvas.DrawString("直播时长: "+strconv.FormatFloat(float64(item.Live.StopDate-item.Live.StartDate)/3600000.0, 'f', 1, 64)+"小时", startWidth, channelStart+fontH*5)
} else {
t := "结束时间:"
l, _ := canvas.MeasureString(t)
canvas.DrawString(t, startWidth, channelStart+fontH*4)
canvas.SetRGB255(0, 128, 0)
t = "正在直播"
canvas.DrawString(t, startWidth+l*1.1, channelStart+fontH*4)
canvas.SetColor(color.Black)
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)
t := "收益:"
l, _ := canvas.MeasureString(t)
canvas.DrawString(t, startWidth, channelStart+fontH*8)
t = "¥" + strconv.Itoa(int(item.Live.TotalIncome))
canvas.SetRGB255(255, 0, 0)
canvas.DrawString(t, startWidth+l*1.1, channelStart+fontH*8)
canvas.SetColor(color.Black)
DanmakuStart := channelStart + faceH
for i := 0; i < len(item.Danmakus); i++ {
moveW := startWidth2
danmuNow := DanmakuStart + danmuH*float64(i+1)
danItem := item.Danmakus[i]
t := time.UnixMilli(danItem.SendDate).Format("15:04:05")
l, _ := canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
moveW += l + dz
t = danItem.Name
l, _ = canvas.MeasureString(t)
canvas.SetRGB255(24, 144, 255)
canvas.DrawString(t, moveW, danmuNow)
canvas.SetColor(color.Black)
moveW += l + dz
switch danItem.Type {
case 0:
t = danItem.Message
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
moveW += l + dz
case 1:
t = danmakuTypeMap[danItem.Type]
l, _ = canvas.MeasureString(t)
canvas.SetRGB255(255, 0, 0)
canvas.DrawString(t, moveW, danmuNow)
moveW += l + dz
t = danItem.Message
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
canvas.SetColor(color.Black)
moveW += l + dz
case 2, 3:
t = danmakuTypeMap[danItem.Type]
l, _ = canvas.MeasureString(t)
if danItem.Type == 3 {
canvas.SetRGB255(0, 85, 255)
} else {
canvas.SetRGB255(128, 0, 128)
}
canvas.DrawString(t, moveW, danmuNow)
moveW += l + dz
t = danItem.Message
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
moveW += l
t = "["
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
moveW += l
t = "¥" + strconv.FormatFloat(danItem.Price, 'f', 1, 64)
l, _ = canvas.MeasureString(t)
canvas.SetRGB255(255, 0, 0)
canvas.DrawString(t, moveW, danmuNow)
if danItem.Type == 3 {
canvas.SetRGB255(0, 85, 255)
} else {
canvas.SetRGB255(128, 0, 128)
}
moveW += l
t = "]"
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
canvas.SetColor(color.Black)
moveW += l + dz
case 4, 5, 6, 7, 8:
t = danmakuTypeMap[danItem.Type]
canvas.SetRGB255(0, 128, 0)
l, _ = canvas.MeasureString(t)
canvas.DrawString(t, moveW, danmuNow)
canvas.SetColor(color.Black)
moveW += l + dz
default:
canvas.SetRGB255(0, 128, 0)
l, _ = canvas.MeasureString("未知类型" + strconv.Itoa(int(danItem.Type)))
canvas.DrawString(t, moveW, danmuNow)
canvas.SetColor(color.Black)
moveW += l + dz
}
if moveW > mcw {
mcw = moveW
}
}
channelStart = DanmakuStart + float64(len(item.Danmakus)+1)*danmuH
}
im := canvas.Image().(*image.RGBA)
nim := im.SubImage(image.Rect(0, 0, int(mcw), ch))
f, err := os.Create(drawedFile)
if err != nil {
log.Errorln("[bilibili]", err)
data, err := imgfactory.ToBytes(nim)
if err != nil {
log.Errorln("[bilibili]", err)
return
}
ctx.SendChain(message.ImageBytes(data))
return
}
_, err = imgfactory.WriteTo(nim, f)
_ = f.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
})
engine.OnRegex(`^设置b站cookie?\s+(.*)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
cookie := ctx.State["regex_matched"].([]string)[1]
err := cfg.Set(cookie)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功设置b站cookie为" + cookie))
})
engine.OnFullMatch("更新vup", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
err := updateVup()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("vup已更新"))
})
}
func initFacePic(filename, faceURL string) error {
if file.IsNotExist(filename) {
data, err := web.GetData(faceURL)
if err != nil {
return err
}
err = os.WriteFile(filename, data, 0666)
if err != nil {
return err
}
}
return nil
}
func int2rbg(t int64) (int64, int64, int64) {
var buf [8]byte
binary.LittleEndian.PutUint64(buf[:], uint64(t))
b, g, r := int64(buf[0]), int64(buf[1]), int64(buf[2])
return r, g, b
}
func getPara(ctx *zero.Ctx) bool {
keyword := ctx.State["regex_matched"].([]string)[1]
if !re.MatchString(keyword) {
searchRes, err := bz.SearchUser(cfg, keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
return true
}
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
ctx.SendChain(message.Text("输入为纯数字, 请选择查询uid还是用户名, 输入对应序号:\n0. 查询uid\n1. 查询用户名"))
for {
select {
case <-time.After(time.Second * 10):
ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择查询uid"))
ctx.State["uid"] = keyword
return true
case c := <-recv:
msg := c.Event.Message.ExtractPlainText()
num, err := strconv.Atoi(msg)
if err != nil {
ctx.SendChain(message.Text("请输入数字!"))
continue
}
if num < 0 || num > 1 {
ctx.SendChain(message.Text("序号非法!"))
continue
}
if num == 0 {
ctx.State["uid"] = keyword
return true
} else if num == 1 {
searchRes, err := bz.SearchUser(cfg, keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
return true
}
}
}
}

View File

@@ -0,0 +1,107 @@
// Package bilibili bilibili卡片解析
package bilibili
import (
"regexp"
"time"
bz "github.com/FloatTech/AnimeAPI/bilibili"
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"
)
var (
limit = ctxext.NewLimiterManager(time.Second*10, 1)
searchVideo = `bilibili.com\\?/video\\?/(?:av(\d+)|([bB][vV][0-9a-zA-Z]+))`
searchDynamic = `(t.bilibili.com|m.bilibili.com\\?/dynamic)\\?/(\d+)`
searchArticle = `bilibili.com\\?/read\\?/(?:cv|mobile\\?/)(\d+)`
searchLiveRoom = `live.bilibili.com\\?/(\d+)`
searchVideoRe = regexp.MustCompile(searchVideo)
searchDynamicRe = regexp.MustCompile(searchDynamic)
searchArticleRe = regexp.MustCompile(searchArticle)
searchLiveRoomRe = regexp.MustCompile(searchLiveRoom)
)
// 插件主体
func init() {
en := control.Register("bilibiliparse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "b站链接解析",
Help: "例:- t.bilibili.com/642277677329285174\n- bilibili.com/read/cv17134450\n- bilibili.com/video/BV13B4y1x7pS\n- live.bilibili.com/22603245 ",
})
en.OnRegex(`((b23|acg).tv|bili2233.cn)/[0-9a-zA-Z]+`).SetBlock(true).Limit(limit.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["regex_matched"].([]string)[0]
realurl, err := bz.GetRealURL("https://" + url)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
switch {
case searchVideoRe.MatchString(realurl):
ctx.State["regex_matched"] = searchVideoRe.FindStringSubmatch(realurl)
handleVideo(ctx)
case searchDynamicRe.MatchString(realurl):
ctx.State["regex_matched"] = searchDynamicRe.FindStringSubmatch(realurl)
handleDynamic(ctx)
case searchArticleRe.MatchString(realurl):
ctx.State["regex_matched"] = searchArticleRe.FindStringSubmatch(realurl)
handleArticle(ctx)
case searchLiveRoomRe.MatchString(realurl):
ctx.State["regex_matched"] = searchLiveRoomRe.FindStringSubmatch(realurl)
handleLive(ctx)
}
})
en.OnRegex(searchVideo).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleVideo)
en.OnRegex(searchDynamic).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleDynamic)
en.OnRegex(searchArticle).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleArticle)
en.OnRegex(searchLiveRoom).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleLive)
}
func handleVideo(ctx *zero.Ctx) {
id := ctx.State["regex_matched"].([]string)[1]
if id == "" {
id = ctx.State["regex_matched"].([]string)[2]
}
card, err := bz.GetVideoInfo(id)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
msg, err := videoCard2msg(card)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(msg...)
}
func handleDynamic(ctx *zero.Ctx) {
msg, err := dynamicDetail(ctx.State["regex_matched"].([]string)[2])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(msg...)
}
func handleArticle(ctx *zero.Ctx) {
card, err := bz.GetArticleInfo(ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(articleCard2msg(card, ctx.State["regex_matched"].([]string)[1])...)
}
func handleLive(ctx *zero.Ctx) {
card, err := bz.GetLiveRoomInfo(ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(liveCard2msg(card)...)
}

View File

@@ -0,0 +1,90 @@
package bilibili
import (
"os"
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
"github.com/jinzhu/gorm"
"github.com/tidwall/gjson"
)
var (
vtbURLs = [...]string{"https://api.vtbs.moe/v1/short", "https://api.tokyo.vtbs.moe/v1/short", "https://vtbs.musedash.moe/v1/short"}
vdb *vupdb
)
// vupdb 分数数据库
type vupdb gorm.DB
type vup struct {
Mid int64 `gorm:"column:mid;primary_key"`
Uname string `gorm:"column:uname"`
Roomid int64 `gorm:"column:roomid"`
}
func (vup) TableName() string {
return "vup"
}
// initializeVup 初始化vup数据库
func initializeVup(dbpath string) (*vupdb, error) {
if _, err := os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
f, err := os.Create(dbpath)
if err != nil {
return nil, err
}
defer f.Close()
}
gdb, err := gorm.Open("sqlite3", dbpath)
if err != nil {
return nil, err
}
gdb.AutoMigrate(&vup{})
return (*vupdb)(gdb), nil
}
func (vdb *vupdb) insertVupByMid(mid int64, uname string, roomid int64) (err error) {
db := (*gorm.DB)(vdb)
v := vup{
Mid: mid,
Uname: uname,
Roomid: roomid,
}
if err = db.Model(&vup{}).First(&v, "mid = ? ", mid).Error; err != nil {
if gorm.IsRecordNotFoundError(err) {
err = db.Model(&vup{}).Create(&v).Error
}
}
return
}
// filterVup 筛选vup
func (vdb *vupdb) filterVup(ids []int64) (vups []vup, err error) {
db := (*gorm.DB)(vdb)
if err = db.Model(&vup{}).Find(&vups, "mid in (?)", ids).Error; err != nil {
return vups, err
}
return
}
func updateVup() error {
for _, v := range vtbURLs {
data, err := web.GetData(v)
if err != nil {
return err
}
gjson.Get(binary.BytesToString(data), "@this").ForEach(func(key, value gjson.Result) bool {
mid := value.Get("mid").Int()
uname := value.Get("uname").String()
roomid := value.Get("roomid").Int()
err = vdb.insertVupByMid(mid, uname, roomid)
return err == nil
})
if err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,377 @@
// Package bilibili b站推送
package bilibili
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"
"github.com/pkg/errors"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
bz "github.com/FloatTech/AnimeAPI/bilibili"
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
)
const (
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
referer = "https://www.bilibili.com/"
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v"
)
// bdb bilibili推送数据库
var bdb *bilibilipushdb
var (
lastTime = map[int64]int64{}
liveStatus = map[int64]int{}
upMap = map[int64]string{}
)
func init() {
en := control.Register("bilibilipush", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "b站推送",
Help: "- 添加b站订阅[uid|name]\n" +
"- 取消b站订阅[uid|name]\n" +
"- 取消b站动态订阅[uid|name]\n" +
"- 取消b站直播订阅[uid|name]\n" +
"- b站推送列表\n" +
"Tips: 需要配合job一起使用, 全局只需要设置一个, 无视响应状态推送, 下为例子\n" +
"记录在\"@every 5m\"触发的指令)\n" +
"拉取b站推送",
PrivateDataFolder: "bilibilipush",
})
// 加载bilibili推送数据库
dbpath := en.DataFolder()
dbfile := dbpath + "push.db"
bdb = initializePush(dbfile)
en.OnRegex(`^添加[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := subscribe(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
})
en.OnRegex(`^取消[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := unsubscribe(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("已取消" + name + "的订阅"))
})
en.OnRegex(`^取消[B|b]站动态订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
if err := unsubscribeDynamic(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("已取消" + name + "的动态订阅"))
})
en.OnRegex(`^取消[B|b]站直播订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
name, err := getName(buid)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if err := unsubscribeLive(buid, gid); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
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 {
gid = -ctx.Event.UserID
}
bpl := bdb.getAllPushByGroup(gid)
msg := "--------B站推送列表--------"
for _, v := range bpl {
if _, ok := upMap[v.BilibiliUID]; !ok {
bdb.updateAllUp()
}
msg += fmt.Sprintf("\nuid:%-12d 动态:", v.BilibiliUID)
if v.DynamicDisable == 0 {
msg += "●"
} else {
msg += "○"
}
msg += " 直播:"
if v.LiveDisable == 0 {
msg += "●"
} else {
msg += "○"
}
msg += " up主" + upMap[v.BilibiliUID]
}
data, err := text.RenderToBase64(msg, text.FontFile, 600, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
en.OnRegex(`拉取[B|b]站推送$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
err := sendDynamic(ctx)
if err != nil {
ctx.SendPrivateMessage(ctx.Event.UserID, message.Text("Error: bilibilipush,", err))
}
err = sendLive(ctx)
if err != nil {
ctx.SendPrivateMessage(ctx.Event.UserID, message.Text("Error: bilibilipush,", err))
}
})
}
// 取得uid的名字
func getName(buid int64) (name string, err error) {
var ok bool
if name, ok = upMap[buid]; !ok {
var data []byte
data, err = web.RequestDataWithHeaders(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", func(r *http.Request) error {
r.Header.Set("refer", referer)
r.Header.Set("user-agent", ua)
cookie := ""
if cfg != nil {
cookie, err = cfg.Load()
if err != nil {
return err
}
}
r.Header.Set("cookie", cookie)
return nil
}, nil)
if err != nil {
return
}
status := int(gjson.Get(binary.BytesToString(data), "code").Int())
if status != 0 {
err = errors.New(gjson.Get(binary.BytesToString(data), "message").String())
return
}
name = gjson.Get(binary.BytesToString(data), "data.name").String()
bdb.insertBilibiliUp(buid, name)
upMap[buid] = name
}
return
}
// subscribe 订阅
func subscribe(buid, groupid int64) (err error) {
bpMap := map[string]any{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 0,
"dynamic_disable": 0,
}
return bdb.insertOrUpdateLiveAndDynamic(bpMap)
}
// unsubscribe 取消订阅
func unsubscribe(buid, groupid int64) (err error) {
bpMap := map[string]any{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 1,
"dynamic_disable": 1,
}
return bdb.insertOrUpdateLiveAndDynamic(bpMap)
}
func unsubscribeDynamic(buid, groupid int64) (err error) {
bpMap := map[string]any{
"bilibili_uid": buid,
"group_id": groupid,
"dynamic_disable": 1,
}
return bdb.insertOrUpdateLiveAndDynamic(bpMap)
}
func unsubscribeLive(buid, groupid int64) (err error) {
bpMap := map[string]any{
"bilibili_uid": buid,
"group_id": groupid,
"live_disable": 1,
}
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)
if err != nil {
return
}
cardList = gjson.Get(binary.BytesToString(data), "data.cards").Array()
return
}
func getLiveList(uids ...int64) (string, error) {
m := make(map[string]any)
m["uids"] = uids
b, err := json.Marshal(m)
if err != nil {
return "", err
}
data, err := web.PostData(bz.LiveListURL, "application/json", bytes.NewReader(b))
if err != nil {
return "", err
}
return binary.BytesToString(data), nil
}
func sendDynamic(ctx *zero.Ctx) error {
uids := bdb.getAllBuidByDynamic()
for _, buid := range uids {
time.Sleep(2 * time.Second)
cardList, err := getUserDynamicCard(buid)
if err != nil {
return err
}
if len(cardList) == 0 {
return errors.Errorf("%v的历史动态数为0", buid)
}
t, ok := lastTime[buid]
// 第一次先记录时间,啥也不做
if !ok {
lastTime[buid] = cardList[0].Get("desc.timestamp").Int()
return nil
}
for i := len(cardList) - 1; i >= 0; i-- {
ct := cardList[i].Get("desc.timestamp").Int()
if ct > t && ct > time.Now().Unix()-600 {
lastTime[buid] = ct
m, ok := control.Lookup("bilibilipush")
if ok {
groupList := bdb.getAllGroupByBuidAndDynamic(buid)
dc, err := bz.LoadDynamicDetail(cardList[i].Raw)
if err != nil {
err = errors.Errorf("动态%v的解析有问题,%v", cardList[i].Get("desc.dynamic_id_str"), err)
return err
}
msg, err := dynamicCard2msg(&dc)
if err != nil {
err = errors.Errorf("动态%v的解析有问题,%v", cardList[i].Get("desc.dynamic_id_str"), err)
return err
}
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
time.Sleep(time.Millisecond * 100)
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
}
}
}
}
}
}
}
return nil
}
func sendLive(ctx *zero.Ctx) error {
uids := bdb.getAllBuidByLive()
ll, err := getLiveList(uids...)
if err != nil {
return err
}
gjson.Get(ll, "data").ForEach(func(key, value gjson.Result) bool {
newStatus := int(value.Get("live_status").Int())
if newStatus == 2 {
newStatus = 0
}
if _, ok := liveStatus[key.Int()]; !ok {
liveStatus[key.Int()] = newStatus
return true
}
oldStatus := liveStatus[key.Int()]
if newStatus != oldStatus && newStatus == 1 {
liveStatus[key.Int()] = newStatus
m, ok := control.Lookup("bilibilipush")
if ok {
groupList := bdb.getAllGroupByBuidAndLive(key.Int())
roomID := value.Get("short_id").Int()
if roomID == 0 {
roomID = value.Get("room_id").Int()
}
lURL := bz.LiveURL + strconv.FormatInt(roomID, 10)
lName := value.Get("uname").String()
lTitle := value.Get("title").String()
lCover := value.Get("cover_from_user").String()
if lCover == "" {
lCover = value.Get("keyframe").String()
}
var msg []message.MessageSegment
msg = append(msg, message.Text(lName+" 正在直播:\n"))
msg = append(msg, message.Text(lTitle))
msg = append(msg, message.Image(lCover))
msg = append(msg, message.Text("直播链接:", lURL))
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
time.Sleep(time.Millisecond * 100)
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
}
}
}
}
} else if newStatus != oldStatus {
liveStatus[key.Int()] = newStatus
}
return true
})
return nil
}

View File

@@ -1,14 +1,13 @@
package bilibilipush
package bilibili
import (
"encoding/json"
"os"
"github.com/jinzhu/gorm"
_ "github.com/logoove/sqlite" // import sql
)
// bilibilipushdb bili推送数据库
// bilibilipushdb bilibili推送数据库
type bilibilipushdb gorm.DB
type bilibilipush struct {
@@ -34,8 +33,8 @@ func (bilibiliup) TableName() string {
return "bilibili_up"
}
// initialize 初始化ScoreDB数据库
func initialize(dbpath string) *bilibilipushdb {
// initializePush 初始化bilibilipushdb数据库
func initializePush(dbpath string) *bilibilipushdb {
var err error
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
@@ -54,17 +53,23 @@ func initialize(dbpath string) *bilibilipushdb {
}
// insertOrUpdateLiveAndDynamic 插入或更新数据库
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interface{}) (err error) {
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]any) (err error) {
db := (*gorm.DB)(bdb)
bp := bilibilipush{}
data, _ := json.Marshal(&bpMap)
_ = json.Unmarshal(data, &bp)
if err = db.Debug().Model(&bilibilipush{}).First(&bp, "bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Error; err != nil {
data, err := json.Marshal(&bpMap)
if err != nil {
return
}
err = json.Unmarshal(data, &bp)
if err != nil {
return
}
if err = db.Model(&bilibilipush{}).First(&bp, "bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Error; err != nil {
if gorm.IsRecordNotFoundError(err) {
err = db.Debug().Model(&bilibilipush{}).Create(&bp).Error
err = db.Model(&bilibilipush{}).Create(&bp).Error
}
} else {
err = db.Debug().Model(&bilibilipush{}).Where("bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Update(bpMap).Error
err = db.Model(&bilibilipush{}).Where("bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Update(bpMap).Error
}
return
}
@@ -72,7 +77,7 @@ func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interfa
func (bdb *bilibilipushdb) getAllBuidByLive() (buidList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Debug().Model(&bilibilipush{}).Find(&bpl, "live_disable = 0")
db.Model(&bilibilipush{}).Find(&bpl, "live_disable = 0")
temp := make(map[int64]bool)
for _, v := range bpl {
_, ok := temp[v.BilibiliUID]
@@ -87,7 +92,7 @@ func (bdb *bilibilipushdb) getAllBuidByLive() (buidList []int64) {
func (bdb *bilibilipushdb) getAllBuidByDynamic() (buidList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Debug().Model(&bilibilipush{}).Find(&bpl, "dynamic_disable = 0")
db.Model(&bilibilipush{}).Find(&bpl, "dynamic_disable = 0")
temp := make(map[int64]bool)
for _, v := range bpl {
_, ok := temp[v.BilibiliUID]
@@ -102,7 +107,7 @@ func (bdb *bilibilipushdb) getAllBuidByDynamic() (buidList []int64) {
func (bdb *bilibilipushdb) getAllGroupByBuidAndLive(buid int64) (groupList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Debug().Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and live_disable = 0", buid)
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and live_disable = 0", buid)
for _, v := range bpl {
groupList = append(groupList, v.GroupID)
}
@@ -112,7 +117,7 @@ func (bdb *bilibilipushdb) getAllGroupByBuidAndLive(buid int64) (groupList []int
func (bdb *bilibilipushdb) getAllGroupByBuidAndDynamic(buid int64) (groupList []int64) {
db := (*gorm.DB)(bdb)
var bpl []bilibilipush
db.Debug().Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and dynamic_disable = 0", buid)
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and dynamic_disable = 0", buid)
for _, v := range bpl {
groupList = append(groupList, v.GroupID)
}
@@ -121,7 +126,7 @@ func (bdb *bilibilipushdb) getAllGroupByBuidAndDynamic(buid int64) (groupList []
func (bdb *bilibilipushdb) getAllPushByGroup(groupID int64) (bpl []bilibilipush) {
db := (*gorm.DB)(bdb)
db.Debug().Model(&bilibilipush{}).Find(&bpl, "group_id = ? and (live_disable = 0 or dynamic_disable = 0)", groupID)
db.Model(&bilibilipush{}).Find(&bpl, "group_id = ? and (live_disable = 0 or dynamic_disable = 0)", groupID)
return
}
@@ -131,13 +136,13 @@ func (bdb *bilibilipushdb) insertBilibiliUp(buid int64, name string) {
BilibiliUID: buid,
Name: name,
}
db.Debug().Model(&bilibiliup{}).Create(bu)
db.Model(&bilibiliup{}).Create(bu)
}
func (bdb *bilibilipushdb) updateAllUp() {
db := (*gorm.DB)(bdb)
var bul []bilibiliup
db.Debug().Model(&bilibiliup{}).Find(&bul)
db.Model(&bilibiliup{}).Find(&bul)
for _, v := range bul {
upMap[v.BilibiliUID] = v.Name
}

326
plugin/bilibili/card2msg.go Normal file
View File

@@ -0,0 +1,326 @@
package bilibili
import (
"encoding/json"
"time"
bz "github.com/FloatTech/AnimeAPI/bilibili"
"github.com/FloatTech/floatbox/binary"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
msgType = map[int]string{
1: "转发了动态",
2: "有图营业",
4: "无图营业",
8: "投稿了视频",
16: "投稿了短视频",
64: "投稿了文章",
256: "投稿了音频",
2048: "发布了简报",
4200: "发布了直播",
4308: "发布了直播",
}
)
// dynamicCard2msg 处理DynCard
func dynamicCard2msg(dynamicCard *bz.DynamicCard) (msg []message.MessageSegment, err error) {
var (
card bz.Card
vote bz.Vote
cType int
)
msg = make([]message.MessageSegment, 0, 16)
// 初始化结构体
err = json.Unmarshal(binary.StringToBytes(dynamicCard.Card), &card)
if err != nil {
return
}
if dynamicCard.Extension.Vote != "" {
err = json.Unmarshal(binary.StringToBytes(dynamicCard.Extension.Vote), &vote)
if err != nil {
return
}
}
cType = dynamicCard.Desc.Type
// 生成消息
switch cType {
case 1:
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
card.Item.Content, "\n",
"转发的内容: \n"))
var originMsg []message.MessageSegment
var co bz.Card
co, err = bz.LoadCardDetail(card.Origin)
if err != nil {
return
}
originMsg, err = card2msg(dynamicCard, &co, card.Item.OrigType)
if err != nil {
return
}
msg = append(msg, originMsg...)
case 2:
msg = append(msg, message.Text(card.User.Name, "在", time.Unix(int64(card.Item.UploadTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Description))
for i := 0; i < len(card.Item.Pictures); i++ {
msg = append(msg, message.Image(card.Item.Pictures[i].ImgSrc))
}
case 4:
msg = append(msg, message.Text(card.User.Uname, "在", time.Unix(int64(card.Item.Timestamp), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Content, "\n"))
if dynamicCard.Extension.Vote != "" {
msg = append(msg, message.Text("【投票】", vote.Desc, "\n",
"截止日期: ", time.Unix(int64(vote.Endtime), 0).Format("2006-01-02 15:04:05"), "\n",
"参与人数: ", bz.HumanNum(vote.JoinNum), "\n",
"投票选项( 最多选择", vote.ChoiceCnt, "项 )\n"))
for i := 0; i < len(vote.Options); i++ {
msg = append(msg, message.Text("- ", vote.Options[i].Idx, ". ", vote.Options[i].Desc, "\n"))
if vote.Options[i].ImgURL != "" {
msg = append(msg, message.Image(vote.Options[i].ImgURL))
}
}
}
case 8:
msg = append(msg, message.Text(card.Owner.Name, "在", time.Unix(int64(card.Pubdate), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title))
msg = append(msg, message.Image(card.Pic))
msg = append(msg, message.Text(card.Desc, "\n",
card.ShareSubtitle, "\n",
"视频链接: ", card.ShortLink, "\n"))
case 16:
msg = append(msg, message.Text(card.User.Name, "在", time.Unix(int64(card.Item.UploadTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Description))
msg = append(msg, message.Image(card.Item.Cover.Default))
case 64:
msg = append(msg, message.Text(card.Author.(map[string]any)["name"], "在", time.Unix(int64(card.PublishTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title, "\n",
card.Summary))
for i := 0; i < len(card.ImageUrls); i++ {
msg = append(msg, message.Image(card.ImageUrls[i]))
}
if card.ID != 0 {
msg = append(msg, message.Text("文章链接: https://www.bilibili.com/read/cv", card.ID, "\n"))
}
case 256:
msg = append(msg, message.Text(card.Upper, "在", time.Unix(int64(card.Ctime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title))
msg = append(msg, message.Image(card.Cover))
msg = append(msg, message.Text(card.Intro, "\n"))
if card.ID != 0 {
msg = append(msg, message.Text("音频链接: https://www.bilibili.com/audio/au", card.ID, "\n"))
}
case 2048:
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
card.Vest.Content, "\n",
card.Sketch.Title, "\n",
card.Sketch.DescText, "\n"))
msg = append(msg, message.Image(card.Sketch.CoverURL))
msg = append(msg, message.Text("分享链接: ", card.Sketch.TargetURL, "\n"))
case 4308:
if dynamicCard.Desc.UserProfile.Info.Uname != "" {
msg = append(msg, message.Text(dynamicCard.Desc.UserProfile.Info.Uname, msgType[cType], "\n"))
}
msg = append(msg, message.Image(card.LivePlayInfo.Cover))
msg = append(msg, message.Text("\n", card.LivePlayInfo.Title, "\n",
"房间号: ", card.LivePlayInfo.RoomID, "\n",
"分区: ", card.LivePlayInfo.ParentAreaName))
if card.LivePlayInfo.ParentAreaName != card.LivePlayInfo.AreaName {
msg = append(msg, message.Text("-", card.LivePlayInfo.AreaName))
}
if card.LivePlayInfo.LiveStatus == 0 {
msg = append(msg, message.Text("未开播 \n"))
} else {
msg = append(msg, message.Text("直播中 ", card.LivePlayInfo.WatchedShow, "\n"))
}
msg = append(msg, message.Text("直播链接: ", card.LivePlayInfo.Link))
default:
msg = append(msg, message.Text("动态id: ", dynamicCard.Desc.DynamicIDStr, "未知动态类型: ", cType, "\n"))
}
if dynamicCard.Desc.DynamicIDStr != "" {
msg = append(msg, message.Text("动态链接: ", bz.TURL, dynamicCard.Desc.DynamicIDStr))
}
return
}
// card2msg cType=1, 2, 4, 8, 16, 64, 256, 2048, 4200, 4308时,处理Card字符串,cType为card类型
func card2msg(dynamicCard *bz.DynamicCard, card *bz.Card, cType int) (msg []message.MessageSegment, err error) {
var (
vote bz.Vote
)
msg = make([]message.MessageSegment, 0, 16)
// 生成消息
switch cType {
case 1:
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
card.Item.Content, "\n",
"转发的内容: \n"))
var originMsg []message.MessageSegment
var co bz.Card
co, err = bz.LoadCardDetail(card.Origin)
if err != nil {
return
}
originMsg, err = card2msg(dynamicCard, &co, card.Item.OrigType)
if err != nil {
return
}
msg = append(msg, originMsg...)
case 2:
msg = append(msg, message.Text(card.User.Name, "在", time.Unix(int64(card.Item.UploadTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Description))
for i := 0; i < len(card.Item.Pictures); i++ {
msg = append(msg, message.Image(card.Item.Pictures[i].ImgSrc))
}
case 4:
msg = append(msg, message.Text(card.User.Uname, "在", time.Unix(int64(card.Item.Timestamp), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Content, "\n"))
if dynamicCard.Extension.Vote != "" {
msg = append(msg, message.Text("【投票】", vote.Desc, "\n",
"截止日期: ", time.Unix(int64(vote.Endtime), 0).Format("2006-01-02 15:04:05"), "\n",
"参与人数: ", bz.HumanNum(vote.JoinNum), "\n",
"投票选项( 最多选择", vote.ChoiceCnt, "项 )\n"))
for i := 0; i < len(vote.Options); i++ {
msg = append(msg, message.Text("- ", vote.Options[i].Idx, ". ", vote.Options[i].Desc, "\n"))
if vote.Options[i].ImgURL != "" {
msg = append(msg, message.Image(vote.Options[i].ImgURL))
}
}
}
case 8:
msg = append(msg, message.Text(card.Owner.Name, "在", time.Unix(int64(card.Pubdate), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title))
msg = append(msg, message.Image(card.Pic))
msg = append(msg, message.Text(card.Desc, "\n",
card.ShareSubtitle, "\n",
"视频链接: ", card.ShortLink, "\n"))
case 16:
msg = append(msg, message.Text(card.User.Name, "在", time.Unix(int64(card.Item.UploadTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Item.Description))
msg = append(msg, message.Image(card.Item.Cover.Default))
case 64:
msg = append(msg, message.Text(card.Author.(map[string]any)["name"], "在", time.Unix(int64(card.PublishTime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title, "\n",
card.Summary))
for i := 0; i < len(card.ImageUrls); i++ {
msg = append(msg, message.Image(card.ImageUrls[i]))
}
if card.ID != 0 {
msg = append(msg, message.Text("文章链接: https://www.bilibili.com/read/cv", card.ID, "\n"))
}
case 256:
msg = append(msg, message.Text(card.Upper, "在", time.Unix(int64(card.Ctime), 0).Format("2006-01-02 15:04:05"), msgType[cType], "\n",
card.Title))
msg = append(msg, message.Image(card.Cover))
msg = append(msg, message.Text(card.Intro, "\n"))
if card.ID != 0 {
msg = append(msg, message.Text("音频链接: https://www.bilibili.com/audio/au", card.ID, "\n"))
}
case 2048:
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
card.Vest.Content, "\n",
card.Sketch.Title, "\n",
card.Sketch.DescText, "\n"))
msg = append(msg, message.Image(card.Sketch.CoverURL))
msg = append(msg, message.Text("分享链接: ", card.Sketch.TargetURL, "\n"))
case 4308:
if dynamicCard.Desc.UserProfile.Info.Uname != "" {
msg = append(msg, message.Text(dynamicCard.Desc.UserProfile.Info.Uname, msgType[cType], "\n"))
}
msg = append(msg, message.Image(card.LivePlayInfo.Cover))
msg = append(msg, message.Text("\n", card.LivePlayInfo.Title, "\n",
"房间号: ", card.LivePlayInfo.RoomID, "\n",
"分区: ", card.LivePlayInfo.ParentAreaName))
if card.LivePlayInfo.ParentAreaName != card.LivePlayInfo.AreaName {
msg = append(msg, message.Text("-", card.LivePlayInfo.AreaName))
}
if card.LivePlayInfo.LiveStatus == 0 {
msg = append(msg, message.Text("未开播 \n"))
} else {
msg = append(msg, message.Text("直播中 ", card.LivePlayInfo.WatchedShow, "\n"))
}
msg = append(msg, message.Text("直播链接: ", card.LivePlayInfo.Link))
default:
msg = append(msg, message.Text("动态id: ", dynamicCard.Desc.DynamicIDStr, "未知动态类型: ", cType, "\n"))
}
if dynamicCard.Desc.DynamicIDStr != "" {
msg = append(msg, message.Text("动态链接: ", bz.TURL, dynamicCard.Desc.DynamicIDStr))
}
return
}
// dynamicDetail 用动态id查动态信息
func dynamicDetail(dynamicIDStr string) (msg []message.MessageSegment, err error) {
dyc, err := bz.GetDynamicDetail(dynamicIDStr)
if err != nil {
return
}
return dynamicCard2msg(&dyc)
}
// articleCard2msg 专栏转消息
func articleCard2msg(card bz.Card, defaultID string) (msg []message.MessageSegment) {
msg = make([]message.MessageSegment, 0, 16)
for i := 0; i < len(card.OriginImageUrls); i++ {
msg = append(msg, message.Image(card.OriginImageUrls[i]))
}
msg = append(msg, message.Text("\n", card.Title, "\n", "UP主: ", card.AuthorName, "\n",
"阅读: ", bz.HumanNum(card.Stats.View), " 评论: ", bz.HumanNum(card.Stats.Reply), "\n",
bz.CVURL, defaultID))
return
}
// liveCard2msg 直播卡片转消息
func liveCard2msg(card bz.RoomCard) (msg []message.MessageSegment) {
msg = make([]message.MessageSegment, 0, 16)
msg = append(msg, message.Image(card.RoomInfo.Keyframe))
msg = append(msg, message.Text("\n", card.RoomInfo.Title, "\n",
"主播: ", card.AnchorInfo.BaseInfo.Uname, "\n",
"房间号: ", card.RoomInfo.RoomID, "\n"))
if card.RoomInfo.ShortID != 0 {
msg = append(msg, message.Text("短号: ", card.RoomInfo.ShortID, "\n"))
}
msg = append(msg, message.Text("分区: ", card.RoomInfo.ParentAreaName))
if card.RoomInfo.ParentAreaName != card.RoomInfo.AreaName {
msg = append(msg, message.Text("-", card.RoomInfo.AreaName))
}
if card.RoomInfo.LiveStatus == 0 {
msg = append(msg, message.Text("未开播 \n"))
} else {
msg = append(msg, message.Text("直播中 ", bz.HumanNum(card.RoomInfo.Online), "人气\n"))
}
if card.RoomInfo.ShortID != 0 {
msg = append(msg, message.Text("直播间链接: ", bz.LURL, card.RoomInfo.ShortID))
} else {
msg = append(msg, message.Text("直播间链接: ", bz.LURL, card.RoomInfo.RoomID))
}
return
}
// videoCard2msg 视频卡片转消息
func videoCard2msg(card bz.Card) (msg []message.MessageSegment, err error) {
var mCard bz.MemberCard
msg = make([]message.MessageSegment, 0, 16)
mCard, err = bz.GetMemberCard(card.Owner.Mid)
if err != nil {
return
}
msg = append(msg, message.Text("标题: ", card.Title, "\n"))
if card.Rights.IsCooperation == 1 {
for i := 0; i < len(card.Staff); i++ {
msg = append(msg, message.Text(card.Staff[i].Title, ": ", card.Staff[i].Name, " 粉丝: ", bz.HumanNum(card.Staff[i].Follower), "\n"))
}
} else {
msg = append(msg, message.Text("UP主: ", card.Owner.Name, " 粉丝: ", bz.HumanNum(mCard.Fans), "\n"))
}
msg = append(msg, message.Text("播放: ", bz.HumanNum(card.Stat.View), " 弹幕: ", bz.HumanNum(card.Stat.Danmaku)))
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))
return
}

View File

@@ -0,0 +1,84 @@
package bilibili
import (
"testing"
bz "github.com/FloatTech/AnimeAPI/bilibili"
)
func TestArticleInfo(t *testing.T) {
card, err := bz.GetArticleInfo("17279244")
if err != nil {
t.Fatal(err)
}
t.Log(articleCard2msg(card, "17279244"))
}
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 {
t.Fatal(err)
}
t.Logf("%+v\n", card)
}
func TestVideoInfo(t *testing.T) {
card, err := bz.GetVideoInfo("10007")
if err != nil {
t.Fatal(err)
}
t.Log(videoCard2msg(card))
card, err = bz.GetVideoInfo("BV1xx411c7mD")
if err != nil {
t.Fatal(err)
}
t.Log(videoCard2msg(card))
card, err = bz.GetVideoInfo("bv1xx411c7mD")
if err != nil {
t.Fatal(err)
}
t.Log(videoCard2msg(card))
card, err = bz.GetVideoInfo("BV1mF411j7iU")
if err != nil {
t.Fatal(err)
}
t.Log(videoCard2msg(card))
}
func TestLiveRoomInfo(t *testing.T) {
card, err := bz.GetLiveRoomInfo("83171")
if err != nil {
t.Fatal(err)
}
t.Log(liveCard2msg(card))
}

View File

@@ -0,0 +1,75 @@
// Package bookreview 书评
package bookreview
import (
"time"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/floatbox/binary"
fcext "github.com/FloatTech/floatbox/ctxext"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
)
func init() {
engine := control.Register("bookreview", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "哀伤雪刃推书书评",
Help: "- 书评[xxx]\n- 随机书评",
PublicDataFolder: "BookReview",
})
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
db.DBPath = engine.DataFolder() + "bookreview.db"
// os.RemoveAll(dbpath)
_, _ = engine.GetLazyData("bookreview.db", true)
err := db.Open(time.Hour * 24)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Create("bookreview", &book{})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
n, err := db.Count("bookreview")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
log.Infof("[bookreview]读取%d条书评", n)
return true
})
// 中文、英文、数字但不包括下划线等符号
engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$", getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
data, err := text.RenderToBase64(b.BookReview, text.FontFile, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
engine.OnFullMatch("随机书评", getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
br := getRandomBookReview()
data, err := text.RenderToBase64(br.BookReview, text.FontFile, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
}

View File

@@ -1,10 +1,14 @@
package bookreview
import sql "github.com/FloatTech/sqlite"
type book struct {
ID uint64 `db:"id"`
BookReview string `db:"bookreview"`
}
var db = &sql.Sqlite{}
// 暂时随机选择一个书评
func getBookReviewByKeyword(keyword string) (b book) {
_ = db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")

View File

@@ -0,0 +1,50 @@
// Package breakrepeat 打断复读
package breakrepeat
import (
"math/rand"
"strconv"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/RomiChan/syncx"
zero "github.com/wdvxdr1123/ZeroBot"
)
const throttle = 3 // 不可超过 9
var sm syncx.Map[int64, string]
func init() {
engine := control.Register("breakrepeat", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "打断复读",
Help: "- 打断" + strconv.Itoa(throttle) + "次以上复读\n",
})
engine.On("message/group", zero.OnlyGroup, func(ctx *zero.Ctx) bool {
return !zero.HasPicture(ctx)
}).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
raw := ctx.Event.RawMessage
r, ok := sm.Load(gid)
if !ok || len(r) <= 3 || r[3:] != raw {
sm.Store(gid, "0: "+raw)
return
}
c := int(r[0] - '0')
if c < throttle {
sm.Store(gid, strconv.Itoa(c+1)+": "+raw)
return
}
sm.Delete(gid)
if len(r) > 5 {
ru := []rune(r[3:])
rand.Shuffle(len(ru), func(i, j int) {
ru[i], ru[j] = ru[j], ru[i]
})
r = string(ru)
}
ctx.Send(r)
})
}

View File

@@ -9,9 +9,9 @@ import (
"net/url"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/antchfx/htmlquery"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
@@ -22,7 +22,6 @@ const (
searchURL = "https://www.shicimingju.com/cangtoushi/index.html"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
referer = "https://www.shicimingju.com/cangtoushi/index.html"
prio = 20
)
var (
@@ -31,92 +30,110 @@ var (
)
func init() {
engine := control.Register("cangtoushi", &control.Options{
engine := control.Register("cangtoushi", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "藏头诗\n" +
"- 藏头诗[xxx]\n- 藏尾诗[xxx]",
Brief: "藏头诗, 藏尾诗",
Help: "- 藏头诗[xxx]\n- 藏尾诗[xxx]",
})
engine.OnRegex("藏头诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
engine.OnRegex(`藏头诗\s?([一-龥]{3,10})$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
kw := ctx.State["regex_matched"].([]string)[1]
login()
err := login()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
data, err := search(kw, "7", "0")
if err != nil {
log.Errorln("[cangtoushi]:", err)
ctx.SendChain(message.Text("ERROR: ", err))
return
}
text, err := dealHTML(helper.BytesToString(data))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
text := dealHTML(helper.BytesToString(data))
ctx.SendChain(message.Text(text))
})
engine.OnRegex("藏尾诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
engine.OnRegex(`藏尾诗\s?([一-龥]{3,10})$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
kw := ctx.State["regex_matched"].([]string)[1]
login()
err := login()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
data, err := search(kw, "7", "2")
if err != nil {
log.Errorln("[cangtoushi]:", err)
ctx.SendChain(message.Text("ERROR: ", err))
return
}
text, err := dealHTML(helper.BytesToString(data))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
text := dealHTML(helper.BytesToString(data))
ctx.SendChain(message.Text(text))
})
}
func login() {
func login() error {
gCurCookieJar, _ = cookiejar.New(nil)
client := &http.Client{
Jar: gCurCookieJar,
}
request, err := http.NewRequest("GET", loginURL, nil)
if err != nil {
log.Errorln("[cangtoushi]:", err)
return err
}
request.Header.Add("User-Agent", ua)
response, err := client.Do(request)
if err != nil {
log.Errorln("[cangtoushi]:", err)
return err
}
data, err := io.ReadAll(response.Body)
if err != nil {
log.Errorln("[cangtoushi]:", err)
return err
}
response.Body.Close()
doc, err := htmlquery.Parse(strings.NewReader(helper.BytesToString(data)))
if err != nil {
log.Errorln("[cangtoushi]:", err)
return err
}
csrf = htmlquery.SelectAttr(htmlquery.FindOne(doc, "//input[@name='_csrf']"), "value")
return nil
}
func search(kw, zishu, position string) (data []byte, err error) {
postStr := fmt.Sprintf("_csrf=%s&kw=%s&zishu=%s&position=%s", url.QueryEscape(csrf), url.QueryEscape(kw), zishu, position)
log.Println("postStr:", postStr)
client := &http.Client{
Jar: gCurCookieJar,
}
request, err := http.NewRequest("POST", searchURL, strings.NewReader(postStr))
if err != nil {
log.Errorln("[cangtoushi]:", err)
return nil, err
}
request.Header.Add("Referer", referer)
request.Header.Add("User-Agent", ua)
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
response, err := client.Do(request)
if err != nil {
log.Errorln("[cangtoushi]:", err)
return nil, err
}
data, err = io.ReadAll(response.Body)
if err != nil {
log.Errorln("[cangtoushi]:", err)
return nil, err
}
response.Body.Close()
return
}
func dealHTML(data string) (text string) {
func dealHTML(data string) (text string, err error) {
doc, err := htmlquery.Parse(strings.NewReader(data))
if err != nil {
log.Errorln("[cangtoushi]:", err)
return "", err
}
text = htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@class='card']/div[@class='card']"))
text = strings.ReplaceAll(text, " ", "")
text = strings.Replace(text, "\n", "", 1)
return text
return text, nil
}

View File

@@ -6,31 +6,25 @@ import (
"strconv"
"time"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
)
const (
dbpath = "data/Chat/"
dbfile = dbpath + "kimoi.json"
prio = 10
)
var (
poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
engine = control.Register("chat", &control.Options{
poke = rate.NewManager[int64](time.Minute*5, 8) // 戳一戳
engine = control.Register("chat", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]\n- mua|啾咪|摸|上你|傻|裸|贴|老婆|抱|亲|一下|咬|操|123|进去|调教|搓|让|捏|挤|略|呐|原味|胖次|内裤|内衣|衣服|ghs|批|憨批|kkp|咕|骚|喜欢|suki|好き|看|不能|砸了|透|口我|草我|自慰|onani|オナニー|炸了|色图|涩图|告白|对不起|回来|吻|软|壁咚|掰开|女友|是|喵|嗷呜|叫|拜|佬|awsl|臭|香|腿|张开|脚|脸|头发|手|pr|舔|小穴|腰|诶嘿嘿|可爱|扭蛋|鼻|眼|色气|推|床|举|手冲|饿|变|敲|爬|怕|冲|射|不穿|迫害|猫粮|揪尾巴|薄荷|早|晚安|揉|榨|掐|胸|奶子|欧派|嫩|蹭|牵手|握手|拍照|w|睡不着|欧尼酱|哥|爱你|过来|自闭|打不过|么么哒|很懂|膝枕|累了|安慰|洗澡|一起睡觉|一起|多大|姐姐|糖|嗦|牛子|🐂子|🐮子|嫌弃|紧|baka|笨蛋|插|插进来|屁股|翘|翘起来|抬|抬起|爸|傲娇|rua|咕噜咕噜|咕噜|上床|做爱|吃掉|吃|揪|种草莓|种草|掀|妹|病娇|嘻",
Brief: "基础反应, 群空调",
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]",
})
kimomap = make(kimo, 256)
chatList = make([]string, 0, 256)
)
func init() { // 插件主体
// 被喊名字
engine.OnFullMatch("", zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnFullMatch("", zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var nickname = zero.BotConfig.NickName[0]
time.Sleep(time.Second * 1)
@@ -44,7 +38,7 @@ func init() { // 插件主体
))
})
// 戳一戳
engine.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).SetPriority(prio).
engine.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
var nickname = zero.BotConfig.NickName[0]
switch {
@@ -63,18 +57,18 @@ func init() { // 插件主体
// 群空调
var AirConditTemp = map[int64]int{}
var AirConditSwitch = map[int64]bool{}
engine.OnFullMatch("空调开").SetBlock(true).SetPriority(prio).
engine.OnFullMatch("空调开").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
AirConditSwitch[ctx.Event.GroupID] = true
ctx.SendChain(message.Text("❄️哔~"))
})
engine.OnFullMatch("空调关").SetBlock(true).SetPriority(prio).
engine.OnFullMatch("空调关").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
AirConditSwitch[ctx.Event.GroupID] = false
delete(AirConditTemp, ctx.Event.GroupID)
ctx.SendChain(message.Text("💤哔~"))
})
engine.OnRegex(`设置温度(\d+)`).SetBlock(true).SetPriority(prio).
engine.OnRegex(`设置温度(\d+)`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if _, exist := AirConditTemp[ctx.Event.GroupID]; !exist {
AirConditTemp[ctx.Event.GroupID] = 26
@@ -93,7 +87,7 @@ func init() { // 插件主体
))
}
})
engine.OnFullMatch(`群温度`).SetBlock(true).SetPriority(prio).
engine.OnFullMatch(`群温度`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if _, exist := AirConditTemp[ctx.Event.GroupID]; !exist {
AirConditTemp[ctx.Event.GroupID] = 26
@@ -110,13 +104,4 @@ func init() { // 插件主体
))
}
})
initChatList(func() {
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).SetPriority(prio).Handle(
func(ctx *zero.Ctx) {
key := ctx.MessageString()
val := *kimomap[key]
text := val[rand.Intn(len(val))]
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
})
}

View File

@@ -6,19 +6,20 @@ import (
"strconv"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
engine := control.Register("choose", &control.Options{
engine := control.Register("choose", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "choose\n" +
"- 选择可口可乐还是百事可乐\n" +
"- 选择肯德基还是麦当劳还是必胜客",
Brief: "选择困难症帮手",
Help: "例: 选择可口可乐还是百事可乐\n" +
"选择肯德基还是麦当劳还是必胜客",
})
engine.OnPrefix("选择").SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("选择").SetBlock(true).Handle(handle)
}
func handle(ctx *zero.Ctx) {
rawOptions := strings.Split(ctx.State["args"].(string), "还是")

View File

@@ -0,0 +1,73 @@
// Package chouxianghua 抽象话转化
package chouxianghua
import (
"time"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
fcext "github.com/FloatTech/floatbox/ctxext"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
)
func init() {
en := control.Register("chouxianghua", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "翻译为抽象话",
Help: "- 抽象翻译xxx",
PublicDataFolder: "ChouXiangHua",
})
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$",
fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
db.DBPath = en.DataFolder() + "cxh.db"
// os.RemoveAll(dbpath)
_, _ = en.GetLazyData("cxh.db", true)
err := db.Open(time.Hour * 24)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Create("pinyin", &pinyin{})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
n, err := db.Count("pinyin")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
logrus.Printf("[chouxianghua]读取%d条拼音", n)
return true
}),
).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
r := cx(ctx.State["regex_matched"].([]string)[1])
ctx.SendChain(message.Text(r))
})
}
func cx(s string) (r string) {
h := []rune(s)
for i := 0; i < len(h); i++ {
if i < len(h)-1 {
e := getEmojiByPronun(getPronunByDWord(h[i], h[i+1]))
if e != "" {
r += e
i++
continue
}
}
e := getEmojiByPronun(getPinyinByWord(string(h[i])))
if e != "" {
r += e
continue
}
r += string(h[i])
}
return
}

View File

@@ -1,5 +1,7 @@
package chouxianghua
import sql "github.com/FloatTech/sqlite"
type pinyin struct {
Word string `db:"word"`
Pronun string `db:"pronunciation"`
@@ -9,6 +11,8 @@ type emoji struct {
Emoji string `db:"emoji"`
}
var db = &sql.Sqlite{}
func getPinyinByWord(word string) string {
var p pinyin
_ = db.Find("pinyin", &p, "where word = '"+word+"'")

33
plugin/chrev/init.go Normal file
View File

@@ -0,0 +1,33 @@
// Package chrev 英文字符反转
package chrev
import (
"strings"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
// 初始化engine
engine := control.Register("chrev", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "英文字符翻转",
Help: "例: 翻转 I love you",
})
// 处理字符翻转指令
engine.OnRegex(`^翻转\s*([A-Za-z\s]*)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 获取需要翻转的字符串
str := ctx.State["regex_matched"].([]string)[1]
// 将字符顺序翻转
tmp := strings.Builder{}
for i := len(str) - 1; i >= 0; i-- {
tmp.WriteRune(charMap[str[i]])
}
// 发送翻转后的字符串
ctx.SendChain(message.Text(tmp.String()))
})
}

59
plugin/chrev/map.go Normal file
View File

@@ -0,0 +1,59 @@
package chrev
var charMap [256]rune
func init() {
charMap[' '] = ' '
charMap['a'] = 'ɐ'
charMap['b'] = 'q'
charMap['c'] = 'ɔ'
charMap['d'] = 'p'
charMap['e'] = 'ǝ'
charMap['f'] = 'ɟ'
charMap['g'] = 'ƃ'
charMap['h'] = 'ɥ'
charMap['i'] = 'ᴉ'
charMap['j'] = 'ɾ'
charMap['k'] = 'ʞ'
charMap['l'] = 'l'
charMap['m'] = 'ɯ'
charMap['n'] = 'u'
charMap['o'] = 'o'
charMap['p'] = 'd'
charMap['q'] = 'b'
charMap['r'] = 'ɹ'
charMap['s'] = 's'
charMap['t'] = 'ʇ'
charMap['u'] = 'n'
charMap['v'] = 'ʌ'
charMap['w'] = 'ʍ'
charMap['x'] = 'x'
charMap['y'] = 'ʎ'
charMap['z'] = 'z'
charMap['A'] = '∀'
charMap['B'] = 'ᗺ'
charMap['C'] = 'Ɔ'
charMap['D'] = 'ᗡ'
charMap['E'] = 'Ǝ'
charMap['F'] = 'Ⅎ'
charMap['G'] = '⅁'
charMap['H'] = 'H'
charMap['I'] = 'I'
charMap['J'] = 'ſ'
charMap['K'] = 'ʞ'
charMap['L'] = '˥'
charMap['M'] = 'W'
charMap['N'] = 'N'
charMap['O'] = 'O'
charMap['P'] = 'Ԁ'
charMap['Q'] = 'Ò'
charMap['R'] = 'ᴚ'
charMap['S'] = 'S'
charMap['T'] = '⏊'
charMap['U'] = '∩'
charMap['V'] = 'Λ'
charMap['W'] = 'M'
charMap['X'] = 'X'
charMap['Y'] = '⅄'
charMap['Z'] = 'Z'
}

71
plugin/coser/coser.go Normal file
View File

@@ -0,0 +1,71 @@
// Package coser images
package coser
import (
"errors"
"math/rand"
"os"
"time"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/AnimeAPI/setu"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
var (
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
coserURL = "http://ovooa.com/API/cosplay/api.php"
)
func init() {
p, err := setu.NewPool(setu.DefaultPoolDir,
func(s string) (string, error) {
if s != "coser" {
return "", errors.New("invalid call")
}
typ := setu.DefaultPoolDir + "/" + "coser"
if file.IsNotExist(typ) {
err := os.MkdirAll(typ, 0755)
if err != nil {
return "", err
}
}
data, err := web.RequestDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua, nil)
if err != nil {
return "", err
}
arr := gjson.Get(helper.BytesToString(data), "data.data").Array()
if len(arr) == 0 {
return "", errors.New("data is empty")
}
pic := arr[rand.Intn(len(arr))]
return pic.String(), nil
}, web.GetData, time.Minute)
if err != nil {
panic(err)
}
control.Register("coser", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "三次元coser",
Help: "- coser",
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser").SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
pic, err := p.Roll("coser")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if id := ctx.Send(message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+pic))}).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
})
}

74
plugin/cpstory/cpstory.go Normal file
View File

@@ -0,0 +1,74 @@
// Package cpstory cp短打
package cpstory
import (
"strings"
"time"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/math"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
)
func init() {
engine := control.Register("cpstory", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "cp短打", // 这里也许有更好的名字
Help: "- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
PublicDataFolder: "CpStory",
})
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
db.DBPath = engine.DataFolder() + "cp.db"
// os.RemoveAll(dbpath)
_, _ = engine.GetLazyData("cp.db", true)
err := db.Open(time.Hour * 24)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Create("cp_story", &cpstory{})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
n, err := db.Count("cp_story")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
logrus.Printf("[cpstory]读取%d条故事", n)
return true
})
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cs := getRandomCpStory()
gong := ctx.CardOrNickName(math.Str2Int64(ctx.State["regex_matched"].([]string)[1]))
shou := ctx.CardOrNickName(math.Str2Int64(ctx.State["regex_matched"].([]string)[2]))
text := strings.ReplaceAll(cs.Story, "<攻>", gong)
text = strings.ReplaceAll(text, "<受>", shou)
text = strings.ReplaceAll(text, cs.Gong, gong)
text = strings.ReplaceAll(text, cs.Shou, shou)
ctx.SendChain(message.Text(text))
})
engine.OnPrefix("磕cp", getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cs := getRandomCpStory()
params := strings.Split(ctx.State["args"].(string), " ")
if len(params) < 2 {
ctx.SendChain(message.Text(ctx.Event.MessageID), message.Text("请用空格分开两个人名"))
} else {
gong := params[0]
shou := params[1]
text := strings.ReplaceAll(cs.Story, "<攻>", gong)
text = strings.ReplaceAll(text, "<受>", shou)
text = strings.ReplaceAll(text, cs.Gong, gong)
text = strings.ReplaceAll(text, cs.Shou, gong)
ctx.SendChain(message.Text(text))
}
})
}

View File

@@ -1,5 +1,7 @@
package cpstory
import sql "github.com/FloatTech/sqlite"
type cpstory struct {
ID int64 `db:"id"`
Gong string `db:"gong"`
@@ -7,6 +9,8 @@ type cpstory struct {
Story string `db:"story"`
}
var db = &sql.Sqlite{}
func getRandomCpStory() (cs cpstory) {
_ = db.Pick("cp_story", &cs)
return

74
plugin/curse/curse.go Normal file
View File

@@ -0,0 +1,74 @@
// Package curse 骂人插件(求骂,自卫)
package curse
import (
"time"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/process"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
const (
minLevel = "min"
maxLevel = "max"
)
func init() {
engine := control.Register("curse", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Brief: "骂人反击",
Help: "- 骂我\n- 大力骂我",
PublicDataFolder: "Curse",
})
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
db.DBPath = engine.DataFolder() + "curse.db"
_, err := engine.GetLazyData("curse.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Open(time.Hour * 24)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Create("curse", &curse{})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
c, err := db.Count("curse")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
logrus.Infoln("[curse]加载", c, "条骂人语录")
return true
})
engine.OnFullMatch("骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
text := getRandomCurseByLevel(minLevel).Text
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
engine.OnFullMatch("大力骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
text := getRandomCurseByLevel(maxLevel).Text
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe, getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
text := getRandomCurseByLevel(maxLevel).Text
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
}

View File

@@ -1,11 +1,15 @@
package curse
import sql "github.com/FloatTech/sqlite"
type curse struct {
ID uint32 `db:"id"`
Text string `db:"text"`
Level string `db:"level"`
}
var db = &sql.Sqlite{}
func getRandomCurseByLevel(level string) (c curse) {
_ = db.Find("curse", &c, "where level = '"+level+"' ORDER BY RANDOM() limit 1")
return

View File

@@ -0,0 +1,37 @@
// Package dailynews 今日早报
package dailynews
import (
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
const api = "http://dwz.2xb.cn/zaob"
func init() {
engine := control.Register("dailynews", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "今日早报",
Help: "- 今日早报",
PrivateDataFolder: "dailynews",
})
engine.OnFullMatch(`今日早报`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData(api)
if err != nil {
return
}
picURL := gjson.Get(binary.BytesToString(data), "imageUrl").String()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image(picURL))
})
}

51
plugin/danbooru/main.go Normal file
View File

@@ -0,0 +1,51 @@
// Package deepdanbooru 二次元图片标签识别
package deepdanbooru
import (
"crypto/md5"
"encoding/hex"
"strings"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/imgfactory"
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"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
func init() { // 插件主体
engine := control.Register("danbooru", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "二次元图片标签识别",
Help: "- 鉴赏图片[图片]",
PrivateDataFolder: "danbooru",
})
cachefolder := engine.DataFolder()
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyGroup, zero.MustProvidePicture).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
t, st, err := tagurl("", url)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
digest := md5.Sum(helper.StringToBytes(url))
f := cachefolder + hex.EncodeToString(digest[:])
if file.IsNotExist(f) {
_ = imgfactory.SavePNG2Path(f, t)
}
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+f))}
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text("tags: ", strings.Join(st.tseq, ","))))
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
}
})
}

119
plugin/danbooru/tag.go Normal file
View File

@@ -0,0 +1,119 @@
package deepdanbooru
import (
"bytes"
"encoding/json"
"fmt"
"image"
"net/url"
"sort"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/gg"
"github.com/FloatTech/imgfactory"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text" // jpg png gif
_ "golang.org/x/image/webp" // webp
)
const api = "https://nsfwtag.azurewebsites.net/api/tag?limit=0.5&url="
type sorttags struct {
tags map[string]float64
tseq []string
}
func newsorttags(tags map[string]float64) (s *sorttags) {
t := make([]string, 0, len(tags))
for k := range tags {
t = append(t, k)
}
return &sorttags{tags: tags, tseq: t}
}
func (s *sorttags) Len() int {
return len(s.tags)
}
func (s *sorttags) Less(i, j int) bool {
v1 := s.tseq[i]
v2 := s.tseq[j]
return s.tags[v1] >= s.tags[v2]
}
// Swap swaps the elements with indexes i and j.
func (s *sorttags) Swap(i, j int) {
s.tseq[j], s.tseq[i] = s.tseq[i], s.tseq[j]
}
func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
ch := make(chan []byte, 1)
go func() {
var data []byte
data, err = web.GetData(u)
ch <- data
}()
data, err := web.GetData(api + url.QueryEscape(u))
if err != nil {
return
}
tags := make(map[string]float64)
err = json.Unmarshal(data, &tags)
if err != nil {
return
}
longestlen := 0
for k := range tags {
if len(k) > longestlen {
longestlen = len(k)
}
}
longestlen++
st = newsorttags(tags)
sort.Sort(st)
boldfd, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
if err != nil {
return
}
consfd, err := file.GetLazyData(text.ConsolasFontFile, control.Md5File, true)
if err != nil {
return
}
data = <-ch
if err != nil {
return
}
img, _, err := image.Decode(bytes.NewReader(data))
if err != nil {
return
}
img = imgfactory.Limit(img, 1280, 720)
canvas := gg.NewContext(img.Bounds().Size().X, img.Bounds().Size().Y+int(float64(img.Bounds().Size().X)*0.2)+len(tags)*img.Bounds().Size().X/25)
canvas.SetRGB(1, 1, 1)
canvas.Clear()
canvas.DrawImage(img, 0, 0)
if err = canvas.ParseFontFace(boldfd, float64(img.Bounds().Size().X)*0.1); err != nil {
return
}
canvas.SetRGB(0, 0, 0)
canvas.DrawString(name, float64(img.Bounds().Size().X)*0.02, float64(img.Bounds().Size().Y)+float64(img.Bounds().Size().X)*0.1)
i := float64(img.Bounds().Size().Y) + float64(img.Bounds().Size().X)*0.2
if err = canvas.ParseFontFace(consfd, float64(img.Bounds().Size().X)*0.04); err != nil {
return
}
rate := float64(img.Bounds().Size().X) * 0.04
for _, k := range st.tseq {
canvas.DrawString(fmt.Sprintf("* %-*s -%.3f-", longestlen, k, tags[k]), float64(img.Bounds().Size().X)*0.04, i)
i += rate
}
im = canvas.Image()
return
}

56
plugin/diana/bing.go Normal file
View File

@@ -0,0 +1,56 @@
// Package diana 虚拟偶像女团 A-SOUL 成员嘉然相关
package diana
import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
fcext "github.com/FloatTech/floatbox/ctxext"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
)
var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "嘉然相关", // 也许使用常用功能当Brief更好
Help: "- 小作文\n" +
"- 发大病\n" +
"- 教你一篇小作文[作文]",
PublicDataFolder: "Diana",
})
func init() {
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
err := data.LoadText(engine.DataFolder() + "text.db")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
return true
})
// 随机发送一篇上面的小作文
engine.OnFullMatch("小作文", getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 绕过第一行发病
ctx.SendChain(message.Text(data.RandText()))
})
// 逆天
engine.OnFullMatch("发大病", getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 第一行是发病
ctx.SendChain(message.Text(data.HentaiText()))
})
// 增加小作文
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission, getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
} else {
ctx.SendChain(message.Text("记住啦!"))
}
})
}

71
plugin/diana/data/text.go Normal file
View File

@@ -0,0 +1,71 @@
// Package data 加载位于 datapath 的小作文
package data
import (
"crypto/md5"
"encoding/binary"
"time"
binutils "github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/file"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/control"
"github.com/sirupsen/logrus"
)
var db = sql.Sqlite{}
type text struct {
ID int64 `db:"id"`
Data string `db:"data"`
}
// LoadText 加载小作文
func LoadText(dbfile string) error {
_, err := file.GetLazyData(dbfile, control.Md5File, false)
db.DBPath = dbfile
if err != nil {
return err
}
err = db.Open(time.Hour * 24)
if err != nil {
return err
}
err = db.Create("text", &text{})
if err != nil {
return err
}
c, err := db.Count("text")
if err != nil {
return err
}
logrus.Printf("[Diana]读取%d条小作文", c)
return nil
}
// AddText 添加小作文
func AddText(txt string) error {
s := md5.Sum(binutils.StringToBytes(txt))
i := binary.LittleEndian.Uint64(s[:8])
return db.Insert("text", &text{ID: int64(i), Data: txt})
}
// RandText 随机小作文
func RandText() string {
var t text
err := db.Pick("text", &t)
if err != nil {
return err.Error()
}
return t.Data
}
// HentaiText 发大病
func HentaiText() string {
var t text
err := db.Find("text", &t, "where id = -3802576048116006195")
if err != nil {
return err.Error()
}
return t.Data
}

253
plugin/drawlots/main.go Normal file
View File

@@ -0,0 +1,253 @@
// Package drawlots 多功能抽签插件
package drawlots
import (
"bytes"
"errors"
"image"
"image/color"
"image/gif"
"math/rand"
"os"
"strconv"
"strings"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/imgfactory"
ctrl "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
"github.com/fumiama/jieba/util/helper"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
type info struct {
lotsType string // 文件后缀
quantity int // 签数
}
var (
lotsList = func() map[string]info {
lotsList, err := getList()
if err != nil {
logrus.Infoln("[drawlots]加载失败:", err)
} else {
logrus.Infoln("[drawlots]加载", len(lotsList), "个抽签")
}
return lotsList
}()
en = control.Register("drawlots", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "多功能抽签",
Help: "支持图包文件夹和gif抽签\n" +
"-------------\n" +
"- (刷新)抽签列表\n- 抽[签名]签\n- 看[gif签名]签\n- 加[签名]签[gif图片]\n- 删[gif签名]签",
PrivateDataFolder: "drawlots",
}).ApplySingle(ctxext.DefaultSingle)
datapath = file.BOTPATH + "/" + en.DataFolder()
)
func init() {
en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
lotsList, err := getList() // 刷新列表
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
messageText := &strings.Builder{}
messageText.WriteString(" 签 名 [ 类 型 ]----签数\n")
messageText.WriteString("———————————\n")
for name, fileInfo := range lotsList {
messageText.WriteString(name + "[" + fileInfo.lotsType + "]----" + strconv.Itoa(fileInfo.quantity) + "\n")
messageText.WriteString("----------\n")
}
textPic, err := text.RenderToBase64(messageText.String(), text.BoldFontFile, 400, 50)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image("base64://" + helper.BytesToString(textPic)))
})
en.OnRegex(`^抽(.+)签$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
lotsType := ctx.State["regex_matched"].([]string)[1]
fileInfo, ok := lotsList[lotsType]
if !ok {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("才...才没有", lotsType, "签这种东西啦")))
return
}
if fileInfo.lotsType == "folder" {
picPath, err := randFile(lotsType, 3)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("file:///"+picPath))
return
}
lotsImg, err := randGif(lotsType + "." + fileInfo.lotsType)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
// 生成图片
data, err := imgfactory.ToBytes(lotsImg)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.ImageBytes(data))
})
en.OnRegex(`^看(.+)签$`, zero.UserOrGrpAdmin).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
id := ctx.Event.MessageID
lotsName := ctx.State["regex_matched"].([]string)[1]
fileInfo, ok := lotsList[lotsName]
if !ok {
ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦")))
return
}
if fileInfo.lotsType == "folder" {
ctx.Send(message.ReplyWithMessage(id, message.Text("只能查看gif签哦~")))
return
}
ctx.Send(message.ReplyWithMessage(id, message.Image("file:///"+datapath+lotsName+"."+fileInfo.lotsType)))
})
en.OnRegex(`^加(.+)签.*`, zero.SuperUserPermission, zero.MustProvidePicture).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
id := ctx.Event.MessageID
lotsName := ctx.State["regex_matched"].([]string)[1]
if lotsName == "" {
ctx.Send(message.ReplyWithMessage(id, message.Text("请使用正确的指令形式哦~")))
return
}
picURL := ctx.State["image_url"].([]string)[0]
gifdata, err := web.GetData(picURL)
if err != nil {
return
}
im, err := gif.DecodeAll(bytes.NewReader(gifdata))
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
fileName := datapath + "/" + lotsName + ".gif"
err = file.DownloadTo(picURL, fileName)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
lotsList[lotsName] = info{
lotsType: "gif",
quantity: len(im.Image),
}
ctx.Send(message.ReplyWithMessage(id, message.Text("成功!")))
})
en.OnRegex(`^删(.+)签$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
id := ctx.Event.MessageID
lotsName := ctx.State["regex_matched"].([]string)[1]
fileInfo, ok := lotsList[lotsName]
if !ok {
ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦")))
return
}
if fileInfo.lotsType == "folder" {
ctx.Send(message.ReplyWithMessage(id, message.Text("为了防止误删图源,图包请手动移除哦~")))
return
}
err := os.Remove(datapath + lotsName + "." + fileInfo.lotsType)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
delete(lotsList, lotsName)
ctx.Send(message.ReplyWithMessage(id, message.Text("成功!")))
})
}
func getList() (list map[string]info, err error) {
list = make(map[string]info, 100)
files, err := os.ReadDir(datapath)
if err != nil {
return
}
if len(files) == 0 {
err = errors.New("什么签也没有哦~")
return
}
for _, lots := range files {
if lots.IsDir() {
files, _ := os.ReadDir(datapath + "/" + lots.Name())
list[lots.Name()] = info{
lotsType: "folder",
quantity: len(files),
}
continue
}
before, after, ok := strings.Cut(lots.Name(), ".")
if !ok || before == "" {
continue
}
file, err := os.Open(datapath + "/" + lots.Name())
if err != nil {
return nil, err
}
im, err := gif.DecodeAll(file)
_ = file.Close()
if err != nil {
return nil, err
}
list[before] = info{
lotsType: after,
quantity: len(im.Image),
}
}
return
}
func randFile(path string, indexMax int) (string, error) {
picPath := datapath + path
files, err := os.ReadDir(picPath)
if err != nil {
return "", err
}
if len(files) > 0 {
drawFile := files[rand.Intn(len(files))]
// 如果是文件夹就递归
if drawFile.IsDir() {
indexMax--
if indexMax <= 0 {
return "", errors.New("图包[" + path + "]存在太多非图片文件,请清理~")
}
return randFile(path, indexMax)
}
return picPath + "/" + drawFile.Name(), err
}
return "", errors.New("图包[" + path + "]不存在签内容!")
}
func randGif(gifName string) (image.Image, error) {
name := datapath + gifName
file, err := os.Open(name)
if err != nil {
return nil, err
}
im, err := gif.DecodeAll(file)
_ = file.Close()
if err != nil {
return nil, err
}
/*
firstImg, err := imgfactory.Load(name)
if err != nil {
return nil, err
}
v := im.Image[rand.Intn(len(im.Image))]
return imgfactory.Size(firstImg, firstImg.Bounds().Dx(), firstImg.Bounds().Dy()).InsertUpC(v, 0, 0, firstImg.Bounds().Dx()/2, firstImg.Bounds().Dy()/2).Clone().Image(),err
/*/
// 如果gif图片出现信息缺失请使用上面注释掉的代码把下面注释了(上面代码部分图存在bug)
v := im.Image[rand.Intn(len(im.Image))]
return imgfactory.NewFactoryBG(v.Rect.Dx(), v.Rect.Dy(), color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err
// */
}

39
plugin/dress/api.go Normal file
View File

@@ -0,0 +1,39 @@
package dress
import (
"fmt"
"github.com/FloatTech/floatbox/web"
"github.com/tidwall/gjson"
)
const (
dressURL = "http://www.yoooooooooo.com/gitdress"
male = "dress"
female = "girldress"
dressListURL = dressURL + "/%v/album/list.json"
dressDetailURL = dressURL + "/%v/album/%v/info.json"
dressImageURL = dressURL + "/%v/album/%v/%v-m.webp"
)
func dressList(sex string) (dressList []string, err error) {
data, err := web.GetData(fmt.Sprintf(dressListURL, sex))
if err != nil {
return
}
arr := gjson.ParseBytes(data).Get("@this").Array()
dressList = make([]string, len(arr))
for i, v := range arr {
dressList[i] = v.String()
}
return
}
func detail(sex, name string) (count int, err error) {
data, err := web.GetData(fmt.Sprintf(dressDetailURL, sex, name))
if err != nil {
return
}
count = int(gjson.ParseBytes(data).Get("@this.#").Int())
return
}

113
plugin/dress/dress.go Normal file
View File

@@ -0,0 +1,113 @@
// Package dress 女装
package dress
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
"github.com/FloatTech/floatbox/binary"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
engine := control.Register("dress", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "女装",
Help: "女装\n" +
"- 女装\n" +
"- 男装\n" +
"- 随机女装\n" +
"- 随机男装",
PrivateDataFolder: "dress",
})
engine.OnFullMatchGroup([]string{"女装", "男装"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
matched := ctx.State["matched"].(string)
sex := male
if matched == "男装" {
sex = female
}
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
nameList, err := dressList(sex)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
tex := "请输入" + matched + "序号\n"
for i, v := range nameList {
tex += fmt.Sprintf("%d. %s\n", i, v)
}
base64Str, err := text.RenderToBase64(tex, text.FontFile, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("base64://" + binary.BytesToString(base64Str)))
for {
select {
case <-time.After(time.Second * 120):
ctx.SendChain(message.Text(matched, "指令过期"))
return
case c := <-recv:
msg := c.Event.Message.ExtractPlainText()
num, err := strconv.Atoi(msg)
if err != nil {
ctx.SendChain(message.Text("请输入数字!"))
continue
}
if num < 0 || num >= len(nameList) {
ctx.SendChain(message.Text("序号非法!"))
continue
}
name := nameList[num]
sendImage(ctx, sex, matched, name)
return
}
}
})
engine.OnFullMatchGroup([]string{"随机女装", "随机男装"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
matched := strings.TrimPrefix(ctx.State["matched"].(string), "随机")
sex := male
if matched == "男装" {
sex = female
}
nameList, err := dressList(sex)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
name := nameList[rand.Intn(len(nameList))]
sendImage(ctx, sex, matched, name)
})
}
func sendImage(ctx *zero.Ctx, sex, matched, name string) {
ctx.SendChain(message.Text("请欣赏", matched, ": ", name))
count, err := detail(sex, name)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
imageList := make([]string, count)
for i := range imageList {
imageList[i] = fmt.Sprintf(dressImageURL, sex, name, i+1)
}
m := message.Message{}
for _, v := range imageList {
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(v)))
}
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
}

109
plugin/drift_bottle/main.go Normal file
View File

@@ -0,0 +1,109 @@
// Package driftbottle 漂流瓶
package driftbottle
import (
"fmt"
"hash/crc64"
"strconv"
"sync"
"time"
"unicode/utf8"
"github.com/FloatTech/floatbox/binary"
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 sea struct {
ID int64 `db:"id"` // ID qq_grp_name_msg 的 crc64 hashCheck.
QQ int64 `db:"qq"` // Get current user(Who sends this)
Name string `db:"Name"` // his or her name at that time:P
Msg string `db:"msg"` // What he or she sent to bot?
Grp int64 `db:"grp"` // which group sends this msg?
Time string `db:"time"` // we need to know the current time,master>
}
var seaSide = &sql.Sqlite{}
var seaLocker sync.RWMutex
// We need a container to inject what we need :(
func init() {
en := control.Register("driftbottle", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "漂流瓶",
Help: "- @bot pick" + "- @bot throw xxx (xxx为投递内容)",
PrivateDataFolder: "driftbottle",
})
seaSide.DBPath = en.DataFolder() + "sea.db"
err := seaSide.Open(time.Hour * 24)
if err != nil {
panic(err)
}
_ = createChannel(seaSide)
en.OnFullMatch("pick", zero.OnlyToMe, zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
be, err := fetchBottle(seaSide)
if err != nil {
ctx.SendChain(message.Text("ERR:", err))
}
idstr := strconv.Itoa(int(be.ID))
qqstr := strconv.Itoa(int(be.QQ))
grpstr := strconv.Itoa(int(be.Grp))
botname := zero.BotConfig.NickName[0]
msg := message.Message{message.CustomNode(botname, ctx.Event.SelfID, botname+"试着帮你捞出来了这个~\nID:"+idstr+"\n投递人: "+be.Name+"("+qqstr+")"+"\n群号: "+grpstr+"\n时间: "+be.Time+"\n内容: \n"+be.Msg)}
ctx.Send(msg)
})
en.OnRegex(`throw.*?(.*)`, zero.OnlyToMe, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
senderFormatTime := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
rawSenderMessage := ctx.State["regex_matched"].([]string)[1]
rawMessageCallBack := message.UnescapeCQCodeText(rawSenderMessage)
keyWordsNum := utf8.RuneCountInString(rawMessageCallBack)
if keyWordsNum < 10 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("需要投递的内容过少( "))
return
}
// check current needs and prepare to throw drift_bottle.
err = globalbottle(
ctx.Event.UserID,
ctx.Event.GroupID,
senderFormatTime,
ctx.CardOrNickName(ctx.Event.UserID),
rawMessageCallBack,
).throw(seaSide)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已经帮你丢出去了哦~")))
})
}
func globalbottle(qq, grp int64, time, name, msg string) *sea { // Check as if the User is available and collect information to store.
id := int64(crc64.Checksum(binary.StringToBytes(fmt.Sprintf("%d_%d_%s_%s_%s", grp, qq, time, name, msg)), crc64.MakeTable(crc64.ISO)))
return &sea{ID: id, Grp: grp, Time: time, QQ: qq, Name: name, Msg: msg}
}
func (be *sea) throw(db *sql.Sqlite) error {
seaLocker.Lock()
defer seaLocker.Unlock()
return db.Insert("global", be)
}
func fetchBottle(db *sql.Sqlite) (*sea, error) {
seaLocker.Lock()
defer seaLocker.Unlock()
be := new(sea)
return be, db.Pick("global", be)
}
func createChannel(db *sql.Sqlite) error {
seaLocker.Lock()
defer seaLocker.Unlock()
return db.Create("global", &sea{})
}

249
plugin/emojimix/emoji.go Normal file
View File

@@ -0,0 +1,249 @@
// Package emojimix 合成emoji
package emojimix
var emojis = map[rune]int64{
128516: 20201001, // 😄 grinning face with smiling eyes
128512: 20201001, // 😀 grinning face
128578: 20201001, // 🙂 slightly smiling face
128579: 20201001, // 🙃 upside-down face
128521: 20201001, // 😉 winking face
128522: 20201001, // 😊 smiling face with smiling eyes
128518: 20201001, // 😆 grinning squinting face
128515: 20201001, // 😃 grinning face with big eyes
128513: 20201001, // 😁 beaming face with smiling eyes
129315: 20201001, // 🤣 rolling on the floor laughing
128517: 20201001, // 😅 grinning face with sweat
128514: 20201001, // 😂 face with tears of joy
128519: 20201001, // 😇 smiling face with halo
129392: 20201001, // 🥰 smiling face with hearts
128525: 20201001, // 😍 smiling face with heart-eyes
128536: 20201001, // 😘 face blowing a kiss
129321: 20201001, // 🤩 star-struck
128535: 20201001, // 😗 kissing face
128538: 20201001, // 😚 kissing face with closed eyes
128537: 20201001, // 😙 kissing face with smiling eyes
128539: 20201001, // 😛 face with tongue
128541: 20201001, // 😝 squinting face with tongue
128523: 20201001, // 😋 face savoring food
129394: 20201001, // 🥲 smiling face with tear
129297: 20201001, // 🤑 money-mouth face
128540: 20201001, // 😜 winking face with tongue
129303: 20201001, // 🤗 smiling face with open hands hugs
129323: 20201001, // 🤫 shushing face quiet whisper
129300: 20201001, // 🤔 thinking face question hmmm
129325: 20201001, // 🤭 face with hand over mouth embarrassed
129320: 20201001, // 🤨 face with raised eyebrow question
129296: 20201001, // 🤐 zipper-mouth face
128528: 20201001, // 😐 neutral face
128529: 20201001, // 😑 expressionless face
128566: 20201001, // 😶 face without mouth
129322: 20201001, // 🤪 zany face
128527: 20201001, // 😏 smirking face suspicious
128530: 20201001, // 😒 unamused face
128580: 20201001, // 🙄 face with rolling eyes
128556: 20201001, // 😬 grimacing face
128558: 20210218, // 😮 face exhaling
129317: 20201001, // 🤥 lying face
128524: 20201001, // 😌 relieved face
128532: 20201001, // 😔 pensive face
128554: 20201001, // 😪 sleepy face
129316: 20201001, // 🤤 drooling face
128564: 20201001, // 😴 sleeping face
128567: 20201001, // 😷 face with medical mask
129298: 20201001, // 🤒 face with thermometer
129301: 20201001, // 🤕 face with head-bandage
129314: 20201001, // 🤢 nauseated face
129326: 20201001, // 🤮 face vomiting throw
129319: 20201001, // 🤧 sneezing face
129397: 20201001, // 🥵 hot face warm
129398: 20201001, // 🥶 cold face freezing ice
128565: 20201001, // 😵 face with crossed-out eyes
129396: 20201001, // 🥴 woozy face drunk tipsy drug high
129327: 20201001, // 🤯 exploding head mindblow
129312: 20201001, // 🤠 cowboy hat face
129395: 20201001, // 🥳 partying face
129400: 20201001, // 🥸 disguised face
129488: 20201001, // 🧐 face with monocle glasses
128526: 20201001, // 😎 smiling face with sunglasses
128533: 20201001, // 😕 confused face
128543: 20201001, // 😟 worried face
128577: 20201001, // 🙁 slightly frowning face
128559: 20201001, // 😯 hushed face
128562: 20201001, // 😲 astonished face
129299: 20201001, // 🤓 nerd face glasses
128563: 20201001, // 😳 flushed face
129402: 20201001, // 🥺 pleading face
128551: 20201001, // 😧 anguished face
128552: 20201001, // 😨 fearful face
128550: 20201001, // 😦 frowning face with open mouth
128560: 20201001, // 😰 anxious face with sweat
128549: 20201001, // 😥 sad but relieved face
128557: 20201001, // 😭 loudly crying face
128553: 20201001, // 😩 weary face
128546: 20201001, // 😢 crying face
128547: 20201001, // 😣 persevering face
128544: 20201001, // 😠 angry face
128531: 20201001, // 😓 downcast face with sweat
128534: 20201001, // 😖 confounded face
129324: 20201001, // 🤬 face with symbols on mouth
128542: 20201001, // 😞 disappointed face
128555: 20201001, // 😫 tired face
128548: 20201001, // 😤 face with steam from nose
129393: 20201001, // 🥱 yawning face
128169: 20201001, // 💩 pile of poo
128545: 20201001, // 😡 pouting face
128561: 20201001, // 😱 face screaming in fear
128127: 20201001, // 👿 angry face with horns
128128: 20201001, // 💀 skull
128125: 20201001, // 👽 alien
128520: 20201001, // 😈 smiling face with horns devil
129313: 20201001, // 🤡 clown face
128123: 20201001, // 👻 ghost
129302: 20201001, // 🤖 robot
128175: 20201001, // 💯 hundred points percent
128064: 20201001, // 👀 eyes
127801: 20201001, // 🌹 rose flower
127804: 20201001, // 🌼 blossom flower
127799: 20201001, // 🌷 tulip flower
127797: 20201001, // 🌵 cactus
127821: 20201001, // 🍍 pineapple
127874: 20201001, // 🎂 birthday cake
127751: 20210831, // 🌇 sunset
129473: 20201001, // 🧁 cupcake muffin
127911: 20210521, // 🎧 headphone earphone
127800: 20210218, // 🌸 cherry blossom flower
129440: 20201001, // 🦠 microbe germ bacteria virus covid corona
128144: 20201001, // 💐 bouquet flowers
127789: 20201001, // 🌭 hot dog food
128139: 20201001, // 💋 kiss mark lips
127875: 20201001, // 🎃 jack-o-lantern pumpkin
129472: 20201001, // 🧀 cheese wedge
9749: 20201001, // ☕ hot beverage coffee cup tea
127882: 20201001, // 🎊 confetti ball
127880: 20201001, // 🎈 balloon
9924: 20201001, // ⛄ snowman without snow
128142: 20201001, // 💎 gem stone crystal diamond
127794: 20201001, // 🌲 evergreen tree
129410: 20210218, // 🦂 scorpion
128584: 20201001, // 🙈 see-no-evil monkey
128148: 20201001, // 💔 broken heart
128140: 20201001, // 💌 love letter heart
128152: 20201001, // 💘 heart with arrow
128159: 20201001, // 💟 heart decoration
128158: 20201001, // 💞 revolving hearts
128147: 20201001, // 💓 beating heart
128149: 20201001, // 💕 two hearts
128151: 20201001, // 💗 growing heart
129505: 20201001, // 🧡 orange heart
128155: 20201001, // 💛 yellow heart
10084: 20210218, // ❤ mending heart
128156: 20201001, // 💜 purple heart
128154: 20201001, // 💚 green heart
128153: 20201001, // 💙 blue heart
129294: 20201001, // 🤎 brown heart
129293: 20201001, // 🤍 white heart
128420: 20201001, // 🖤 black heart
128150: 20201001, // 💖 sparkling heart
128157: 20201001, // 💝 heart with ribbon
127873: 20211115, // 🎁 wrapped-gift
129717: 20211115, // 🪵 wood
127942: 20211115, // 🏆 trophy
127838: 20210831, // 🍞 bread
128240: 20201001, // 📰 newspaper
128302: 20201001, // 🔮 crystal ball
128081: 20201001, // 👑 crown
128055: 20201001, // 🐷 pig face
129412: 20210831, // 🦄 unicorn
127771: 20201001, // 🌛 first quarter moon face
129420: 20201001, // 🦌 deer
129668: 20210521, // 🪄 magic wand
128171: 20201001, // 💫 dizzy
128049: 20201001, // 🐱 meow cat face
129409: 20201001, // 🦁 lion
128293: 20201001, // 🔥 fire
128038: 20210831, // 🐦 bird
129415: 20201001, // 🦇 bat
129417: 20210831, // 🦉 owl
127752: 20201001, // 🌈 rainbow
128053: 20201001, // 🐵 monkey face
128029: 20201001, // 🐝 honeybee bumblebee wasp
128034: 20201001, // 🐢 turtle
128025: 20201001, // 🐙 octopus
129433: 20201001, // 🦙 llama alpaca
128016: 20210831, // 🐐 goat
128060: 20201001, // 🐼 panda
128040: 20201001, // 🐨 koala
129445: 20201001, // 🦥 sloth
128059: 20210831, // 🐻 bear
128048: 20201001, // 🐰 rabbit face
129428: 20201001, // 🦔 hedgehog
128054: 20211115, // 🐶 dog puppy
128041: 20211115, // 🐩 poodle dog
129437: 20211115, // 🦝 raccoon
128039: 20211115, // 🐧 penguin
128012: 20210218, // 🐌 snail
128045: 20201001, // 🐭 mouse face rat
128031: 20210831, // 🐟 fish
127757: 20201001, // 🌍 globe showing Europe-Africa
127774: 20201001, // 🌞 sun with face
127775: 20201001, // 🌟 glowing star
11088: 20201001, // ⭐ star
127772: 20201001, // 🌜 last quarter moon face
129361: 20201001, // 🥑 avocado
127820: 20211115, // 🍌 banana
127827: 20210831, // 🍓 strawberry
127819: 20210521, // 🍋 lemon
127818: 20211115, // 🍊 tangerine orange
}
var qqface = map[int]rune{
0: 128558, // 😮 face exhaling
1: 128556, // 😬 grimacing face
2: 128525, // 😍 smiling face with heart-eyes
4: 128526, // 😎 smiling face with sunglasses
5: 128557, // 😭 loudly crying face
6: 129402, // 🥺 pleading face
7: 129296, // 🤐 zipper-mouth face
8: 128554, // 😪 sleepy face
11: 128545, // 😡 pouting face
12: 128539, // 😛 face with tongue
13: 128513, // 😁 beaming face with smiling eyes
14: 128578, // 🙂 slightly smiling face
15: 128577, // 🙁 slightly frowning face
16: 128526, // 😎 smiling face with sunglasses
19: 129326, // 🤮 face vomiting throw
20: 129325, // 🤭 face with hand over mouth embarrassed
21: 128522, // 😊 smiling face with smiling eyes
23: 128533, // 😕 confused face
24: 128523, // 😋 face savoring food
27: 128531, // 😓 downcast face with sweat
28: 128516, // 😄 grinning face with smiling eyes
31: 129324, // 🤬 face with symbols on mouth
32: 129300, // 🤔 thinking face question hmmm
33: 129323, // 🤫 shushing face quiet whisper
34: 128565, // 😵 face with crossed-out eyes
35: 128547, // 😣 persevering face
37: 128128, // 💀 skull
46: 128055, // 🐷 pig face
53: 127874, // 🎂 birthday cake
59: 128169, // 💩 pile of poo
60: 9749, // ☕ hot beverage coffee cup tea
63: 127801, // 🌹 rose flower
66: 10084, // ❤ mending heart
67: 128148, // 💔 broken heart
69: 127873, // 🎁 wrapped-gift
74: 127774, // 🌞 sun with face
75: 127772, // 🌜 last quarter moon face
96: 128517, // 😅 grinning face with sweat
104: 129393, // 🥱 yawning face
109: 128535, // 😗 kissing face
110: 128562, // 😲 astonished face
111: 129402, // 🥺 pleading face
172: 128539, // 😛 face with tongue
182: 128514, // 😂 face with tears of joy
187: 128123, // 👻 ghost
247: 128567, // 😷 face with medical mask
272: 128579, // 🙃 upside-down face
320: 129395, // 🥳 partying face
325: 128561, // 😱 face screaming in fear
}

101
plugin/emojimix/mix.go Normal file
View File

@@ -0,0 +1,101 @@
// Package emojimix 合成emoji
package emojimix
import (
"fmt"
"net/http"
"strconv"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
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]{
DisableOnDefault: false,
Brief: "合成emoji",
Help: "- [emoji][emoji]",
}).OnMessage(match).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
r := ctx.State["emojimix"].([]rune)
logrus.Debugln("[emojimix] match:", r)
r1, r2 := r[0], r[1]
u1 := fmt.Sprintf(bed, emojis[r1], r1, r1, r2)
u2 := fmt.Sprintf(bed, emojis[r2], r2, r2, r1)
logrus.Debugln("[emojimix] u1:", u1)
logrus.Debugln("[emojimix] u2:", u2)
resp1, err := http.Head(u1)
if err == nil {
resp1.Body.Close()
if resp1.StatusCode == http.StatusOK {
ctx.SendChain(message.Image(u1))
return
}
}
resp2, err := http.Head(u2)
if err == nil {
resp2.Body.Close()
if resp2.StatusCode == http.StatusOK {
ctx.SendChain(message.Image(u2))
return
}
}
})
}
func match(ctx *zero.Ctx) bool {
logrus.Debugln("[emojimix] msg:", ctx.Event.Message)
if len(ctx.Event.Message) == 2 {
r1 := face2emoji(ctx.Event.Message[0])
if _, ok := emojis[r1]; !ok {
return false
}
r2 := face2emoji(ctx.Event.Message[1])
if _, ok := emojis[r2]; !ok {
return false
}
ctx.State["emojimix"] = []rune{r1, r2}
return true
}
r := []rune(ctx.Event.RawMessage)
logrus.Debugln("[emojimix] raw msg:", ctx.Event.RawMessage)
if len(r) == 2 {
if _, ok := emojis[r[0]]; !ok {
return false
}
if _, ok := emojis[r[1]]; !ok {
return false
}
ctx.State["emojimix"] = r
return true
}
return false
}
func face2emoji(face message.MessageSegment) rune {
if face.Type == "text" {
r := []rune(face.Data["text"])
if len(r) != 1 {
return 0
}
return r[0]
}
if face.Type != "face" {
return 0
}
id, err := strconv.Atoi(face.Data["id"])
if err != nil {
return 0
}
if r, ok := qqface[id]; ok {
return r
}
return 0
}

45
plugin/event/data.go Normal file
View File

@@ -0,0 +1,45 @@
package event
type storage int64
// 申请
func (s *storage) setapply(on bool) {
if on {
*s |= 0b001
} else {
*s &= 0b110
}
}
// 邀请
func (s *storage) setinvite(on bool) {
if on {
*s |= 0b010
} else {
*s &= 0b101
}
}
// 主人
func (s *storage) setmaster(on bool) {
if on {
*s |= 0b100
} else {
*s &= 0b011
}
}
// 申请
func (s *storage) isapplyon() bool {
return *s&0b001 > 0
}
// 邀请
func (s *storage) isinviteon() bool {
return *s&0b010 > 0
}
// 主人
func (s *storage) ismasteroff() bool {
return *s&0b100 > 0
}

144
plugin/event/event.go Normal file
View File

@@ -0,0 +1,144 @@
// Package event 好友申请以及群聊邀请事件处理
package event
import (
"encoding/binary"
"strconv"
"time"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
base14 "github.com/fumiama/go-base16384"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
engine := control.Register("event", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "好友申请和群聊邀请事件处理",
Help: "- [开启|关闭]自动同意[申请|邀请|主人]\n" +
"- [同意|拒绝][申请|邀请][flag]\n" +
"Tips: 信息默认发送给主人列表第一位, 默认同意所有主人的事件, flag跟随事件一起发送",
})
engine.On("request/group/invite").SetBlock(false).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
su := zero.BotConfig.SuperUsers[0]
now := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
flag, err := strconv.ParseInt(ctx.Event.Flag, 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
var buf [8]byte
binary.BigEndian.PutUint64(buf[:], uint64(flag))
es := base14.EncodeToString(buf[1:])
userid := ctx.Event.UserID
username := ctx.CardOrNickName(userid)
data := (storage)(c.GetData(-su))
groupid := ctx.Event.GroupID
groupname := ctx.GetGroupInfo(groupid, true).Name
logrus.Info("[event]收到来自[", username, "](", userid, ")的群聊邀请,群:[", groupname, "](", groupid, ")")
if data.isinviteon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) {
ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "")
ctx.SendPrivateForwardMessage(su, message.Message{message.CustomNode(username, userid,
"已自动同意在"+now+"收到来自"+
"\n用户:["+username+"]("+strconv.FormatInt(userid, 10)+")的群聊邀请"+
"\n群聊:["+groupname+"]("+strconv.FormatInt(groupid, 10)+")"+
"\nflag:"+es)})
return
}
ctx.SendPrivateForwardMessage(su,
message.Message{message.CustomNode(username, userid,
"在"+now+"收到来自"+
"\n用户:["+username+"]("+strconv.FormatInt(userid, 10)+")的群聊邀请"+
"\n群聊:["+groupname+"]("+strconv.FormatInt(groupid, 10)+")"+
"\n请在下方复制flag并在前面加上:"+
"\n同意/拒绝邀请,来决定同意还是拒绝"),
message.CustomNode(username, userid, es)})
}
})
engine.On("request/friend").SetBlock(false).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
su := zero.BotConfig.SuperUsers[0]
now := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
flag, err := strconv.ParseInt(ctx.Event.Flag, 10, 64)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
var buf [8]byte
binary.BigEndian.PutUint64(buf[:], uint64(flag))
es := base14.EncodeToString(buf[1:])
comment := ctx.Event.Comment
userid := ctx.Event.UserID
username := ctx.CardOrNickName(userid)
data := (storage)(c.GetData(-su))
logrus.Info("[event]收到来自[", username, "](", userid, ")的好友申请")
if data.isapplyon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) {
ctx.SetFriendAddRequest(ctx.Event.Flag, true, "")
ctx.SendPrivateForwardMessage(su, message.Message{message.CustomNode(username, userid,
"已自动同意在"+now+"收到来自"+
"\n用户:["+username+"]("+strconv.FormatInt(userid, 10)+")"+
"\n的好友请求:"+comment+
"\nflag:"+es)})
return
}
ctx.SendPrivateForwardMessage(su,
message.Message{message.CustomNode(username, userid,
"在"+now+"收到来自"+
"\n用户:["+username+"]("+strconv.FormatInt(userid, 10)+")"+
"\n的好友请求:"+comment+
"\n请在下方复制flag并在前面加上:"+
"\n同意/拒绝申请,来决定同意还是拒绝"),
message.CustomNode(username, userid, es)})
}
})
engine.OnRegex(`^(同意|拒绝)(申请|邀请)\s*([一-踀]{4})\s*(.*)$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
su := zero.BotConfig.SuperUsers[0]
cmd := ctx.State["regex_matched"].([]string)[1]
org := ctx.State["regex_matched"].([]string)[2]
es := ctx.State["regex_matched"].([]string)[3]
other := ctx.State["regex_matched"].([]string)[4]
var buf [8]byte
copy(buf[1:], base14.DecodeFromString(es))
flag := strconv.FormatInt(int64(binary.BigEndian.Uint64(buf[:])), 10)
ok := cmd == "同意"
switch org {
case "申请":
ctx.SetFriendAddRequest(flag, ok, other)
ctx.SendPrivateMessage(su, message.Text("已", cmd, org))
case "邀请":
ctx.SetGroupAddRequest(flag, "invite", ok, other)
ctx.SendPrivateMessage(su, message.Text("已", cmd, org))
}
})
engine.OnRegex(`^(开启|关闭)自动同意(申请|邀请|主人)$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
su := zero.BotConfig.SuperUsers[0]
option := ctx.State["regex_matched"].([]string)[1]
from := ctx.State["regex_matched"].([]string)[2]
data := (storage)(c.GetData(-su))
switch from {
case "申请":
data.setapply(option == "开启")
case "邀请":
data.setinvite(option == "开启")
case "主人":
data.setmaster(option == "关闭")
}
err := c.SetData(-su, int64(data))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("已设置自动同意" + from + "为" + option))
})
}

45
plugin/font/main.go Normal file
View File

@@ -0,0 +1,45 @@
// Package font 渲染任意文字到图片
package font
import (
"github.com/FloatTech/floatbox/binary"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
control.Register("font", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "渲染任意文字到图片",
Help: "- (用[字体])渲染文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]",
}).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
fnt := ctx.State["regex_matched"].([]string)[1]
txt := ctx.State["regex_matched"].([]string)[2]
switch fnt {
case "用终末体":
fnt = text.SyumatuFontFile
case "用终末变体":
fnt = text.NisiFontFile
case "用紫罗兰体":
fnt = text.VioletEvergardenFontFile
case "用樱酥体":
fnt = text.SakuraFontFile
case "用Consolas体":
fnt = text.ConsolasFontFile
case "用苹方体":
fallthrough
default:
fnt = text.FontFile
}
b, err := text.RenderToBase64(txt, fnt, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
})
}

View File

@@ -7,75 +7,63 @@ import (
"encoding/hex"
"encoding/json"
"image"
"math/rand"
"io"
"os"
"strconv"
"time"
"github.com/fogleman/gg" // 注册了 jpg png gif
"github.com/FloatTech/gg" // 注册了 jpg png gif
"github.com/FloatTech/imgfactory"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/txt2img"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/math"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/pool"
)
var (
const (
// 底图缓存位置
images = "data/Fortune/"
// 基础文件位置
omikujson = "data/Fortune/text.json"
// 字体文件位置
font = "data/Font/sakura.ttf"
// 生成图缓存位置
cache = images + "cache/"
// 底图类型列表:车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌
// 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师"}
)
var (
// 底图类型列表
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘", "东方归言录", "奇异恩典", "夏日口袋", "ASoul", "Hololive"}
// 映射底图与 index
index = make(map[string]uint8)
// 签文
omikujis []map[string]string
fontdata []byte
)
func init() {
// 插件主体
en := control.Register("fortune", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "每日运势",
Help: "- 运势 | 抽签\n" +
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘 | 东方归言录 | 奇异恩典 | 夏日口袋 | ASoul | Hololive]",
PublicDataFolder: "Fortune",
})
_ = os.RemoveAll(cache)
err := os.MkdirAll(cache, 0755)
if err != nil {
panic(err)
}
for i, s := range table {
index[s] = uint8(i)
}
err := os.MkdirAll(images, 0755)
if err != nil {
panic(err)
}
err = os.MkdirAll(cache, 0755)
if err != nil {
panic(err)
}
process.SleepAbout1sTo2s()
data, err := file.GetLazyData(omikujson, true, false)
if err != nil {
panic(err)
}
err = json.Unmarshal(data, &omikujis)
if err != nil {
panic(err)
}
_, err = file.GetLazyData(font, false, true)
if err != nil {
panic(err)
}
// 插件主体
en := control.Register("fortune", &control.Options{
DisableOnDefault: false,
Help: "每日运势: \n" +
"- 运势|抽签\n" +
"- 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]",
})
en.OnRegex(`^设置底图(.*)`).SetBlock(true).SecondPriority().
en.OnRegex(`^设置底图\s?(.*)`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
if gid <= 0 {
@@ -84,9 +72,9 @@ func init() {
}
i, ok := index[ctx.State["regex_matched"].([]string)[1]]
if ok {
c, ok := control.Lookup("fortune")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
err = c.SetData(gid, int64(i)&0xff)
err := c.SetData(gid, int64(i)&0xff)
if err != nil {
ctx.SendChain(message.Text("设置失败:", err))
return
@@ -99,7 +87,28 @@ func init() {
}
ctx.SendChain(message.Text("没有这个底图哦~"))
})
en.OnFullMatchGroup([]string{"运势", "抽签"}).SetBlock(true).SecondPriority().
en.OnFullMatchGroup([]string{"运势", "抽签"}, fcext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
data, err := file.GetLazyData(omikujson, control.Md5File, false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = json.Unmarshal(data, &omikujis)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
if fontdata == nil {
fontdata, err = file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
}
return true
},
)).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 获取该群背景类型,默认车万
kind := "车万"
@@ -109,7 +118,7 @@ func init() {
gid = -ctx.Event.UserID
}
logrus.Debugln("[fortune]gid:", ctx.Event.GroupID, "uid:", ctx.Event.UserID)
c, ok := control.Lookup("fortune")
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
v := uint8(c.GetData(gid) & 0xff)
if int(v) < len(table) {
@@ -118,66 +127,53 @@ func init() {
}
// 检查背景图片是否存在
zipfile := images + kind + ".zip"
_, err = file.GetLazyData(zipfile, false, false)
_, err := file.GetLazyData(zipfile, control.Md5File, false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 生成种子
t, _ := strconv.ParseInt(time.Now().Format("20060102"), 10, 64)
seed := ctx.Event.UserID + t
// 随机获取背景
background, index, err := randimage(zipfile, seed)
background, index, err := randimage(zipfile, ctx)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 随机获取签文
title, text := randtext(seed)
randtextindex := fcext.RandSenderPerDayN(ctx.Event.UserID, len(omikujis))
title, text := omikujis[randtextindex]["title"], omikujis[randtextindex]["content"]
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
cachefile := cache + hex.EncodeToString(digest[:])
var data []byte
switch file.IsExist(cachefile) {
case true:
data, err = os.ReadFile(cachefile)
if err == nil {
break
err = pool.SendImageFromPool(cachefile, cachefile, func() error {
f, err := os.Create(cachefile)
if err != nil {
return err
}
_ = os.Remove(cachefile)
fallthrough
case false:
// 绘制背景
data, err = draw(background, title, text)
}
_, err = draw(background, fontdata, title, text, f)
_ = f.Close()
return err
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
_ = os.WriteFile(cachefile, data, 0644)
// 发送图片
ctx.SendChain(message.Image("base64://" + helper.BytesToString(data)))
})
}
// @function randimage 随机选取zip内的文件
// @param path zip路径
// @param seed 随机数种子
// @param ctx *zero.Ctx
// @return 文件路径 & 错误信息
func randimage(path string, seed int64) (im image.Image, index int, err error) {
func randimage(path string, ctx *zero.Ctx) (im image.Image, index int, err error) {
reader, err := zip.OpenReader(path)
if err != nil {
return
}
defer reader.Close()
rand.Seed(seed)
index = rand.Intn(len(reader.File))
file := reader.File[index]
file := reader.File[fcext.RandSenderPerDayN(ctx.Event.UserID, len(reader.File))]
f, err := file.Open()
if err != nil {
return
@@ -188,40 +184,30 @@ func randimage(path string, seed int64) (im image.Image, index int, err error) {
return
}
// @function randtext 随机选取签文
// @param file 文件路径
// @param seed 随机数种子
// @return 签名 & 签文 & 错误信息
func randtext(seed int64) (string, string) {
rand.Seed(seed)
r := rand.Intn(len(omikujis))
return omikujis[r]["title"], omikujis[r]["content"]
}
// @function draw 绘制运势图
// @param background 背景图片路径
// @param seed 随机数种子
// @param title 签名
// @param text 签文
// @return 错误信息
func draw(back image.Image, title, text string) ([]byte, error) {
func draw(back image.Image, fontdata []byte, title, txt string, f io.Writer) (int64, error) {
canvas := gg.NewContext(back.Bounds().Size().Y, back.Bounds().Size().X)
canvas.DrawImage(back, 0, 0)
// 写标题
canvas.SetRGB(1, 1, 1)
if err := canvas.LoadFontFace(font, 45); err != nil {
return nil, err
if err := canvas.ParseFontFace(fontdata, 45); err != nil {
return -1, err
}
sw, _ := canvas.MeasureString(title)
canvas.DrawString(title, 140-sw/2, 112)
// 写正文
canvas.SetRGB(0, 0, 0)
if err := canvas.LoadFontFace(font, 23); err != nil {
return nil, err
if err := canvas.ParseFontFace(fontdata, 23); err != nil {
return -1, err
}
tw, th := canvas.MeasureString("测")
tw, th = tw+10, th+10
r := []rune(text)
r := []rune(txt)
xsum := rowsnum(len(r), 9)
switch xsum {
default:
@@ -245,7 +231,7 @@ func draw(back image.Image, title, text string) ([]byte, error) {
}
}
}
return txt2img.TxtCanvas{Canvas: canvas}.ToBase64()
return imgfactory.WriteTo(canvas.Image(), f)
}
func offest(total, now int, distance float64) float64 {

69
plugin/funny/laugh.go Normal file
View File

@@ -0,0 +1,69 @@
// Package funny 冷笑话
package funny
import (
"strings"
"time"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
fcext "github.com/FloatTech/floatbox/ctxext"
sql "github.com/FloatTech/sqlite"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
type joke struct {
ID uint32 `db:"id"`
Text string `db:"text"`
}
var db = &sql.Sqlite{}
func init() {
en := control.Register("funny", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "讲个笑话",
Help: "- 讲个笑话[@xxx|qq号|人名] | 夸夸[@xxx|qq号|人名] ",
PublicDataFolder: "Funny",
})
en.OnPrefixGroup([]string{"讲个笑话", "夸夸"}, fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
db.DBPath = en.DataFolder() + "jokes.db"
_, err := en.GetLazyData("jokes.db", true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Open(time.Hour * 24)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = db.Create("jokes", &joke{})
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
c, err := db.Count("jokes")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
logrus.Infoln("[funny]加载", c, "个笑话")
return true
})).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
// 获取名字
name := ctx.NickName()
var j joke
err := db.Pick("jokes", &j)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text(strings.ReplaceAll(j.Text, "%name", name)))
})
}

16
plugin/genshin/data.go Normal file
View File

@@ -0,0 +1,16 @@
package genshin
type storage uint64
func (s *storage) is5starsmode() bool {
return *s&1 == 1
}
func (s *storage) setmode(is5stars bool) bool {
if is5stars {
*s |= 1
} else {
*s &= 0xffffffff_fffffffe
}
return is5stars
}

380
plugin/genshin/ys.go Normal file
View File

@@ -0,0 +1,380 @@
// Package genshin 原神抽卡
package genshin
import (
"archive/zip"
"image"
"image/color"
"image/draw"
"image/jpeg"
"image/png"
"math/rand"
"regexp"
"strings"
"sync/atomic"
fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/process"
"github.com/FloatTech/imgfactory"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/golang/freetype"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
type zipfilestructure map[string][]*zip.File
var (
totl uint64 // 累计抽奖次数
filetree = make(zipfilestructure, 32)
starN3, starN4, starN5 *zip.File
namereg = regexp.MustCompile(`_(.*)\.png`)
)
func init() {
engine := control.Register("genshin", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "原神模拟抽卡",
Help: "- 原神十连\n- 切换原神卡池",
PublicDataFolder: "Genshin",
}).ApplySingle(ctxext.DefaultSingle)
engine.OnFullMatch("切换原神卡池").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("找不到服务!"))
return
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
store := (storage)(c.GetData(gid))
if store.setmode(!store.is5starsmode()) {
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("切换到五星卡池~"))
} else {
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("切换到普通卡池~"))
}
err := c.SetData(gid, int64(store))
if err != nil {
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("ERROR: ", err))
}
})
engine.OnFullMatch("原神十连", fcext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
zipfile := engine.DataFolder() + "Genshin.zip"
_, err := engine.GetLazyData("Genshin.zip", false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
err = parsezip(zipfile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
return true
},
)).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("找不到服务!"))
return
}
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
store := (storage)(c.GetData(gid))
img, str, mode, err := randnums(10, store)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
b, err := imgfactory.ToBytes(img)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if mode {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
message.Text("恭喜你抽到了: \n", str), message.ImageBytes(b)))
} else {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
message.Text("十连成功~"), message.ImageBytes(b)))
}
})
}
func randnums(nums int, store storage) (rgba *image.RGBA, str string, replyMode bool, err error) {
var (
fours, fives = make([]*zip.File, 0, 10), make([]*zip.File, 0, 10) // 抽到 四, 五星角色
threeArms, fourArms, fiveArms = make([]*zip.File, 0, 10), make([]*zip.File, 0, 10), make([]*zip.File, 0, 10) // 抽到 三 , 四, 五星武器
fourN, fiveN = 0, 0 // 抽到 四, 五星角色的数量
bgs = make([]*zip.File, 0, 10) // 背景图片名
threeN2, fourN2, fiveN2 = 0, 0, 0 // 抽到 三 , 四, 五星武器的数量
hero, stars = make([]*zip.File, 0, 10), make([]*zip.File, 0, 10) // 角色武器名, 储存星级图标
cicon = make([]*zip.File, 0, 10) // 元素图标
fivebg, fourbg, threebg = filetree["five_bg.jpg"][0], filetree["four_bg.jpg"][0], filetree["three_bg.jpg"][0] // 背景图片名
fivelen = len(filetree["five"])
five2len = len(filetree["five2"])
threelen = len(filetree["Three"])
fourlen = len(filetree["four"])
four2len = len(filetree["four2"])
)
if totl%9 == 0 { // 累计9次加入一个五星
switch rand.Intn(2) {
case 0:
fiveN++
fives = append(fives, filetree["five"][rand.Intn(fivelen)])
case 1:
fiveN2++
fiveArms = append(fiveArms, filetree["five2"][rand.Intn(five2len)])
}
nums--
}
if store.is5starsmode() { // 5星模式
for i := 0; i < nums; i++ {
switch rand.Intn(2) {
case 0:
fiveN++
fives = append(fives, filetree["five"][rand.Intn(fivelen)])
case 1:
fiveN2++
fiveArms = append(fiveArms, filetree["five2"][rand.Intn(five2len)])
}
}
} else { // 默认模式
for i := 0; i < nums; i++ {
a := rand.Intn(1000) // 抽卡几率 三星80% 四星17% 五星3%
switch {
case a >= 0 && a <= 800:
threeN2++
threeArms = append(threeArms, filetree["Three"][rand.Intn(threelen)])
case a > 800 && a <= 885:
fourN++
fours = append(fours, filetree["four"][rand.Intn(fourlen)]) // 随机角色
case a > 885 && a <= 970:
fourN2++
fourArms = append(fourArms, filetree["four2"][rand.Intn(four2len)]) // 随机武器
case a > 970 && a <= 985:
fiveN++
fives = append(fives, filetree["five"][rand.Intn(fivelen)])
default:
fiveN2++
fiveArms = append(fiveArms, filetree["five2"][rand.Intn(five2len)])
}
}
if fourN+fourN2 == 0 && threeN2 > 0 { // 没有四星时自动加入
threeN2--
threeArms = threeArms[:len(threeArms)-1]
switch rand.Intn(2) {
case 0:
fourN++
fours = append(fours, filetree["four"][rand.Intn(fourlen)]) // 随机角色
case 1:
fourN2++
fourArms = append(fourArms, filetree["four2"][rand.Intn(four2len)]) // 随机武器
}
}
_ = atomic.AddUint64(&totl, 1)
}
icon := func(f *zip.File) *zip.File {
name := f.Name
name = name[strings.LastIndex(name, "/")+1:strings.Index(name, "_")] + ".png"
logrus.Debugln("[genshin]get named file", name)
return filetree[name][0]
}
he := func(cnt int, id int, f *zip.File, bg *zip.File) {
var hen *[]*zip.File
for i := 0; i < cnt; i++ {
switch id {
case 1:
hen = &threeArms
case 2:
hen = &fourArms
case 3:
hen = &fours
case 4:
hen = &fiveArms
case 5:
hen = &fives
}
bgs = append(bgs, bg) // 加入颜色背景
hero = append(hero, (*hen)[i])
stars = append(stars, f) // 加入星级图标
cicon = append(cicon, icon((*hen)[i])) // 加入元素图标
}
}
if fiveN > 0 { // 按顺序加入
he(fiveN, 5, starN5, fivebg) // 五星角色
str += reply(fives, 1, str)
replyMode = true
}
if fourN > 0 {
he(fourN, 3, starN4, fourbg) // 四星角色
}
if fiveN2 > 0 {
he(fiveN2, 4, starN5, fivebg) // 五星武器
str += reply(fiveArms, 2, str)
replyMode = true
}
if fourN2 > 0 {
he(fourN2, 2, starN4, fourbg) // 四星武器
}
if threeN2 > 0 {
he(threeN2, 1, starN3, threebg) // 三星武器
}
var c1, c2, c3 uint8 = 50, 50, 50 // 背景颜色
img00, err := filetree["bg0.jpg"][0].Open() // 打开背景图片
if err != nil {
return
}
rectangle := image.Rect(0, 0, 1920, 1080) // 图片宽度, 图片高度
rgba = image.NewRGBA(rectangle)
draw.Draw(rgba, rgba.Bounds(), image.NewUniform(color.RGBA{c1, c2, c3, 255}), image.Point{}, draw.Over)
context := freetype.NewContext() // 创建一个新的上下文
context.SetDPI(72) // 每英寸 dpi
context.SetClip(rgba.Bounds())
context.SetDst(rgba)
defer img00.Close()
img0, err := jpeg.Decode(img00) // 读取一个本地图像
if err != nil {
return
}
offset := image.Pt(0, 0) // 图片在背景上的位置
draw.Draw(rgba, img0.Bounds().Add(offset), img0, image.Point{}, draw.Over)
w1, h1 := 230, 0
for i := 0; i < len(hero); i++ {
if i > 0 {
w1 += 146 // 图片宽度
}
imgs, err := bgs[i].Open() // 取出背景图片
if err != nil {
return nil, "", false, err
}
defer imgs.Close()
img, _ := jpeg.Decode(imgs)
offset := image.Pt(w1, h1)
draw.Draw(rgba, img.Bounds().Add(offset), img, image.Point{}, draw.Over)
imgs1, err := hero[i].Open() // 取出图片名
if err != nil {
return nil, "", false, err
}
defer imgs1.Close()
img1, _ := png.Decode(imgs1)
offset1 := image.Pt(w1, h1)
draw.Draw(rgba, img1.Bounds().Add(offset1), img1, image.Point{}, draw.Over)
imgs2, err := stars[i].Open() // 取出星级图标
if err != nil {
return nil, "", false, err
}
defer imgs2.Close()
img2, _ := png.Decode(imgs2)
offset2 := image.Pt(w1, h1)
draw.Draw(rgba, img2.Bounds().Add(offset2), img2, image.Point{}, draw.Over)
imgs3, err := cicon[i].Open() // 取出类型图标
if err != nil {
return nil, "", false, err
}
defer imgs3.Close()
img3, _ := png.Decode(imgs3)
offset3 := image.Pt(w1, h1)
draw.Draw(rgba, img3.Bounds().Add(offset3), img3, image.Point{}, draw.Over)
}
imgs4, err := filetree["Reply.png"][0].Open() // "分享" 图标
if err != nil {
return nil, "", false, err
}
defer imgs4.Close()
img4, err := png.Decode(imgs4)
if err != nil {
return nil, "", false, err
}
offset4 := image.Pt(1270, 945) // 宽, 高
draw.Draw(rgba, img4.Bounds().Add(offset4), img4, image.Point{}, draw.Over)
return
}
func parsezip(zipFile string) error {
zipReader, err := zip.OpenReader(zipFile) // will not close
if err != nil {
return err
}
for _, f := range zipReader.File {
if f.FileInfo().IsDir() {
filetree[f.Name] = make([]*zip.File, 0, 32)
continue
}
f.Name = f.Name[8:]
i := strings.LastIndex(f.Name, "/")
if i < 0 {
filetree[f.Name] = []*zip.File{f}
logrus.Debugln("[genshin]insert file", f.Name)
continue
}
folder := f.Name[:i]
if folder != "" {
filetree[folder] = append(filetree[folder], f)
logrus.Debugln("[genshin]insert file into", folder)
if folder == "gacha" {
switch f.Name[i+1:] {
case "ThreeStar.png":
starN3 = f
case "FourStar.png":
starN4 = f
case "FiveStar.png":
starN5 = f
}
}
}
}
return nil
}
// 取出角色武器名
func reply(z []*zip.File, num int, nameStr string) string {
var tmp strings.Builder
tmp.Grow(128)
switch {
case num == 1:
tmp.WriteString("★五星角色★\n")
case num == 2 && len(nameStr) > 0:
tmp.WriteString("\n★五星武器★\n")
default:
tmp.WriteString("★五星武器★\n")
}
for i := range z {
tmp.WriteString(namereg.FindStringSubmatch(z[i].Name)[1] + " * ")
}
return tmp.String()
}

103
plugin/gif/README.md Normal file
View File

@@ -0,0 +1,103 @@
# ZeroBot-Plugin-Gif
[ZeroBot QQ机器人](https://github.com/wdvxdr1123/ZeroBot)插件可以制作各种沙雕gif图
> 素材包地址: https://gitcode.net/anto_july/imagematerials
## 触发方式
1. [指令词]+[qq号] 如爬123456
2. [指令词]+[图片] 如:爬[图片]
3. [指令词]+[艾特] 如:爬@小H
## 指令列表
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x]
- [x] 灰度
- [x] 上翻
- [x] 下翻
- [x] 左翻
- [x] 右翻
- [x] 反色
- [x] 倒放
- [x] 浮雕
- [x] 打码
- [x] 负片
- [x] 旋转45
- [x] 变形100 100
- [x]
- [x] 娶|结婚申请|结婚登记
- [x] 像只
- [x] 阿尼亚喜欢
- [x] 我永远喜欢|永远喜欢
- [x] 像样的亲亲
- [x] 国旗
- [x] 不要靠近
- [x] 万能表情|空白表情
- [x] 采访
- [x] 需要|你可能需要
- [x] 这像画吗
- [x] 小画家
- [x] 完美
- [x] 玩游戏 (应该使用透视变换)
- [x] 出警
- [x] 警察
- [x] 舔|舔屏|prpr (应该使用透视变换)
- [x] 安全感
- [x] 精神支柱
- [x] 想什么
- [x] 墙纸
- [x] 为什么at我
- [x] 交个朋友
- [x] 打工人|继续干活
- [x] 兑换券
- [ ] 捂脸 (使用了透视变换, 需要研究矩阵变换)
- [x] 注意力涣散
- [x] 垃圾桶|垃圾
- [x]
- [x] 啾啾
- [x] 2敲
- [x] 听音乐
- [ ] 群青 (需要mask)
- [ ] 加载中 (需要mask)
- [x] 永远爱你 (未加闪光)
- [ ] 关注 (处理文字麻烦)
- [x] 2拍
- [x]
- [x]
- [x] 打拳 (未加闪光)
- [ ] 复读 (处理文字麻烦)
- [x]
- [x]
- [x]
- [x]
- [x] 紧贴
- [ ] 膜拜 (使用了透视变换, 需要研究矩阵变换)
- [ ] 小天使 (摆)
- [ ] 一直 (摆)
- [x]
- [ ] 问问 (摆)
- [ ] 典中典 (摆)
- [ ] 震惊 (摆)
- [ ] 哈哈镜 (摆)
- [ ] 对称 (猎奇, 不整)
- [x]
- [x] 2蹭
- [x] 诶嘿
- [x] 膜拜
- [x]
- [x]
- [x] 给我变
- [x] 玩一下
- [x] 不要看
- [x] 小天使
- [x] 你的
- [x] 我老婆
- [x] 远离
- [x] 抬棺

109
plugin/gif/context.go Normal file
View File

@@ -0,0 +1,109 @@
package gif
import (
"os"
"strconv"
"sync"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/imgfactory"
"github.com/sirupsen/logrus"
)
type context struct {
usrdir string
headimgsdir []string
}
func dlchan(name string, s *string, wg *sync.WaitGroup, exit func(error)) {
defer wg.Done()
target := datapath + `materials/` + name
if file.IsNotExist(target) {
data, err := web.RequestDataWith(web.NewTLS12Client(), `https://gitcode.net/m0_60838134/imagematerials/-/raw/main/`+name, "GET", "gitcode.net", web.RandUA(), nil)
if err != nil {
_ = os.Remove(target)
exit(err)
return
}
f, err := os.Create(target)
if err != nil {
exit(err)
return
}
_, err = f.Write(data)
_ = f.Close()
if err != nil {
_ = os.Remove(target)
exit(err)
return
}
logrus.Debugln("[gif] dl", name, "to", target, "succeeded")
} else {
logrus.Debugln("[gif] dl", name, "exists at", target)
}
*s = target
}
func dlblock(name string) (string, error) {
target := datapath + `materials/` + name
if file.IsNotExist(target) {
data, err := web.RequestDataWith(web.NewTLS12Client(), `https://gitcode.net/m0_60838134/imagematerials/-/raw/main/`+name, "GET", "gitcode.net", web.RandUA(), nil)
if err != nil {
_ = os.Remove(target)
return "", err
}
f, err := os.Create(target)
if err != nil {
return "", err
}
_, err = f.Write(data)
_ = f.Close()
if err != nil {
_ = os.Remove(target)
return "", err
}
logrus.Debugln("[gif] dl", name, "to", target, "succeeded")
} else {
logrus.Debugln("[gif] dl", name, "exists at", target)
}
return target, nil
}
func dlrange(prefix string, end int, wg *sync.WaitGroup, exit func(error)) []string {
if file.IsNotExist(datapath + `materials/` + prefix) {
err := os.MkdirAll(datapath+`materials/`+prefix, 0755)
if err != nil {
exit(err)
return nil
}
}
c := make([]string, end)
for i := range c {
wg.Add(1)
go dlchan(prefix+"/"+strconv.Itoa(i)+".png", &c[i], wg, exit)
}
return c
}
// 新的上下文
func newContext(user int64) *context {
c := new(context)
c.usrdir = datapath + "users/" + strconv.FormatInt(user, 10) + `/`
_ = os.MkdirAll(c.usrdir, 0755)
c.headimgsdir = make([]string, 2)
c.headimgsdir[0] = c.usrdir + "0.gif"
c.headimgsdir[1] = c.usrdir + "1.gif"
return c
}
func loadFirstFrames(paths []string, size int) (imgs []*imgfactory.Factory, err error) {
imgs = make([]*imgfactory.Factory, size)
for i := range imgs {
imgs[i], err = imgfactory.LoadFirstFrame(paths[i], 0, 0)
if err != nil {
return nil, err
}
}
return imgs, nil
}

1448
plugin/gif/gif.go Normal file

File diff suppressed because it is too large Load Diff

43
plugin/gif/logo.go Normal file
View File

@@ -0,0 +1,43 @@
package gif
import (
"image"
"strconv"
"strings"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/process"
"github.com/FloatTech/imgfactory"
)
func (cc *context) prepareLogos(s ...string) error {
for i, v := range s {
_, err := strconv.Atoi(v)
if err != nil {
err = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.usrdir+strconv.Itoa(i)+".gif")
} else {
err = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.usrdir+strconv.Itoa(i)+".gif")
}
if err != nil {
return err
}
process.SleepAbout1sTo2s()
}
return nil
}
func (cc *context) getLogo(w int, h int) (*image.NRGBA, error) {
frame, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], w, h)
if err != nil {
return nil, err
}
return frame.Circle(0).Image(), nil
}
func (cc *context) getLogo2(w int, h int) (*image.NRGBA, error) {
frame, err := imgfactory.LoadFirstFrame(cc.headimgsdir[1], w, h)
if err != nil {
return nil, err
}
return frame.Circle(0).Image(), nil
}

1507
plugin/gif/png.go Normal file

File diff suppressed because it is too large Load Diff

170
plugin/gif/run.go Normal file
View File

@@ -0,0 +1,170 @@
// Package gif 制图
package gif
import (
"strconv"
"strings"
"github.com/FloatTech/floatbox/file"
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"
)
var (
cmd = make([]string, 0)
datapath string
cmdMap = map[string]func(cc *context, args ...string) (string, error){
"搓": cuo,
"冲": xqe,
"摸": mo,
"拍": pai,
"丢": diu,
"吃": chi,
"敲": qiao,
"啃": ken,
"蹭": ceng,
"爬": pa,
"撕": si,
"灰度": grayscale,
"上翻": flipV,
"下翻": flipV,
"左翻": flipH,
"右翻": flipH,
"反色": invert,
"浮雕": convolve3x3,
"打码": blur,
"负片": invertAndGrayscale,
"旋转": rotate,
"变形": deformation,
"亲": kiss,
"结婚申请": marriage,
"结婚登记": marriage,
"阿尼亚喜欢": anyasuki,
"像只": alike,
"我永远喜欢": alwaysLike,
"永远喜欢": alwaysLike,
"像样的亲亲": decentKiss,
"国旗": chinaFlag,
"不要靠近": dontTouch,
"万能表情": universal,
"空白表情": universal,
"采访": interview,
"需要": need,
"你可能需要": need,
"这像画吗": paint,
"小画家": painter,
"完美": perfect,
"玩游戏": playGame,
"出警": police,
"警察": police1,
"舔": prpr,
"舔屏": prpr,
"prpr": prpr,
"安全感": safeSense,
"精神支柱": support,
"想什么": thinkwhat,
"墙纸": wallpaper,
"为什么at我": whyatme,
"交个朋友": makeFriend,
"打工人": backToWork,
"继续干活": backToWork,
"兑换券": coupon,
"注意力涣散": distracted,
"垃圾桶": garbage,
"垃圾": garbage,
"捶": thump,
"啾啾": jiujiu,
"2敲": knock,
"听音乐": listenMusic,
"永远爱你": loveYou,
"2拍": pat,
"顶": jackUp,
"捣": pound,
"打拳": punch,
"滚": roll,
"吸": suck,
"嗦": suck,
"扔": throw,
"锤": hammer,
"紧贴": tightly,
"紧紧贴着": tightly,
"转": turn,
"蒙蔽": mengbi,
"踩": cai,
"好玩": haowan,
"2转": whirl,
"2滚": push,
"踢球": tiqiu,
"2舔": lick,
"可莉吃": klee,
"胡桃啃": hutaoken,
"怀": huai,
"砰": peng,
"你犯法了": fanfa,
"炖": dun,
"2蹭": ceng2,
"诶嘿": eihei,
"膜拜": worship,
"吞": ci,
"揍": zou,
"给我变": bian,
"玩一下": van,
"不要看": neko,
"小天使": xiaotianshi,
"你的": youer,
"我老婆": nowife,
"远离": yuanli,
"抬棺": taiguan,
"一直": alwaysDoGif,
}
)
func init() { // 插件主体
for k := range cmdMap {
cmd = append(cmd, k)
}
en := control.Register("gif", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "制图",
Help: "下为制图命令:\n" +
"- 搓|- 冲|- 摸|-拍|- 丢|- 吃|- 敲|- 啃|- 蹭|- 爬|- 撕\n" +
"- 吸|- 嗦|- 扔|- 锤|- 紧贴|紧紧贴着|- 转|- 抬棺|- 远离\n" +
"- 揍|- 吞|- 膜拜|- 诶嘿|- 2蹭|- 你犯法了|- 砰|- 注意力涣散\n" +
"- 2敲|- 听音乐|- 永远爱你|- 2拍|- 顶|- 捣|- 打拳|- 滚\n" +
"- 灰度|- 上翻|- 下翻|- 左翻|- 右翻|- 反色|- 浮雕|- 打码\n" +
"- 负片|- 旋转|- 变形|- 亲|- 结婚申请|结婚登记|- 阿尼亚喜欢XXX\n" +
"- 像只|- 我永远喜欢XXX|- 像样的亲亲|- 国旗|- 不要靠近\n" +
"- 蒙蔽|- 踩|- 好玩|- 2转|- 踢球|- 2舔|- 可莉吃|- 胡桃啃|- 怀\n" +
"- 小画家|- 完美|- 玩游戏|- 出警|- 警察|- 舔|舔屏|prpr\n" +
"- 安全感|- 精神支柱|- 想什么|- 墙纸|- 为什么at我|- 交个朋友\n" +
"- 打工人|- 继续干活|- 兑换券|- 炖|- 垃圾桶|- 垃圾|- 捶|- 啾啾\n" +
"- 我老婆|- 小天使XXX|- 你的XXX|- 不要看|- 玩一下XXX|- 给我变\n" +
"- 万能表情|- 空白表情|- 采访|- 需要|- 你可能需要|- 这像画吗\n" +
"- 一直(支持动图)\n" +
"例: 制图命令XXX[@用户|QQ号|图片]\n" +
"Tips: XXX可以为限制长度的任何文字\n" +
"对Bot使用为 @Bot制图命令[XXX]@Bot",
PrivateDataFolder: "gif",
}).ApplySingle(ctxext.DefaultSingle)
datapath = file.BOTPATH + "/" + en.DataFolder()
en.OnRegex(`^(` + strings.Join(cmd, "|") + `)[\s\S]*?(\[CQ:(image\,file=([0-9a-zA-Z]{32}).*|at.+?(\d{5,11}))\].*|(\d+))$`).
SetBlock(true).Handle(func(ctx *zero.Ctx) {
c := newContext(ctx.Event.UserID)
list := ctx.State["regex_matched"].([]string)
err := c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
argslist := strings.Split(strings.TrimSuffix(strings.TrimPrefix(list[0], list[1]), list[2]), " ")
picurl, err := cmdMap[list[1]](c, argslist...)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image(picurl))
})
}

View File

@@ -4,12 +4,13 @@ package github
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
control "github.com/FloatTech/zbputils/control"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -17,12 +18,12 @@ import (
)
func init() { // 插件主体
control.Register("github", &control.Options{
control.Register("github", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "GitHub仓库搜索\n" +
"- >github [xxx]\n" +
Brief: "GitHub仓库搜索",
Help: "- >github [xxx]\n" +
"- >github -p [xxx]",
}).OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).FirstPriority().
}).OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 发送请求
header := http.Header{
@@ -60,9 +61,9 @@ func init() { // 插件主体
"Star/Fork/Issue: ",
repo.Get("watchers").Int(), "/", repo.Get("forks").Int(), "/", repo.Get("open_issues").Int(), "\n",
"Language: ",
notnull(repo.Get("language").Str, "None"), "\n",
notnull(repo.Get("language").Str), "\n",
"License: ",
notnull(strings.ToUpper(repo.Get("license.key").Str), "None"), "\n",
notnull(strings.ToUpper(repo.Get("license.key").Str)), "\n",
"Last pushed: ",
repo.Get("pushed_at").Str, "\n",
"Jump: ",
@@ -78,9 +79,9 @@ func init() { // 插件主体
"Star/Fork/Issue: ",
repo.Get("watchers").Int(), "/", repo.Get("forks").Int(), "/", repo.Get("open_issues").Int(), "\n",
"Language: ",
notnull(repo.Get("language").Str, "None"), "\n",
notnull(repo.Get("language").Str), "\n",
"License: ",
notnull(strings.ToUpper(repo.Get("license.key").Str), "None"), "\n",
notnull(strings.ToUpper(repo.Get("license.key").Str)), "\n",
"Last pushed: ",
repo.Get("pushed_at").Str, "\n",
"Jump: ",
@@ -95,10 +96,10 @@ func init() { // 插件主体
}
// notnull 如果传入文本为空,则返回默认值
//nolint: unparam
func notnull(text, defstr string) string {
func notnull(text string) string {
if text == "" {
return defstr
return "None"
}
return text
}
@@ -117,7 +118,7 @@ func netGet(dest string, header http.Header) ([]byte, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

View File

@@ -0,0 +1,473 @@
package guessmusic
import (
"encoding/json"
"math/rand"
"net/url"
"os"
"strconv"
"strings"
"time"
wyy "github.com/FloatTech/AnimeAPI/neteasemusic"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/zbputils/ctxext"
"github.com/pkg/errors"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
// API配置
engine.OnPrefix("设置猜歌API", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["args"].(string)
if option == "帮助" {
ctx.SendChain(message.Text(
"项目地址:binaryify.github.io/NeteaseCloudMusicApi" +
"\n网上有基于该框架的API,可以自行搜索白嫖。\n" +
"添加API指令:\n设置猜歌API [API首页网址]"))
return
}
if !strings.HasSuffix(option, "/") {
option += "/"
}
cfg.APIURL = option
err := saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
// API配置
engine.OnRegex(`^猜歌(开启|关闭)(歌单|歌词)自动下载`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
swtich := ctx.State["regex_matched"].([]string)[1]
option := ctx.State["regex_matched"].([]string)[2]
chose := true
if swtich == "关闭" {
chose = false
}
if option == "歌单" {
cfg.API = chose
} else {
cfg.Local = chose
}
err := saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
engine.OnFullMatch("登录网易云", zero.SuperUserPermission, func(ctx *zero.Ctx) bool {
if !zero.OnlyPrivate(ctx) {
ctx.SendChain(message.Text("为了保护登录过程,请bot主人私聊。"))
return false
}
return true
}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyURL := cfg.APIURL + "login/qr/key"
data, err := web.GetData(keyURL)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "获取网易云key失败,", err))
return
}
var keyInfo keyInfo
err = json.Unmarshal(data, &keyInfo)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "解析网易云key失败,", err))
return
}
qrURL := cfg.APIURL + "login/qr/create?key=" + keyInfo.Data.Unikey + "&qrimg=1"
data, err = web.GetData(qrURL)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "获取网易云二维码失败,", err))
return
}
var qrInfo qrInfo
err = json.Unmarshal(data, &qrInfo)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "解析网易云二维码失败,", err))
return
}
ctx.SendChain(message.Text("[请使用手机APP扫描二维码或者进入网页扫码登录]\n", qrInfo.Data.Qrurl),
message.Image("base64://"+strings.ReplaceAll(qrInfo.Data.Qrimg, "data:image/png;base64,", "")),
message.Text("二维码有效时间为6分钟,登陆后请耐心等待结果,获取cookie过程有些漫长。"))
i := 0
for range time.NewTicker(10 * time.Second).C {
APIURL := cfg.APIURL + "login/qr/check?key=" + url.QueryEscape(keyInfo.Data.Unikey)
data, err := web.GetData(APIURL)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "无法获取登录状态,", err))
return
}
var cookiesInfo cookyInfo
err = json.Unmarshal(data, &cookiesInfo)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "解析登录状态失败,", err))
return
}
switch cookiesInfo.Code {
case 803:
cfg.Cookie = cookiesInfo.Cookie
err = saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
return
case 801:
i++
if i%6 == 0 { // 每1分钟才提醒一次,减少提示(380/60=6次)
ctx.SendChain(message.Text("状态:", cookiesInfo.Message))
}
continue
case 800:
ctx.SendChain(message.Text("状态:", cookiesInfo.Message))
return
default:
ctx.SendChain(message.Text("状态:", cookiesInfo.Message))
continue
}
}
})
engine.OnRegex(`^歌单信息\s*((https:\/\/music\.163\.com\/#\/playlist\?id=)?(\d+)|http:\/\/music\.163\.com\/playlist\/(\d+).*)$`).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
listID := ctx.State["regex_matched"].([]string)[3] + ctx.State["regex_matched"].([]string)[4]
_, err := strconv.ParseInt(listID, 10, 64)
if err != nil {
ctx.SendChain(message.Text("请输入正确的歌单ID或者歌单连接"))
return
}
APIURL := cfg.APIURL + "playlist/detail?id=" + listID
data, err := web.GetData(APIURL)
if err != nil {
ctx.SendChain(message.Text("无法连接歌单,", err))
return
}
var parsed listInfoOfAPI
err = json.Unmarshal(data, &parsed)
if err != nil {
ctx.SendChain(message.Text("无法解析歌单ID内容,", err))
return
}
ctx.SendChain(
message.Image(parsed.Playlist.CoverImgURL),
message.Text(
"歌单名称:", parsed.Playlist.Name,
"\n歌单ID:", parsed.Playlist.ID,
"\n创建人:", parsed.Playlist.Creator.Nickname,
"\n创建时间:", time.Unix(parsed.Playlist.CreateTime/1000, 0).Format("2006-01-02"),
"\n标签:", strings.Join(parsed.Playlist.Tags, ";"),
"\n歌曲数量:", parsed.Playlist.TrackCount,
"\n歌单简介:\n", parsed.Playlist.Description,
"\n更新时间:", time.Unix(parsed.Playlist.UpdateTime/1000, 0).Format("2006-01-02"),
))
})
// 本地绑定网易云歌单ID
engine.OnRegex(`^(.*)绑定网易云\s*((https:\/\/music\.163\.com\/#\/playlist\?id=)?(\d+)|http:\/\/music\.163\.com\/playlist\/(\d+).*)$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
listName := ctx.State["regex_matched"].([]string)[1]
listID := ctx.State["regex_matched"].([]string)[4] + ctx.State["regex_matched"].([]string)[5]
ctx.SendChain(message.Text("正在校验歌单信息,请稍等"))
pathOfMusic := cfg.MusicPath + listName + "/"
if file.IsNotExist(pathOfMusic) {
ctx.SendChain(message.Text(serviceErr, "歌单不存在于本地"))
return
}
// 是否存在该歌单
APIURL := cfg.APIURL + "playlist/track/all?id=" + listID
data, err := web.GetData(APIURL)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
var parsed musicListOfApI
err = json.Unmarshal(data, &parsed)
if err != nil {
ctx.SendChain(message.Text(serviceErr, "无法解析歌单ID内容,", err))
return
}
if parsed.Code != 200 {
ctx.SendChain(message.Text(serviceErr, parsed.Code))
return
}
mid, _ := strconv.ParseInt(listID, 10, 64)
cfg.Playlist = append(cfg.Playlist, listRaw{
Name: listName,
ID: mid,
})
err = saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
engine.OnPrefix("解除绑定", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
delList := ctx.State["args"].(string)
filelist, err := getlist(cfg.MusicPath)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
var playID int64
for _, listinfo := range filelist {
if delList == listinfo.Name {
playID = listinfo.ID
break
}
}
// 删除ID
if playID == 0 { // 如果ID没有且没删除文件
ctx.SendChain(message.Text("歌单名称错误或者该歌单并没有绑定网易云,可以发送“歌单列表”获取歌单名称"))
return
}
index := -1
for i, list := range cfg.Playlist {
if playID == list.ID {
index = i
break
}
}
if index == -1 {
ctx.SendChain(message.Text("歌单名称错误或者该歌单并没有绑定网易云,可以发送“歌单列表”获取歌单名称"))
return
}
cfg.Playlist = append(cfg.Playlist[:index], cfg.Playlist[index+1:]...)
err = saveConfig(cfgFile)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
// 下载歌曲到对应的歌单里面
engine.OnRegex(`^下载歌单\s*((https:\/\/music\.163\.com\/#\/playlist\?id=)?(\d+)|http:\/\/music\.163\.com\/playlist\/(\d+).*[^\s$])\s*到\s*(.*)$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[3] + ctx.State["regex_matched"].([]string)[4]
listName := ctx.State["regex_matched"].([]string)[5]
ctx.SendChain(message.Text("正在校验歌单信息,请稍等"))
// 是否存在该歌单
if file.IsNotExist(cfg.MusicPath + listName) {
ctx.SendChain(message.Text("歌单不存在,是否创建?(是/否)"))
next := zero.NewFutureEvent("message", 999, false, zero.OnlyGroup, zero.RegexRule(`(是|否)`), ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(120 * time.Second)
answer := ""
for {
select {
case <-wait.C:
wait.Stop()
ctx.SendChain(message.Text("等待超时,取消下载"))
return
case c := <-recv:
wait.Stop()
answer = c.Event.Message.String()
}
if answer == "否" {
ctx.SendChain(message.Text("下载已经取消"))
return
}
if answer != "" {
break
}
}
err := os.MkdirAll(cfg.MusicPath+listName, 0755)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
}
ctx.SendChain(message.Text("开始下载歌曲,需要一定时间下载,请稍等"))
listID, err := strconv.ParseInt(keyword, 10, 64)
if err == nil {
err = downloadlist(listID, cfg.MusicPath+listName+"/")
}
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
}
// 随机从歌单下载歌曲(歌单ID, 音乐保存路径)
func drawByAPI(playlistID int64, musicPath string) (musicName string, err error) {
APIURL := cfg.APIURL + "playlist/track/all?id=" + strconv.FormatInt(playlistID, 10)
data, err := web.GetData(APIURL)
if err != nil {
err = errors.Errorf("无法获取歌单列表\n%s", err)
return
}
var parsed musicListOfApI
err = json.Unmarshal(data, &parsed)
if err != nil {
err = errors.Errorf("无法读取歌单列表\n%s", err)
return
}
listlen := len(parsed.Songs)
randidx := rand.Intn(listlen)
// 将"/"符号去除,不然无法生成文件
name := strings.ReplaceAll(parsed.Songs[randidx].Name, "/", "·")
musicID := parsed.Songs[randidx].ID
artistName := ""
for i, ARInfo := range parsed.Songs[randidx].Ar {
if i != 0 {
artistName += "&" + ARInfo.Name
} else {
artistName += ARInfo.Name
}
}
cource := ""
if parsed.Songs[randidx].Alia != nil {
cource = strings.Join(parsed.Songs[randidx].Alia, "&")
// 将"/"符号去除,不然无法下载
cource = strings.ReplaceAll(cource, "/", "&")
}
if name == "" || musicID == 0 {
err = errors.New("无法获API取歌曲信息")
return
}
if cource != "" {
name += " - " + artistName + " - " + cource
} else {
name += " - " + artistName
}
// 下载歌曲
err = wyy.DownloadMusic(musicID, name, musicPath)
if err == nil {
musicName = name + ".mp3"
if cfg.Local {
// 下载歌词
_ = wyy.DownloadLrc(musicID, name, musicPath+"歌词/")
}
}
return
}
// 下载歌单歌曲(歌单ID, 音乐保存路径)
func downloadlist(playlistID int64, musicPath string) error {
APIURL := cfg.APIURL + "playlist/track/all?id=" + strconv.FormatInt(playlistID, 10)
data, err := web.GetData(APIURL)
if err != nil {
return err
}
var parsed musicListOfApI
err = json.Unmarshal(data, &parsed)
if err != nil {
return err
}
if parsed.Code != 200 {
err = errors.Errorf("requset code : %d", parsed.Code)
return err
}
for _, info := range parsed.Songs {
// 将"/"符号去除,不然无法生成文件
musicName := strings.ReplaceAll(info.Name, "/", "·")
musicID := info.ID
artistName := ""
for i, ARInfo := range info.Ar {
if i != 0 {
artistName += "&" + ARInfo.Name
} else {
artistName += ARInfo.Name
}
}
cource := ""
if info.Alia != nil {
cource = strings.Join(info.Alia, "&")
// 将"/"符号去除,不然无法下载
cource = strings.ReplaceAll(cource, "/", "&")
}
if musicName == "" || musicID == 0 {
err = errors.New("无法获API取歌曲信息")
return err
}
if cource != "" {
musicName += " - " + artistName + " - " + cource
} else {
musicName += " - " + artistName
}
// 下载歌曲
err = wyy.DownloadMusic(musicID, musicName, musicPath)
if err == nil {
if cfg.Local {
// 下载歌词
_ = wyy.DownloadLrc(musicID, musicName, musicPath+"歌词/")
}
}
}
return nil
}
/*****************************************************************/
/**************************独角兽API*******************************/
/*****************************************************************/
// 下载从独角兽抽到的歌曲ID(歌单ID, 音乐保存路径, 歌词保存路径)
func downloadByOvooa(playlistID int64, musicPath string) (musicName string, err error) {
// 抽取歌曲
mid, err := drawByOvooa(playlistID)
if err != nil {
err = errors.Errorf("API%s", err)
return
}
// 获取完成的歌名
musiclist, err := wyy.SearchMusic(strconv.Itoa(mid), 1)
if err != nil {
err = errors.Errorf("API歌曲下载ERROR: %s", err)
return
}
// 歌曲ID理论是唯一的
mun := len(musiclist)
if mun == 1 {
// 拉取歌名
musicList := make([]string, mun)
i := 0
for musicName := range musiclist {
musicList[i] = musicName
}
name := musicList[0]
// 下载歌曲
err = wyy.DownloadMusic(mid, name, musicPath)
if err == nil {
musicName = name + ".mp3"
if cfg.Local {
// 下载歌词
_ = wyy.DownloadLrc(mid, name, musicPath+"歌词/")
}
}
} else {
err = errors.Errorf("music IDThis music ID sreached munber is %d", mun)
}
return
}
// 通过独角兽API随机抽取歌单歌曲ID(参数歌单ID)
func drawByOvooa(playlistID int64) (musicID int, err error) {
APIURL := "https://ovooa.com/API/163_Music_Rand/api.php?id=" + strconv.FormatInt(playlistID, 10)
data, err := web.GetData(APIURL)
if err != nil {
return
}
var parsed ovooaData
err = json.Unmarshal(data, &parsed)
if err != nil {
return
}
if parsed.Code != 1 {
return
}
return parsed.Data.ID, nil
}

View File

@@ -0,0 +1,316 @@
package guessmusic
import (
"bytes"
"io/fs"
"math/rand"
"os"
"os/exec"
"strconv"
"strings"
"sync"
"time"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/zbputils/ctxext"
"github.com/pkg/errors"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var cuttime = [...]string{"00:00:05", "00:00:30", "00:01:00"} // 音乐切割时间点,可自行调节时间(时:分:秒)
func init() {
engine.OnRegex(`^(个人|团队)猜歌(-(.*))?$`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
mode := ctx.State["regex_matched"].([]string)[3]
gid := ctx.Event.GroupID
// 获取本地列表
filelist, err := getlist(cfg.MusicPath)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
// 加载默认歌单
if mode == "" {
index := -1
for i, dlist := range cfg.Defaultlist {
if dlist.GroupID == gid {
index = i
break
}
}
if index == -1 {
// 如果没有设置就默认第一个文件夹
mode = filelist[0].Name
} else {
mode = cfg.Defaultlist[index].Name
ok := true
for _, listinfo := range filelist {
if mode == listinfo.Name {
ok = false
break
}
}
// 如果默认的歌单不存在了清空设置
if ok {
cfg.Defaultlist = append(cfg.Defaultlist[:index], cfg.Defaultlist[index+1:]...)
_ = saveConfig(cfgFile)
mode = filelist[0].Name
}
}
}
ctx.SendChain(message.Text("正在准备歌曲,请稍等\n回答“-[歌曲信息(歌名歌手等)|提示|取消]”\n一共3段语音,6次机会"))
// 随机抽歌
pathOfMusic, musicName, err := musicLottery(cfg.MusicPath, mode)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
// 解析歌曲信息
music := strings.Split(musicName, ".")
// 获取音乐后缀
musictype := music[len(music)-1]
if !strings.Contains(musictypelist, musictype) {
ctx.SendChain(message.Text("抽取到了歌曲:\n",
musicName, "\n该歌曲不是音乐后缀,请联系bot主人修改"))
return
}
// 获取音乐信息
musicInfo := strings.Split(strings.ReplaceAll(musicName, "."+musictype, ""), " - ")
infoNum := len(musicInfo)
if infoNum == 1 {
ctx.SendChain(message.Text("抽取到了歌曲:\n",
musicName, "\n该歌曲命名不符合命名规则,请联系bot主人修改"))
return
}
answerString := "歌名:" + musicInfo[0] + "\n歌手:" + musicInfo[1]
if infoNum > 2 {
musicInfo[2] = strings.ReplaceAll(musicInfo[2], "&", "\n")
answerString += "\n其他信息:\n" + musicInfo[2]
}
musicInfo = append(musicInfo, answerString)
// 切割音频,生成3个10秒的音频
outputPath := cachePath + strconv.FormatInt(gid, 10) + "/"
err = cutMusic(musicName, pathOfMusic, outputPath)
if err != nil {
ctx.SendChain(message.Text(err))
return
}
// 进行猜歌环节
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + outputPath + "0.wav"))
var next *zero.FutureEvent
if ctx.State["regex_matched"].([]string)[1] == "个人" {
next = zero.NewFutureEvent("message", 999, false, zero.OnlyGroup, zero.RegexRule(`^-\S{1,}`), ctx.CheckSession())
} else {
next = zero.NewFutureEvent("message", 999, false, zero.OnlyGroup, zero.RegexRule(`^-\S{1,}`), zero.CheckGroup(ctx.Event.GroupID))
}
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(40 * time.Second)
tick := time.NewTimer(105 * time.Second)
after := time.NewTimer(120 * time.Second)
wg := sync.WaitGroup{}
var (
messageStr message.MessageSegment // 文本信息
tickCount = 0 // 音频数量
answerCount = 0 // 问答次数
win bool // 是否赢得游戏
)
for {
select {
case <-tick.C:
ctx.SendChain(message.Text("猜歌游戏,你还有15s作答时间"))
case <-after.C:
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
message.Text("时间超时,猜歌结束,公布答案:\n", answerString)))
return
case <-wait.C:
wait.Reset(40 * time.Second)
tickCount++
if tickCount > 2 {
wait.Stop()
continue
}
ctx.SendChain(
message.Text("好像有些难度呢,再听这段音频,要仔细听哦"),
)
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + outputPath + strconv.Itoa(tickCount) + ".wav"))
case c := <-recv:
wg.Add(1)
go func() {
messageStr, answerCount, tickCount, win = gameMatch(c, ctx.Event.UserID, musicInfo, answerCount, tickCount)
if win { // 游戏结束的话
wait.Stop()
tick.Stop()
after.Stop()
ctx.SendChain(message.Reply(c.Event.MessageID), messageStr)
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
} else {
wait.Reset(40 * time.Second)
tick.Reset(105 * time.Second)
after.Reset(120 * time.Second)
if tickCount > 2 || messageStr.Data["text"] == "你无权限取消" {
ctx.SendChain(message.Reply(c.Event.MessageID), messageStr)
} else {
ctx.SendChain(message.Reply(c.Event.MessageID), messageStr)
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + outputPath + strconv.Itoa(tickCount) + ".wav"))
}
}
wg.Done()
}()
wg.Wait()
if win {
return
}
}
}
})
}
// 随机抽取音乐
func musicLottery(musicPath, listName string) (pathOfMusic, musicName string, err error) {
// 读取歌单文件
pathOfMusic = musicPath + listName + "/"
if file.IsNotExist(pathOfMusic) {
err = errors.New("指定的歌单不存在,可发送“歌单列表”查看歌单列表")
return
}
files, err := os.ReadDir(pathOfMusic)
if err != nil {
return
}
// 获取绑定的网易云
var playlistID int64
for _, listinfo := range cfg.Playlist {
if listinfo.Name == listName {
playlistID = listinfo.ID
}
}
// 如果本地列表为空
if len(files) == 0 {
if playlistID == 0 || !cfg.API {
err = errors.New("本地歌单数据为0")
return
}
// 如果绑定了歌单ID
if cfg.APIURL == "" {
// 如果没有配置过API地址,尝试连接独角兽
musicName, err = downloadByOvooa(playlistID, pathOfMusic)
if err != nil {
err = errors.Errorf("本地歌单数据为0,API下载歌曲失败\n%s", err)
}
} else {
// 从API中抽取歌曲
musicName, err = drawByAPI(playlistID, pathOfMusic)
if err != nil {
err = errors.Errorf("本地歌单数据为0,API下载歌曲失败\n%s", err)
}
}
return
}
// 进行随机抽取
if playlistID == 0 || !cfg.API {
musicName = getLocalMusic(files, 10)
} else {
switch rand.Intn(3) { // 三分二概率抽取API的
case 1:
musicName = getLocalMusic(files, 10)
default:
if cfg.APIURL == "" {
// 如果没有配置过API地址,尝试连接独角兽
musicName, err = downloadByOvooa(playlistID, pathOfMusic)
} else {
// 从API中抽取歌曲
musicName, err = drawByAPI(playlistID, pathOfMusic)
}
if err != nil {
musicName = getLocalMusic(files, 10)
}
}
}
if musicName == "" {
err = errors.New("抽取歌曲轮空了,请重试")
}
return
}
// 从本地列表中随机抽取一首( indexMax : 最大递归次数 )
func getLocalMusic(files []fs.DirEntry, indexMax int) (musicName string) {
if len(files) > 1 {
music := files[rand.Intn(len(files))]
// 如果是文件夹就递归
if music.IsDir() {
indexMax--
if indexMax <= 0 {
return
}
musicName = getLocalMusic(files, indexMax)
} else {
musicName = music.Name()
}
} else {
music := files[0]
if !music.IsDir() {
musicName = files[0].Name()
}
}
return
}
// 切割音乐成三个10s音频
func cutMusic(musicName, pathOfMusic, outputPath string) (err error) {
err = os.MkdirAll(outputPath, 0755)
if err != nil {
err = errors.Errorf("[生成歌曲目录错误]ERROR: %s", err)
return
}
var stderr bytes.Buffer
cmdArguments := []string{"-y", "-i", pathOfMusic + musicName,
"-ss", cuttime[0], "-t", "10", file.BOTPATH + "/" + outputPath + "0.wav",
"-ss", cuttime[1], "-t", "10", file.BOTPATH + "/" + outputPath + "1.wav",
"-ss", cuttime[2], "-t", "10", file.BOTPATH + "/" + outputPath + "2.wav", "-hide_banner"}
cmd := exec.Command("ffmpeg", cmdArguments...)
cmd.Stderr = &stderr
err = cmd.Run()
if err != nil {
err = errors.Errorf("[生成歌曲错误]ERROR: %s", stderr.String())
return
}
return
}
// 数据匹配(结果信息,答题次数,提示次数,是否结束游戏)
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)
switch {
case answer == "取消":
if c.Event.UserID == beginner {
return message.Text("游戏已取消,猜歌答案是\n", musicInfo[len(musicInfo)-1], "\n\n\n下面欣赏猜歌的歌曲"), answerTimes, tickTimes, true
}
return message.Text("你无权限取消"), answerTimes, tickTimes, false
case answer == "提示":
tickTimes++
if tickTimes > 2 {
return message.Text("已经没有提示了哦"), answerTimes, tickTimes, false
}
return message.Text("再听这段音频,要仔细听哦"), answerTimes, tickTimes, false
case strings.Contains(musicInfo[0], answer) || strings.EqualFold(musicInfo[0], answer):
return message.Text("太棒了,你猜对歌曲名了!答案是\n", musicInfo[len(musicInfo)-1], "\n\n下面欣赏猜歌的歌曲"), answerTimes, tickTimes, true
case strings.Contains(musicInfo[1], answer) || strings.EqualFold(musicInfo[1], answer):
return message.Text("太棒了,你猜对歌手名了!答案是\n", musicInfo[len(musicInfo)-1], "\n\n下面欣赏猜歌的歌曲"), answerTimes, tickTimes, true
case len(musicInfo) == 4 && (strings.Contains(musicInfo[2], answer) || strings.EqualFold(musicInfo[2], answer)):
return message.Text("太棒了,你猜对相关信息了!答案是\n", musicInfo[len(musicInfo)-1], "\n\n下面欣赏猜歌的歌曲"), answerTimes, tickTimes, true
default:
answerTimes++
tickTimes++
switch {
case tickTimes > 2 && answerTimes < 6:
return message.Text("答案不对哦,还有", 6-answerTimes, "次答题,加油啊~"), answerTimes, tickTimes, false
case tickTimes > 2:
return message.Text("次数到了,没能猜出来。答案是\n", musicInfo[len(musicInfo)-1], "\n\n下面欣赏猜歌的歌曲"), answerTimes, tickTimes, true
default:
return message.Text("答案不对,再听这段音频,要仔细听哦"), answerTimes, tickTimes, false
}
}
}

580
plugin/guessmusic/main.go Normal file
View File

@@ -0,0 +1,580 @@
// Package guessmusic 基于zbp的猜歌插件
package guessmusic
import (
"encoding/json"
"os"
"strconv"
"strings"
"time"
wyy "github.com/FloatTech/AnimeAPI/neteasemusic"
"github.com/FloatTech/imgfactory"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/pkg/errors"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/single"
"github.com/wdvxdr1123/ZeroBot/message"
// 图片输出
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/process"
"github.com/FloatTech/gg"
"github.com/FloatTech/zbputils/img/text"
)
const serviceErr = "[guessmusic]error:"
var (
// 用户数据
cfg config
// 插件主体
engine = control.Register("guessmusic", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "猜歌插件",
Help: "------bot主人指令------\n" +
"- 设置猜歌歌库路径 [绝对路径]\n" +
"- [创建/删除]歌单 [歌单名称]\n" +
"- 下载歌曲[歌曲名称/网易云歌曲ID]到[歌单名称]\n" +
"------管 理 员 指 令------\n" +
"- 设置猜歌默认歌单 [歌单名称]\n" +
"- 上传歌曲[群文件的音乐名]到[歌单名称]\n" +
"------公 用 指 令------\n" +
"- 歌单列表\n" +
"- [个人/团队]猜歌\n" +
"\n------重 要 事 项------\n" +
"1.本插件依赖ffmpeg\n" +
"2.\"删除[歌单名称]\"是将本地歌单数据全部删除, 慎用\n" +
"3.不支持下载VIP歌曲,如有需求请用群文件上传\n" +
"4.未设置默认歌单的场合,猜歌歌单为歌单列表第一个。\n" +
"此外可在\"[个人/团队]猜歌\"指令后面添加[-歌单名称]进行指定歌单猜歌\n" +
"5.猜歌内容必须以[-]开头才会识别\n" +
"6.歌曲命名规则为:\n歌名 - 歌手 - 其他(歌曲出处之类)" +
"\n------插 件 扩 展------\n" +
"内置了独角兽API,但API不保证可靠性。\n" +
"可以自行搭建或寻找NeteaseCloudMusicApi框架的API,本插件支持该API以下指令\n" +
"NeteaseCloudMusicApi项目地址:\nhttps://binaryify.github.io/NeteaseCloudMusicApi/#/\n" +
"- 设置猜歌API帮助\n" +
"- 设置猜歌API [API首页网址]\n" +
"- 猜歌[开启/关闭][歌单/歌词]自动下载\n" +
"- 登录网易云(这个指令目前不知道能干嘛,总之先保留了)\n" +
"- 歌单信息 [网易云歌单链接/ID]\n" +
"- [歌单名称]绑定网易云[网易云歌单链接/ID]\n" +
"- 下载歌单[网易云歌单链接/ID]到[歌单名称]\n" +
"- 解除绑定 [歌单名称]",
PrivateDataFolder: "guessmusic",
}).ApplySingle(single.New(
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
single.WithPostFn[int64](func(ctx *zero.Ctx) {
ctx.Break()
ctx.Send(
message.ReplyWithMessage(ctx.Event.MessageID,
message.Text("已经有正在进行的游戏..."),
),
)
}),
))
// 用于存放歌曲三个片段的缓存文件夹
cachePath = engine.DataFolder() + "cache/"
// 用于存放用户的配置
cfgFile = engine.DataFolder() + "config.json"
// ffmpeg支持的格式
musictypelist = "mp3;MP3;wav;WAV;amr;AMR;3gp;3GP;3gpp;3GPP;acc;ACC"
)
func init() {
// 新建缓存文件夹
err := os.MkdirAll(cachePath, 0755)
if err != nil {
panic(serviceErr + err.Error())
}
// 载入用户配置
if file.IsExist(cfgFile) {
reader, err := os.Open(cfgFile)
if err == nil {
err = json.NewDecoder(reader).Decode(&cfg)
}
if err != nil {
panic(serviceErr + err.Error())
}
err = reader.Close()
if err != nil {
panic(serviceErr + err.Error())
}
} else {
// 配置默认 config
cfg = config{
MusicPath: file.BOTPATH + "/data/guessmusic/music/", // 绝对路径,歌库根目录,通过指令进行更改
Playlist: []listRaw{
{
Name: "这里是歌单名称,id为网易云歌单ID",
ID: 123456,
},
},
Defaultlist: []dlist{
{
GroupID: 123456,
Name: "这里是歌单名称,gid是群号",
},
},
API: true,
Local: true,
}
err = saveConfig(cfgFile)
if err != nil {
panic(serviceErr + err.Error())
}
}
// 用户配置
engine.OnPrefix("设置猜歌歌库路径", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["args"].(string)
musicPath := strings.ReplaceAll(option, "\\", "/")
if !strings.HasSuffix(musicPath, "/") {
musicPath += "/"
}
err := os.MkdirAll(musicPath, 0755)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
cfg.MusicPath = musicPath
err = saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
engine.OnPrefix("创建歌单", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
newList := cfg.MusicPath + ctx.State["args"].(string)
if file.IsNotExist(newList) {
err := os.MkdirAll(newList, 0755)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
} else {
ctx.SendChain(message.Text("歌单已存在!"))
}
})
engine.OnPrefix("删除歌单", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
delList := ctx.State["args"].(string)
err = os.RemoveAll(cfg.MusicPath + delList)
if err != nil {
ctx.SendChain(message.Text("删除失败,可能是歌单名称错误。\n可以发送“歌单列表”获取歌单名称"))
return
}
// 删除绑定的网易云ID
index := -1
for i, list := range cfg.Playlist {
if delList == list.Name {
index = i
break
}
}
if index == -1 {
ctx.SendChain(message.Text("成功!"))
return
}
cfg.Playlist = append(cfg.Playlist[:index], cfg.Playlist[index+1:]...)
err = saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
// 下载歌曲到对应的歌单里面
engine.OnRegex(`^下载歌曲\s*(.*)\s*到\s*(.*)$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
listName := ctx.State["regex_matched"].([]string)[2]
ctx.SendChain(message.Text("正在校验歌单信息,请稍等"))
// 是否存在该歌单
if file.IsNotExist(cfg.MusicPath + listName) {
ctx.SendChain(message.Text("歌单不存在,是否创建?(是/否)"))
next := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`(是|否)`), ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(120 * time.Second)
answer := ""
for {
select {
case <-wait.C:
wait.Stop()
ctx.SendChain(message.Text("等待超时,取消下载"))
return
case c := <-recv:
wait.Stop()
answer = c.Event.Message.String()
}
if answer == "否" {
ctx.SendChain(message.Text("下载已经取消"))
return
}
if answer != "" {
break
}
}
err = os.MkdirAll(cfg.MusicPath+listName, 0777)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
}
searchlist, err := wyy.SearchMusic(keyword, 5)
if err != nil {
ctx.SendChain(message.Text("查询歌曲失败!\nerr:", err))
return
}
if len(searchlist) == 0 {
ctx.SendChain(message.Text("歌曲没有查询到,请确认信息正确"))
return
}
var musicchoose []string
for musicName := range searchlist {
musicchoose = append(musicchoose, musicName)
}
savePath := cfg.MusicPath + listName + "/"
index := 0
if len(musicchoose) > 1 {
var msg []string
msg = append(msg, "搜索到相近的歌曲,请回复对应序号进行下载或回复取消")
for i, musicName := range musicchoose {
msg = append(msg, strconv.Itoa(i)+"."+musicName)
}
ctx.SendChain(message.Text(strings.Join(msg, "\n")))
next := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`[0-4]|取消`), ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(120 * time.Second)
answer := ""
for {
select {
case <-wait.C:
wait.Stop()
ctx.SendChain(message.Text("等待超时,取消下载"))
return
case c := <-recv:
wait.Stop()
answer = c.Event.Message.String()
if answer == "取消" {
ctx.SendChain(message.Text("已取消下载"))
return
}
index, _ = strconv.Atoi(answer)
}
if answer != "" {
break
}
}
}
musicName := musicchoose[index]
// 下载歌曲
err = wyy.DownloadMusic(searchlist[musicName], musicName, savePath)
if err == nil {
if cfg.Local {
// 下载歌词
_ = wyy.DownloadLrc(searchlist[musicName], musicName, savePath+"歌词/")
}
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
// 从群文件下载歌曲
engine.OnRegex(`^上传歌曲\s*(.*)\s*到\s*(.*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
fileName := ctx.State["regex_matched"].([]string)[1]
listName := ctx.State["regex_matched"].([]string)[2]
// 判断群文件是否存在
fileSearchName, fileURL := getFileURLbyFileName(ctx, fileName)
if fileSearchName == "" {
ctx.SendChain(message.Text(serviceErr, "请确认群文件文件名称是否正确或存在"))
return
}
// 解析歌曲信息
music := strings.Split(fileSearchName, ".")
// 获取音乐后缀
musictype := music[len(music)-1]
if !strings.Contains(musictypelist, musictype) {
ctx.SendChain(message.Text(fileSearchName, "不是插件支持的后缀,请更改后缀"))
return
}
// 获取音乐信息
musicInfo := strings.Split(strings.ReplaceAll(fileSearchName, "."+musictype, ""), " - ")
infoNum := len(musicInfo)
if infoNum == 1 {
ctx.SendChain(message.Text(fileSearchName, "不符合命名规则,请更改名称"))
return
}
fileName = "歌名:" + musicInfo[0] + "\n歌手:" + musicInfo[1]
musicAlia := ""
if infoNum > 2 {
musicAlia = musicInfo[2]
fileName += "\n其他信息:\n" + strings.ReplaceAll(musicAlia, "&", "\n")
}
// 是否存在该歌单
if file.IsNotExist(cfg.MusicPath + listName) {
if !zero.SuperUserPermission(ctx) {
ctx.SendChain(message.Text("歌单名称错误。\n可以发送“歌单列表”获取歌单名称"))
return
}
ctx.SendChain(message.Text("歌单不存在,是否创建?(是/否)"))
next := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`(是|否)`), ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(120 * time.Second)
answer := ""
for {
select {
case <-wait.C:
wait.Stop()
ctx.SendChain(message.Text("等待超时,取消下载"))
return
case c := <-recv:
wait.Stop()
answer = c.Event.Message.String()
}
if answer == "否" {
ctx.SendChain(message.Text("下载已经取消"))
return
}
if answer != "" {
break
}
}
err = os.MkdirAll(cfg.MusicPath+listName, 0755)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
}
// 下载歌曲
ctx.SendChain(message.Text("在群文件中找到了歌曲,信息如下:\n", fileName, "\n确认正确后回复“是/否”进行上传"))
next := zero.NewFutureEvent("message", 999, false, zero.RegexRule(`(是|否)`), ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
wait := time.NewTimer(120 * time.Second)
answer := ""
for {
select {
case <-wait.C:
wait.Stop()
ctx.SendChain(message.Text("等待超时,取消上传"))
return
case c := <-recv:
wait.Stop()
answer = c.Event.Message.String()
}
if answer == "否" {
ctx.SendChain(message.Text("上传已经取消"))
return
}
if answer != "" {
break
}
}
err = file.DownloadTo(fileURL, cfg.MusicPath+listName+"/"+fileSearchName)
if err == nil {
process.SleepAbout1sTo2s()
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
engine.OnFullMatch("歌单列表").SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
filelist, err := getlist(cfg.MusicPath)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
/***********设置图片的大小和底色***********/
number := len(filelist)
fontSize := 20.0
if number < 10 {
number = 10
}
canvas := gg.NewContext(480, int(80+fontSize*float64(number)))
canvas.SetRGB(1, 1, 1) // 白色
canvas.Clear()
/***********下载字体,可以注销掉***********/
boldfd, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
}
fd, err := file.GetLazyData(text.FontFile, control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
}
/***********设置字体颜色为黑色***********/
canvas.SetRGB(0, 0, 0)
/***********设置字体大小,并获取字体高度用来定位***********/
if err = canvas.ParseFontFace(boldfd, fontSize); err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
_, h := canvas.MeasureString("序号\t\t歌单名\t\t\t歌曲数量\t\t网易云歌单ID")
/***********绘制标题***********/
canvas.DrawString("序号\t\t歌单名\t\t歌曲数量\t\t网易云歌单ID", 20, 50-h) // 放置在中间位置
canvas.DrawString("——————————————————————", 20, 70-h)
/***********设置字体大小,并获取字体高度用来定位***********/
if err = canvas.ParseFontFace(fd, fontSize); err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
_, h = canvas.MeasureString("焯")
j := 0
for i, listinfo := range filelist {
canvas.DrawString(strconv.Itoa(i), 15, float64(85+20*i)-h)
canvas.DrawString(listinfo.Name, 85, float64(85+20*i)-h)
canvas.DrawString(strconv.Itoa(listinfo.Number), 220, float64(85+20*i)-h)
if listinfo.ID != 0 {
canvas.DrawString(strconv.FormatInt(listinfo.ID, 10), 320, float64(85+20*i)-h)
}
j = i + 2
}
for _, dlist := range cfg.Defaultlist {
if dlist.GroupID == ctx.Event.GroupID {
canvas.DrawString("当前设置的默认歌单为: "+dlist.Name, 80, float64(85+20*j)-h)
}
}
data, err := imgfactory.ToBytes(canvas.Image())
if err != nil {
ctx.SendChain(message.Text(serviceErr, err))
return
}
if id := ctx.SendChain(message.ImageBytes(data)); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
engine.OnPrefix("设置猜歌默认歌单", zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["args"].(string)
gid := ctx.Event.GroupID
if file.IsNotExist(cfg.MusicPath + option) {
ctx.SendChain(message.Text("歌单名称错误,可以发送“歌单列表”获取歌单名称"))
return
}
cfg.Defaultlist = append(cfg.Defaultlist, dlist{
GroupID: gid,
Name: option,
})
err = saveConfig(cfgFile)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text(serviceErr, err))
}
})
}
// 保存用户配置
func saveConfig(cfgFile string) error {
if reader, err := os.Create(cfgFile); err == nil {
err = json.NewEncoder(reader).Encode(&cfg)
if err != nil {
return err
}
} else {
return err
}
return nil
}
// 获取本地歌单列表
func getlist(pathOfMusic string) (list []listinfo, err error) {
wyyID := make(map[string]int64, 100)
for _, wyyinfo := range cfg.Playlist {
wyyID[wyyinfo.Name] = wyyinfo.ID
}
err = os.MkdirAll(pathOfMusic, 0755)
if err != nil {
return
}
files, err := os.ReadDir(pathOfMusic)
if err != nil {
return
}
if len(files) == 0 {
err = errors.New("所设置的歌库不存在任何歌单!")
return
}
for _, name := range files {
if !name.IsDir() {
continue
}
listName := name.Name()
listfiles, err := os.ReadDir(pathOfMusic + listName)
if err != nil {
continue
}
list = append(list, listinfo{
Name: listName,
Number: len(listfiles),
ID: wyyID[listName],
})
}
return
}
// 遍历群文件
func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileURL string) {
filesOfGroup := ctx.GetThisGroupRootFiles(ctx.Event.GroupID)
files := filesOfGroup.Get("files").Array()
folders := filesOfGroup.Get("folders").Array()
// 遍历当前目录的文件名
if len(files) != 0 {
for _, fileNameOflist := range files {
if strings.Contains(fileNameOflist.Get("file_name").String(), fileName) {
fileSearchName = fileNameOflist.Get("file_name").String()
fileURL = ctx.GetThisGroupFileUrl(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
return
}
}
}
// 遍历子文件夹
if len(folders) != 0 {
for _, folderNameOflist := range folders {
folderID := folderNameOflist.Get("folder_id").String()
fileSearchName, fileURL = getFileURLbyfolderID(ctx, fileName, folderID)
if fileSearchName != "" {
return
}
}
}
return
}
func getFileURLbyfolderID(ctx *zero.Ctx, fileName, folderid string) (fileSearchName, fileURL string) {
filesOfGroup := ctx.GetThisGroupFilesByFolder(folderid)
files := filesOfGroup.Get("files").Array()
folders := filesOfGroup.Get("folders").Array()
// 遍历当前目录的文件名
if len(files) != 0 {
for _, fileNameOflist := range files {
if strings.Contains(fileNameOflist.Get("file_name").String(), fileName) {
fileSearchName = fileNameOflist.Get("file_name").String()
fileURL = ctx.GetThisGroupFileUrl(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
return
}
}
}
// 遍历子文件夹
if len(folders) != 0 {
for _, folderNameOflist := range folders {
folderID := folderNameOflist.Get("folder_id").String()
fileSearchName, fileURL = getFileURLbyfolderID(ctx, fileName, folderID)
if fileSearchName != "" {
return
}
}
}
return
}

446
plugin/guessmusic/struct.go Normal file
View File

@@ -0,0 +1,446 @@
package guessmusic
// config内容
type config struct {
MusicPath string `json:"musicPath"`
APIURL string `json:"apiURL"`
Playlist []listRaw `json:"playlist"`
Defaultlist []dlist `json:"defaultlist"`
Local bool `json:"local"`
API bool `json:"api"`
Cookie string `json:"cookie"`
}
// 记录歌单绑定的网易云歌单ID
type listRaw struct {
Name string `json:"name"` // 歌单名称
ID int64 `json:"id"` // 歌单绑定的网易云ID
}
// 记录群默认猜歌
type dlist struct {
GroupID int64 `json:"gid"` // 群号
Name string `json:"name"` // 歌单名称
}
// 本地歌单列表信息
type listinfo struct {
Name string `json:"name"` // 歌单名称
Number int // 歌曲数量
ID int64 // 歌单绑定的歌曲ID
}
/*****************************************************************/
/***************NeteaseCloudMusicApi框架API************************/
/*****************************************************************/
// 获取登陆信息
type keyInfo struct {
Data struct {
Code int `json:"code"`
Unikey string `json:"unikey"`
} `json:"data"`
Code int `json:"code"`
}
type cookyInfo struct {
Code int `json:"code"`
Message string `json:"message"`
Cookie string `json:"cookie"`
}
type qrInfo struct {
Code int `json:"code"`
Data struct {
Qrurl string `json:"qrurl"`
Qrimg string `json:"qrimg"`
} `json:"data"`
}
// 获取歌单信息
type listInfoOfAPI struct {
Code int `json:"code"`
RelatedVideos interface{} `json:"relatedVideos"`
Playlist struct {
ID int64 `json:"id"`
Name string `json:"name"`
CoverImgID int64 `json:"coverImgId"`
CoverImgURL string `json:"coverImgUrl"`
CoverImgIDStr string `json:"coverImgId_str"`
AdType int `json:"adType"`
UserID int `json:"userId"`
CreateTime int64 `json:"createTime"`
Status int `json:"status"`
OpRecommend bool `json:"opRecommend"`
HighQuality bool `json:"highQuality"`
NewImported bool `json:"newImported"`
UpdateTime int64 `json:"updateTime"`
TrackCount int `json:"trackCount"`
SpecialType int `json:"specialType"`
Privacy int `json:"privacy"`
TrackUpdateTime int64 `json:"trackUpdateTime"`
CommentThreadID string `json:"commentThreadId"`
PlayCount int `json:"playCount"`
TrackNumberUpdateTime int64 `json:"trackNumberUpdateTime"`
SubscribedCount int `json:"subscribedCount"`
CloudTrackCount int `json:"cloudTrackCount"`
Ordered bool `json:"ordered"`
Description string `json:"description"`
Tags []string `json:"tags"`
UpdateFrequency interface{} `json:"updateFrequency"`
BackgroundCoverID int `json:"backgroundCoverId"`
BackgroundCoverURL interface{} `json:"backgroundCoverUrl"`
TitleImage int `json:"titleImage"`
TitleImageURL interface{} `json:"titleImageUrl"`
EnglishTitle interface{} `json:"englishTitle"`
OfficialPlaylistType interface{} `json:"officialPlaylistType"`
Subscribers []struct {
DefaultAvatar bool `json:"defaultAvatar"`
Province int `json:"province"`
AuthStatus int `json:"authStatus"`
Followed bool `json:"followed"`
AvatarURL string `json:"avatarUrl"`
AccountStatus int `json:"accountStatus"`
Gender int `json:"gender"`
City int `json:"city"`
Birthday int `json:"birthday"`
UserID int `json:"userId"`
UserType int `json:"userType"`
Nickname string `json:"nickname"`
Signature string `json:"signature"`
Description string `json:"description"`
DetailDescription string `json:"detailDescription"`
AvatarImgID int64 `json:"avatarImgId"`
BackgroundImgID int64 `json:"backgroundImgId"`
BackgroundURL string `json:"backgroundUrl"`
Authority int `json:"authority"`
Mutual bool `json:"mutual"`
ExpertTags interface{} `json:"expertTags"`
Experts interface{} `json:"experts"`
DjStatus int `json:"djStatus"`
VipType int `json:"vipType"`
RemarkName interface{} `json:"remarkName"`
AuthenticationTypes int `json:"authenticationTypes"`
AvatarDetail interface{} `json:"avatarDetail"`
Anchor bool `json:"anchor"`
BackgroundImgIDStr string `json:"backgroundImgIdStr"`
AvatarImgIDStr string `json:"avatarImgIdStr"`
AvatarImgIDString string `json:"AvatarImgIDString"`
} `json:"subscribers"`
Subscribed interface{} `json:"subscribed"`
Creator struct {
DefaultAvatar bool `json:"defaultAvatar"`
Province int `json:"province"`
AuthStatus int `json:"authStatus"`
Followed bool `json:"followed"`
AvatarURL string `json:"avatarUrl"`
AccountStatus int `json:"accountStatus"`
Gender int `json:"gender"`
City int `json:"city"`
Birthday int `json:"birthday"`
UserID int `json:"userId"`
UserType int `json:"userType"`
Nickname string `json:"nickname"`
Signature string `json:"signature"`
Description string `json:"description"`
DetailDescription string `json:"detailDescription"`
AvatarImgID int64 `json:"avatarImgId"`
BackgroundImgID int64 `json:"backgroundImgId"`
BackgroundURL string `json:"backgroundUrl"`
Authority int `json:"authority"`
Mutual bool `json:"mutual"`
ExpertTags interface{} `json:"expertTags"`
Experts interface{} `json:"experts"`
DjStatus int `json:"djStatus"`
VipType int `json:"vipType"`
RemarkName interface{} `json:"remarkName"`
AuthenticationTypes int `json:"authenticationTypes"`
AvatarDetail struct {
UserType int `json:"userType"`
IdentityLevel int `json:"identityLevel"`
IdentityIconURL string `json:"identityIconUrl"`
} `json:"avatarDetail"`
Anchor bool `json:"anchor"`
BackgroundImgIDStr string `json:"backgroundImgIdStr"`
AvatarImgIDStr string `json:"avatarImgIdStr"`
AvatarImgIDString string `json:"AvatarImgIDString"`
} `json:"creator"`
Tracks []struct {
Name string `json:"name"`
ID int `json:"id"`
Pst int `json:"pst"`
T int `json:"t"`
Ar []struct {
ID int `json:"id"`
Name string `json:"name"`
Tns []interface{} `json:"tns"`
Alias []interface{} `json:"alias"`
} `json:"ar"`
Alia []string `json:"alia"`
Pop int `json:"pop"`
St int `json:"st"`
Rt string `json:"rt"`
Fee int `json:"fee"`
V int `json:"v"`
Crbt interface{} `json:"crbt"`
Cf string `json:"cf"`
Al struct {
ID int `json:"id"`
Name string `json:"name"`
PicURL string `json:"picUrl"`
Tns []interface{} `json:"tns"`
PicStr string `json:"pic_str"`
Pic int64 `json:"pic"`
} `json:"al"`
Dt int `json:"dt"`
H struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float64 `json:"vd"`
Sr int `json:"sr"`
} `json:"h"`
M struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float64 `json:"vd"`
Sr int `json:"sr"`
} `json:"m"`
L struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float64 `json:"vd"`
Sr int `json:"sr"`
} `json:"l"`
Sq interface{} `json:"sq"`
Hr interface{} `json:"hr"`
A interface{} `json:"a"`
Cd string `json:"cd"`
No int `json:"no"`
RtURL interface{} `json:"rtUrl"`
Ftype int `json:"ftype"`
RtUrls []interface{} `json:"rtUrls"`
DjID int `json:"djId"`
Copyright int `json:"copyright"`
SID int `json:"s_id"`
Mark int `json:"mark"`
OriginCoverType int `json:"originCoverType"`
OriginSongSimpleData interface{} `json:"originSongSimpleData"`
TagPicList interface{} `json:"tagPicList"`
ResourceState bool `json:"resourceState"`
Version int `json:"version"`
SongJumpInfo interface{} `json:"songJumpInfo"`
EntertainmentTags interface{} `json:"entertainmentTags"`
Single int `json:"single"`
NoCopyrightRcmd interface{} `json:"noCopyrightRcmd"`
Alg interface{} `json:"alg"`
Rtype int `json:"rtype"`
Rurl interface{} `json:"rurl"`
Mst int `json:"mst"`
Cp int `json:"cp"`
Mv int `json:"mv"`
PublishTime int64 `json:"publishTime"`
Tns []string `json:"tns,omitempty"`
} `json:"tracks"`
VideoIds interface{} `json:"videoIds"`
Videos interface{} `json:"videos"`
TrackIds []struct {
ID int `json:"id"`
V int `json:"v"`
T int `json:"t"`
At int64 `json:"at"`
Alg interface{} `json:"alg"`
UID int `json:"uid"`
RcmdReason string `json:"rcmdReason"`
Sc interface{} `json:"sc"`
Lr int `json:"lr,omitempty"`
} `json:"trackIds"`
ShareCount int `json:"shareCount"`
CommentCount int `json:"commentCount"`
RemixVideo interface{} `json:"remixVideo"`
SharedUsers interface{} `json:"sharedUsers"`
HistorySharedUsers interface{} `json:"historySharedUsers"`
GradeStatus string `json:"gradeStatus"`
Score interface{} `json:"score"`
AlgTags interface{} `json:"algTags"`
} `json:"playlist"`
Urls interface{} `json:"urls"`
Privileges []struct {
ID int `json:"id"`
Fee int `json:"fee"`
Payed int `json:"payed"`
RealPayed int `json:"realPayed"`
St int `json:"st"`
Pl int `json:"pl"`
Dl int `json:"dl"`
Sp int `json:"sp"`
Cp int `json:"cp"`
Subp int `json:"subp"`
Cs bool `json:"cs"`
Maxbr int `json:"maxbr"`
Fl int `json:"fl"`
Pc interface{} `json:"pc"`
Toast bool `json:"toast"`
Flag int `json:"flag"`
PaidBigBang bool `json:"paidBigBang"`
PreSell bool `json:"preSell"`
PlayMaxbr int `json:"playMaxbr"`
DownloadMaxbr int `json:"downloadMaxbr"`
MaxBrLevel string `json:"maxBrLevel"`
PlayMaxBrLevel string `json:"playMaxBrLevel"`
DownloadMaxBrLevel string `json:"downloadMaxBrLevel"`
PlLevel string `json:"plLevel"`
DlLevel string `json:"dlLevel"`
FlLevel string `json:"flLevel"`
Rscl int `json:"rscl"`
FreeTrialPrivilege struct {
ResConsumable bool `json:"resConsumable"`
UserConsumable bool `json:"userConsumable"`
ListenType interface{} `json:"listenType"`
} `json:"freeTrialPrivilege"`
ChargeInfoList []struct {
Rate int `json:"rate"`
ChargeURL interface{} `json:"chargeUrl"`
ChargeMessage interface{} `json:"chargeMessage"`
ChargeType int `json:"chargeType"`
} `json:"chargeInfoList"`
} `json:"privileges"`
SharedPrivilege interface{} `json:"sharedPrivilege"`
ResEntrance interface{} `json:"resEntrance"`
}
// 获取歌单列表
type musicListOfApI struct {
Songs []struct {
Name string `json:"name"`
ID int `json:"id"`
Pst int `json:"pst"`
T int `json:"t"`
Ar []struct {
ID int `json:"id"`
Name string `json:"name"`
Tns []interface{} `json:"tns"`
Alias []interface{} `json:"alias"`
} `json:"ar"`
Alia []string `json:"alia"`
Pop int `json:"pop"`
St int `json:"st"`
Rt string `json:"rt"`
Fee int `json:"fee"`
V int `json:"v"`
Crbt interface{} `json:"crbt"`
Cf string `json:"cf"`
Al struct {
ID int `json:"id"`
Name string `json:"name"`
PicURL string `json:"picUrl"`
Tns []interface{} `json:"tns"`
PicStr string `json:"pic_str"`
Pic int64 `json:"pic"`
} `json:"al"`
Dt int `json:"dt"`
H struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float32 `json:"vd"`
Sr int `json:"sr"`
} `json:"h"`
M struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float32 `json:"vd"`
Sr int `json:"sr"`
} `json:"m"`
L struct {
Br int `json:"br"`
Fid int `json:"fid"`
Size int `json:"size"`
Vd float32 `json:"vd"`
Sr int `json:"sr"`
} `json:"l"`
Sq interface{} `json:"sq"`
Hr interface{} `json:"hr"`
A interface{} `json:"a"`
Cd string `json:"cd"`
No int `json:"no"`
RtURL interface{} `json:"rtUrl"`
Ftype int `json:"ftype"`
RtUrls []interface{} `json:"rtUrls"`
DjID int `json:"djId"`
Copyright int `json:"copyright"`
SID int `json:"s_id"`
Mark int `json:"mark"`
OriginCoverType int `json:"originCoverType"`
OriginSongSimpleData interface{} `json:"originSongSimpleData"`
TagPicList interface{} `json:"tagPicList"`
ResourceState bool `json:"resourceState"`
Version int `json:"version"`
SongJumpInfo interface{} `json:"songJumpInfo"`
EntertainmentTags interface{} `json:"entertainmentTags"`
AwardTags interface{} `json:"awardTags"`
Single int `json:"single"`
NoCopyrightRcmd interface{} `json:"noCopyrightRcmd"`
Rtype int `json:"rtype"`
Rurl interface{} `json:"rurl"`
Mst int `json:"mst"`
Cp int `json:"cp"`
Mv int `json:"mv"`
PublishTime int64 `json:"publishTime"`
Tns []string `json:"tns,omitempty"`
} `json:"songs"`
Privileges []struct {
ID int `json:"id"`
Fee int `json:"fee"`
Payed int `json:"payed"`
St int `json:"st"`
Pl int `json:"pl"`
Dl int `json:"dl"`
Sp int `json:"sp"`
Cp int `json:"cp"`
Subp int `json:"subp"`
Cs bool `json:"cs"`
Maxbr int `json:"maxbr"`
Fl int `json:"fl"`
Toast bool `json:"toast"`
Flag int `json:"flag"`
PreSell bool `json:"preSell"`
PlayMaxbr int `json:"playMaxbr"`
DownloadMaxbr int `json:"downloadMaxbr"`
MaxBrLevel string `json:"maxBrLevel"`
PlayMaxBrLevel string `json:"playMaxBrLevel"`
DownloadMaxBrLevel string `json:"downloadMaxBrLevel"`
PlLevel string `json:"plLevel"`
DlLevel string `json:"dlLevel"`
FlLevel string `json:"flLevel"`
Rscl int `json:"rscl"`
FreeTrialPrivilege struct {
ResConsumable bool `json:"resConsumable"`
UserConsumable bool `json:"userConsumable"`
ListenType interface{} `json:"listenType"`
} `json:"freeTrialPrivilege"`
ChargeInfoList []struct {
Rate int `json:"rate"`
ChargeURL interface{} `json:"chargeUrl"`
ChargeMessage interface{} `json:"chargeMessage"`
ChargeType int `json:"chargeType"`
} `json:"chargeInfoList"`
} `json:"privileges"`
Code int `json:"code"`
}
/*****************************************************************/
/*********************独角兽API随机抽歌信息**************************/
/*****************************************************************/
// 独角兽API随机抽歌信息
type ovooaData struct {
Code int `json:"code"`
Text string `json:"text"`
Data struct {
Song string `json:"song"`
Singer string `json:"singer"`
Cover string `json:"cover"`
Music string `json:"Music"`
ID int `json:"id"`
} `json:"data"`
}

119
plugin/heisi/heisi.go Normal file
View File

@@ -0,0 +1,119 @@
// Package heisi 黑丝
package heisi
import (
"errors"
"math/rand"
"os"
"strconv"
"time"
"unsafe"
"github.com/FloatTech/AnimeAPI/setu"
fbctxext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
heisiPic []item
baisiPic []item
jkPic []item
jurPic []item
zukPic []item
mcnPic []item
fileList = [...]string{"heisi.bin", "baisi.bin", "jk.bin", "jur.bin", "zuk.bin", "mcn.bin"}
)
func init() { // 插件主体
p, err := setu.NewPool(setu.DefaultPoolDir,
func(s string) (string, error) {
if s != "黑丝" && s != "白丝" && s != "jk" && s != "巨乳" && s != "足控" && s != "网红" {
return "", errors.New("invalid call")
}
typ := setu.DefaultPoolDir + "/" + s
if file.IsNotExist(typ) {
err := os.MkdirAll(typ, 0755)
if err != nil {
return "", err
}
}
var pic item
switch s {
case "黑丝":
pic = heisiPic[rand.Intn(len(heisiPic))]
case "白丝":
pic = baisiPic[rand.Intn(len(baisiPic))]
case "jk":
pic = jkPic[rand.Intn(len(jkPic))]
case "巨乳":
pic = jurPic[rand.Intn(len(jurPic))]
case "足控":
pic = zukPic[rand.Intn(len(zukPic))]
case "网红":
pic = mcnPic[rand.Intn(len(mcnPic))]
}
return pic.String(), nil
}, func(s string) ([]byte, error) {
return web.RequestDataWith(web.NewTLS12Client(), s, "GET", "http://hs.heisiwu.com/", web.RandUA(), nil)
}, time.Minute)
if err != nil {
panic(err)
}
engine := control.Register("heisi", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "黑丝",
Help: "- 来点黑丝\n- 来点白丝\n- 来点jk\n- 来点巨乳\n- 来点足控\n- 来点网红",
PublicDataFolder: "Heisi",
})
engine.OnFullMatchGroup([]string{"来点黑丝", "来点白丝", "来点jk", "来点巨乳", "来点足控", "来点网红"}, zero.OnlyGroup, fbctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
for i, filePath := range fileList {
data, err := engine.GetLazyData(filePath, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
if len(data)%10 != 0 {
ctx.SendChain(message.Text("ERROR: invalid data " + strconv.Itoa(i)))
return false
}
s := (*slice)(unsafe.Pointer(&data))
s.len /= 10
s.cap /= 10
switch i {
case 0:
heisiPic = *(*[]item)(unsafe.Pointer(s))
case 1:
baisiPic = *(*[]item)(unsafe.Pointer(s))
case 2:
jkPic = *(*[]item)(unsafe.Pointer(s))
case 3:
jurPic = *(*[]item)(unsafe.Pointer(s))
case 4:
zukPic = *(*[]item)(unsafe.Pointer(s))
case 5:
mcnPic = *(*[]item)(unsafe.Pointer(s))
}
}
return true
})).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
matched := ctx.State["matched"].(string)
pic, err := p.Roll(matched[3*2:])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+pic))}
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
})
}

48
plugin/heisi/packer.go Normal file
View File

@@ -0,0 +1,48 @@
package heisi
import (
"encoding/binary"
"encoding/hex"
"fmt"
"math/bits"
)
const (
template2021 = "http://hs.heisiwu.com/wp-content/uploads/%4d/%02d/%4d%02d16%06d-611a3%8s.jpg"
templategeneral = "http://hs.heisiwu.com/wp-content/uploads/%4d/%02d/%015x"
)
type item [10]byte
// String item to url
func (it item) String() string {
year, month := int((it[0]>>4)&0x0f), int(it[0]&0x0f)
year += 2021
if year == 2021 {
num := binary.BigEndian.Uint32(it[1:5])
dstr := hex.EncodeToString(it[5:9])
return fmt.Sprintf(template2021, year, month, year, month, num, dstr)
}
d := binary.BigEndian.Uint64(it[1:9])
isscaled := it[9]&0x80 > 0
num := int(it[9] & 0x7f)
trestore := fmt.Sprintf(templategeneral, year, month, d&0x0fffffff_ffffffff)
if num > 0 {
trestore += fmt.Sprintf("-%d", num)
}
if isscaled {
trestore += "-scaled"
}
d = bits.RotateLeft64(d, 4) & 0x0f
switch d {
case 0:
trestore += ".jpg"
case 1:
trestore += ".png"
case 2:
trestore += ".webp"
default:
return "invalid ext"
}
return trestore
}

15
plugin/heisi/slice.go Normal file
View File

@@ -0,0 +1,15 @@
package heisi
import "unsafe"
// slice is the runtime representation of a slice.
// It cannot be used safely or portably and its representation may
// change in a later release.
//
// Unlike reflect.SliceHeader, its Data field is sufficient to guarantee the
// data it references will not be garbage collected.
type slice struct {
data unsafe.Pointer
len int
cap int
}

174
plugin/hitokoto/hitokoto.go Normal file
View File

@@ -0,0 +1,174 @@
// Package hitokoto 一言
package hitokoto
import (
"math/rand"
"strconv"
"strings"
"time"
"github.com/FloatTech/floatbox/binary"
fcext "github.com/FloatTech/floatbox/ctxext"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
engine := control.Register("hitokoto", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "一言",
Help: "- 一言[xxx]\n" +
"- 系列一言",
PublicDataFolder: "Hitokoto",
})
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
dbfile := engine.DataFolder() + "hitokoto.db"
_, err := engine.GetLazyData("hitokoto.db", false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
hdb, err = initialize(dbfile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
return true
})
engine.OnPrefix(`一言`, getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
args := ctx.State["args"].(string)
blist, err := hdb.getByKey(strings.TrimSpace(args))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if len(blist) == 0 {
ctx.SendChain(message.Text("ERROR: hitokoto empty"))
return
}
m := make(message.Message, 0, 10)
text := strings.Builder{}
if len(blist) <= 10 {
for _, b := range blist {
text.WriteString(b.Hitokoto)
text.WriteString("\n——")
text.WriteString(b.From)
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
text.Reset()
}
} else {
indexes := map[int]struct{}{}
for i := 0; i < 10; i++ {
ind := rand.Intn(len(blist))
if _, ok := indexes[ind]; ok {
i--
continue
}
indexes[ind] = struct{}{}
}
for k := range indexes {
b := blist[k]
text.WriteString(b.Hitokoto)
text.WriteString("\n——")
text.WriteString(b.From)
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
text.Reset()
}
}
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
})
engine.OnFullMatch(`系列一言`, getdb).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
recv, cancel := next.Repeat()
defer cancel()
results, err := hdb.getAllCategory()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
tex := strings.Builder{}
tex.WriteString("请输入系列一言序号\n")
for i, v := range results {
tex.WriteString(strconv.Itoa(i))
tex.WriteString(". ")
tex.WriteString(v.Category)
tex.WriteString("\n")
}
base64Str, err := text.RenderToBase64(tex.String(), text.FontFile, 400, 20)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Image("base64://" + binary.BytesToString(base64Str)))
for {
select {
case <-time.After(time.Second * 120):
ctx.SendChain(message.Text("系列一言指令过期"))
return
case c := <-recv:
msg := c.Event.Message.ExtractPlainText()
num, err := strconv.Atoi(msg)
if err != nil {
ctx.SendChain(message.Text("请输入数字!"))
continue
}
if num < 0 || num >= len(results) {
ctx.SendChain(message.Text("序号非法!"))
continue
}
ctx.SendChain(message.Text("请欣赏系列一言: ", results[num].Category))
hlist, err := hdb.getByCategory(results[num].Category)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if len(hlist) == 0 {
ctx.SendChain(message.Text("ERROR: hitokoto empty"))
return
}
m := make(message.Message, 0, 10)
text := strings.Builder{}
if len(hlist) <= 10 {
for _, b := range hlist {
text.WriteString(b.Hitokoto)
text.WriteString("\n——")
text.WriteString(b.From)
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
text.Reset()
}
} else {
indexes := map[int]struct{}{}
for i := 0; i < 10; i++ {
ind := rand.Intn(len(hlist))
if _, ok := indexes[ind]; ok {
i--
continue
}
indexes[ind] = struct{}{}
}
for k := range indexes {
b := hlist[k]
text.WriteString(b.Hitokoto)
text.WriteString("\n——")
text.WriteString(b.From)
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String())))
text.Reset()
}
}
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
return
}
}
})
}

73
plugin/hitokoto/model.go Normal file
View File

@@ -0,0 +1,73 @@
package hitokoto
import (
"os"
"github.com/jinzhu/gorm"
)
// hdb 表情包数据库全局变量
var hdb *hitokotodb
// hitokotodb 表情包数据库
type hitokotodb gorm.DB
// initialize 初始化
func initialize(dbpath string) (db *hitokotodb, err error) {
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
f, err := os.Create(dbpath)
if err != nil {
return nil, err
}
_ = f.Close()
}
gdb, err := gorm.Open("sqlite3", dbpath)
if err != nil {
return
}
gdb.AutoMigrate(&hitokoto{})
return (*hitokotodb)(gdb), nil
}
type hitokoto struct {
ID int `json:"id" gorm:"column:id;primary_key"`
Hitokoto string `json:"hitokoto" gorm:"column:hitokoto"`
Type string `json:"type" gorm:"column:type"`
From string `json:"from" gorm:"column:from"`
FromWho string `json:"from_who" gorm:"column:from_who"`
Creator string `json:"creator" gorm:"column:creator"`
CreatorUID int `json:"creator_uid" gorm:"column:creator_uid"`
Reviewer int `json:"reviewer" gorm:"column:reviewer"`
UUID string `json:"uuid" gorm:"column:uuid"`
CreatedAt string `json:"created_at" gorm:"column:created_at"`
Category string `json:"catogory" gorm:"column:category"`
}
// TableName 表名
func (hitokoto) TableName() string {
return "hitokoto"
}
func (hdb *hitokotodb) getByKey(key string) (b []hitokoto, err error) {
db := (*gorm.DB)(hdb)
err = db.Where("hitokoto like ?", "%"+key+"%").Find(&b).Error
return
}
type result struct {
Category string
Count int
}
func (hdb *hitokotodb) getAllCategory() (results []result, err error) {
db := (*gorm.DB)(hdb)
err = db.Table("hitokoto").Select("category, count(1) as count").Group("category").Scan(&results).Error
return
}
func (hdb *hitokotodb) getByCategory(category string) (h []hitokoto, err error) {
db := (*gorm.DB)(hdb)
err = db.Where("category = ?", category).Find(&h).Error
return
}

View File

@@ -2,7 +2,6 @@
package hs
import (
"fmt"
"os"
"strconv"
"strings"
@@ -12,16 +11,15 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
)
var (
cachedir = file.BOTPATH + "/data/hs/"
reqconf = [...]string{"GET", "https://hs.fbigame.com",
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36"}
)
var reqconf = [...]string{"GET", "https://hs.fbigame.com",
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36"}
const (
hs = `https://hs.fbigame.com/ajax.php?`
@@ -43,21 +41,17 @@ const (
)
func init() {
os.RemoveAll(cachedir)
err := os.MkdirAll(cachedir, 0755)
if err != nil {
panic(err)
}
engine := control.Register("hs", &control.Options{
engine := control.Register("hs", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "炉石\n" +
"- 搜卡[xxxx]\n" +
Brief: "炉石搜卡",
Help: "- 搜卡[xxxx]\n" +
"- [卡组代码xxx]\n" +
"- 更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp",
})
PrivateDataFolder: "hs",
}).ApplySingle(ctxext.DefaultSingle)
cachedir := file.BOTPATH + "/" + engine.DataFolder()
engine.OnRegex(`^搜卡(.+)$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
SetBlock(true).Handle(func(ctx *zero.Ctx) {
List := ctx.State["regex_matched"].([]string)[1]
g := sh(List)
t := int(gjson.Get(g, `list.#`).Int())
@@ -69,27 +63,19 @@ func init() {
for i := 0; i < t && i < 5; i++ {
cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String()
cachefile := cachedir + cid
imgcq := `[CQ:image,file=` + "file:///" + cachefile + `]`
if file.IsNotExist(cachefile) {
data, err := web.ReqWith(
data, err := web.RequestDataWith(web.NewDefaultClient(),
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(),
reqconf[0], reqconf[1], reqconf[2])
reqconf[0], reqconf[1], reqconf[2], nil)
if err == nil {
err = os.WriteFile(cachefile, data, 0644)
}
if err != nil {
imgcq = err.Error()
continue
}
}
sk = append(
sk,
message.CustomNode(
zero.BotConfig.NickName[0],
ctx.Event.SelfID,
imgcq, // 图片
),
)
sk = append(sk, ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+cachefile)))
}
if id := ctx.SendGroupForwardMessage(
ctx.Event.GroupID,
@@ -100,8 +86,7 @@ func init() {
})
// 卡组
engine.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
fmt.Print("成功")
SetBlock(true).Handle(func(ctx *zero.Ctx) {
List := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(
message.Image(kz(List)),
@@ -110,10 +95,10 @@ func init() {
}
func sh(s string) string {
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
data, err := web.RequestDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2], nil)
if err == nil {
url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
r, err := web.RequestDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2], nil)
if err == nil {
return helper.BytesToString(r)
}
@@ -122,10 +107,10 @@ func sh(s string) string {
}
func kz(s string) string {
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
data, err := web.RequestDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2], nil)
if err == nil {
url := hs + para + "mod=general_deck_image&deck_code=" + s + "&deck_text=&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
r, err := web.RequestDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2], nil)
if err == nil {
return "base64://" + gjson.Get(helper.BytesToString(r), "img").String()
}

135
plugin/hyaku/main.go Normal file
View File

@@ -0,0 +1,135 @@
// Package hyaku 百人一首
package hyaku
import (
"bytes"
"encoding/csv"
"fmt"
"math/rand"
"os"
"reflect"
"strconv"
"unsafe"
"github.com/FloatTech/floatbox/binary"
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"
)
const bed = "https://gitcode.net/u011570312/OguraHyakuninIsshu/-/raw/master/"
type line struct {
番号, 歌人, 上の句, 下の句, 上の句ひらがな, 下の句ひらがな string
}
func (l *line) String() string {
b := binary.NewWriterF(func(w *binary.Writer) {
r := reflect.ValueOf(l).Elem().Type()
for i := 0; i < r.NumField(); i++ {
switch i {
case 0:
w.WriteString("●")
case 1:
w.WriteString("◉")
case 2, 3:
w.WriteString("○")
case 4, 5:
w.WriteString("◎")
}
w.WriteString(r.Field(i).Name)
w.WriteString("")
w.WriteString((*[6]string)(unsafe.Pointer(l))[i])
w.WriteString("\n")
}
})
return binary.BytesToString(b)
}
var lines [100]*line
func init() {
engine := control.Register("hyaku", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "百人一首",
Help: "- 百人一首(随机发一首)\n" +
"- 百人一首之n",
PrivateDataFolder: "hyaku",
})
err := os.MkdirAll(engine.DataFolder()+"img", 0755)
if err != nil {
panic(err)
}
data, err := engine.GetCustomLazyData(bed, "小倉百人一首.csv")
if err != nil {
panic(err)
}
records, err := csv.NewReader(bytes.NewReader(data)).ReadAll()
if err != nil {
panic(err)
}
records = records[1:] // skip title
if len(records) != 100 {
panic("invalid csvfile")
}
for j, r := range records {
if len(r) != 6 {
panic("invalid csvfile")
}
i, err := strconv.Atoi(r[0])
if err != nil {
panic(err)
}
i--
if j != i {
panic("invalid csvfile")
}
lines[i] = (*line)(*(*unsafe.Pointer)(unsafe.Pointer(&r)))
}
engine.OnFullMatch("百人一首").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
i := rand.Intn(100)
img0, err := engine.GetCustomLazyData(bed, fmt.Sprintf("img/%03d.jpg", i+1))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
img1, err := engine.GetCustomLazyData(bed, fmt.Sprintf("img/%03d.png", i+1))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(
message.ImageBytes(img0),
message.Text("\n", lines[i]),
message.ImageBytes(img1),
)
})
engine.OnRegex(`^百人一首之\s?(\d+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if i > 100 || i < 1 {
ctx.SendChain(message.Text("ERROR: 超出范围"))
return
}
img0, err := engine.GetCustomLazyData(bed, fmt.Sprintf("img/%03d.jpg", i))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
img1, err := engine.GetCustomLazyData(bed, fmt.Sprintf("img/%03d.png", i))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(
message.ImageBytes(img0),
message.Text("\n", lines[i-1]),
message.ImageBytes(img1),
)
})
}

View File

@@ -0,0 +1,150 @@
// Package imagefinder 关键字搜图
package imagefinder
import (
"encoding/json"
"errors"
"math/rand"
"net/http"
"net/url"
"reflect"
"regexp"
"strings"
"github.com/quic-go/quic-go/http3"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/AnimeAPI/pixiv"
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/pool"
)
type resultjson struct {
Error bool `json:"error"`
Message string `json:"message"`
Data struct {
Illusts []struct {
ID int64 `json:"id"`
Title string `json:"title"`
AltTitle string `json:"altTitle"`
Description string `json:"description"`
Type int64 `json:"type"`
CreateDate string `json:"createDate"`
UploadDate string `json:"uploadDate"`
Sanity int64 `json:"sanity"`
Width int64 `json:"width"`
Height int64 `json:"height"`
PageCount int64 `json:"pageCount"`
Tags []struct {
Name string `json:"name"`
Translation string `json:"translation"`
} `json:"tags"`
Statistic struct {
Bookmarks int64 `json:"bookmarks"`
Likes int64 `json:"likes"`
Comments int64 `json:"comments"`
Views int64 `json:"views"`
} `json:"statistic"`
Image string `json:"image"`
} `json:"illusts"`
Scores []float64 `json:"scores"`
HasNext bool `json:"has_next"`
} `json:"data"`
}
var hrefre = regexp.MustCompile(`<a href=".*">`)
func init() {
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "关键字搜图",
Help: "- 来张 [xxx]",
}).OnRegex(`^来张\s?(.*)$`, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
soutujson, err := soutuapi(keyword)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
rannum := rand.Intn(len(soutujson.Data.Illusts))
il := soutujson.Data.Illusts[rannum]
illust, err := pixiv.Works(il.ID)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if len(illust.ImageUrls) == 0 {
ctx.SendChain(message.Text("ERROR: nil image url"))
return
}
u := illust.ImageUrls[0]
n := u[strings.LastIndex(u, "/")+1 : len(u)-4]
f := illust.Path(0)
err = pool.SendImageFromPool(n, f, func() error {
// 下载图片
return illust.DownloadToCache(0)
}, ctxext.SendFakeForwardToGroup(ctx,
message.Text(
il.Width, "x", il.Height, "\n",
"标题: ", il.Title, "\n",
"副标题: ", il.AltTitle, "\n",
"ID: ", il.ID, "\n",
"画师: ", illust.UserName, " (", illust.UserID, ")", "\n",
"分级:", il.Sanity, "\n",
hrefre.ReplaceAllString(strings.ReplaceAll(strings.ReplaceAll(il.Description, "<br />", "\n"), "</a>", ""), ""),
printtags(reflect.ValueOf(&il.Tags)),
),
), ctxext.GetFirstMessageInForward(ctx))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
})
}
// soutuapi 请求api
func soutuapi(keyword string) (r resultjson, err error) {
var data []byte
data, err = web.RequestDataWith(&http.Client{Transport: &http3.RoundTripper{}},
"https://api.pixivel.moe/v2/pixiv/illust/search/"+url.QueryEscape(keyword)+"?page=0",
"GET",
"https://pixivel.moe/",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36",
nil,
)
if err != nil {
return
}
err = json.Unmarshal(data, &r)
if err == nil && r.Error {
err = errors.New(r.Message)
}
return
}
func printtags(r reflect.Value) string {
tags := r.Elem()
s := binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
for i := 0; i < tags.Len(); i++ {
_ = w.WriteByte('\n')
tag := tags.Index(i)
_ = w.WriteByte('#')
w.WriteString(tag.Field(0).String())
if !tag.Field(1).IsZero() {
w.WriteString(" (")
w.WriteString(tag.Field(1).String())
w.WriteString(")")
}
}
}))
return s
}

Some files were not shown because too many files have changed in this diff Show More