Compare commits

..

101 Commits

Author SHA1 Message Date
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
fumiama
925e6847f3 🎨 adjust prio 2022-01-15 17:06:50 +08:00
fumiama
9462cbc7e0 🔥 shrink README 2022-01-15 17:02:33 +08:00
fumiama
8ec4271419 🐛 fix curse over-widely matching 2022-01-15 17:00:07 +08:00
fumiama
173fd250cb 🐛 fix: manager timer panic 2022-01-15 15:41:27 +08:00
fumiama
89bdc1e496 🐛 fix gif panic 2022-01-15 15:18:25 +08:00
fumiama
48736d3f4a 💩👌 make lint happy 2022-01-15 11:02:34 +08:00
himawari
f8df60f06b fix:修复直播状态更新的bug (#107)
* feat:添加b站推送,写了一半

* feat:添加b站推送(后续看情况,替换掉chromepd)

* fix:修复一直推送直播的bug

* fix:添加缓存路径

* feat:添加推送列表,修复重复发消息的bug

* feat:发现禁用有用,删除多余指令

* fix:修改格式

* fix:sleep无效

* fix:修改直播card

* fix:增加长度

* fix:修改readme

* fix:修lint,并去掉cron

* fix:修lint

* fix:去掉日志

* fix:更新旧状态

* fix:删掉多余方法

* fix:优化判断语句

* fix:修lint

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-01-15 11:01:33 +08:00
github-actions[bot]
9bd0ed03a5 🎨 改进代码样式 2022-01-14 14:18:27 +00:00
himawari
cb1e4bcdb7 feat:添加b站推送功能 (#106)
* feat:添加b站推送,写了一半

* feat:添加b站推送(后续看情况,替换掉chromepd)

* fix:修复一直推送直播的bug

* fix:添加缓存路径

* feat:添加推送列表,修复重复发消息的bug

* feat:发现禁用有用,删除多余指令

* fix:修改格式

* fix:sleep无效

* fix:修改直播card

* fix:增加长度

* fix:修改readme

* fix:修lint,并去掉cron

* fix:修lint

* fix:去掉日志

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-01-14 22:17:24 +08:00
fumiama
af8e6a63b9 💩👌 make lint happy 2022-01-14 22:17:03 +08:00
fumiama
8c8cd709b5 🔖 v1.2.4-beta1 2022-01-14 20:07:57 +08:00
fumiama
18ae566d34 💩👌 make lint happy 2022-01-14 20:00:02 +08:00
fumiama
9cfa44d434 🐛 fix: aireply 表情 2022-01-14 13:34:46 +08:00
fumiama
23393d9157 ✏️ edit import 2022-01-14 13:17:59 +08:00
fumiama
b676e00f0b 🐛 fix fontfile notfound error 2022-01-14 12:10:05 +08:00
fumiama
790200e519 🔥 运势 移除下载锁 2022-01-13 23:03:42 +08:00
fumiama
ccde99e695 📝 运势 恢复为传递 base64 2022-01-13 23:02:20 +08:00
fumiama
a80f8082cc 📝 update zbputils 2022-01-13 20:57:07 +08:00
fumiama
4b194627bb ️ remove cachefile on start 2022-01-13 20:51:07 +08:00
fumiama
d983c66597 💫 🎉 添加插件 DeepDanbooru二次元图标签识别 2022-01-13 20:47:07 +08:00
fumiama
30f6b57941 🐛 fix txt2img 2022-01-13 20:30:26 +08:00
fumiama
107979c459 🔥 drop writer 2022-01-13 19:17:59 +08:00
fumiama
f05f09d741 🍱 🎨 ️ 运势 不解压 不传 base64 2022-01-13 16:43:50 +08:00
fumiama
bc989f2fb0 🐛 fix score cache error 2022-01-12 12:33:02 +08:00
fumiama
9b4494a24f 🐛 fix new user error 2022-01-12 12:25:16 +08:00
fumiama
d3fafa7b9a 🐛 fix: fortune dlmu 2022-01-12 12:11:14 +08:00
fumiama
ce1e85e0a3 🔥 优化 score 并发 2022-01-12 11:57:16 +08:00
fumiama
560df5cade 🐛 fix(#95): aifalse error unckeck 2022-01-12 11:39:03 +08:00
fumiama
9f6e361e6e 💩👌 make lint happy 2022-01-12 11:33:55 +08:00
fumiama
00be4a856f 🎨 🚚 move zbpctrl into zbputils 2022-01-12 11:33:12 +08:00
fumiama
606aec4ec1 🚚 🎉 📝 合并 gif 2022-01-11 16:09:33 +08:00
96 changed files with 2955 additions and 1181 deletions

12
.gitignore vendored
View File

@@ -1,15 +1,3 @@
data/SetuTime/cache
data/control
data/SetuTime/search
data/manager
data/acgimage
data/saucenao
data/fortune
data/hs
data/nsetu
data/nwife
data/sleep
data/score
plugins/*.so
plugins/*.dll
.idea/

View File

@@ -64,6 +64,8 @@ run:
deadline: 5m
issues-exit-code: 1
tests: false
skip-dirs:
- order
# output configuration options
output:

View File

@@ -45,7 +45,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
## 功能
> 在编译时,以下功能除插件控制外,均可通过注释`main.go`中的相应`import`而物理禁用,减小插件体积。
> 通过插件控制,还可动态管理某个功能在某个群的打开/关闭。
- **web管理** `import _ "github.com/FloatTech/zbpctrl/web"`
- **web管理** `import _ "github.com/FloatTech/zbputils/control/web"`
- 开启后可执行文件大约增加 5M ,默认注释不开启。如需开启请自行编辑`main.go`取消注释
- 需要配合 [webgui](https://github.com/FloatTech/bot-manager) 使用
- **动态加载插件** `import _ github.com/FloatTech/ZeroBot-Plugin-Dynamic/dyloader`
@@ -58,6 +58,8 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] /还原 xxx (在发送的群/用户还原xxx的开启状态到初始状态)
- [x] /禁止 service qq1 qq2... (禁止 qqs 使用服务 service)
- [x] /允许 service qq1 qq2... (重新允许 qqs 使用服务 service)
- [x] /封禁 qq1 qq2... (禁止 qqs 使用全部服务)
- [x] /解封 qq1 qq2... (允许 qqs 使用全部服务)
- [x] /用法 xxx
- [x] /服务列表
- [x] /服务详情
@@ -69,14 +71,14 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 空调关
- [x] 群温度
- [x] 设置温度[正整数]
- [x] @Bot mua|啾咪|摸|上你|傻|裸|贴|老婆|抱|亲|一下|咬|操|123|进去|调教|搓|让|捏|挤|略|呐|原味|胖次|内裤|内衣|衣服|ghs|批|憨批|kkp|咕|骚|喜欢|suki|好き|看|不能|砸了|透|口我|草我|自慰|onani|オナニー|炸了|色图|涩图|告白|对不起|回来|吻|软|壁咚|掰开|女友|是|喵|嗷呜|叫|拜|佬|awsl|臭|香|腿|张开|脚|脸|头发|手|pr|舔|小穴|腰|诶嘿嘿|可爱|扭蛋|鼻|眼|色气|推|床|举|手冲|饿|变|敲|爬|怕|冲|射|不穿|迫害|猫粮|揪尾巴|薄荷|早|晚安|揉|榨|掐|胸|奶子|欧派|嫩|蹭|牵手|握手|拍照|w|睡不着|欧尼酱|哥|爱你|过来|自闭|打不过|么么哒|很懂|膝枕|累了|安慰|洗澡|一起睡觉|一起|多大|姐姐|糖|嗦|牛子|🐂子|🐮子|嫌弃|紧|baka|笨蛋|插|插进来|屁股|翘|翘起来|抬|抬起|爸|傲娇|rua|咕噜咕噜|咕噜|上床|做爱|吃掉|吃|揪|种草莓|种草|掀|妹|病娇|
- [x] @Bot mua | 啾咪 | 摸 | 上你 | 傻 | 裸 | 贴 | 老婆 | 抱 | 亲 | 一下 | 咬 | 操 | 123 | 进去 | 调教 | 搓 | 让 | 捏 | 挤 | 略 | 呐 | 原味 | 胖次 | 内裤 | 内衣 | 衣服 | ghs | 批 | 憨批 | kkp | 咕 | 骚 | 喜欢 | suki | 好き | 看 | 不能 | 砸了 | 透 | 口我 | 草我 | 自慰 | onani | オナニー | 炸了 | 色图 | 涩图 | 告白 | 对不起 | 回来 | 吻 | 软 | 壁咚 | 掰开 | 女友 | 是 | 喵 | 嗷呜 | 叫 | 拜 | 佬 | awsl | 臭 | 香 | 腿 | 张开 | 脚 | 脸 | 头发 | 手 | pr | 舔 | 小穴 | 腰 | 诶嘿嘿 | 可爱 | 扭蛋 | 鼻 | 眼 | 色气 | 推 | 床 | 举 | 手冲 | 饿 | 变 | 敲 | 爬 | 怕 | 冲 | 射 | 不穿 | 迫害 | 猫粮 | 揪尾巴 | 薄荷 | 早 | 晚安 | 揉 | 榨 | 掐 | 胸 | 奶子 | 欧派 | 嫩 | 蹭 | 牵手 | 握手 | 拍照 | w | 睡不着 | 欧尼酱 | 哥 | 爱你 | 过来 | 自闭 | 打不过 | 么么哒 | 很懂 | 膝枕 | 累了 | 安慰 | 洗澡 | 一起睡觉 | 一起 | 多大 | 姐姐 | 糖 | 嗦 | 牛子 | 🐂子 | 🐮子 | 嫌弃 | 紧 | baka | 笨蛋 | 插 | 插进来 | 屁股 | 翘 | 翘起来 | 抬 | 抬起 | 爸 | 傲娇 | rua | 咕噜咕噜 | 咕噜 | 上床 | 做爱 | 吃掉 | 吃 | 揪 | 种草莓 | 种草 | 掀 | 妹 | 病娇 |
- **ATRI** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri"`
- [x] 具体指令看 /用法 atri
- 注:本插件基于 [ATRI](https://github.com/Kyomotoi/ATRI) ,为 Golang 移植版
- **群管** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_manager"`
- [x] 禁言[@xxx][分钟]
- [x] 解除禁言[@xxx]
- [x] 我要自闭|禅定 x [分钟|小时|天]
- [x] 我要自闭 | 禅定 x [分钟 | 小时 | 天]
- [x] 开启全员禁言
- [x] 解除全员禁言
- [x] 升为管理[@xxx]
@@ -90,15 +92,15 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] *退群通知
- [x] 设置欢迎语[欢迎~]
- [x] 在[MM]月[dd]日的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 在[MM]月[每周|周几]的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 在[MM]月[每周 | 周几]的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 取消在[MM]月[dd]日的[hh]点[mm]分的提醒
- [x] 取消在[MM]月[每周|周几]的[hh]点[mm]分的提醒
- [x] 取消在[MM]月[每周 | 周几]的[hh]点[mm]分的提醒
- [x] 在"cron"时(用[url])提醒大家[xxx]
- [x] 取消在"cron"的提醒
- [x] 列出所有提醒
- [x] 翻牌
- [x] [开启|关闭]入群验证
- [x] [开启|关闭]gist加群自动审批
- [x] [开启 | 关闭]入群验证
- [x] [开启 | 关闭]gist加群自动审批
- [ ] 同意好友请求
- [ ] 撤回[@xxx] [xxx]
- [ ] 警告[@xxx]
@@ -121,8 +123,8 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 卖萌[@xxx]
- [x] 抽老婆[@xxx]
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife"`
- [x] waifu|随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
- **gif** `import _ "github.com/tdf1939/ZeroBot-Plugin-Gif/plugin_gif"`
- [x] waifu | 随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
- **gif** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif"`
- [x] 爬[@xxx]
- [x] 摸[@xxx]
- [x] 搓[@xxx]
@@ -147,30 +149,37 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 刷新所有本地setu
- [x] 所有本地setu分类
- 注:刷新文件夹较慢,请耐心等待刷新完成,会提示“成功”。
- **nsfw图片识别** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nsfw"`
- [x] nsfw打分[图片]
- [x] 当图片属于非 neutral 类别时自动发送评价(默认禁用,启用输入 /启用 nsfwauto)
- **lolicon** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon"`
- [x] 来份萝莉
- **搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao"`
- [x] 以图搜图|搜索图片|以图识图[图片]
- [x] 以图搜图 | 搜索图片 | 以图识图[图片]
- [x] 搜图[P站图片ID]
- **搜番** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe"`
- [x] 搜番|搜索番剧[图片]
- **随机图片与AI点评** `github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage`
- [x] 搜番 | 搜索番剧[图片]
- **随机图片与AI点评** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage`
- [x] 随机图片(评级大于6的图将私发)
- [x] 直接随机(无r18检测务必小心仅管理可用)
- [x] 设置随机图片网址[url]
- [x] 太涩了(撤回最近发的图)
- [x] 评价图片(发送一张图片让bot评分)
- **DeepDanbooru二次元图标签识别** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru`
- [x] 鉴赏图片[图片]
- **叔叔的AI二次元图片放大** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_scale"`
- [x] 放大图片[图片]
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_fortune`
- [x] 运势|抽签
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]
- [x] 运势 | 抽签
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘]
- **睡眠管理** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage`
- [x] 早安|晚安
- [x] 早安 | 晚安
- **浅草寺求签** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji`
- [x] 求签|占卜
- [x] 求签 | 占卜
- [x] 解签
- **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili"`
- [x] >vup info [名字|uid]
- [x] >user info [名字|uid]
- [x] >vup info [名字 | uid]
- [x] >user info [名字 | uid]
- [x] /开启粉丝日报
- **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana"`
- [x] 小作文
@@ -182,7 +191,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 查询鬼东西[序号][@xxx]
- 注:由于需要科学,默认注释。
- **AIfalse** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false"`
- [x] 查询计算机当前活跃度: [检查身体|自检|启动自检|系统状态]
- [x] 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]
- [x] 清理缓存 (仅适用于 gocq 且需要 bot 的运行目录和 gocq 相同)
- [ ] 简易语音
- [ ] 爬图合成 [@xxx]
@@ -190,7 +199,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 抽wife[@xxx]
- [x] 添加wife[名字][图片]
- [x] 删除wife[名字]
- [x] [让|不让]所有人均可添加wife
- [x] [让 | 不让]所有人均可添加wife
- 注:不同群添加后不会重叠
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
- [x] /mcstart xxx
@@ -203,7 +212,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
-更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp
- **人工智能回复** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply"`
- [x] @Bot 任意文本(任意一句话回复)
- [x] 设置回复模式[青云客|小爱]
- [x] 设置回复模式[青云客 | 小爱]
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
- [x] 来张 [xxx]
- **拼音首字母释义工具** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nbnhhsh"`
@@ -218,6 +227,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- **vtb语录** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation"`
- [x] vtb语录
- [x] 随机vtb
- [x] 更新vtb
- **书评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review"`
- [x] 书评[xxx]
- [x] 随机书评
@@ -226,8 +236,6 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" `
- [x] 小说[xxx]
- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao"`
- [x] 骂他[@xxx]|骂他[qq号] (停用)
- [x] 骂我 (停用)
- [x] 哄我
- [x] 渣我
- [x] 来碗绿茶
@@ -235,24 +243,36 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
- [x] 来碗毒鸡汤
- [x] 讲个段子
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"`
- [x] 讲个笑话[@xxx]|讲个笑话[qq号]
- [x] 讲个笑话[@xxx] | 讲个笑话[qq号]
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua"`
- [x] 抽象翻译[xxx]
- **绝绝子** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi"`
- [x] 喝奶茶绝绝子|绝绝子吃饭
- [x] 喝奶茶绝绝子 | 绝绝子吃饭
- **藏头诗** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi"`
- [x] 藏头诗[xxx]
- [x] 藏尾诗[xxx]
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory"`
- [x] 组cp[@xxx][@xxx]
- [x] cp大老师 雪乃
- [x] cp大老师 雪乃
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
- [x] 签到
- [x] 获得签到背景[@xxx]|获得签到背景
- [x] 获得签到背景[@xxx] | 获得签到背景
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"`
- [x] 骂我
- [x] 大力骂我
- [x] @bot 他妈|公交车|你妈|操|屎|去死|快死|日|逼|尼玛|艾滋|癌症|有病|戴套|啊对对对|烦你|你爹|屮|tui|cnm
- **b站推送** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push"`
- [x] 添加订阅[uid]
- [x] 取消订阅[uid]
- [x] 取消动态订阅[uid]
- [x] 取消直播订阅[uid]
- [x] 推送列表
- **网易云音乐热评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wangyiyun"`
- [x] 来份网易云热评
- **b站视频链接解析** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_parse"`
- [x] https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA
- **煎蛋网无聊图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_jandan"`
- [x] 来份屌图
- [x] 更新屌图
- **TODO...**
## 使用方法

2
data

Submodule data updated: 1349bd0d4a...0090d93bda

32
go.mod
View File

@@ -3,10 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin
go 1.17
require (
github.com/FloatTech/AnimeAPI v1.2.0
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.6
github.com/FloatTech/zbpctrl v1.2.3-add1
github.com/FloatTech/zbputils v1.2.3-add1
github.com/FloatTech/AnimeAPI v1.2.5
github.com/FloatTech/sqlite v0.1.0
github.com/FloatTech/zbputils v1.2.5
github.com/antchfx/htmlquery v1.2.4
github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0
@@ -20,13 +19,13 @@ require (
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
github.com/tidwall/gjson v1.13.0
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
)
require (
github.com/FloatTech/imgfactory v0.1.1 // indirect
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc // indirect
github.com/antchfx/xpath v1.2.0 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
@@ -34,37 +33,32 @@ require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d // indirect
golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe // indirect
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect
golang.org/x/sys v0.0.0-20220207234003-57398862261d // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.8 // indirect
golang.org/x/tools v0.1.9 // 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
lukechampine.com/uint128 v1.2.0 // 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/ccgo/v3 v3.15.13 // indirect
modernc.org/libc v1.14.5 // 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/sqlite v1.14.6 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
)

118
go.sum
View File

@@ -1,26 +1,23 @@
github.com/FloatTech/AnimeAPI v1.2.0 h1:1P6hOEqNOB8EeC7PD5LuIRL9aWRKNVjKF6kP8X1ZYmI=
github.com/FloatTech/AnimeAPI v1.2.0/go.mod h1:P2pJSBhflFXJsJPUwhHt13obMVBRc9WJxEKx4bJ+11Q=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.6 h1:canagsXdWdQWTRwNq5U80dAc22hMARTICBxssUtOxhI=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.6/go.mod h1:umANZgKejUlyBT7c6OfaF8pmnf24QHgqhja94iSpQW4=
github.com/FloatTech/AnimeAPI v1.2.5 h1:X0NLJSl9o63vRwGRPn/XiojOOBqZRbY94TxPEvhiVRo=
github.com/FloatTech/AnimeAPI v1.2.5/go.mod h1:nJpebBjTNUpr4cV0bR0Xu54/SP78+iN7hJ2EfQWbM7M=
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
github.com/FloatTech/imgfactory v0.1.1 h1:ooL2+fV8yrMhv1ShGGKsN0Rm/flWoKnvqXaUD+dC3DQ=
github.com/FloatTech/imgfactory v0.1.1/go.mod h1:ThDALab8aOuU6KVYESVWFqmjcqtm03e0SvGlTw6s+aw=
github.com/FloatTech/zbpctrl v1.2.3-add1 h1:YkLR95p4SOCv6E2EnQ0qFO1O0mcBi+9n0gRhPUVJddA=
github.com/FloatTech/zbpctrl v1.2.3-add1/go.mod h1:70cC4XawE8bpbYz/OFA6d6uecK8jTc61pUCY5eXMaC0=
github.com/FloatTech/zbputils v1.2.3-add1 h1:gzLw4aa7HhVB7cRUIcJUdFoM/fqxy6yEOXwtt5nw+40=
github.com/FloatTech/zbputils v1.2.3-add1/go.mod h1:+NZ6tqt9lR2ilyiIh/+90tZlSW2pXx0IyOFlpOiqadE=
github.com/FloatTech/sqlite v0.1.0 h1:Geh6Z+DWZXmyXVOhM0U2oXT7b1Ob6sQtuyjInk+MCUk=
github.com/FloatTech/sqlite v0.1.0/go.mod h1:XS0oeSqtH6lFzpPRiDE9fV6+zMcuUF5/6o+tQVO1QZE=
github.com/FloatTech/zbputils v1.2.5 h1:/JyN6ear5PPpBjrjQEQT0/8mPBMJYBswLiNIzfmGYU8=
github.com/FloatTech/zbputils v1.2.5/go.mod h1:e9e8998yQkzS24IqZ8jLUssTk607hD/Tj3zGyBikIIc=
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/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=
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/corona10/goimagehash v1.0.3 h1:NZM518aKLmoNluluhfHGxT3LGOnrojrxhGn63DR/CZA=
github.com/corona10/goimagehash v1.0.3/go.mod h1:VkvE0mLn84L4aF8vCb6mafVajEb6QYMHl2ZJLn0mOGI=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
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=
@@ -53,8 +50,11 @@ 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/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
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/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
@@ -67,15 +67,16 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er
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/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
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/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
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/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
@@ -85,11 +86,19 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
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/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
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/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
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/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
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=
@@ -99,14 +108,13 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2
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 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
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/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
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/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@@ -114,6 +122,7 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S
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/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -122,8 +131,8 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/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 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
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=
@@ -134,14 +143,15 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
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/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M=
github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
@@ -153,10 +163,13 @@ github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ
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 v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
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/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4 h1:T/m7vDUFKdLd0xfSZHVPQGaRZ73nwPzidLW7hTn25mg=
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
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/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
@@ -166,10 +179,10 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
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-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 h1:kACShD3qhmr/3rLmg1yXyt+N4HcwutKyPRB93s54TIU=
golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
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=
@@ -183,10 +196,11 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
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-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/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/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=
@@ -206,13 +220,15 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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-20210806184541-e5e7981a1069/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-20220110181412-a018aaa089fe h1:W8vbETX/n8S6EmY0Pu4Ix7VvpsJUESTwl0oCK8MJOgk=
golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc=
golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
@@ -223,26 +239,32 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/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.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8=
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
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.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
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/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.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
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=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/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=
@@ -264,7 +286,6 @@ 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.2/go.mod h1:6kii3AptTDI+nUrM9RFBoIEUEisSWCbdczD9ZwQH2FE=
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=
@@ -299,17 +320,21 @@ modernc.org/ccgo/v3 v3.12.86/go.mod h1:dN7S26DLTgVSni1PVA3KxxHTcykyDurf3OgUzNqTS
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/ccgo/v3 v3.15.1/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0=
modernc.org/ccgo/v3 v3.15.9/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0=
modernc.org/ccgo/v3 v3.15.10/go.mod h1:wQKxoFn0ynxMuCLfFD09c8XPUCc8obfchoVR9Cn0fI8=
modernc.org/ccgo/v3 v3.15.12/go.mod h1:VFePOWoCd8uDGRJpq/zfJ29D0EVzMSyID8LCMWYbX6I=
modernc.org/ccgo/v3 v3.15.13 h1:hqlCzNJTXLrhS70y1PqWckrF9x1btSQRC7JFuQcBg5c=
modernc.org/ccgo/v3 v3.15.13/go.mod h1:QHtvdpeODlXjdK3tsbpyK+7U9JV4PQsrPGIbtmc0KfY=
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
modernc.org/ccorpus v1.11.4 h1:YOmQBBzE8GC/puUx76D5j/gJYIZQsydrh6VMJVfXF0M=
modernc.org/ccorpus v1.11.4/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.3/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
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=
@@ -344,9 +369,11 @@ 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/libc v1.14.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk=
modernc.org/libc v1.14.2/go.mod h1:MX1GBLnRLNdvmK9azU9LCxZ5lMyhrbEMK8rG3X/Fe34=
modernc.org/libc v1.14.3/go.mod h1:GPIvQVOVPizzlqyRX3l756/3ppsAgg1QgPxjr5Q4agQ=
modernc.org/libc v1.14.5 h1:DAHvwGoVRDZs5iJXnX9RJrgXSsorupCWmJ2ac964Owk=
modernc.org/libc v1.14.5/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak=
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=
@@ -357,14 +384,11 @@ 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.13.0/go.mod h1:2qO/6jZJrcQaxFUHxOwa6Q6WfiGSsiVj6GXX0Ker+Jg=
modernc.org/sqlite v1.14.4 h1:F3DRiVZKnCLqIQ0LhEGqBLnw9LcdADciCwCIHQ8bD5g=
modernc.org/sqlite v1.14.4/go.mod h1:LWtcO8JtBrt29KKmTqNNXDjAn36vHa/3nHvOYoVIAjc=
modernc.org/sqlite v1.14.6 h1:Jt5P3k80EtDBWaq1beAxnWW+5MdHXbZITujnRS7+zWg=
modernc.org/sqlite v1.14.6/go.mod h1:yiCvMv3HblGmzENNIaNtFhfaNIwcla4u2JQEwJPzfEc=
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.5.9/go.mod h1:bcwjvBJ2u0exY6K35eAmxXBBij5kXb1dHlAWmfhqThE=
modernc.org/tcl v1.10.0/go.mod h1:WzWapmP/7dHVhFoyPpEaNSVTL8xtewhouN/cqSJ5A2s=
modernc.org/tcl v1.11.0/go.mod h1:zsTUpbQ+NxQEjOjCUlImDLPv1sG8Ww0qp66ZvyOxCgw=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.1.2/go.mod h1:sj9T1AGBG0dm6SCVzldPOHWrif6XBpooJtbttMn1+Js=
modernc.org/z v1.2.21/go.mod h1:uXrObx4pGqXWIMliC5MiKuwAyMrltzwpteOFUP1PWCc=
modernc.org/z v1.3.0/go.mod h1:+mvgLH814oDjtATDdT3rs84JnUIpkvAF5B8AVkNlE2g=

30
main.go
View File

@@ -10,7 +10,7 @@ import (
// 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用
// 插件控制
// webctrl "github.com/FloatTech/zbpctrl/web" // web 后端控制
// webctrl "github.com/FloatTech/zbputils/control/web" // web 后端控制
// 词库类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
@@ -27,19 +27,19 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_translation" // 翻译
// 娱乐类
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wtf" // 鬼东西
_ "github.com/FloatTech/ZeroBot-Plugin-Gif" // 制图
// _ "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_coser" // 三次元小姐姐
_ "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_jandan" // 煎蛋网无聊图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
@@ -50,19 +50,27 @@ import (
_ "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_wangyiyun" // 网易云音乐热评
// b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana" // 嘉心糖发病
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_parse" // b站视频链接解析
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push" // b站推送
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana" // 嘉心糖发病
// 二次元图片
_ "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_nsfw" // nsfw图片识别
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao" // 以图搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_scale" // 叔叔的AI二次元图片放大
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_setutime" // 来份涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe" // 搜番
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation" // vtb语录
@@ -73,12 +81,14 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/driver"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
contents = []string{
"* OneBot + ZeroBot + Golang",
"* Version 1.2.3 - 2022-01-07 20:09:30 +0800 CST",
"* Version 1.2.5 - 2022-01-30 20:06:00 +0800 CST",
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
@@ -121,6 +131,7 @@ func init() {
logrus.SetLevel(logrus.WarnLevel)
}
}
// 启用 gui
// webctrl.InitGui(*g)
}
@@ -149,13 +160,14 @@ func getKanban() string {
}
func main() {
order.Wait()
printBanner()
// 帮助
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 功能"))
})
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()))
})

14
order/init.go Normal file
View File

@@ -0,0 +1,14 @@
package order
import "sync"
var wg sync.WaitGroup
// DoneOnExit 在退出时执行 Done
func DoneOnExit() func() {
wg.Add(1)
return wg.Done
}
// Wait 等待
var Wait = wg.Wait

62
order/prio.go Normal file
View File

@@ -0,0 +1,62 @@
// Package order 各个插件的优先级
package order
const (
PrioChat = iota * 10
PrioSleepManage
PrioAtri
PrioManager
PrioACGImage
PrioAIFalse
PrioAIWife
PrioBase14
PrioBilibili
PrioBiliBiliParse
PrioBilibiliPush
PrioBookReview
PrioCangTouShi
PrioChoose
PrioChouXiangHua
PrioCoser
PrioCPStory
PrioDanbooru
PrioDiana
PrioFansDaily
PrioFortune
PrioFunny
PrioGIF
PrioGithub
PrioHS
PrioImageFinder
PrioJandan
PrioJueJueZi
PrioLolicon
PrioMinecraft
PrioMoyu
PrioMusic
PrioNativeSetu
PrioNativeWife
PrioNBNHHSH
PrioNovel
PrioNSFW
PrioNSFWAuto
PrioOmikuji
PrioReborn
PrioRuncode
PrioSauceNao
PrioScale
PrioScore
PrioSetuTime
PrioShaDiao
PrioShinDan
PrioTraceMoe
PrioTranslation
PrioVtbQuotation
PrioWangYiYun
PrioWtf
PrioCurse
PrioMockingBird
PrioAIReply
)

View File

@@ -4,16 +4,16 @@ package acgimage
import (
"net/url"
"strings"
"time"
"github.com/FloatTech/AnimeAPI/classify"
"github.com/FloatTech/AnimeAPI/picture"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/imgpool"
"github.com/FloatTech/zbputils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -25,13 +25,12 @@ const (
var (
// r18有一定保护一般不会发出图片
randapi = "&loli=true&r18=true"
msgof = make(map[int64]int64)
msgof = make(map[int64]message.MessageID)
block = false
limit = rate.NewManager(time.Minute, 5)
)
func init() { // 插件主体
engine := control.Register("acgimage", &control.Options{
engine := control.Register("acgimage", order.PrioACGImage, &control.Options{
DisableOnDefault: false,
Help: "随机图片与AI点评\n" +
"- 随机图片(评级大于6的图将私发)\n" +
@@ -39,8 +38,8 @@ func init() { // 插件主体
"- 设置随机图片网址[url]\n" +
"- 太涩了(撤回最近发的图)\n" +
"- 评价图片(发送一张图片让bot评分)",
})
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
}).ApplySingle(ctxext.DefaultSingle)
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["regex_matched"].([]string)[1]
if !strings.HasPrefix(url, "http") {
@@ -51,17 +50,13 @@ func init() { // 插件主体
}
})
// 有保护的随机图片
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
engine.OnFullMatch("随机图片", zero.OnlyGroup).Limit(ctxext.LimitByUser).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if limit.Load(ctx.Event.UserID).Acquire() {
class, dhash, comment, _ := classify.Classify(randapi, true)
replyClass(ctx, class, dhash, comment, false)
return
}
ctx.SendChain(message.Text("你太快啦!"))
class, dhash, comment, _ := classify.Classify(randapi, true)
replyClass(ctx, class, dhash, comment, false)
})
// 直接随机图片无r18保护后果自负。如果出r18图可尽快通过发送"太涩了"撤回
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
engine.OnFullMatch("直接随机", ctxext.UserOrGrpAdmin).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if block {
ctx.SendChain(message.Text("请稍后再试哦"))
@@ -78,7 +73,7 @@ func init() { // 插件主体
}
})
// 撤回最后的直接随机图片
engine.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
engine.OnFullMatch("太涩了", zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
msg, ok := msgof[ctx.Event.GroupID]
if ok {
@@ -87,7 +82,7 @@ func init() { // 插件主体
}
})
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
@@ -96,49 +91,63 @@ func init() { // 插件主体
break
}
})
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
dhash := ctx.State["regex_matched"].([]string)[1]
if len(dhash) == 5*3 {
var u string
if web.IsSupportIPv6 {
ctx.SendChain(message.Image(apiheadv6 + dhash + ".webp"))
u = apiheadv6 + dhash + ".webp"
} else {
ctx.SendChain(message.Image(apihead + dhash))
u = apihead + dhash
}
m, hassent, err := imgpool.NewImage(ctxext.Send(ctx), ctxext.GetMessage(ctx), dhash, u)
if err == nil && !hassent {
ctx.SendChain(message.Image(m.String()))
}
}
})
}
func setLastMsg(id int64, msg int64) {
func setLastMsg(id int64, msg message.MessageID) {
msgof[id] = msg
}
func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload bool) {
if isupload {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
return
}
b14, err := url.QueryUnescape(dhash)
if err != nil {
return
}
var img message.MessageSegment
var u string
if web.IsSupportIPv6 {
img = message.Image(apiheadv6 + dhash + ".webp")
u = apiheadv6 + dhash + ".webp"
} else {
img = message.Image(apihead + dhash)
u = apihead + dhash
}
var send ctxext.NoCtxSendMsg
if class > 5 {
if dhash != "" && !isupload {
send = ctxext.SendTo(ctx, ctx.Event.UserID)
if dhash != "" {
ctx.SendChain(message.Text(comment + "\n给你点提示哦" + b14))
ctx.Event.GroupID = 0
ctx.SendChain(img)
return
} else {
ctx.SendChain(message.Text(comment))
}
} else {
send = func(msg interface{}) int64 {
return ctx.Send(append(msg.(message.Message), message.Text(comment))).ID()
}
ctx.SendChain(message.Text(comment))
return
}
if isupload {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
return
m, hassent, err := imgpool.NewImage(send, ctxext.GetMessage(ctx), b14, u)
if err == nil && !hassent {
send(message.Message{message.Image(m.String())})
}
ctx.SendChain(img, message.Text(comment))
}

View File

@@ -7,20 +7,22 @@ import (
"os"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/mem"
"github.com/FloatTech/ZeroBot-Plugin/order"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
engine := control.Register("aifalse", &control.Options{
engine := control.Register("aifalse", order.PrioAIFalse, &control.Options{
DisableOnDefault: false,
Help: "AIfalse\n" +
"- 查询计算机当前活跃度: [检查身体|自检|启动自检|系统状态]",
"- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]",
})
engine.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
@@ -43,20 +45,33 @@ func init() { // 插件主体
}
func cpuPercent() float64 {
percent, _ := cpu.Percent(time.Second, false)
percent, err := cpu.Percent(time.Second, false)
if err != nil {
return -1
}
return math.Round(percent[0])
}
func memPercent() float64 {
memInfo, _ := mem.VirtualMemory()
memInfo, err := mem.VirtualMemory()
if err != nil {
return -1
}
return math.Round(memInfo.UsedPercent)
}
func diskPercent() string {
parts, _ := disk.Partitions(true)
parts, err := disk.Partitions(true)
if err != nil {
return err.Error()
}
msg := ""
for _, p := range parts {
diskInfo, _ := disk.Usage(p.Mountpoint)
diskInfo, err := disk.Usage(p.Mountpoint)
if err != nil {
msg += "\n - " + err.Error()
continue
}
pc := uint(math.Round(diskInfo.UsedPercent))
if pc > 0 {
msg += fmt.Sprintf("\n - %s(%dM) %d%%", p.Mountpoint, diskInfo.Total/1024/1024, pc)

View File

@@ -1,3 +1,4 @@
// Package aireply AI 回复
package aireply
import (
@@ -5,44 +6,41 @@ import (
"time"
"github.com/FloatTech/AnimeAPI/aireply"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
serviceName = "aireply"
prio = 256
)
var modes = [...]string{"青云客", "小爱"}
func init() { // 插件主体
bucket := rate.NewManager(time.Minute, 20) // 接口回复限速器
engine := control.Register(serviceName, &control.Options{
engine := control.Register(serviceName, order.PrioAIReply, &control.Options{
DisableOnDefault: false,
Help: "人工智能回复\n" +
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]\n- ",
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
})
// 回复 @和包括名字
engine.OnMessage(zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
aireply := aireply.NewAIReply(getReplyMode(ctx))
if !bucket.Load(ctx.Event.UserID).Acquire() {
// 频繁触发,不回复
return
}
reply := aireply.Talk(ctx.ExtractPlainText())
reply := message.ParseMessageFromString(aireply.Talk(ctx.ExtractPlainText(), zero.BotConfig.NickName[0]))
// 回复
time.Sleep(time.Second * 1)
if ctx.Event.MessageType == "group" {
ctx.SendChain(message.Reply(ctx.Event.MessageID), reply)
if zero.OnlyPublic(ctx) {
reply = append(reply, message.Reply(ctx.Event.MessageID))
ctx.Send(reply)
return
}
ctx.SendChain(reply)
ctx.Send(reply)
})
engine.OnPrefix(`设置回复模式`).SetBlock(true).SetPriority(20).
engine.OnPrefix(`设置回复模式`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
err := setReplyMode(ctx, param)

View File

@@ -1,32 +1,27 @@
package aireply
import (
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/AnimeAPI/aireply"
"github.com/FloatTech/AnimeAPI/mockingbird"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const ttsprio = 250
func init() {
limit := rate.NewManager(time.Second*10, 1)
control.Register("mockingbird", &control.Options{
control.Register("mockingbird", order.PrioMockingBird, &control.Options{
DisableOnDefault: false,
Help: "拟声鸟\n- @Bot 任意文本(任意一句话回复)",
}).OnMessage(zero.OnlyToMe, func(ctx *zero.Ctx) bool {
return limit.Load(ctx.Event.UserID).Acquire()
}).SetBlock(true).SetPriority(ttsprio).
}).OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
r := aireply.NewAIReply(getReplyMode(ctx))
ctx.SendChain(mockingbird.Speak(ctx.Event.UserID, func() string {
return r.TalkPlain(msg)
}))
ctx.SendChain(message.Record(mockingbird.Speak(ctx.Event.UserID, func() string {
return r.TalkPlain(msg, zero.BotConfig.NickName[0])
})))
})
}

View File

@@ -6,9 +6,12 @@ import (
"math/rand"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -16,14 +19,12 @@ const (
)
func init() { // 插件主体
// TODO: 1.17 特性暂不增加
// rand.Seed(time.Now().UnixMicro())
rand.Seed(time.Now().UnixNano())
control.Register("aiwife", &control.Options{
control.Register("aiwife", order.PrioAIWife, &control.Options{
DisableOnDefault: false,
Help: "AIWife\n" +
"- waifu|随机waifu",
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).SetBlock(true).
"- 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

@@ -12,30 +12,30 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
// 服务名
servicename = "atri"
// ATRI 所有命令的优先级
prio = 15
// ATRI 表情的 codechina 镜像
res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/"
)
func init() { // 插件主体
engine := control.Register(servicename, &control.Options{
engine := control.Register(servicename, order.PrioAtri, &control.Options{
DisableOnDefault: false,
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- 答应我",
})
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio).
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup(servicename)
if ok && !c.IsEnabledIn(ctx.Event.GroupID) {
@@ -44,7 +44,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯呜呜……夏生先生……?"))
}
})
engine.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(prio).
engine.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c, ok := control.Lookup(servicename)
if ok && c.IsEnabledIn(ctx.Event.GroupID) {
@@ -53,7 +53,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("Zzz……Zzz……"))
}
})
engine.OnFullMatch("萝卜子", atriSleep).SetBlock(true).SetPriority(prio).
engine.OnFullMatch("萝卜子", atriSleep).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
switch rand.Intn(2) {
@@ -63,17 +63,17 @@ func init() { // 插件主体
ctx.SendChain(randRecord("RocketPunch.amr"))
}
})
engine.OnFullMatchGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnFullMatchGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSleep, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(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"}, atriSleep, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(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()
@@ -113,7 +113,7 @@ 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 { // 中午
@@ -126,7 +126,7 @@ 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()
@@ -169,7 +169,7 @@ func init() { // 插件主体
))
}
})
engine.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSleep, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText(
@@ -190,7 +190,7 @@ func init() { // 插件主体
"呣......我的高性能,毫无遗憾地施展出来了......",
))
})
engine.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSleep, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText(
@@ -205,26 +205,26 @@ func init() { // 插件主体
))
})
engine.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSleep).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("YES.png", "NO.jpg"))
}
})
engine.OnKeywordGroup([]string{"啊这"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"啊这"}, atriSleep).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg"))
}
})
engine.OnKeywordGroup([]string{"我好了"}, atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"我好了"}, atriSleep).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).
engine.OnFullMatchGroup([]string{"", "?", "¿"}, atriSleep).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
switch rand.Intn(5) {
@@ -234,7 +234,7 @@ func init() { // 插件主体
ctx.SendChain(randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
}
})
engine.OnKeyword("离谱", atriSleep).SetBlock(true).SetPriority(prio).
engine.OnKeyword("离谱", atriSleep).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(5) {
case 0:
@@ -243,7 +243,7 @@ func init() { // 插件主体
ctx.SendChain(randImage("WH.jpg"))
}
})
engine.OnKeyword("答应我", atriSleep, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeyword("答应我", atriSleep, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
process.SleepAbout1sTo2s()
ctx.SendChain(randText("我无法回应你的请求"))

View File

@@ -4,21 +4,23 @@ package b14coder
import (
"unsafe"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
base14 "github.com/fumiama/go-base16384"
tea "github.com/fumiama/gofastTEA"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
en := control.Register("base16384", &control.Options{
en := control.Register("base16384", order.PrioBase14, &control.Options{
DisableOnDefault: false,
Help: "base16384加解密\n" +
"- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
})
en.OnRegex(`^加密(.*)`).SetBlock(true).ThirdPriority().
en.OnRegex(`^加密\s?(.*)`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es, err := base14.UTF16be2utf8(base14.EncodeString(str))
@@ -28,7 +30,7 @@ func init() {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex("^解密([\u4e00-\u8e00]*[\u3d01-\u3d06]?)$").SetBlock(true).ThirdPriority().
en.OnRegex(`^解密\s?([一-踀]*[㴁-㴆]?)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
str := ctx.State["regex_matched"].([]string)[1]
es, err := base14.UTF82utf16be(helper.StringToBytes(str))
@@ -38,7 +40,7 @@ func init() {
ctx.SendChain(message.Text("解密失败!"))
}
})
en.OnRegex(`^用(.*)加密(.*)`).SetBlock(true).ThirdPriority().
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 := getea(key)
@@ -49,7 +51,7 @@ func init() {
ctx.SendChain(message.Text("加密失败!"))
}
})
en.OnRegex("^用(.*)解密([\u4e00-\u8e00]*[\u3d01-\u3d06]?)$").SetBlock(true).ThirdPriority().
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 := getea(key)

View File

@@ -5,10 +5,12 @@ import (
"net/http"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/fumiama/cron"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
type follower struct {
@@ -25,7 +27,7 @@ type follower struct {
// 开启日报推送
func init() {
fansDaily()
en := control.Register("fansdaily", &control.Options{
en := control.Register("fansdaily", order.PrioFansDaily, &control.Options{
DisableOnDefault: true,
Help: "fansdaily\n- /开启粉丝日报\n- /关闭粉丝日报",
})

View File

@@ -5,22 +5,24 @@ import (
"io/ioutil"
"net/http"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var engine = control.Register("bilibili", &control.Options{
var engine = control.Register("bilibili", order.PrioBilibili, &control.Options{
DisableOnDefault: false,
Help: "bilibili\n" +
"- >vup info [名字|uid]\n" +
"- >user info [名字|uid]",
"- >vup info [名字 | uid]\n" +
"- >user info [名字 | uid]",
})
// 查成分的
func init() {
engine.OnRegex(`^>user info\s(.{1,25})$`).SetBlock(true).
engine.OnRegex(`^>(?:user|vup)\s?info\s?(.{1,25})$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
rest, err := uid(keyword)

View File

@@ -0,0 +1,66 @@
// Package bilibiliparse b站视频链接解析
package bilibiliparse
import (
"regexp"
"strings"
"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/FloatTech/ZeroBot-Plugin/order"
)
var (
bilibiliRe = "https://www.bilibili.com/video/av[0-9]+|https://www.bilibili.com/video/BV[0-9a-zA-Z]+|https://b23.tv/[0-9a-zA-Z]+"
validRe = "https://www.bilibili.com/video/(BV[0-9a-zA-Z]+)"
)
func init() {
engine := control.Register("bilibiliparse", order.PrioBiliBiliParse, &control.Options{
DisableOnDefault: false,
Help: "b站视频链接解析\n" +
"- https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA",
})
engine.OnRegex(bilibiliRe).SetBlock(true).Handle(func(ctx *zero.Ctx) {
bilibiliURL := ctx.State["regex_matched"].([]string)[0]
m := parseURL(bilibiliURL)
if len(m) != 0 {
ctx.Send(m)
}
})
}
func parseURL(bilibiliURL string) (m message.Message) {
doc, err := htmlquery.LoadURL(bilibiliURL)
if err != nil {
log.Errorln("[bilibiliparse]:访问的链接为", bilibiliURL, ",错误为", err)
}
videoURL := htmlquery.FindOne(doc, "/html/head/meta[@itemprop='url']").Attr[2].Val
re := regexp.MustCompile(validRe)
if !re.MatchString(videoURL) {
return
}
bv := re.FindStringSubmatch(videoURL)[1]
title := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/h1/span/text()").Data
m = append(m, message.Text(title+"\n"))
view := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='view']/text()").Data
dm := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='dm']/text()").Data
m = append(m, message.Text(view+dm+"\n"))
t := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[3]/text()").Data
m = append(m, message.Text(t))
image := htmlquery.FindOne(doc, "/html/head/meta[@itemprop='image']").Attr[2].Val
m = append(m, message.Image(image))
like := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='like']/text()").Data
coin := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='coin']/text()").Data
m = append(m, message.Text("\n点赞", strings.TrimSpace(like)+"投币:", strings.TrimSpace(coin)+"\n"))
collect := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='collect']/text()").Data
share := htmlquery.FindOne(doc, "//*[@id='arc_toolbar_report']/div[1]/span[@class='share']/text()").Data
m = append(m, message.Text("收藏:", strings.TrimSpace(collect)+"分享:", strings.TrimSpace(share)+"\n"))
m = append(m, message.Text(bv))
return
}

View File

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

View File

@@ -0,0 +1,32 @@
package bilibilipush
import (
"os"
"github.com/FloatTech/zbputils/process"
log "github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
cachePath = dbpath + "cache/"
dbpath = "data/bilibilipush/"
dbfile = dbpath + "push.db"
)
// bdb bilibili推送数据库
var bdb *bilibilipushdb
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
bdb = initialize(dbfile)
log.Println("[bilibilipush]加载bilibilipush数据库")
}()
}

View File

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

View File

@@ -7,12 +7,14 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/txt2img"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
engine := control.Register("bookreview", &control.Options{
engine := control.Register("bookreview", order.PrioBookReview, &control.Options{
DisableOnDefault: false,
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
})
@@ -21,11 +23,11 @@ func init() {
engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
data, err := txt2img.RenderToBase64(b.BookReview, 40, 20)
data, err := text.RenderToBase64(b.BookReview, text.FontFile, 400, 20)
if err != nil {
log.Println("err:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 {
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
@@ -33,11 +35,11 @@ func init() {
engine.OnFullMatch("随机书评").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
br := getRandomBookReview()
data, err := txt2img.RenderToBase64(br.BookReview, 40, 20)
data, err := text.RenderToBase64(br.BookReview, text.FontFile, 400, 20)
if err != nil {
log.Println("err:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 {
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})

View File

@@ -5,9 +5,11 @@ import (
log "github.com/sirupsen/logrus"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const dbpath = "data/BookReview/"
@@ -18,6 +20,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
// os.RemoveAll(dbpath)
_ = os.MkdirAll(dbpath, 0755)

View File

@@ -9,12 +9,14 @@ import (
"net/url"
"strings"
control "github.com/FloatTech/zbpctrl"
control "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"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -22,7 +24,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,12 +32,12 @@ var (
)
func init() {
engine := control.Register("cangtoushi", &control.Options{
engine := control.Register("cangtoushi", order.PrioCangTouShi, &control.Options{
DisableOnDefault: false,
Help: "藏头诗\n" +
"- 藏头诗[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()
data, err := search(kw, "7", "0")
@@ -47,7 +48,7 @@ func init() {
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()
data, err := search(kw, "7", "2")

View File

@@ -6,23 +6,24 @@ import (
"strconv"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
dbpath = "data/Chat/"
dbfile = dbpath + "kimoi.json"
prio = 10
)
var (
poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
engine = control.Register("chat", &control.Options{
engine = control.Register("chat", order.PrioChat, &control.Options{
DisableOnDefault: false,
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]\n- mua|啾咪|摸|上你|傻|裸|贴|老婆|抱|亲|一下|咬|操|123|进去|调教|搓|让|捏|挤|略|呐|原味|胖次|内裤|内衣|衣服|ghs|批|憨批|kkp|咕|骚|喜欢|suki|好き|看|不能|砸了|透|口我|草我|自慰|onani|オナニー|炸了|色图|涩图|告白|对不起|回来|吻|软|壁咚|掰开|女友|是|喵|嗷呜|叫|拜|佬|awsl|臭|香|腿|张开|脚|脸|头发|手|pr|舔|小穴|腰|诶嘿嘿|可爱|扭蛋|鼻|眼|色气|推|床|举|手冲|饿|变|敲|爬|怕|冲|射|不穿|迫害|猫粮|揪尾巴|薄荷|早|晚安|揉|榨|掐|胸|奶子|欧派|嫩|蹭|牵手|握手|拍照|w|睡不着|欧尼酱|哥|爱你|过来|自闭|打不过|么么哒|很懂|膝枕|累了|安慰|洗澡|一起睡觉|一起|多大|姐姐|糖|嗦|牛子|🐂子|🐮子|嫌弃|紧|baka|笨蛋|插|插进来|屁股|翘|翘起来|抬|抬起|爸|傲娇|rua|咕噜咕噜|咕噜|上床|做爱|吃掉|吃|揪|种草莓|种草|掀|妹|病娇|嘻",
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]\n- mua | 啾咪 | 摸 | 上你 | 傻 | 裸 | 贴 | 老婆 | 抱 | 亲 | 一下 | 咬 | 操 | 123 | 进去 | 调教 | 搓 | 让 | 捏 | 挤 | 略 | 呐 | 原味 | 胖次 | 内裤 | 内衣 | 衣服 | ghs | 批 | 憨批 | kkp | 咕 | 骚 | 喜欢 | suki | 好き | 看 | 不能 | 砸了 | 透 | 口我 | 草我 | 自慰 | onani | オナニー | 炸了 | 色图 | 涩图 | 告白 | 对不起 | 回来 | 吻 | 软 | 壁咚 | 掰开 | 女友 | 是 | 喵 | 嗷呜 | 叫 | 拜 | 佬 | awsl | 臭 | 香 | 腿 | 张开 | 脚 | 脸 | 头发 | 手 | pr | 舔 | 小穴 | 腰 | 诶嘿嘿 | 可爱 | 扭蛋 | 鼻 | 眼 | 色气 | 推 | 床 | 举 | 手冲 | 饿 | 变 | 敲 | 爬 | 怕 | 冲 | 射 | 不穿 | 迫害 | 猫粮 | 揪尾巴 | 薄荷 | 早 | 晚安 | 揉 | 榨 | 掐 | 胸 | 奶子 | 欧派 | 嫩 | 蹭 | 牵手 | 握手 | 拍照 | w | 睡不着 | 欧尼酱 | 哥 | 爱你 | 过来 | 自闭 | 打不过 | 么么哒 | 很懂 | 膝枕 | 累了 | 安慰 | 洗澡 | 一起睡觉 | 一起 | 多大 | 姐姐 | 糖 | 嗦 | 牛子 | 🐂子 | 🐮子 | 嫌弃 | 紧 | baka | 笨蛋 | 插 | 插进来 | 屁股 | 翘 | 翘起来 | 抬 | 抬起 | 爸 | 傲娇 | rua | 咕噜咕噜 | 咕噜 | 上床 | 做爱 | 吃掉 | 吃 | 揪 | 种草莓 | 种草 | 掀 | 妹 | 病娇 | 嘻",
})
kimomap = make(kimo, 256)
chatList = make([]string, 0, 256)
@@ -30,7 +31,7 @@ var (
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 +45,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 +64,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 +94,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
@@ -111,7 +112,7 @@ func init() { // 插件主体
}
})
initChatList(func() {
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).SetPriority(prio).Handle(
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).Handle(
func(ctx *zero.Ctx) {
key := ctx.MessageString()
val := *kimomap[key]

View File

@@ -8,12 +8,15 @@ import (
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
type kimo = map[string]*[]string
func initChatList(postinit func()) {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
data, err := file.GetLazyData(dbfile, true, true)

View File

@@ -6,19 +6,21 @@ import (
"strconv"
"strings"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
engine := control.Register("choose", &control.Options{
engine := control.Register("choose", order.PrioChoose, &control.Options{
DisableOnDefault: false,
Help: "choose\n" +
"- 选择可口可乐还是百事可乐\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

@@ -2,18 +2,18 @@
package chouxianghua
import (
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const prio = 10
func init() {
control.Register("chouxianghua", &control.Options{
control.Register("chouxianghua", order.PrioChouXiangHua, &control.Options{
DisableOnDefault: false,
Help: "抽象话\n- 抽象翻译xxx",
}).OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$").SetBlock(true).SetPriority(prio).
}).OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
r := cx(ctx.State["regex_matched"].([]string)[1])
ctx.SendChain(message.Text(r))

View File

@@ -5,9 +5,11 @@ import (
log "github.com/sirupsen/logrus"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -20,6 +22,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
// os.RemoveAll(dbpath)
_ = os.MkdirAll(dbpath, 0755)

View File

@@ -2,38 +2,31 @@
package coser
import (
"time"
"github.com/tidwall/gjson"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
engine = control.Register("coser", &control.Options{
DisableOnDefault: false,
Help: "三次元小姐姐\n- coser",
})
prio = 20
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"
limit = rate.NewManager(time.Minute, 5)
)
func init() {
engine.OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).SetPriority(prio).
control.Register("coser", order.PrioCoser, &control.Options{
DisableOnDefault: false,
Help: "三次元小姐姐\n- coser",
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
ctx.SendChain(message.Text("少女祈祷中......"))
data, err := web.ReqWith(coserURL, "GET", "", ua)
if err != nil {
@@ -48,12 +41,13 @@ func init() {
text,
))
gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool {
imgcq := `[CQ:image,file=` + value.String() + `]`
m = append(m,
message.CustomNode(
ctx.Event.Sender.NickName,
ctx.Event.UserID,
imgcq),
[]message.MessageSegment{
message.Image(value.String()),
}),
)
return true
})

View File

@@ -7,21 +7,19 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/math"
)
const (
prio = 20
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
engine := control.Register("cpstory", &control.Options{
engine := control.Register("cpstory", order.PrioCPStory, &control.Options{
DisableOnDefault: false,
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- cp大老师 雪乃",
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- cp大老师 雪乃",
})
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cs := getRandomCpStory()
gong := ctxext.CardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[1]))
shou := ctxext.CardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[2]))
@@ -31,7 +29,7 @@ func init() {
text = strings.ReplaceAll(text, cs.Shou, gong)
ctx.SendChain(message.Text(text))
})
engine.OnPrefix("cp").SetBlock(true).SetPriority(prio + 1).Handle(func(ctx *zero.Ctx) {
engine.OnPrefix("cp").SetBlock(true).Handle(func(ctx *zero.Ctx) {
cs := getRandomCpStory()
params := strings.Split(ctx.State["args"].(string), " ")
if len(params) < 2 {

View File

@@ -5,9 +5,11 @@ import (
log "github.com/sirupsen/logrus"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -20,6 +22,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
// os.RemoveAll(dbpath)
_ = os.MkdirAll(dbpath, 0755)

View File

@@ -2,49 +2,40 @@
package curse
import (
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
prio = 10
minLevel = "min"
maxLevel = "max"
)
var (
engine = control.Register("curse", &control.Options{
DisableOnDefault: false,
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我\n- @bot 他妈|公交车|你妈|操|屎|去死|快死|日|逼|尼玛|艾滋|癌症|有病|戴套|啊对对对|烦你|你爹|屮|tui|cnm",
})
limit = rate.NewManager(time.Minute, 30)
)
func init() {
engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine := control.Register("curse", order.PrioCurse, &control.Options{
DisableOnDefault: true,
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
})
engine.OnFullMatch("骂我").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("大力骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("大力骂我").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{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "日", "逼", "尼玛", "艾滋", "癌症", "有病", "戴套", "啊对对对", "烦你", "你爹", "屮", "tui", "cnm"}, zero.OnlyToMe).SetBlock(true).SetPriority(prio).
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
text := getRandomCurseByLevel(maxLevel).Text
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))

View File

@@ -5,9 +5,11 @@ import (
"github.com/sirupsen/logrus"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -22,6 +24,7 @@ var (
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, err := file.GetLazyData(dbfile, false, true)

60
plugin_danbooru/main.go Normal file
View File

@@ -0,0 +1,60 @@
// Package deepdanbooru 二次元图片标签识别
package deepdanbooru
import (
"crypto/md5"
"encoding/hex"
"os"
"github.com/FloatTech/AnimeAPI/danbooru"
"github.com/FloatTech/AnimeAPI/saucenao"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/writer"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const cachefile = "data/danbooru/"
func init() { // 插件主体
_ = os.RemoveAll(cachefile)
err := os.MkdirAll(cachefile, 0755)
if err != nil {
panic(err)
}
engine := control.Register("danbooru", order.PrioDanbooru, &control.Options{
DisableOnDefault: false,
Help: "二次元图片标签识别\n" +
"- 鉴赏图片[图片]",
})
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyGroup, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
name := ""
r, err := saucenao.SauceNAO(url)
if err != nil {
name = "未知图片"
} else {
name = r[0].Title
}
t, err := danbooru.TagURL(name, url)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
digest := md5.Sum(helper.StringToBytes(url))
f := cachefile + hex.EncodeToString(digest[:])
if file.IsNotExist(f) {
_ = writer.SavePNG2Path(f, t)
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f))
}
})
}

View File

@@ -8,22 +8,22 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
)
var engine *zero.Engine
var engine = control.Register("diana", order.PrioDiana, &control.Options{
DisableOnDefault: false,
Help: "嘉然\n" +
"- 小作文\n" +
"- 发大病\n" +
"- 教你一篇小作文[作文]\n" +
"- [回复]查重",
})
func init() {
engine = control.Register("diana", &control.Options{
DisableOnDefault: false,
Help: "嘉然\n" +
"- 小作文\n" +
"- 发大病\n" +
"- 教你一篇小作文[作文]\n" +
"- [回复]查重",
})
// 随机发送一篇上面的小作文
engine.OnFullMatch("小作文").SetBlock(true).
Handle(func(ctx *zero.Ctx) {

View File

@@ -9,9 +9,11 @@ import (
log "github.com/sirupsen/logrus"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -28,6 +30,7 @@ type text struct {
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
err := os.MkdirAll(datapath, 0755)
if err != nil {

View File

@@ -5,7 +5,6 @@ import (
"bytes"
"encoding/json"
"math"
"strconv"
"time"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -33,8 +32,7 @@ func init() {
Handle(func(ctx *zero.Ctx) {
msg := ctx.Event.Message
if msg[0].Type == "reply" {
id, _ := strconv.Atoi(msg[0].Data["id"])
msg := ctx.GetMessage(int64(id)).Elements[0].Data["text"]
msg := ctx.GetMessage(message.NewMessageID(msg[0].Data["id"])).Elements[0].Data["text"]
zhiwangjson := zhiwangapi(msg)
if zhiwangjson == nil || zhiwangjson.Code != 0 {

View File

@@ -3,59 +3,86 @@ package fortune
import (
"archive/zip"
"bytes"
"encoding/base64"
"crypto/md5"
"encoding/hex"
"encoding/json"
"image/jpeg"
"image"
"io"
"io/ioutil"
"math/rand"
"os"
"strconv"
"sync"
"time"
"github.com/fogleman/gg"
"github.com/fogleman/gg" // 注册了 jpg png gif
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/writer"
"github.com/FloatTech/zbputils/imgpool"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
// 底图缓存位置
images = "data/Fortune/"
// 基础文件位置
omikujson = "data/Fortune/text.json"
// 字体文件位置
font = "data/Font/sakura.ttf"
// 生成图缓存位置
cache = images + "cache/"
)
var (
// 底图缓存位置
base = "data/fortune/"
// 素材下载网站
site = "https://pan.dihe.moe/fortune/"
// 底图类型列表:车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌
// 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师"}
// 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘"}
// 映射底图与 index
index = make(map[string]uint8)
// 下载锁
dlmu sync.Mutex
// 签文
omikujis []map[string]string
)
func init() {
for i, s := range table {
index[s] = uint8(i)
}
err := os.MkdirAll(base, 0755)
err := os.MkdirAll(images, 0755)
if err != nil {
panic(err)
}
_ = os.RemoveAll(cache)
err = os.MkdirAll(cache, 0755)
if err != nil {
panic(err)
}
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{
en := control.Register("fortune", order.PrioFortune, &control.Options{
DisableOnDefault: false,
Help: "每日运势: \n" +
"- 运势|抽签\n" +
"- 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]",
"- 运势 | 抽签\n" +
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘]",
})
en.OnRegex(`^设置底图(.*)`).SetBlock(true).SecondPriority().
en.OnRegex(`^设置底图\s?(.*)`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
if gid <= 0 {
@@ -79,38 +106,8 @@ func init() {
}
ctx.SendChain(message.Text("没有这个底图哦~"))
})
en.OnFullMatchGroup([]string{"运势", "抽签"}).SetBlock(true).SecondPriority().
en.OnFullMatchGroup([]string{"运势", "抽签"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 检查签文文件是否存在
mikuji := base + "运势签文.json"
if file.IsNotExist(mikuji) {
dlmu.Lock()
if file.IsNotExist(mikuji) {
ctx.SendChain(message.Text("正在下载签文文件,请稍后..."))
err := file.DownloadTo(site+"运势签文.json", mikuji, false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("下载签文文件完毕"))
}
dlmu.Unlock()
}
// 检查字体文件是否存在
ttf := base + "sakura.ttf"
if file.IsNotExist(ttf) {
dlmu.Lock()
if file.IsNotExist(ttf) {
ctx.SendChain(message.Text("正在下载字体文件,请稍后..."))
err := file.DownloadTo(site+"sakura.ttf", ttf, false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("下载字体文件完毕"))
}
dlmu.Unlock()
}
// 获取该群背景类型,默认车万
kind := "车万"
gid := ctx.Event.GroupID
@@ -127,125 +124,92 @@ func init() {
}
}
// 检查背景图片是否存在
folder := base + kind
if file.IsNotExist(folder) {
dlmu.Lock()
if file.IsNotExist(folder) {
ctx.SendChain(message.Text("正在下载背景图片,请稍后..."))
zipfile := kind + ".zip"
zipcache := base + zipfile
err := file.DownloadTo(site+zipfile, zipcache, false)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("下载背景图片完毕"))
err = unpack(zipcache, folder+"/")
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("解压背景图片完毕"))
// 释放空间
os.Remove(zipcache)
}
dlmu.Unlock()
zipfile := images + kind + ".zip"
_, err = file.GetLazyData(zipfile, false, 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, err := randimage(folder+"/", seed)
background, index, err := randimage(zipfile, seed)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 随机获取签文
title, text, err := randtext(mikuji, seed)
title, text := randtext(seed)
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
cachefile := cache + hex.EncodeToString(digest[:])
m, err := imgpool.GetImage(cachefile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 绘制背景
d, err := draw(background, title, text)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
logrus.Debugln("[fortune]", err)
if file.IsNotExist(cachefile) {
f, err := os.Create(cachefile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
_, err = draw(background, title, text, f)
_ = f.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}
m.SetFile(file.BOTPATH + "/" + cachefile)
hassent, err := m.Push(ctxext.Send(ctx), ctxext.GetMessage(ctx))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
if hassent {
return
}
}
// 发送图片
ctx.SendChain(message.Image("base64://" + helper.BytesToString(d)))
ctx.SendChain(message.Image(m.String()))
})
}
// @function unpack 解压资源包
// @param tgt 压缩文件位置
// @param dest 解压位置
// @return 错误信息
func unpack(tgt, dest string) error {
// 路径目录不存在则创建目录
if file.IsNotExist(dest) {
if err := os.MkdirAll(dest, 0755); err != nil {
panic(err)
}
}
reader, err := zip.OpenReader(tgt)
if err != nil {
return err
}
defer reader.Close()
// 遍历解压到文件
for _, file := range reader.File {
// 打开解压文件
rc, err := file.Open()
if err != nil {
return err
}
// 打开目标文件
w, err := os.OpenFile(dest+file.Name, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
rc.Close()
return err
}
// 复制到文件
_, err = io.Copy(w, rc)
rc.Close()
w.Close()
if err != nil {
return err
}
}
return nil
}
// @function randimage 随机选取文件夹下的文件
// @param path 文件夹路径
// @function randimage 随机选取zip内的文件
// @param path zip路径
// @param seed 随机数种子
// @return 文件路径 & 错误信息
func randimage(path string, seed int64) (string, error) {
rd, err := ioutil.ReadDir(path)
func randimage(path string, seed int64) (im image.Image, index int, err error) {
reader, err := zip.OpenReader(path)
if err != nil {
return "", err
return
}
defer reader.Close()
rand.Seed(seed)
return path + rd[rand.Intn(len(rd))].Name(), nil
index = rand.Intn(len(reader.File))
file := reader.File[index]
f, err := file.Open()
if err != nil {
return
}
defer f.Close()
im, _, err = image.Decode(f)
return
}
// @function randtext 随机选取签文
// @param file 文件路径
// @param seed 随机数种子
// @return 签名 & 签文 & 错误信息
func randtext(file string, seed int64) (string, string, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
return "", "", err
}
temp := []map[string]string{}
if err := json.Unmarshal(data, &temp); err != nil {
return "", "", err
}
func randtext(seed int64) (string, string) {
rand.Seed(seed)
r := rand.Intn(len(temp))
return temp[r]["title"], temp[r]["content"], nil
r := rand.Intn(len(omikujis))
return omikujis[r]["title"], omikujis[r]["content"]
}
// @function draw 绘制运势图
@@ -254,29 +218,24 @@ func randtext(file string, seed int64) (string, string, error) {
// @param title 签名
// @param text 签文
// @return 错误信息
func draw(background, title, text string) ([]byte, error) {
// 加载背景
back, err := gg.LoadImage(background)
if err != nil {
return nil, err
}
func draw(back image.Image, 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(base+"sakura.ttf", 45); err != nil {
return nil, err
if err := canvas.LoadFontFace(font, 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(base+"sakura.ttf", 23); err != nil {
return nil, err
if err := canvas.LoadFontFace(font, 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:
@@ -300,17 +259,7 @@ func draw(background, title, text string) ([]byte, error) {
}
}
}
// 转成 base64
buffer := new(bytes.Buffer)
encoder := base64.NewEncoder(base64.StdEncoding, buffer)
var opt jpeg.Options
opt.Quality = 70
err = jpeg.Encode(encoder, canvas.Image(), &opt)
if err != nil {
return nil, err
}
encoder.Close()
return buffer.Bytes(), nil
return writer.WriteTo(canvas.Image(), f)
}
func offest(total, now int, distance float64) float64 {

View File

@@ -7,6 +7,8 @@ import (
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
type joke struct {
@@ -22,6 +24,7 @@ const (
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, err := file.GetLazyData(dbfile, false, true)

View File

@@ -7,7 +7,7 @@ import (
"strings"
"testing"
"github.com/FloatTech/zbputils/sql"
sql "github.com/FloatTech/sqlite"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

View File

@@ -3,32 +3,28 @@ package funny
import (
"strings"
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
engine = control.Register("funny", &control.Options{
engine = control.Register("funny", order.PrioFunny, &control.Options{
DisableOnDefault: false,
Help: "讲个笑话\n" +
"- 讲个笑话[@xxx]|讲个笑话[qq号]",
"- 讲个笑话[@xxx] | 讲个笑话[qq号]",
})
limit = rate.NewManager(time.Minute, 20)
db = &sql.Sqlite{DBPath: dbfile}
db = &sql.Sqlite{DBPath: dbfile}
)
func init() {
engine.OnPrefix("讲个笑话").SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnPrefix("讲个笑话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
// 获取名字
name := ctxext.NickName(ctx)
var j joke

31
plugin_gif/README.md Normal file
View File

@@ -0,0 +1,31 @@
# ZeroBot-Plugin-Gif
[ZeroBot QQ机器人](https://github.com/wdvxdr1123/ZeroBot)插件可以制作各种沙雕gif图
> 素材包地址: https://codechina.csdn.net/u011570312/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] 负片

57
plugin_gif/context.go Normal file
View File

@@ -0,0 +1,57 @@
package gif
import (
"os"
"strconv"
"github.com/FloatTech/zbputils/file"
"github.com/sirupsen/logrus"
)
type context struct {
usrdir string
headimgsdir []string
}
func dlchan(name string, c *chan *string) {
target := datapath + `materials/` + name
if file.IsNotExist(target) {
_ = file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
} else {
logrus.Debugln("[gif] dl", name, "exists")
}
*c <- &target
}
func dlblock(name string) string {
target := datapath + `materials/` + name
if file.IsNotExist(target) {
_ = file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
} else {
logrus.Debugln("[gif] dl", name, "exists")
}
return target
}
func dlrange(prefix string, end int) *[]chan *string {
if file.IsNotExist(datapath + `materials/` + prefix) {
_ = os.MkdirAll(datapath+`materials/`+prefix, 0755)
}
c := make([]chan *string, end)
for i := range c {
c[i] = make(chan *string)
go dlchan(prefix+"/"+strconv.Itoa(i)+".png", &c[i])
}
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
}

161
plugin_gif/gif.go Normal file
View File

@@ -0,0 +1,161 @@
package gif
import (
"image"
"github.com/FloatTech/zbputils/img"
"github.com/FloatTech/zbputils/img/writer"
)
// 摸
func (cc *context) mo() string {
name := cc.usrdir + "摸.gif"
c := dlrange("mo", 5)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im
mo := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 80, 80, 32, 32).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertBottom(tou, 70, 90, 42, 22).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertBottom(tou, 75, 85, 37, 27).Im,
img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertBottom(tou, 85, 75, 27, 37).Im,
img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertBottom(tou, 90, 70, 22, 42).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(1, mo))
return "file:///" + name
}
// 搓
func (cc *context) cuo() string {
name := cc.usrdir + "搓.gif"
c := dlrange("cuo", 5)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 110, 110).Circle(0).Im
m1 := img.Rotate(tou, 72, 0, 0)
m2 := img.Rotate(tou, 144, 0, 0)
m3 := img.Rotate(tou, 216, 0, 0)
m4 := img.Rotate(tou, 288, 0, 0)
cuo := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottomC(tou, 0, 0, 75, 130).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertBottomC(m1.Im, 0, 0, 75, 130).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertBottomC(m2.Im, 0, 0, 75, 130).Im,
img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertBottomC(m3.Im, 0, 0, 75, 130).Im,
img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertBottomC(m4.Im, 0, 0, 75, 130).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(5, cuo))
return "file:///" + name
}
// 敲
func (cc *context) qiao() string {
name := cc.usrdir + "敲.gif"
c := dlrange("qiao", 2)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 40, 40).Circle(0).Im
qiao := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 40, 33, 57, 52).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 38, 36, 58, 50).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(1, qiao))
return "file:///" + name
}
// 吃
func (cc *context) chi() string {
name := cc.usrdir + "吃.gif"
c := dlrange("chi", 3)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 32, 32).Im
chi := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertBottom(tou, 0, 0, 1, 38).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(1, chi))
return "file:///" + name
}
// 蹭
func (cc *context) ceng() string {
name := cc.usrdir + "蹭.gif"
c := dlrange("ceng", 6)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 100, 100).Circle(0).Im
tou2 := img.LoadFirstFrame(cc.headimgsdir[1], 100, 100).Circle(0).Im
ceng := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 75, 77, 40, 88).InsertUp(tou2, 77, 103, 102, 81).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 75, 77, 46, 100).InsertUp(img.Rotate(tou2, 10, 62, 127).Im, 0, 0, 92, 40).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertUp(tou, 75, 77, 67, 99).InsertUp(tou2, 76, 117, 90, 8).Im,
img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertUp(tou, 75, 77, 52, 83).InsertUp(img.Rotate(tou2, -40, 94, 94).Im, 0, 0, 53, -20).Im,
img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertUp(tou, 75, 77, 56, 110).InsertUp(img.Rotate(tou2, -66, 132, 80).Im, 0, 0, 78, 40).Im,
img.LoadFirstFrame(*<-(*c)[5], 0, 0).InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(8, ceng))
return "file:///" + name
}
// 啃
func (cc *context) ken() string {
name := cc.usrdir + "啃.gif"
c := dlrange("ken", 16)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 100, 100).Im
ken := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertBottom(tou, 90, 90, 105, 150).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertBottom(tou, 90, 83, 96, 172).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).InsertBottom(tou, 90, 90, 106, 148).Im,
img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertBottom(tou, 88, 88, 97, 167).Im,
img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertBottom(tou, 90, 85, 89, 179).Im,
img.LoadFirstFrame(*<-(*c)[5], 0, 0).InsertBottom(tou, 90, 90, 106, 151).Im,
img.LoadFirstFrame(*<-(*c)[6], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[7], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[8], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[9], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[10], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[11], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[12], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[13], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[14], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[15], 0, 0).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(7, ken))
return "file:///" + name
}
// 拍
func (cc *context) pai() string {
name := cc.usrdir + "拍.gif"
c := dlrange("pai", 2)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 30, 30).Circle(0).Im
pai := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 0, 0, 1, 47).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 0, 0, 1, 67).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(1, pai))
return "file:///" + name
}
// 冲
func (cc *context) chong() string {
name := cc.usrdir + "冲.gif"
c := dlrange("xqe", 2)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im
chong := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 30, 30, 15, 53).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 30, 30, 40, 53).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(1, chong))
return "file:///" + name
}
// 丢
func (cc *context) diu() string {
name := cc.usrdir + "丢.gif"
c := dlrange("diu", 8)
tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im
diu := []*image.NRGBA{
img.LoadFirstFrame(*<-(*c)[0], 0, 0).InsertUp(tou, 32, 32, 108, 36).Im,
img.LoadFirstFrame(*<-(*c)[1], 0, 0).InsertUp(tou, 32, 32, 122, 36).Im,
img.LoadFirstFrame(*<-(*c)[2], 0, 0).Im,
img.LoadFirstFrame(*<-(*c)[3], 0, 0).InsertUp(tou, 123, 123, 19, 129).Im,
img.LoadFirstFrame(*<-(*c)[4], 0, 0).InsertUp(tou, 185, 185, -50, 200).InsertUp(tou, 33, 33, 289, 70).Im,
img.LoadFirstFrame(*<-(*c)[5], 0, 0).InsertUp(tou, 32, 32, 280, 73).Im,
img.LoadFirstFrame(*<-(*c)[6], 0, 0).InsertUp(tou, 35, 35, 259, 31).Im,
img.LoadFirstFrame(*<-(*c)[7], 0, 0).InsertUp(tou, 175, 175, -50, 220).Im,
}
_ = writer.SaveGIF2Path(name, img.MergeGif(7, diu))
return "file:///" + name
}

19
plugin_gif/logo.go Normal file
View File

@@ -0,0 +1,19 @@
package gif
import (
"strconv"
"strings"
"github.com/FloatTech/zbputils/file"
)
func (cc *context) prepareLogos(s ...string) {
for i, v := range s {
_, err := strconv.Atoi(v)
if err != nil {
_ = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.usrdir+strconv.Itoa(i)+".gif", true)
} else {
_ = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.usrdir+strconv.Itoa(i)+".gif", true)
}
}
}

70
plugin_gif/png.go Normal file
View File

@@ -0,0 +1,70 @@
package gif
import (
"image"
"math/rand"
"strconv"
"github.com/FloatTech/zbputils/img"
"github.com/FloatTech/zbputils/img/writer"
)
// 爬
func (cc *context) pa() string {
name := cc.usrdir + `爬.png`
tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Circle(0).Im
// 随机爬图序号
rand := rand.Intn(60) + 1
dc := img.LoadFirstFrame(dlblock(`pa/`+strconv.Itoa(rand)+`.png`), 0, 0).
InsertBottom(tou, 100, 100, 0, 400).Im
_ = writer.SavePNG2Path(name, dc)
return "file:///" + name
}
// 撕
func (cc *context) si() string {
name := cc.usrdir + `撕.png`
tou := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0).Im
im1 := img.Rotate(tou, 20, 380, 380)
im2 := img.Rotate(tou, -12, 380, 380)
dc := img.LoadFirstFrame(dlblock(`si/0.png`), 0, 0).
InsertBottom(im1.Im, im1.W, im1.H, -3, 370).
InsertBottom(im2.Im, im2.W, im2.H, 653, 310).Im
_ = writer.SavePNG2Path(name, dc)
return "file:///" + name
}
// 简单
func (cc *context) other(value ...string) string {
name := cc.usrdir + value[0] + `.png`
// 加载图片
im := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
var a *image.NRGBA
switch value[0] {
case "上翻", "下翻":
a = im.FlipV().Im
case "左翻", "右翻":
a = im.FlipH().Im
case "反色":
a = im.Invert().Im
case "灰度":
a = im.Grayscale().Im
case "负片":
a = im.Invert().Grayscale().Im
case "浮雕":
a = im.Convolve3x3().Im
case "打码":
a = im.Blur(10).Im
case "旋转":
r, _ := strconv.ParseFloat(value[1], 64)
a = img.Rotate(im.Im, r, 0, 0).Im
case "变形":
w, _ := strconv.Atoi(value[1])
h, _ := strconv.Atoi(value[2])
a = img.Size(im.Im, w, h).Im
}
_ = writer.SavePNG2Path(name, a)
return "file:///" + name
}

70
plugin_gif/run.go Normal file
View File

@@ -0,0 +1,70 @@
// Package gif 制图
package gif
import (
"math/rand"
"os"
"strconv"
"strings"
"time"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
cmds = []string{"搓", "冲", "摸", "拍", "丢", "吃", "敲", "啃", "蹭", "爬", "撕",
"灰度", "上翻", "下翻", "左翻", "右翻", "反色", "浮雕", "打码", "负片"}
botpath, _ = os.Getwd()
datapath = botpath + "/data/gif/"
)
func init() { // 插件主体
_ = os.RemoveAll(datapath) // 清除缓存图片
err := os.MkdirAll(datapath, 0755)
if err != nil {
panic(err)
}
rand.Seed(time.Now().UnixNano()) // 设置种子
control.Register("gif", order.PrioGIF, &control.Options{
DisableOnDefault: false,
Help: "制图\n- " + strings.Join(cmds, "\n- "),
}).ApplySingle(ctxext.DefaultSingle).OnRegex(`^(` + strings.Join(cmds, "|") + `)\D*?(\[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)
c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
var picurl string
switch list[1] {
case "爬":
picurl = c.pa()
case "摸":
picurl = c.mo()
case "吃":
picurl = c.chi()
case "啃":
picurl = c.ken()
case "蹭":
picurl = c.ceng()
case "敲":
picurl = c.qiao()
case "搓":
picurl = c.cuo()
case "拍":
picurl = c.pai()
case "丢":
picurl = c.diu()
case "撕":
picurl = c.si()
case "冲":
picurl = c.chong()
default:
picurl = c.other(list[1]) // "灰度", "上翻", "下翻", "左翻", "右翻", "反色", "倒放", "浮雕", "打码", "负片"
}
ctx.SendChain(message.Image(picurl))
})
}

View File

@@ -9,20 +9,22 @@ import (
"net/url"
"strings"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/tidwall/gjson"
)
func init() { // 插件主体
control.Register("github", &control.Options{
control.Register("github", order.PrioGithub, &control.Options{
DisableOnDefault: false,
Help: "GitHub仓库搜索\n" +
"- >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{

View File

@@ -12,9 +12,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
@@ -49,15 +52,15 @@ func init() {
panic(err)
}
engine := control.Register("hs", &control.Options{
engine := control.Register("hs", order.PrioHS, &control.Options{
DisableOnDefault: false,
Help: "炉石\n" +
"- 搜卡[xxxx]\n" +
"- [卡组代码xxx]\n" +
"- 更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp",
})
}).ApplySingle(ctxext.DefaultSingle)
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,7 +72,6 @@ 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(
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
@@ -79,7 +81,7 @@ func init() {
err = os.WriteFile(cachefile, data, 0644)
}
if err != nil {
imgcq = err.Error()
continue
}
}
sk = append(
@@ -87,7 +89,7 @@ func init() {
message.CustomNode(
zero.BotConfig.NickName[0],
ctx.Event.SelfID,
imgcq, // 图片
[]message.MessageSegment{message.Image("file:///" + cachefile)}, // 图片
),
)
}
@@ -100,7 +102,7 @@ func init() {
})
// 卡组
engine.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
SetBlock(true).Handle(func(ctx *zero.Ctx) {
fmt.Print("成功")
List := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(

View File

@@ -6,11 +6,16 @@ import (
"fmt"
"math/rand"
"net/http"
"strings"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/imgpool"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
type resultjson struct {
@@ -60,18 +65,22 @@ type resultjson struct {
}
func init() {
control.Register("imgfinder", &control.Options{
control.Register("imgfinder", order.PrioImageFinder, &control.Options{
DisableOnDefault: false,
Help: "关键字搜图\n" +
"- 来张 [xxx]",
}).OnRegex(`^来张 (.*)$`, zero.AdminPermission).SetBlock(true).
}).OnRegex(`^来张\s?(.*)$`, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
soutujson := soutuapi(keyword)
pom1 := "https://i.pixiv.re"
rannum := randintn(len(soutujson.Illusts))
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
ctx.SendChain(message.Image(pom1 + pom2))
u := pom1 + pom2
m, hassent, err := imgpool.NewImage(ctxext.Send(ctx), ctxext.GetMessage(ctx), u[strings.LastIndex(u, "/")+1:], u)
if err == nil && !hassent {
ctx.SendChain(message.Image(m.String()))
}
})
}

52
plugin_jandan/data.go Normal file
View File

@@ -0,0 +1,52 @@
package jandan
import (
"os"
"sync"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
log "github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const dbpath = "data/Jandan/"
const dbfile = dbpath + "pics.db"
var db = &sql.Sqlite{DBPath: dbfile}
var mu sync.RWMutex
type picture struct {
ID uint64 `db:"id"`
URL string `db:"url"`
}
func getRandomPicture() (u string, err error) {
var p picture
mu.RLock()
err = db.Pick("picture", &p)
mu.RUnlock()
u = p.URL
return
}
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, _ = file.GetLazyData(dbfile, false, false)
err := db.Create("picture", &picture{})
if err != nil {
panic(err)
}
n, err := db.Count("picture")
if err != nil {
panic(err)
}
log.Printf("[jandan]读取%d张图片", n)
}()
}

91
plugin_jandan/jandan.go Normal file
View File

@@ -0,0 +1,91 @@
// Package jandan 煎蛋网无聊图
package jandan
import (
"fmt"
"hash/crc64"
"regexp"
"strconv"
"github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/control"
"github.com/antchfx/htmlquery"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
api = "http://jandan.net/pic"
)
func init() {
engine := control.Register("jandan", order.PrioJandan, &control.Options{
DisableOnDefault: false,
Help: "煎蛋网无聊图\n- 来份屌图\n- 更新屌图\n",
})
engine.OnFullMatch("来份屌图").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u, err := getRandomPicture()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image(u))
})
engine.OnFullMatch("更新屌图", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.Send("少女更新中...")
webpageURL := api
doc, err := htmlquery.LoadURL(webpageURL)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
re := regexp.MustCompile(`\d+`)
pageTotal, err := strconv.Atoi(re.FindString(htmlquery.FindOne(doc, "//*[@id='comments']/div[2]/div/span[@class='current-comment-page']/text()").Data))
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
LOOP:
for i := 0; i < pageTotal; i++ {
logrus.Infoln("[jandan]", fmt.Sprintf("处理第%d/%d页...", i, pageTotal))
doc, err = htmlquery.LoadURL(webpageURL)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
picList, err := htmlquery.QueryAll(doc, "//*[@class='view_img_link']")
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if len(picList) != 0 {
for _, v := range picList {
u := "https:" + v.Attr[0].Val
i := crc64.Checksum(binary.StringToBytes(u), crc64.MakeTable(crc64.ISO))
mu.RLock()
ok := db.CanFind("picture", "where id="+strconv.FormatUint(i, 10))
mu.RUnlock()
if !ok {
mu.Lock()
db.Insert("picture", &picture{ID: i, URL: u})
mu.Unlock()
} else {
// 开始重复,说明之后都是重复
break LOOP
}
}
}
if i != pageTotal-1 {
webpageURL = "https:" + htmlquery.FindOne(doc, "//*[@id='comments']/div[@class='comments']/div[@class='cp-pagenavi']/a[@class='previous-comment-page']").Attr[1].Val
}
}
ctx.Send("更新完成!")
})
}

View File

@@ -6,37 +6,30 @@ import (
"io"
"net/http"
"strings"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
juejueziURL = "https://www.offjuan.com/api/juejuezi/text"
prio = 15
referer = "https://juejuezi.offjuan.com/"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
)
var (
limit = rate.NewManager(time.Minute, 20)
)
func init() {
control.Register("juejuezi", &control.Options{
control.Register("juejuezi", order.PrioJueJueZi, &control.Options{
DisableOnDefault: false,
Help: "绝绝子生成器\n" +
"- 喝奶茶绝绝子|绝绝子吃饭",
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
"- 喝奶茶绝绝子 | 绝绝子吃饭",
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
toDealStr := []rune(strings.ReplaceAll(ctx.ExtractPlainText(), "绝绝子", ""))
switch len(toDealStr) {
case 0, 1:

View File

@@ -11,8 +11,13 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/imgpool"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -25,11 +30,11 @@ var (
)
func init() {
control.Register("lolicon", &control.Options{
control.Register("lolicon", order.PrioLolicon, &control.Options{
DisableOnDefault: false,
Help: "lolicon\n" +
"- 来份萝莉",
}).OnFullMatch("来份萝莉").SetBlock(true).
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("来份萝莉").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
go func() {
for i := 0; i < math.Min(cap(queue)-len(queue), 2); i++ {
@@ -50,12 +55,23 @@ func init() {
continue
}
url := json.Get("data.0.urls.original").Str
ctx.SendGroupMessage(0, message.Image(strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")))
queue <- url
url = strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")
name := url[strings.LastIndex(url, "/")+1 : len(url)-4]
m, err := imgpool.GetImage(name)
if err != nil {
m.SetFile(url)
_, err = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
process.SleepAbout1sTo2s()
}
if err == nil {
queue <- m.String()
} else {
queue <- url
}
}
}()
select {
case <-time.After(time.Second * 10):
case <-time.After(time.Minute):
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
case url := <-queue:
ctx.SendChain(message.Image(url))

View File

@@ -12,15 +12,15 @@ import (
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_manager/timer"
)
@@ -43,30 +43,30 @@ const (
"- 群聊转发 1234 XXX\n" +
"- 私聊转发 0000 XXX\n" +
"- 在MM月dd日的hh点mm分时(用http://url)提醒大家XXX\n" +
"- 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家XXX\n" +
"- 在MM月[每周 | 周几]的hh点mm分时(用http://url)提醒大家XXX\n" +
"- 取消在MM月dd日的hh点mm分的提醒\n" +
"- 取消在MM月[每周|周几]的hh点mm分的提醒\n" +
"- 取消在MM月[每周 | 周几]的hh点mm分的提醒\n" +
"- 在\"cron\"时(用[url])提醒大家[xxx]\n" +
"- 取消在\"cron\"的提醒\n" +
"- 列出所有提醒\n" +
"- 翻牌\n" +
"- 设置欢迎语XXX\n" +
"- [开启|关闭]入群验证"
"- [开启 | 关闭]入群验证"
)
var (
db = &sql.Sqlite{DBPath: confile}
limit = rate.NewManager(time.Minute*5, 2)
clock timer.Clock
)
var engine = control.Register("manager", &control.Options{
var engine = control.Register("manager", order.PrioManager, &control.Options{
DisableOnDefault: false,
Help: hint,
})
func init() { // 插件主体
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(datapath, 0755)
clock = timer.NewClock(db)
@@ -80,7 +80,7 @@ func init() { // 插件主体
}
}()
// 升为管理
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupAdmin(
ctx.Event.GroupID,
@@ -95,7 +95,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text(nickname + " 升为了管理~"))
})
// 取消管理
engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupAdmin(
ctx.Event.GroupID,
@@ -110,7 +110,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("残念~ " + nickname + " 暂时失去了管理员的资格"))
})
// 踢出群聊
engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupKick(
ctx.Event.GroupID,
@@ -125,7 +125,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("残念~ " + nickname + " 被放逐"))
})
// 退出群聊
engine.OnRegex(`^退出群聊.*?(\d+)`, zero.OnlyToMe, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^退出群聊.*?(\d+)`, zero.OnlyToMe, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupLeave(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要退出的群的群号
@@ -133,7 +133,7 @@ func init() { // 插件主体
)
})
// 开启全体禁言
engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupWholeBan(
ctx.Event.GroupID,
@@ -142,7 +142,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("全员自闭开始~"))
})
// 解除全员禁言
engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupWholeBan(
ctx.Event.GroupID,
@@ -151,7 +151,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("全员自闭结束~"))
})
// 禁言
engine.OnRegex(`^禁言.*?(\d+).*?\s(\d+)(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^禁言.*?(\d+).*?\s(\d+)(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
duration := math.Str2Int64(ctx.State["regex_matched"].([]string)[2])
switch ctx.State["regex_matched"].([]string)[3] {
@@ -175,7 +175,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("小黑屋收留成功~"))
})
// 解除禁言
engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupBan(
ctx.Event.GroupID,
@@ -185,7 +185,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("小黑屋释放成功~"))
})
// 自闭禁言
engine.OnRegex(`^(我要自闭|禅定).*?(\d+)(.*)`, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^(我要自闭|禅定).*?(\d+)(.*)`, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
duration := math.Str2Int64(ctx.State["regex_matched"].([]string)[2])
switch ctx.State["regex_matched"].([]string)[3] {
@@ -209,7 +209,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("那我就不手下留情了~"))
})
// 修改名片
engine.OnRegex(`^修改名片.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^修改名片.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupCard(
ctx.Event.GroupID,
@@ -219,7 +219,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯!已经修改了"))
})
// 修改头衔
engine.OnRegex(`^修改头衔.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^修改头衔.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupSpecialTitle(
ctx.Event.GroupID,
@@ -229,7 +229,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯!已经修改了"))
})
// 申请头衔
engine.OnRegex(`^申请头衔(.*)`, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^申请头衔(.*)`, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupSpecialTitle(
ctx.Event.GroupID,
@@ -239,7 +239,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯!不错的头衔呢~"))
})
// 群聊转发
engine.OnRegex(`^群聊转发.*?(\d+)\s(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^群聊转发.*?(\d+)\s(.*)`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 对CQ码进行反转义
content := ctx.State["regex_matched"].([]string)[2]
@@ -252,7 +252,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
})
// 私聊转发
engine.OnRegex(`^私聊转发.*?(\d+)\s(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^私聊转发.*?(\d+)\s(.*)`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 对CQ码进行反转义
content := ctx.State["regex_matched"].([]string)[2]
@@ -265,7 +265,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
})
// 定时提醒
engine.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
dateStrs := ctx.State["regex_matched"].([]string)
ts := timer.GetFilledTimer(dateStrs, ctx.Event.SelfID, ctx.Event.GroupID, false)
@@ -277,7 +277,7 @@ func init() { // 插件主体
}
})
// 定时 cron 提醒
engine.OnRegex(`^在"(.*)"时(用.+)?提醒大家(.*)`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^在"(.*)"时(用.+)?提醒大家(.*)`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
dateStrs := ctx.State["regex_matched"].([]string)
var url, alert string
@@ -300,7 +300,7 @@ func init() { // 插件主体
}
})
// 取消定时
engine.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
dateStrs := ctx.State["regex_matched"].([]string)
ts := timer.GetFilledTimer(dateStrs, ctx.Event.SelfID, ctx.Event.GroupID, true)
@@ -313,7 +313,7 @@ func init() { // 插件主体
}
})
// 取消 cron 定时
engine.OnRegex(`^取消在"(.*)"的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnRegex(`^取消在"(.*)"的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
dateStrs := ctx.State["regex_matched"].([]string)
ts := timer.Timer{Cron: dateStrs[1], GrpID: ctx.Event.GroupID}
@@ -326,17 +326,13 @@ func init() { // 插件主体
}
})
// 列出本群所有定时
engine.OnFullMatch("列出所有提醒", zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnFullMatch("列出所有提醒", zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(clock.ListTimers(ctx.Event.GroupID)))
})
// 随机点名
engine.OnFullMatchGroup([]string{"翻牌"}, zero.OnlyGroup).SetBlock(true).SetPriority(40).
engine.OnFullMatchGroup([]string{"翻牌"}, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("少女祈祷中......"))
return
}
// 无缓存获取群员列表
list := ctx.CallAction("get_group_member_list", zero.Params{
"group_id": ctx.Event.GroupID,
@@ -369,7 +365,7 @@ func init() { // 插件主体
)
})
// 入群欢迎
engine.OnNotice().SetBlock(false).FirstPriority().
engine.OnNotice().SetBlock(false).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.NoticeType == "group_increase" && ctx.Event.SelfID != ctx.Event.UserID {
var w welcome
@@ -421,7 +417,7 @@ func init() { // 插件主体
}
})
// 退群提醒
engine.OnNotice().SetBlock(false).SetPriority(40).
engine.OnNotice().SetBlock(false).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.NoticeType == "group_decrease" {
userid := ctx.Event.UserID
@@ -429,7 +425,7 @@ func init() { // 插件主体
}
})
// 设置欢迎语
engine.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
w := &welcome{
GrpID: ctx.Event.GroupID,
@@ -443,7 +439,7 @@ func init() { // 插件主体
}
})
// 入群后验证开关
engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["regex_matched"].([]string)[1]
c, ok := control.Lookup("manager")
@@ -468,7 +464,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("找不到服务!"))
})
// 加群 gist 验证开关
engine.OnRegex(`^(.*)gist加群自动审批$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
engine.OnRegex(`^(.*)gist加群自动审批$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
option := ctx.State["regex_matched"].([]string)[1]
c, ok := control.Lookup("manager")
@@ -493,7 +489,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("找不到服务!"))
})
// 运行 CQ 码
engine.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(0).
engine.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var cmd = ctx.State["regex_matched"].([]string)[1]
cmd = strings.ReplaceAll(cmd, "&#91;", "[")
@@ -504,7 +500,7 @@ func init() { // 插件主体
// 根据 gist 自动同意加群
// 加群请在github新建一个gist其文件名为本群群号的字符串的md5(小写)内容为一行是当前unix时间戳(10分钟内有效)。
// 然后请将您的用户名和gist哈希(小写)按照username/gisthash的格式填写到回答即可。
engine.OnRequest().SetBlock(false).FirstPriority().Handle(func(ctx *zero.Ctx) {
engine.OnRequest().SetBlock(false).Handle(func(ctx *zero.Ctx) {
/*if ctx.Event.RequestType == "friend" {
ctx.SetFriendAddRequest(ctx.Event.Flag, true, "")
}*/

View File

@@ -1,7 +1,7 @@
package timer
import (
"github.com/FloatTech/zbputils/sql"
sql "github.com/FloatTech/sqlite"
)
// Timer 计时器

View File

@@ -7,12 +7,11 @@ import (
"sync"
"time"
sql "github.com/FloatTech/sqlite"
"github.com/fumiama/cron"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/zbputils/sql"
)
// Clock 时钟
@@ -39,10 +38,10 @@ var (
// NewClock 添加一个新时钟
func NewClock(db *sql.Sqlite) (c Clock) {
c.loadTimers(db)
c.cron = cron.New()
c.entries = make(map[uint32]cron.EntryID)
c.timers = &map[uint32]*Timer{}
c.loadTimers(db)
c.cron.Start()
return
}

View File

@@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/FloatTech/zbputils/sql"
sql "github.com/FloatTech/sqlite"
"github.com/sirupsen/logrus"
)

View File

@@ -6,10 +6,12 @@ import (
"io/ioutil"
"net/http"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
// 此功能实现依赖MCSManager项目对服务器的管理apimc服务器如果没有在该管理平台部署此功能无效
@@ -18,7 +20,7 @@ import (
const api = "http://your.addr:23333/api/start_server/%s/?apikey=apikey"
var engine = control.Register("minecraft", &control.Options{
var engine = control.Register("minecraft", order.PrioMinecraft, &control.Options{
DisableOnDefault: false,
Help: "minecraft\n" +
"- /mcstart xxx\n" +

View File

@@ -4,10 +4,12 @@ package moyu
import (
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/fumiama/cron"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() { // 插件主体
@@ -18,12 +20,12 @@ func init() { // 插件主体
c.Start()
}
control.Register("moyu", &control.Options{
control.Register("moyu", order.PrioMoyu, &control.Options{
DisableOnDefault: true,
Help: "moyu\n" +
"- 添加摸鱼提醒\n" +
"- 删除摸鱼提醒",
}).OnFullMatch("删除摸鱼提醒", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(20).
}).OnFullMatch("删除摸鱼提醒", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
m, ok := control.Lookup("moyu")
if ok {
@@ -38,7 +40,7 @@ func init() { // 插件主体
}
})
zero.OnFullMatch("添加摸鱼提醒", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(20).
zero.OnFullMatch("添加摸鱼提醒", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
m, ok := control.Lookup("moyu")
if ok {

View File

@@ -11,29 +11,25 @@ import (
"strings"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var limit = rate.NewManager(time.Minute*3, 5)
func init() {
control.Register("music", &control.Options{
control.Register("music", order.PrioMusic, &control.Options{
DisableOnDefault: false,
Help: "点歌\n" +
"- 点歌[xxx]\n" +
"- 网易点歌[xxx]\n" +
"- 酷我点歌[xxx]\n" +
"- 酷狗点歌[xxx]",
}).OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).FirstPriority().
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
// switch 平台
switch ctx.State["regex_matched"].([]string)[1] {
case "酷我":

View File

@@ -3,19 +3,21 @@ package nativesetu
import (
"bytes"
"image"
"io"
"io/fs"
"os"
"strings"
"sync"
"github.com/corona10/goimagehash"
"github.com/sirupsen/logrus"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"golang.org/x/image/webp"
_ "golang.org/x/image/webp" // import webp decoding
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
// setuclass holds setus in a folder, which is the class name.
@@ -25,14 +27,11 @@ type setuclass struct {
Path string `db:"path"` // Path 图片路径
}
var (
setuclasses []string
db = &sql.Sqlite{DBPath: dbfile}
mu sync.RWMutex
)
var ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}}
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
err := os.MkdirAll(datapath, 0755)
if err != nil {
@@ -45,24 +44,32 @@ func init() {
logrus.Println("[nsetu] set setu dir to", setupath)
}
}
if file.IsExist(dbfile) {
err := db.Open()
if err == nil {
setuclasses, err = db.ListTables()
}
if err != nil {
logrus.Errorln("[nsetu]", err)
}
}
}()
}
func scanall(path string) error {
setuclasses = nil
type nsetu struct {
db *sql.Sqlite
mu sync.RWMutex
}
func (n *nsetu) List() (l []string) {
if file.IsExist(n.db.DBPath) {
err := n.db.Open()
if err == nil {
l, err = n.db.ListTables()
}
if err != nil {
logrus.Errorln("[nsetu]", err)
}
}
return
}
func (n *nsetu) scanall(path string) error {
model := &setuclass{}
root := os.DirFS(path)
_ = db.Close()
_ = os.Remove(dbfile)
_ = n.db.Close()
_ = os.Remove(n.db.DBPath)
return fs.WalkDir(root, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
@@ -70,12 +77,11 @@ func scanall(path string) error {
if d.IsDir() {
clsn := d.Name()
if clsn != "." {
mu.Lock()
err = db.Create(clsn, model)
setuclasses = append(setuclasses, clsn)
mu.Unlock()
n.mu.Lock()
err = n.db.Create(clsn, model)
n.mu.Unlock()
if err == nil {
err = scanclass(root, path, clsn)
err = n.scanclass(root, path, clsn)
if err != nil {
logrus.Errorln("[nsetu]", err)
return err
@@ -87,17 +93,21 @@ func scanall(path string) error {
})
}
func scanclass(root fs.FS, path, clsn string) error {
func (n *nsetu) scanclass(root fs.FS, path, clsn string) error {
ds, err := fs.ReadDir(root, path)
if err != nil {
return err
}
mu.Lock()
_ = db.Truncate(clsn)
mu.Unlock()
n.mu.Lock()
_ = n.db.Truncate(clsn)
n.mu.Unlock()
for _, d := range ds {
if !d.IsDir() {
relpath := path + "/" + d.Name()
nm := d.Name()
ln := strings.ToLower(nm)
if !d.IsDir() &&
(strings.HasSuffix(ln, ".jpg") || strings.HasSuffix(ln, ".jpeg") ||
strings.HasSuffix(ln, ".png") || strings.HasSuffix(ln, ".gif") || strings.HasSuffix(ln, ".webp")) {
relpath := path + "/" + nm
logrus.Debugln("[nsetu] read", relpath)
f, e := fs.ReadFile(root, relpath)
if e != nil {
@@ -105,10 +115,6 @@ func scanclass(root fs.FS, path, clsn string) error {
}
b := bytes.NewReader(f)
img, _, e := image.Decode(b)
if e != nil {
b.Seek(0, io.SeekStart)
img, e = webp.Decode(b)
}
if e != nil {
return e
}
@@ -117,10 +123,10 @@ func scanclass(root fs.FS, path, clsn string) error {
return e
}
dhi := int64(dh.GetHash())
logrus.Debugln("[nsetu] insert", d.Name(), "with id", dhi, "into", clsn)
mu.Lock()
err = db.Insert(clsn, &setuclass{ImgID: dhi, Name: d.Name(), Path: relpath})
mu.Unlock()
logrus.Debugln("[nsetu] insert", nm, "with id", dhi, "into", clsn)
n.mu.Lock()
err = n.db.Insert(clsn, &setuclass{ImgID: dhi, Name: nm, Path: relpath})
n.mu.Unlock()
if err != nil {
return err
}

View File

@@ -10,8 +10,10 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/rule"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -25,7 +27,7 @@ var (
)
func init() {
engine := control.Register("nativesetu", &control.Options{
engine := control.Register("nativesetu", order.PrioNativeSetu, &control.Options{
DisableOnDefault: false,
Help: "本地涩图\n" +
"- 本地[xxx]\n" +
@@ -34,13 +36,13 @@ func init() {
"- 刷新所有本地setu\n" +
"- 所有本地setu分类",
})
engine.OnRegex(`^本地(.*)$`, func(ctx *zero.Ctx) bool { return rule.FirstValueInList(setuclasses)(ctx) }).SetBlock(true).SetPriority(36).
engine.OnRegex(`^本地(.*)$`, rule.FirstValueInList(ns)).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
imgtype := ctx.State["regex_matched"].([]string)[1]
sc := new(setuclass)
mu.RLock()
err := db.Pick(imgtype, sc)
mu.RUnlock()
ns.mu.RLock()
err := ns.db.Pick(imgtype, sc)
ns.mu.RUnlock()
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
} else {
@@ -48,17 +50,17 @@ func init() {
ctx.SendChain(message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p))
}
})
engine.OnRegex(`^刷新本地(.*)$`, func(ctx *zero.Ctx) bool { return rule.FirstValueInList(setuclasses)(ctx) }, zero.SuperUserPermission).SetBlock(true).SetPriority(36).
engine.OnRegex(`^刷新本地(.*)$`, rule.FirstValueInList(ns), zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
imgtype := ctx.State["regex_matched"].([]string)[1]
err := scanclass(os.DirFS(setupath), imgtype, imgtype)
err := ns.scanclass(os.DirFS(setupath), imgtype, imgtype)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text("ERROR: ", err))
}
})
engine.OnRegex(`^设置本地setu绝对路径(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(36).
engine.OnRegex(`^设置本地setu绝对路径(.*)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
setupath = ctx.State["regex_matched"].([]string)[1]
err := os.WriteFile(cfgfile, helper.StringToBytes(setupath), 0644)
@@ -68,21 +70,21 @@ func init() {
ctx.SendChain(message.Text("ERROR: ", err))
}
})
engine.OnFullMatch("刷新所有本地setu", zero.SuperUserPermission).SetBlock(true).SetPriority(36).
engine.OnFullMatch("刷新所有本地setu", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := scanall(setupath)
err := ns.scanall(setupath)
if err == nil {
ctx.SendChain(message.Text("成功!"))
} else {
ctx.SendChain(message.Text("ERROR: ", err))
}
})
engine.OnFullMatch("所有本地setu分类").SetBlock(true).SetPriority(36).
engine.OnFullMatch("所有本地setu分类").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
msg := "所有本地setu分类"
mu.RLock()
for i, c := range setuclasses {
n, err := db.Count(c)
ns.mu.RLock()
for i, c := range ns.List() {
n, err := ns.db.Count(c)
if err == nil {
msg += fmt.Sprintf("\n%02d. %s(%d)", i, c, n)
} else {
@@ -90,7 +92,7 @@ func init() {
logrus.Errorln("[nsetu]", err)
}
}
mu.RUnlock()
ns.mu.RUnlock()
ctx.SendChain(message.Text(msg))
})
}

View File

@@ -12,12 +12,13 @@ import (
"strings"
"time"
"github.com/FloatTech/AnimeAPI/picture"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/ZeroBot-Plugin/order"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
)
@@ -31,11 +32,11 @@ func init() {
if err != nil {
panic(err)
}
engine := control.Register("nwife", &control.Options{
engine := control.Register("nwife", order.PrioNativeWife, &control.Options{
DisableOnDefault: false,
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让|不让]所有人均可添加wife",
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
})
engine.OnPrefix("抽wife", zero.OnlyGroup).SetBlock(true).SetPriority(20).
engine.OnPrefix("抽wife", zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
grpf := strconv.FormatInt(ctx.Event.GroupID, 36)
wifes, err := os.ReadDir(base + "/" + grpf)
@@ -61,7 +62,7 @@ func init() {
}
})
// 上传一张图
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, picture.MustGiven).SetBlock(true).SetPriority(20).
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
name := ""
for _, elem := range ctx.Event.Message {
@@ -93,7 +94,7 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("没有找到wife的名字"))
}
})
engine.OnPrefix("删除wife", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(20).
engine.OnPrefix("删除wife", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
name := ""
for _, elem := range ctx.Event.Message {
@@ -117,7 +118,7 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("没有找到wife的名字"))
}
})
engine.OnSuffix("所有人均可添加wife", zero.SuperUserPermission, zero.OnlyGroup).SetBlock(true).SetPriority(20).
engine.OnSuffix("所有人均可添加wife", zero.SuperUserPermission, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
text := ""
for _, elem := range ctx.Event.Message {

View File

@@ -7,13 +7,19 @@ import (
"net/url"
"strings"
"github.com/FloatTech/zbputils/control"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
zero.OnRegex(`^[?]{1,2} ?([a-z0-9]+)$`).SetBlock(false).
control.Register("nbnhhsh", order.PrioNBNHHSH, &control.Options{
DisableOnDefault: false,
Help: "拼音首字母释义工具\n- ?? [缩写]",
}).OnRegex(`^[?]{1,2} ?([a-z0-9]+)$`).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(message.Text(keyword + ": " + strings.Join(getValue(keyword), ", ")))

View File

@@ -9,18 +9,19 @@ import (
"net/url"
"regexp"
"strings"
"time"
"github.com/antchfx/htmlquery"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
ub "github.com/FloatTech/zbputils/binary"
"github.com/FloatTech/zbputils/txt2img"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -38,20 +39,15 @@ const (
var (
gCurCookieJar *cookiejar.Jar
engine = control.Register("novel", &control.Options{
engine = control.Register("novel", order.PrioNovel, &control.Options{
DisableOnDefault: false,
Help: "铅笔小说网搜索\n- 小说[xxx]",
})
limit = rate.NewManager(time.Minute, 5)
)
func init() {
engine.OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
engine.OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
ctx.SendChain(message.Text("少女祈祷中......"))
login(username, password)
searchKey := ctx.State["regex_matched"].([]string)[1]
@@ -68,7 +64,7 @@ func init() {
log.Errorln("[novel]", err)
}
if len(list) != 0 {
text := ""
txt := ""
for _, v := range list {
bookName := htmlquery.InnerText(htmlquery.FindOne(v, "/dd[1]/h3/a[1]"))
category := htmlquery.InnerText(htmlquery.FindOne(v, "/dt/span[1]"))
@@ -84,13 +80,13 @@ func init() {
webpageURL := websiteURL + "/book/" + id + "/"
downloadURL := websiteURL + "/modules/article/txtarticle.php?id=" + id
text += fmt.Sprintf("书名:%s\n类型:%s\n作者:%s\n状态:%s\n字数:%s\n简介:%s\n更新时间:%s\n最新章节:%s\n网页链接:%s\n下载地址:%s\n\n", bookName, category, author, status, wordNumbers, description, updateTime, latestChapter, webpageURL, downloadURL)
txt += fmt.Sprintf("书名:%s\n类型:%s\n作者:%s\n状态:%s\n字数:%s\n简介:%s\n更新时间:%s\n最新章节:%s\n网页链接:%s\n下载地址:%s\n\n", bookName, category, author, status, wordNumbers, description, updateTime, latestChapter, webpageURL, downloadURL)
}
data, err := txt2img.RenderToBase64(text, 40, 20)
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
if err != nil {
log.Println("err:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 {
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
} else {
@@ -118,13 +114,7 @@ func init() {
webpageURL := websiteURL + "/book/" + id + "/"
downloadURL := websiteURL + "/modules/article/txtarticle.php?id=" + id
text := fmt.Sprintf("书名:%s\n类型:%s\n作者:%s\n状态:%s\n简介:%s\n更新时间:%s\n最新章节:%s\n网页链接:%s\n下载地址:%s\n", bookName, category, author, status, description, updateTime, latestChapter, webpageURL, downloadURL)
data, err := txt2img.RenderToBase64(text, 40, 20)
if err != nil {
log.Println("err:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
ctx.SendChain(message.Text(text))
}
})
}

101
plugin_nsfw/main.go Normal file
View File

@@ -0,0 +1,101 @@
// Package nsfw 图片合规性审查
package nsfw
import (
"github.com/FloatTech/AnimeAPI/nsfw"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/process"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
engine := control.Register("nsfw", order.PrioNSFW, &control.Options{
DisableOnDefault: false,
Help: "nsfw图片识别\n- nsfw打分[图片]",
}).ApplySingle(ctxext.DefaultSingle)
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"nsfw打分"}, zero.OnlyGroup, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["image_url"].([]string)
if len(url) > 0 {
ctx.SendChain(message.Text("少女祈祷中..."))
p, err := nsfw.Classify(url...)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(judge(p[0]))))
}
})
en := control.Register("nsfwauto", order.PrioNSFWAuto, &control.Options{
DisableOnDefault: true,
Help: "nsfw图片自动识别\n- 当图片属于非 neutral 类别时自动发送评价",
})
en.OnMessage(ctxext.Exists).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["image_url"].([]string)
if len(url) > 0 {
process.SleepAbout1sTo2s()
p, err := nsfw.Classify(url...)
if err != nil {
return
}
process.SleepAbout1sTo2s()
autojudge(ctx, p[0])
}
})
}
func judge(p nsfw.Picture) string {
if p.Neutral > 0.3 {
return "普通哦"
}
c := ""
if p.Drawings > 0.3 || p.Neutral < 0.3 {
c = "二次元"
} else {
c = "三次元"
}
if p.Hentai > 0.3 {
c += " hentai"
}
if p.Porn > 0.3 {
c += " porn"
}
if p.Sexy > 0.3 {
c += " hso"
}
return c
}
func autojudge(ctx *zero.Ctx, p nsfw.Picture) {
if p.Neutral > 0.3 {
return
}
c := ""
if p.Drawings > 0.3 {
c = "二次元"
} else {
c = "三次元"
}
i := 0
if p.Hentai > 0.3 {
c += " hentai"
i++
}
if p.Porn > 0.3 {
c += " porn"
i++
}
if p.Sexy > 0.3 {
c += " hso"
i++
}
if i > 0 {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(c)))
}
}

View File

@@ -5,9 +5,11 @@ import (
log "github.com/sirupsen/logrus"
sql "github.com/FloatTech/sqlite"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -19,11 +21,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
func init() {
go func() {
defer func() {
if err := recover(); err != nil {
log.Println(err)
}
}()
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, _ = file.GetLazyData(dbfile, false, true)

View File

@@ -12,8 +12,11 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/txt2img"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -21,15 +24,15 @@ const (
)
var (
engine = control.Register("omikuji", &control.Options{
engine = control.Register("omikuji", order.PrioOmikuji, &control.Options{
DisableOnDefault: false,
Help: "浅草寺求签\n" +
"- 求签|占卜\n- 解签",
})
"- 求签 | 占卜\n- 解签",
}).ApplySingle(ctxext.DefaultSingle)
)
func init() { // 插件主体
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetPriority(10).SetBlock(true).
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
miku := bangoToday(ctx.Event.UserID)
ctx.SendChain(
@@ -38,13 +41,13 @@ func init() { // 插件主体
message.Image(fmt.Sprintf(bed, miku, 1)),
)
})
engine.OnFullMatchGroup([]string{"解签"}).SetPriority(10).SetBlock(true).
engine.OnFullMatchGroup([]string{"解签"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
kujiBytes, err := txt2img.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), 40, 20)
kujiBytes, err := text.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), text.FontFile, 400, 20)
if err != nil {
log.Errorln("[omikuji]:", err)
}
if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id == 0 {
if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})

View File

@@ -9,6 +9,8 @@ import (
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -27,6 +29,7 @@ var (
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
err := os.MkdirAll(datapath, 0755)
if err != nil {

View File

@@ -6,14 +6,16 @@ import (
"math/rand"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
rand.Seed(time.Now().UnixNano())
control.Register("reborn", &control.Options{
control.Register("reborn", order.PrioReborn, &control.Options{
DisableOnDefault: false,
Help: "投胎\n- reborn",
}).OnFullMatch("reborn").SetBlock(true).

View File

@@ -9,16 +9,17 @@ import (
"strings"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/tidwall/gjson"
)
var (
limit = rate.NewManager(time.Minute*3, 5)
templates = map[string]string{
"py2": "print 'Hello World!'",
"ruby": "puts \"Hello World!\";",
@@ -92,7 +93,7 @@ var (
)
func init() {
control.Register("runcode", &control.Options{
control.Register("runcode", order.PrioRuncode, &control.Options{
DisableOnDefault: false,
Help: "在线代码运行: \n" +
">runcode [language] [code block]\n" +
@@ -103,46 +104,42 @@ func init() {
"JavaScript || TypeScript || PHP || Shell \n" +
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
"R || VB || Py2 || Perl || Pascal || Scala",
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
}).ApplySingle(ctxext.DefaultSingle).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
language := ctx.State["regex_matched"].([]string)[1]
language = strings.ToLower(language)
if runType, exist := table[language]; !exist {
// 不支持语言
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("语言不是受支持的编程语种呢~"),
)
} else {
language := ctx.State["regex_matched"].([]string)[1]
language = strings.ToLower(language)
if runType, exist := table[language]; !exist {
// 不支持语言
// 执行运行
block := ctx.State["regex_matched"].([]string)[2]
block = message.UnescapeCQCodeText(block)
if block == "help" {
// 输出模板
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("语言不是受支持的编程语种呢~"),
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text(
">runcode ", language, "\n",
templates[language],
),
)
} else {
// 执行运行
block := ctx.State["regex_matched"].([]string)[2]
block = message.UnescapeCQCodeText(block)
if block == "help" {
// 输出模板
if output, err := runCode(block, runType); err != nil {
// 运行失败
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text(
">runcode ", language, "\n",
templates[language],
),
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("ERROR: ", err),
)
} else {
if output, err := runCode(block, runType); err != nil {
// 运行失败
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("ERROR: ", err),
)
} else {
// 运行成功
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text(output),
)
}
// 运行成功
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text(output),
)
}
}
}

View File

@@ -3,39 +3,32 @@ package saucenao
import (
"fmt"
"os"
"strconv"
"github.com/FloatTech/AnimeAPI/ascii2d"
"github.com/FloatTech/AnimeAPI/picture"
"github.com/FloatTech/AnimeAPI/pixiv"
"github.com/FloatTech/AnimeAPI/saucenao"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/imgpool"
"github.com/FloatTech/zbputils/process"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/file"
)
var (
datapath = file.BOTPATH + "/data/saucenao/"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() { // 插件主体
_ = os.RemoveAll(datapath)
err := os.MkdirAll(datapath, 0755)
if err != nil {
panic(err)
}
engine := control.Register("saucenao", &control.Options{
engine := control.Register("saucenao", order.PrioSauceNao, &control.Options{
DisableOnDefault: false,
Help: "搜图\n" +
"- 以图搜图|搜索图片|以图识图[图片]\n" +
"- 以图搜图 | 搜索图片 | 以图识图[图片]\n" +
"- 搜图[P站图片ID]",
})
// 根据 PID 搜图
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).FirstPriority().
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
id, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
ctx.SendChain(message.Text("少女祈祷中......"))
@@ -47,22 +40,42 @@ func init() { // 插件主体
}
if illust.Pid > 0 {
name := strconv.FormatInt(illust.Pid, 10)
filepath := datapath + name
switch {
case file.IsExist(filepath + ".jpg"):
filepath = "file:///" + filepath + ".jpg"
case file.IsExist(filepath + ".png"):
filepath = "file:///" + filepath + ".png"
case file.IsExist(filepath + ".gif"):
filepath = "file:///" + filepath + ".gif"
default:
filepath = ""
}
if filepath == "" {
logrus.Debug("[sausenao]开始下载", name)
filepath, err = pixiv.Download(illust.ImageUrls, datapath, name)
var imgs message.Message
for i := range illust.ImageUrls {
n := name + "_p" + strconv.Itoa(i)
filepath := file.BOTPATH + "/" + pixiv.CacheDir + n
f := ""
m, err := imgpool.GetImage(n)
if err == nil {
filepath = "file:///" + filepath
imgs = append(imgs, message.Image(m.String()))
continue
}
switch {
case file.IsExist(filepath + ".jpg"):
f = filepath + ".jpg"
case file.IsExist(filepath + ".png"):
f = filepath + ".png"
case file.IsExist(filepath + ".gif"):
f = filepath + ".gif"
default:
logrus.Debugln("[sausenao]开始下载", n)
filepath, err = illust.DownloadToCache(i, n)
if err == nil {
f = file.BOTPATH + "/" + filepath
}
}
if f != "" {
m.SetFile(f)
hassent, err := m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
if err == nil {
imgs = append(imgs, message.Image(m.String()))
if hassent {
process.SleepAbout1sTo2s()
}
} else {
logrus.Debugln("[saucenao]", err)
imgs = append(imgs, message.Image("file:///"+f))
}
}
}
txt := message.Text(
@@ -72,9 +85,9 @@ func init() { // 插件主体
"画师ID", illust.UserId, "\n",
"直链:", "https://pixivel.moe/detail?id=", illust.Pid,
)
if filepath != "" {
if imgs != nil {
// 发送搜索结果
ctx.SendChain(message.Image(filepath), message.Text("\n"), txt)
ctx.Send(append(imgs, message.Text("\n"), txt))
} else {
// 图片下载失败,仅发送文字结果
ctx.SendChain(txt)
@@ -84,7 +97,7 @@ func init() { // 插件主体
}
})
// 以图搜图
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority().
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, zero.OnlyGroup, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.SendChain(message.Text("少女祈祷中......"))
@@ -96,34 +109,55 @@ func init() { // 插件主体
// 返回SauceNAO的结果
ctx.SendChain(
message.Text("我有把握是这个!"),
message.Image(result.Thumbnail),
message.Image(result[0].Thumbnail),
message.Text(
"\n",
"相似度:", result.Similarity, "\n",
"标题:", result.Title, "\n",
"插画ID", result.PixivID, "\n",
"画师:", result.MemberName, "\n",
"画师ID", result.MemberID, "\n",
"直链:", "https://pixivel.moe/detail?id=", result.PixivID,
"相似度:", result[0].Similarity, "\n",
"标题:", result[0].Title, "\n",
"插画ID", result[0].PixivID, "\n",
"画师:", result[0].MemberName, "\n",
"画师ID", result[0].MemberID, "\n",
"直链:", "https://pixivel.moe/detail?id=", result[0].PixivID,
),
)
continue
}
if result, err := ascii2d.Ascii2d(pic); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
} else {
// 返回Ascii2d的结果
ctx.SendChain(
message.Text(
"大概是这个?", "\n",
"标题:", result.Title, "\n",
"插画ID", result.Pid, "\n",
"画师:", result.UserName, "\n",
"画师ID", result.UserId, "\n",
"直链:", "https://pixivel.moe/detail?id=", result.Pid,
),
)
continue
} else {
var msg message.Message = []message.MessageSegment{
message.CustomNode(
ctx.Event.Sender.Name(),
ctx.Event.UserID,
"ascii2d搜图结果",
)}
for i := 0; i < len(result) && i < 5; i++ {
msg = append(
msg,
message.CustomNode(
ctx.Event.Sender.Name(),
ctx.Event.UserID,
[]message.MessageSegment{
message.Image(result[i].Thumb),
message.Text(fmt.Sprintf(
"标题:%s\n图源%s\n画师%s\n画师链接%s\n图片链接%s",
result[i].Name,
result[i].Type,
result[i].AuthNm,
result[i].Author,
result[i].Link,
)),
},
),
)
}
if id := ctx.SendGroupForwardMessage(
ctx.Event.GroupID,
msg,
).Get("message_id").Int(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
}
}
})

104
plugin_scale/main.go Normal file
View File

@@ -0,0 +1,104 @@
// Package scale 叔叔的AI二次元图片放大
package scale
import (
"os"
"strconv"
"time"
"github.com/FloatTech/AnimeAPI/nsfw"
"github.com/FloatTech/AnimeAPI/scale"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const cachedir = "data/scale/"
func init() {
_ = os.RemoveAll(cachedir)
err := os.MkdirAll(cachedir, 0755)
if err != nil {
panic(err)
}
engine := control.Register("scale", order.PrioScale, &control.Options{
DisableOnDefault: false,
Help: "叔叔的AI二次元图片放大\n- 放大图片[图片]",
}).ApplySingle(ctxext.DefaultSingle)
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"放大图片"}, zero.OnlyGroup, ctxext.CmdMatch, ctxext.MustGiven, getPara).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["image_url"].([]string)
if len(url) > 0 {
ctx.SendChain(message.Text("少女祈祷中..."))
p, err := nsfw.Classify(url[0])
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
if p[0].Drawings < 0.1 || p[0].Neutral > 0.8 {
ctx.SendChain(message.Text("请发送二次元图片!"))
return
}
paras := ctx.State["scale_paras"].([2]int)
data, err := scale.Get(url[0], paras[0], paras[1], 2)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
n := cachedir + strconv.Itoa(int(ctx.Event.UserID))
f, err := os.Create(n)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
_, _ = f.Write(data)
_ = f.Close()
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + n))
}
})
}
func getPara(ctx *zero.Ctx) bool {
next := zero.NewFutureEvent("message", 999, false, zero.CheckUser(ctx.Event.UserID))
recv, cancel := next.Repeat()
i := 0
paras := [2]int{}
ctx.SendChain(message.Text("请输入模型序号\n0.", scale.Models[0], "\n1.", scale.Models[1], "\n2.", scale.Models[2], "\n3.", scale.Models[3], "\n4.", scale.Models[4]))
for {
select {
case <-time.After(time.Second * 120):
return false
case e := <-recv:
msg := e.Message.ExtractPlainText()
num, err := strconv.Atoi(msg)
if err != nil {
ctx.SendChain(message.Text("请输入数字!"))
continue
}
switch i {
case 0:
if num < 0 || num > 4 {
ctx.SendChain(message.Text("模型序号非法!"))
continue
}
paras[0] = num
ctx.SendChain(message.Text("请输入放大倍数(2-4)"))
case 1:
if num < 2 || num > 4 {
ctx.SendChain(message.Text("放大倍数非法!"))
continue
}
cancel()
paras[1] = num
ctx.State["scale_paras"] = paras
return true
}
i++
}
}
}

View File

@@ -5,7 +5,11 @@ import (
log "github.com/sirupsen/logrus"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -14,17 +18,26 @@ const (
dbfile = dbpath + "score.db"
)
// SDB 得分数据库
var SDB *DB
// sdb 得分数据库
var sdb *scoredb
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_, err := file.GetLazyData(text.BoldFontFile, false, true)
if err != nil {
panic(err)
}
_, err = file.GetLazyData(text.FontFile, false, true)
if err != nil {
panic(err)
}
_ = os.MkdirAll(dbpath, 0755)
os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
SDB = Initialize(dbfile)
sdb = initialize(dbfile)
log.Println("[score]加载score数据库")
}()
}

View File

@@ -8,34 +8,34 @@ import (
_ "github.com/logoove/sqlite" // import sql
)
// DB 分数数据库
type DB gorm.DB
// scoredb 分数数据库
type scoredb gorm.DB
// Score 分数结构体
type Score struct {
// scoretable 分数结构体
type scoretable struct {
UID int64 `gorm:"column:uid;primary_key"`
Score int `gorm:"column:score;default:0"`
}
// TableName ...
func (Score) TableName() string {
func (scoretable) TableName() string {
return "score"
}
// SignIn 签到结构体
type SignIn struct {
// signintable 签到结构体
type signintable struct {
UID int64 `gorm:"column:uid;primary_key"`
Count int `gorm:"column:count;default:0"`
UpdatedAt time.Time
}
// TableName ...
func (SignIn) TableName() string {
func (signintable) TableName() string {
return "sign_in"
}
// Initialize 初始化ScoreDB数据库
func Initialize(dbpath string) *DB {
// initialize 初始化ScoreDB数据库
func initialize(dbpath string) *scoredb {
var err error
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
@@ -49,46 +49,37 @@ func Initialize(dbpath string) *DB {
if err != nil {
panic(err)
}
gdb.AutoMigrate(&Score{}).AutoMigrate(&SignIn{})
return (*DB)(gdb)
}
// Open ...
func Open(dbpath string) (*DB, error) {
db, err := gorm.Open("sqlite3", dbpath)
if err != nil {
return nil, err
}
return (*DB)(db), nil
gdb.AutoMigrate(&scoretable{}).AutoMigrate(&signintable{})
return (*scoredb)(gdb)
}
// Close ...
func (sdb *DB) Close() error {
func (sdb *scoredb) Close() error {
db := (*gorm.DB)(sdb)
return db.Close()
}
// GetScoreByUID 取得分数
func (sdb *DB) GetScoreByUID(uid int64) (s Score) {
func (sdb *scoredb) GetScoreByUID(uid int64) (s scoretable) {
db := (*gorm.DB)(sdb)
db.Debug().Model(&Score{}).FirstOrCreate(&s, "uid = ? ", uid)
db.Debug().Model(&scoretable{}).FirstOrCreate(&s, "uid = ? ", uid)
return s
}
// InsertOrUpdateScoreByUID 插入或更新分数
func (sdb *DB) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
func (sdb *scoredb) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
db := (*gorm.DB)(sdb)
s := Score{
s := scoretable{
UID: uid,
Score: score,
}
if err = db.Debug().Model(&Score{}).First(&s, "uid = ? ", uid).Error; err != nil {
if err = db.Debug().Model(&scoretable{}).First(&s, "uid = ? ", uid).Error; err != nil {
// error handling...
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&Score{}).Create(&s) // newUser not user
err = db.Debug().Model(&scoretable{}).Create(&s).Error // newUser not user
}
} else {
err = db.Debug().Model(&Score{}).Where("uid = ? ", uid).Update(
err = db.Debug().Model(&scoretable{}).Where("uid = ? ", uid).Update(
map[string]interface{}{
"score": score,
}).Error
@@ -97,26 +88,26 @@ func (sdb *DB) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
}
// GetSignInByUID 取得签到次数
func (sdb *DB) GetSignInByUID(uid int64) (si SignIn) {
func (sdb *scoredb) GetSignInByUID(uid int64) (si signintable) {
db := (*gorm.DB)(sdb)
db.Debug().Model(&SignIn{}).FirstOrCreate(&si, "uid = ? ", uid)
db.Debug().Model(&signintable{}).FirstOrCreate(&si, "uid = ? ", uid)
return si
}
// InsertOrUpdateSignInCountByUID 插入或更新签到次数
func (sdb *DB) InsertOrUpdateSignInCountByUID(uid int64, count int) (err error) {
func (sdb *scoredb) InsertOrUpdateSignInCountByUID(uid int64, count int) (err error) {
db := (*gorm.DB)(sdb)
si := SignIn{
si := signintable{
UID: uid,
Count: count,
}
if err = db.Debug().Model(&SignIn{}).First(&si, "uid = ? ", uid).Error; err != nil {
if err = db.Debug().Model(&signintable{}).First(&si, "uid = ? ", uid).Error; err != nil {
// error handling...
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&SignIn{}).Create(&si) // newUser not user
db.Debug().Model(&signintable{}).Create(&si) // newUser not user
}
} else {
err = db.Debug().Model(&SignIn{}).Where("uid = ? ", uid).Update(
err = db.Debug().Model(&signintable{}).Where("uid = ? ", uid).Update(
map[string]interface{}{
"count": count,
}).Error

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"os"
"strconv"
"sync"
"time"
"github.com/fogleman/gg"
@@ -15,62 +14,63 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/txt2img"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/zbputils/img/writer"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
prio = 5
backgroundURL = "https://iw233.cn/API/pc.php?type=json"
referer = "https://iw233.cn/main.html"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
signinMax = 1
// ScoreMax 分数上限定为120
ScoreMax = 120
// SCOREMAX 分数上限定为120
SCOREMAX = 120
)
var (
engine = control.Register("score", &control.Options{
engine = control.Register("score", order.PrioScore, &control.Options{
DisableOnDefault: false,
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx]|获得签到背景",
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景",
})
levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
// 下载锁
mu sync.Mutex
)
func init() {
engine.OnFullMatch("签到").SetBlock(true).SetPriority(prio).
engine.OnFullMatch("签到", zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
now := time.Now()
today := now.Format("20060102")
si := SDB.GetSignInByUID(uid)
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
if file.IsNotExist(picFile) {
mu.Lock()
initPic(picFile)
mu.Unlock()
}
si := sdb.GetSignInByUID(uid)
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
if siUpdateTimeStr != today {
if err := SDB.InsertOrUpdateSignInCountByUID(uid, 0); err != nil {
log.Errorln("[score]:", err)
}
_ = sdb.InsertOrUpdateSignInCountByUID(uid, 0)
}
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
if si.Count >= signinMax && siUpdateTimeStr == today {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
if file.IsExist(drawedFile) {
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
}
return
}
if err := SDB.InsertOrUpdateSignInCountByUID(uid, si.Count+1); err != nil {
log.Errorln("[score]:", err)
}
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
initPic(picFile)
_ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
back, err := gg.LoadImage(picFile)
if err != nil {
log.Errorln("[score]:", err)
ctx.SendChain(message.Text("ERROR:", err))
return
}
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
canvas.SetRGB(1, 1, 1)
@@ -79,27 +79,27 @@ func init() {
monthWord := now.Format("01/02")
hourWord := getHourWord(now)
if err = canvas.LoadFontFace(txt2img.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
log.Println("[score]:", err)
if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
canvas.SetRGB(0, 0, 0)
canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2)
canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2)
nickName := ctxext.CardOrNickName(ctx, uid)
if err = canvas.LoadFontFace(txt2img.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
log.Println("[score]:", err)
if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
add := 1
canvas.DrawString(nickName+fmt.Sprintf(" 小熊饼干+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
score := SDB.GetScoreByUID(uid).Score
score := sdb.GetScoreByUID(uid).Score
score += add
if score > ScoreMax {
score = ScoreMax
if score > SCOREMAX {
score = SCOREMAX
ctx.SendChain(message.At(uid), message.Text("你获得的小熊饼干已经达到上限"))
}
if err := SDB.InsertOrUpdateScoreByUID(uid, score); err != nil {
log.Println("[score]:", err)
}
_ = sdb.InsertOrUpdateScoreByUID(uid, score)
level := getLevel(score)
canvas.DrawString("当前小熊饼干:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(level), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
@@ -110,20 +110,34 @@ func init() {
if level < 10 {
nextLevelScore = levelArray[level+1]
} else {
nextLevelScore = ScoreMax
nextLevelScore = SCOREMAX
}
canvas.SetRGB255(0, 0, 0)
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(score)/float64(nextLevelScore), float64(back.Bounds().Size().Y)*0.1)
canvas.SetRGB255(102, 102, 102)
canvas.Fill()
canvas.DrawString(fmt.Sprintf("%d/%d", score, nextLevelScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
canvasBase64, err := txt2img.CanvasToBase64(canvas)
f, err := os.Create(drawedFile)
if err != nil {
log.Println("[score]:", err)
log.Errorln("[score]", err)
canvasBase64, err := writer.ToBase64(canvas.Image())
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image("base64://" + helper.BytesToString(canvasBase64)))
return
}
ctx.SendChain(message.Image("base64://" + helper.BytesToString(canvasBase64)))
_, err = writer.WriteTo(canvas.Image(), f)
_ = f.Close()
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
})
engine.OnPrefix("获得签到背景", zero.OnlyGroup).SetBlock(true).SetPriority(20).
engine.OnPrefix("获得签到背景", zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
var uidStr string
@@ -134,9 +148,8 @@ func init() {
}
picFile := cachePath + uidStr + time.Now().Format("20060102") + ".png"
if file.IsNotExist(picFile) {
mu.Lock()
initPic(picFile)
mu.Unlock()
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请先签到!"))
return
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile))
})
@@ -174,16 +187,16 @@ func initPic(picFile string) {
if file.IsNotExist(picFile) {
data, err := web.ReqWith(backgroundURL, "GET", referer, ua)
if err != nil {
log.Errorln("[score]:", err)
log.Errorln("[score]", err)
}
picURL := gjson.Get(string(data), "pic").String()
data, err = web.ReqWith(picURL, "GET", "", ua)
if err != nil {
log.Errorln("[score]:", err)
log.Errorln("[score]", err)
}
err = os.WriteFile(picFile, data, 0666)
if err != nil {
log.Errorln("[score]:", err)
log.Errorln("[score]", err)
}
}
}

View File

@@ -2,6 +2,7 @@
package setutime
import (
"errors"
"fmt"
"os"
"strconv"
@@ -10,64 +11,65 @@ import (
"time"
"github.com/FloatTech/AnimeAPI/pixiv"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
sql "github.com/FloatTech/sqlite"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
fileutil "github.com/FloatTech/zbputils/file"
imagepool "github.com/FloatTech/zbputils/imgpool"
"github.com/FloatTech/zbputils/math"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/rule"
"github.com/FloatTech/zbputils/sql"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
// Pools 图片缓冲池
type imgpool struct {
Lock sync.Mutex
DB *sql.Sqlite
Path string
Group int64
List []string
Max int
Pool map[string][]*pixiv.Illust
Form int64
lock sync.Mutex
db *sql.Sqlite
path string
max int
pool map[string][]*pixiv.Illust
}
// NewPoolsCache 返回一个缓冲池对象
func newPools() *imgpool {
cache := &imgpool{
DB: &sql.Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
Path: "data/SetuTime/cache/",
Group: 0,
List: []string{"涩图", "二次元", "风景", "车万"}, // 可以自己加类别,得自己加图片进数据库
Max: 10,
Pool: map[string][]*pixiv.Illust{},
Form: 0,
}
// 每次启动清理缓存
os.RemoveAll(cache.Path)
err := os.MkdirAll(cache.Path, 0755)
func (p *imgpool) List() (l []string) {
var err error
l, err = p.db.ListTables()
if err != nil {
panic(err)
l = []string{"涩图", "二次元", "风景", "车万"}
}
// 如果数据库不存在则下载
_, _ = fileutil.GetLazyData(cache.DB.DBPath, false, false)
for i := range cache.List {
if err := cache.DB.Create(cache.List[i], &pixiv.Illust{}); err != nil {
panic(err)
}
}
return cache
return l
}
var (
pool *imgpool
limit = rate.NewManager(time.Minute*1, 5)
)
var pool = &imgpool{
db: &sql.Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
path: pixiv.CacheDir,
max: 10,
pool: map[string][]*pixiv.Illust{},
}
func init() { // 插件主体
engine := control.Register("setutime", &control.Options{
_ = os.MkdirAll("data/SetuTime", 0755)
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
// 如果数据库不存在则下载
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
err := pool.db.Open()
if err != nil {
panic(err)
}
for _, imgtype := range pool.List() {
if err := pool.db.Create(imgtype, &pixiv.Illust{}); err != nil {
panic(err)
}
}
}()
engine := control.Register("setutime", order.PrioSetuTime, &control.Options{
DisableOnDefault: false,
Help: "涩图\n" +
"- 来份[涩图/二次元/风景/车万]\n" +
@@ -75,179 +77,172 @@ func init() { // 插件主体
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
"- >setu status",
})
go func() {
process.SleepAbout1sTo2s()
pool = newPools()
engine.OnRegex(`^来份(.*)$`, rule.FirstValueInList(pool.List)).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
var imgtype = ctx.State["regex_matched"].([]string)[1]
// 补充池子
go func() {
times := math.Min(pool.Max-pool.size(imgtype), 2)
for i := 0; i < times; i++ {
illust := &pixiv.Illust{}
// 查询出一张图片
if err := pool.DB.Pick(imgtype, illust); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
continue
}
// 下载图片
if err := download(illust, pool.Path); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
continue
}
ctx.SendGroupMessage(pool.Group, []message.MessageSegment{message.Image(file(illust))})
// 向缓冲池添加一张图片
pool.push(imgtype, illust)
time.Sleep(time.Second * 1)
}
}()
// 如果没有缓存阻塞5秒
engine.OnRegex(`^来份(.*)$`, rule.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
var imgtype = ctx.State["regex_matched"].([]string)[1]
// 补充池子
go pool.fill(ctx, imgtype)
// 如果没有缓存阻塞10秒
if pool.size(imgtype) == 0 {
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
time.Sleep(time.Second * 10)
if pool.size(imgtype) == 0 {
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
<-time.After(time.Second * 5)
if pool.size(imgtype) == 0 {
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
return
}
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
return
}
// 从缓冲池里抽一张
if id := ctx.SendChain(message.Image(file(pool.pop(imgtype)))); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
}
// 从缓冲池里抽一张
if id := ctx.SendChain(message.Image(pool.popfile(imgtype))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
engine.OnRegex(`^添加(.*?)(\d+)$`, rule.FirstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
)
ctx.SendChain(message.Text("少女祈祷中......"))
// 查询P站插图信息
illust, err := pixiv.Works(id)
engine.OnRegex(`^添加(.*?)(\d+)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
)
err := pool.add(ctx, imgtype, id)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text("成功向分类", imgtype, "添加图片", id))
})
engine.OnRegex(`^删除(.*?)(\d+)$`, rule.FirstValueInList(pool), zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
)
// 查询数据库
if err := pool.remove(imgtype, id); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("删除成功"))
})
// 查询数据库涩图数量
engine.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
state := []string{"[SetuTime]"}
for _, imgtype := range pool.List() {
num, err := pool.db.Count(imgtype)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
num = 0
}
// 下载插画
if err := download(illust, pool.Path); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 发送到发送者
if id := ctx.SendChain(message.Image(file(illust))); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控,发送失败"))
return
}
// 添加插画到对应的数据库table
if err := pool.DB.Insert(imgtype, illust); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("添加成功"))
})
engine.OnRegex(`^删除(.*?)(\d+)$`, rule.FirstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
)
// 查询数据库
if err := pool.DB.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("删除成功"))
})
// 查询数据库涩图数量
engine.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).SetPriority(23).
Handle(func(ctx *zero.Ctx) {
state := []string{"[SetuTime]"}
for i := range pool.List {
num, err := pool.DB.Count(pool.List[i])
if err != nil {
num = 0
}
state = append(state, "\n")
state = append(state, pool.List[i])
state = append(state, ": ")
state = append(state, fmt.Sprintf("%d", num))
}
ctx.SendChain(message.Text(state))
})
}()
state = append(state, "\n")
state = append(state, imgtype)
state = append(state, ": ")
state = append(state, fmt.Sprintf("%d", num))
}
ctx.SendChain(message.Text(state))
})
}
// size 返回缓冲池指定类型的现有大小
func (p *imgpool) size(imgtype string) int {
return len(p.Pool[imgtype])
return len(p.pool[imgtype])
}
/*
// isFull 返回缓冲池指定类型是否已满
func (p *imgpool) isFull(imgtype string) bool {
return len(p.Pool[imgtype]) >= p.Max
}*/
// push 向缓冲池插入一张图片
func (p *imgpool) push(imgtype string, illust *pixiv.Illust) {
p.Lock.Lock()
defer p.Lock.Unlock()
p.Pool[imgtype] = append(p.Pool[imgtype], illust)
func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
u := illust.ImageUrls[0]
n := u[strings.LastIndex(u, "/")+1 : len(u)-4]
m, err := imagepool.GetImage(n)
if err != nil {
// 下载图片
f := ""
if f, err = illust.DownloadToCache(0, n); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
m.SetFile(fileutil.BOTPATH + "/" + f)
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
}
p.lock.Lock()
p.pool[imgtype] = append(p.pool[imgtype], illust)
p.lock.Unlock()
}
// Push 在缓冲池拿出一张图片
func (p *imgpool) pop(imgtype string) (illust *pixiv.Illust) {
p.Lock.Lock()
defer p.Lock.Unlock()
p.lock.Lock()
defer p.lock.Unlock()
if p.size(imgtype) == 0 {
return
}
illust = p.Pool[imgtype][0]
p.Pool[imgtype] = p.Pool[imgtype][1:]
illust = p.pool[imgtype][0]
p.pool[imgtype] = p.pool[imgtype][1:]
return
}
func file(i *pixiv.Illust) string {
filename := fmt.Sprint(i.Pid)
filepath := fileutil.BOTPATH + `/` + pool.Path + filename
if _, err := os.Stat(filepath + ".jpg"); err == nil || os.IsExist(err) {
func (p *imgpool) file(i *pixiv.Illust) string {
u := i.ImageUrls[0]
m, err := imagepool.GetImage(u[strings.LastIndex(u, "/")+1 : len(u)-4])
if err == nil {
return m.String()
}
filename := fmt.Sprint(i.Pid) + "_p0"
filepath := fileutil.BOTPATH + `/` + p.path + filename
if fileutil.IsExist(filepath + ".jpg") {
return `file:///` + filepath + ".jpg"
}
if _, err := os.Stat(filepath + ".png"); err == nil || os.IsExist(err) {
if fileutil.IsExist(filepath + ".png") {
return `file:///` + filepath + ".png"
}
if _, err := os.Stat(filepath + ".gif"); err == nil || os.IsExist(err) {
if fileutil.IsExist(filepath + ".gif") {
return `file:///` + filepath + ".gif"
}
return ""
}
func download(i *pixiv.Illust, filedir string) /*(string, */ error /*)*/ {
filename := fmt.Sprint(i.Pid)
filepath := filedir + filename
if _, err := os.Stat(filepath + ".jpg"); err == nil || os.IsExist(err) {
return /*filepath + ".jpg",*/ nil
}
if _, err := os.Stat(filepath + ".png"); err == nil || os.IsExist(err) {
return /*filepath + ".png",*/ nil
}
if _, err := os.Stat(filepath + ".gif"); err == nil || os.IsExist(err) {
return /*filepath + ".gif",*/ nil
}
// 下载最大分辨率为 1200 的图片
link := i.ImageUrls
link = strings.ReplaceAll(link, "img-original", "img-master")
link = strings.ReplaceAll(link, "_p0", "_p0_master1200")
link = strings.ReplaceAll(link, ".png", ".jpg")
// 下载
_, err1 := pixiv.Download(link, filedir, filename)
return err1
func (p *imgpool) popfile(imgtype string) string {
return p.file(p.pop(imgtype))
}
// fill 补充池子
func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) {
times := math.Min(p.max-p.size(imgtype), 2)
for i := 0; i < times; i++ {
illust := &pixiv.Illust{}
// 查询出一张图片
if err := p.db.Pick(imgtype, illust); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
continue
}
// 向缓冲池添加一张图片
p.push(ctx, imgtype, illust)
process.SleepAbout1sTo2s()
}
}
func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
if err := p.db.Create(imgtype, &pixiv.Illust{}); err != nil {
return err
}
ctx.SendChain(message.Text("少女祈祷中......"))
// 查询P站插图信息
illust, err := pixiv.Works(id)
if err != nil {
return err
}
// 下载插画
if _, err := illust.DownloadToCache(0, strconv.FormatInt(id, 10)+"_p0"); err != nil {
return err
}
// 发送到发送者
if id := ctx.SendChain(message.Image(p.file(illust))); id.ID() == 0 {
return errors.New("可能被风控,发送失败")
}
// 添加插画到对应的数据库table
if err := p.db.Insert(imgtype, illust); err != nil {
return err
}
return nil
}
func (p *imgpool) remove(imgtype string, id int64) error {
return p.db.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id))
}

View File

@@ -5,14 +5,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("哄我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -5,14 +5,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -5,14 +5,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("发个朋友圈").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -2,10 +2,9 @@
package shadiao
import (
"time"
control "github.com/FloatTech/zbputils/control"
control "github.com/FloatTech/zbpctrl"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
@@ -21,14 +20,12 @@ const (
pyqReferer = "https://pyq.shadiao.app/"
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
loveliveReferer = "https://lovelive.tools/"
prio = 10
)
var (
engine = control.Register("shadiao", &control.Options{
engine = control.Register("shadiao", order.PrioShaDiao, &control.Options{
DisableOnDefault: false,
Help: "沙雕app\n" +
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
})
limit = rate.NewManager(time.Minute, 60)
)

View File

@@ -6,14 +6,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("来碗绿茶").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
@@ -23,10 +21,7 @@ func init() {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
engine.OnFullMatch("渣我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -8,14 +8,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
)
func init() {
engine.OnFullMatch("讲个段子").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))

View File

@@ -2,27 +2,21 @@
package shindan
import (
"time"
"github.com/FloatTech/AnimeAPI/shindanmaker"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/txt2img"
)
"github.com/FloatTech/ZeroBot-Plugin/order"
var (
// 限制调用频率
limit = rate.NewManager(time.Minute*5, 5)
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/img/text"
)
func init() {
engine := control.Register("shindan", &control.Options{
engine := control.Register("shindan", order.PrioShinDan, &control.Options{
DisableOnDefault: false,
Help: "shindan\n" +
"- 今天是什么少女[@xxx]\n" +
@@ -30,37 +24,33 @@ func init() {
"- 卖萌[@xxx]\n" +
"- 抽老婆[@xxx]",
})
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
}
// shindanmaker 处理函数
func handle(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
// 获取名字
name := ctxext.NickName(ctx)
// 调用接口
text, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
// TODO: 可注入
switch ctx.State["id"].(int64) {
case 587874, 162207:
data, err := txt2img.RenderToBase64(text, 40, 20)
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
if err != nil {
log.Errorln("[shindan]:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 {
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
default:
ctx.Send(text)
ctx.Send(txt)
}
}

View File

@@ -3,20 +3,15 @@ package sleepmanage
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage/model"
)
func init() {
go func() {
defer func() {
if err := recover(); err != nil {
log.Println(err)
}
}()
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
model.Initialize(dbfile)

View File

@@ -9,22 +9,22 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage/model"
)
const dbpath = "data/sleep/"
const dbfile = dbpath + "manage.db"
const prio = 4
var engine = control.Register("sleepmanage", &control.Options{
var engine = control.Register("sleepmanage", order.PrioSleepManage, &control.Options{
DisableOnDefault: false,
Help: "sleepmanage\n- 早安\n- 晚安",
})
func init() {
engine.OnFullMatch("早安", isMorning, zero.OnlyGroup).SetBlock(true).SetPriority(prio).
engine.OnFullMatch("早安", isMorning, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
db, err := model.Open(dbfile)
if err != nil {
@@ -41,7 +41,7 @@ func init() {
}
db.Close()
})
engine.OnFullMatch("晚安", isEvening, zero.OnlyGroup).SetBlock(true).SetPriority(prio).
engine.OnFullMatch("晚安", isEvening, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
db, err := model.Open(dbfile)
if err != nil {

View File

@@ -4,11 +4,13 @@ package tracemoe
import (
"fmt"
"github.com/FloatTech/AnimeAPI/picture"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
trmoe "github.com/fumiama/gotracemoe"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
var (
@@ -16,12 +18,12 @@ var (
)
func init() { // 插件主体
engine := control.Register("tracemoe", &control.Options{
engine := control.Register("tracemoe", order.PrioTraceMoe, &control.Options{
DisableOnDefault: false,
Help: "tracemoe\n- 搜番|搜索番剧[图片]",
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]",
})
// 以图搜图
engine.OnKeywordGroup([]string{"搜番", "搜索番剧"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).ThirdPriority().
engine.OnKeywordGroup([]string{"搜番", "搜索番剧"}, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.SendChain(message.Text("少女祈祷中......"))

View File

@@ -6,20 +6,16 @@ import (
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/process"
)
var (
prio = 100
bucket = rate.NewManager(time.Minute, 20) // 接口回复
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func tl(d string) ([]byte, error) {
@@ -42,16 +38,12 @@ func tl(d string) ([]byte, error) {
}
func init() {
control.Register("translation", &control.Options{
control.Register("translation", order.PrioTranslation, &control.Options{
DisableOnDefault: false,
Help: "翻译\n" +
">TL 你好",
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).SetPriority(prio).
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !bucket.Load(ctx.Event.UserID).Acquire() {
// 频繁触发,不回复
return
}
msg := []string{ctx.State["regex_matched"].([]string)[2]}
rely, err := tl(msg[0])
if err != nil {

View File

@@ -6,11 +6,13 @@ import (
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model"
)
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
log.Println("[vtb/cron] 开启vtb数据库日常更新")
vtbDaily()

View File

@@ -5,11 +5,14 @@ import (
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
// 加载数据库
func init() {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, _ = file.GetLazyData(dbfile, false, false)

View File

@@ -14,9 +14,10 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
control "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/txt2img"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/ZeroBot-Plugin/order"
"github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model"
)
@@ -26,9 +27,9 @@ const (
dbfile = dbpath + "vtb.db"
)
var engine = control.Register("vtbquotation", &control.Options{
var engine = control.Register("vtbquotation", order.PrioVtbQuotation, &control.Options{
DisableOnDefault: false,
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb",
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb\n- 更新vtb\n",
})
func init() {
@@ -47,11 +48,11 @@ func init() {
}
defer db.Close()
defer cancel()
firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), 40, 20)
firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
// 步骤012依次选择3个类别
@@ -79,20 +80,20 @@ func init() {
// log.Println(secondStepMessage)
if secondStepMessage == "" {
ctx.SendChain(message.Reply(e.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输"))
firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), 40, 20)
firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
errorCount++
} else {
secondStepMessageBytes, err := txt2img.RenderToBase64(secondStepMessage, 40, 20)
secondStepMessageBytes, err := text.RenderToBase64(secondStepMessage, text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
step++
@@ -110,20 +111,20 @@ func init() {
// log.Println(thirdStepMessage)
if thirdStepMessage == "" {
ctx.SendChain(message.Reply(e.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输"))
secondStepMessageBytes, err := txt2img.RenderToBase64(db.GetAllSecondCategoryMessageByFirstIndex(firstIndex), 40, 20)
secondStepMessageBytes, err := text.RenderToBase64(db.GetAllSecondCategoryMessageByFirstIndex(firstIndex), text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
errorCount++
} else {
thirdStepMessageBytes, err := txt2img.RenderToBase64(thirdStepMessage, 40, 20)
thirdStepMessageBytes, err := text.RenderToBase64(thirdStepMessage, text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
step++
@@ -142,11 +143,11 @@ func init() {
recURL := tc.ThirdCategoryPath
if recURL == "" {
ctx.SendChain(message.Reply(e.MessageID), message.Text("没有内容请重新选择,三次输入错误,指令可退出重输"))
firstStepImageBytes, err := txt2img.RenderToBase64(db.GetAllFirstCategoryMessage(), 40, 20)
firstStepImageBytes, err := text.RenderToBase64(db.GetAllFirstCategoryMessage(), text.FontFile, 400, 20)
if err != nil {
log.Errorln("[vtb]:", err)
}
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 {
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
errorCount++
@@ -194,4 +195,10 @@ func init() {
}
db.Close()
})
engine.OnFullMatch("更新vtb", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.Send("少女祈祷中......")
vtbData()
ctx.Send("vtb数据库已更新")
})
}

34
plugin_wangyiyun/main.go Normal file
View File

@@ -0,0 +1,34 @@
// Package wangyiyun 网易云音乐热评
package wangyiyun
import (
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/FloatTech/zbputils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/order"
)
const (
wangyiyunURL = "http://ovooa.com/API/wyrp/api.php?type=text"
wangyiyunReferer = "http://ovooa.com/"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
)
func init() {
control.Register("wangyiyun", order.PrioWangYiYun, &control.Options{
DisableOnDefault: false,
Help: "wangyiyun \n- 来份网易云热评",
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Text(helper.BytesToString(data)))
})
}

View File

@@ -4,25 +4,21 @@ package wtf
import (
"fmt"
"strconv"
"time"
control "github.com/FloatTech/zbpctrl"
control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
// 限制调用频率
limit = rate.NewManager(time.Minute*5, 5)
"github.com/FloatTech/ZeroBot-Plugin/order"
)
func init() {
en := control.Register("wtf", &control.Options{
en := control.Register("wtf", order.PrioWtf, &control.Options{
DisableOnDefault: false,
Help: "鬼东西\n- 鬼东西列表\n- 查询鬼东西[序号][@xxx]",
})
en.OnFullMatch("鬼东西列表").SetBlock(true).SetPriority(30).
en.OnFullMatch("鬼东西列表").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
s := ""
for i, w := range table {
@@ -30,12 +26,8 @@ func init() {
}
ctx.SendChain(message.Text(s))
})
en.OnRegex(`^查询鬼东西(\d*)`, zero.OnlyGroup).SetBlock(true).SetPriority(30).
en.OnRegex(`^查询鬼东西(\d*)`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
return
}
// 调用接口
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
if err != nil {