mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
Compare commits
156 Commits
v1.2.4
...
v1.3.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a27132f907 | ||
|
|
183be05d82 | ||
|
|
bccf789714 | ||
|
|
55944dddb3 | ||
|
|
f67932cc56 | ||
|
|
6d633fac6a | ||
|
|
86fc5c51c8 | ||
|
|
156e9f07ad | ||
|
|
1ba4722fc7 | ||
|
|
54c9857219 | ||
|
|
ea56c7d0d2 | ||
|
|
0cbe43df97 | ||
|
|
1f941d883a | ||
|
|
f5b3e423fb | ||
|
|
6c7f81ca55 | ||
|
|
3911b5ed82 | ||
|
|
f38f3ab69c | ||
|
|
846db6f063 | ||
|
|
ff068a05b0 | ||
|
|
051b7dd182 | ||
|
|
11870aeed6 | ||
|
|
9bcff82d9c | ||
|
|
309efe8cd8 | ||
|
|
bf54789f0f | ||
|
|
01e527abdb | ||
|
|
db6b558c75 | ||
|
|
9a792eb144 | ||
|
|
44e99664a3 | ||
|
|
9f3dd37bf0 | ||
|
|
f5936d9cb7 | ||
|
|
27e69ef022 | ||
|
|
6262aab6bd | ||
|
|
4781bc8eb7 | ||
|
|
b233c4b638 | ||
|
|
0a0cc807dc | ||
|
|
feeeb63e52 | ||
|
|
5c620d6268 | ||
|
|
a469000d7a | ||
|
|
0e15ac78b2 | ||
|
|
d9e195ccd0 | ||
|
|
cf52997279 | ||
|
|
88318a7151 | ||
|
|
91f522b666 | ||
|
|
1895f8815e | ||
|
|
7be5f52be4 | ||
|
|
0cfb2e4e06 | ||
|
|
5ccf753af3 | ||
|
|
bfcf3cac91 | ||
|
|
bc3d7bc278 | ||
|
|
7cf767f344 | ||
|
|
7aed9a2c89 | ||
|
|
454196a462 | ||
|
|
1597ba7128 | ||
|
|
480523ff27 | ||
|
|
7ec7ab8682 | ||
|
|
ba2d011d48 | ||
|
|
504e6cd1cc | ||
|
|
b8f3700fe4 | ||
|
|
b2cff862bb | ||
|
|
dc348f8500 | ||
|
|
8c40293fed | ||
|
|
48deaf3aca | ||
|
|
6932643788 | ||
|
|
7f972e3d68 | ||
|
|
edb0880999 | ||
|
|
45f0f5cd6c | ||
|
|
e468ac1933 | ||
|
|
55b6b40acf | ||
|
|
5f1190f72e | ||
|
|
b0fbd6507d | ||
|
|
598a664d30 | ||
|
|
211f0a667d | ||
|
|
28fb788778 | ||
|
|
628830fbf5 | ||
|
|
7d235d0077 | ||
|
|
861b0b6cef | ||
|
|
9986c57727 | ||
|
|
f1c9e2331c | ||
|
|
7c1ddc6ab1 | ||
|
|
44ad78761b | ||
|
|
bd6925f2f1 | ||
|
|
3838d74cb8 | ||
|
|
eaad8beb7b | ||
|
|
14acdfdbc3 | ||
|
|
a5fe7a5b40 | ||
|
|
61df3c55b5 | ||
|
|
eb0059c1a3 | ||
|
|
4ca5038ae9 | ||
|
|
121403231a | ||
|
|
b945338a8d | ||
|
|
ae5ea542a0 | ||
|
|
fe95dc8201 | ||
|
|
1eefb4e610 | ||
|
|
8660d8d990 | ||
|
|
37033fe48d | ||
|
|
30665ad8c6 | ||
|
|
f9e4b8db76 | ||
|
|
c486a210e4 | ||
|
|
0cd01959a0 | ||
|
|
d5ac9f7920 | ||
|
|
6b2dd112a6 | ||
|
|
01abfab133 | ||
|
|
e2a56872dc | ||
|
|
6f22a9c4bc | ||
|
|
a2426de70c | ||
|
|
ed7bbf54a7 | ||
|
|
69394377d0 | ||
|
|
8f20487a15 | ||
|
|
fae24db2df | ||
|
|
f8fb791d8f | ||
|
|
f320d9e1e5 | ||
|
|
18bd34fad2 | ||
|
|
cf72d0b36a | ||
|
|
c3722b0a6c | ||
|
|
3af701e803 | ||
|
|
bc4b2e89db | ||
|
|
3cbb589d2c | ||
|
|
63ef93a9f9 | ||
|
|
8c943d2c01 | ||
|
|
806b77acce | ||
|
|
3df0414621 | ||
|
|
04f70b0499 | ||
|
|
0b20087e61 | ||
|
|
5c82600972 | ||
|
|
45edd86cb8 | ||
|
|
8f6b3fa00d | ||
|
|
a16bcda7da | ||
|
|
259b29f6e3 | ||
|
|
477868c601 | ||
|
|
92de963c0c | ||
|
|
a7c56d9e77 | ||
|
|
4fe64eeb44 | ||
|
|
fc0d020a04 | ||
|
|
617e2c9885 | ||
|
|
bb1130490b | ||
|
|
ca18a323e3 | ||
|
|
0770c6e4a1 | ||
|
|
e1dbfe8f6a | ||
|
|
a2854069ac | ||
|
|
9f0efc2bda | ||
|
|
ec5798f264 | ||
|
|
ded20441fa | ||
|
|
47064dbcec | ||
|
|
2cda7ecb04 | ||
|
|
b372892a20 | ||
|
|
fabf62059e | ||
|
|
c524c68809 | ||
|
|
876fd425e4 | ||
|
|
72ed1293f6 | ||
|
|
fa973a9231 | ||
|
|
e245a8f124 | ||
|
|
aa71fa7cb8 | ||
|
|
da5aab3ee6 | ||
|
|
e0317d1fe1 | ||
|
|
3557a0ebc1 | ||
|
|
ddd0cc4538 |
202
README.md
202
README.md
@@ -45,6 +45,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
## 功能
|
||||
> 在编译时,以下功能除插件控制外,均可通过注释`main.go`中的相应`import`而物理禁用,减小插件体积。
|
||||
> 通过插件控制,还可动态管理某个功能在某个群的打开/关闭。
|
||||
> 插件的优先级为`import`的先后顺序
|
||||
- **web管理** `import _ "github.com/FloatTech/zbputils/control/web"`
|
||||
- 开启后可执行文件大约增加 5M ,默认注释不开启。如需开启请自行编辑`main.go`取消注释
|
||||
- 需要配合 [webgui](https://github.com/FloatTech/bot-manager) 使用
|
||||
@@ -56,24 +57,80 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- [x] /全局启用 xxx
|
||||
- [x] /全局禁用 xxx
|
||||
- [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] /服务详情
|
||||
- [x] @Bot 插件冲突检测 (会在本群发送一条消息并在约 1s 后撤回以检测其它同类 bot 中已启用的插件并禁用)
|
||||
- **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat"`
|
||||
- **定时指令触发器** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/job"`
|
||||
- [x] 记录以"完全匹配关键词"触发的(代表我执行的)指令
|
||||
- [x] 取消以"完全匹配关键词"触发的(代表我执行的)指令
|
||||
- [x] 记录在"cron"触发的指令
|
||||
- [x] 取消在"cron"触发的指令
|
||||
- [x] 查看所有触发指令
|
||||
- [x] 查看在"cron"触发的指令
|
||||
- [x] 查看以"完全匹配关键词"触发的(代表我执行的)指令
|
||||
- [x] 注入指令结果:任意指令
|
||||
- [x] 执行指令:任意指令
|
||||
- 注:任意指令可以使用形如`?::参数1提示语::1!`,`?::参数2提示语::2!`,`?::?可选参数3提示语,不回答将填入空值::3!`,`!::从url获取的参数::4!`,`!::?可选的从url获取的参数,出错将填入空值::5!`的未定参数,在注入时一一匹配
|
||||
- 一些示例
|
||||
> 每日9:30推送摸鱼人日历
|
||||
```
|
||||
记录在"30 9 * * *"触发的指令
|
||||
run[CQ:image,file=https://api.vvhan.com/api/moyu]
|
||||
```
|
||||
> 每日12:00以1/2概率执行coser指令
|
||||
```python
|
||||
记录在"0 12 * * *"触发的指令
|
||||
注入指令结果:>runcoderaw py
|
||||
from random import random
|
||||
if random() > 0.5: print('coser')
|
||||
else: print('今天没有coser哦~')
|
||||
```
|
||||
> 每日15:00询问设置定时者否想看coser
|
||||
```python
|
||||
记录在"0 15 * * *"触发的指令
|
||||
注入指令结果:>runcoderaw py
|
||||
if '?::想看coser吗?::1!' == '想': print('coser')
|
||||
else: print('好吧')
|
||||
```
|
||||
> 自行编写简易的选择困难症助手小插件
|
||||
```python
|
||||
记录以"简易的选择困难症助手"触发的指令
|
||||
执行指令:>runcoderaw py
|
||||
from random import random
|
||||
if random() > 0.5: print('您最终会选?::请输入您的选择1::1!')
|
||||
else: print('您最终会选?::请输入您的选择2::2!')
|
||||
简易的选择困难症助手
|
||||
```
|
||||
> 自行编写随机b站404页趣图插件
|
||||
```python
|
||||
记录以"随机b站404页趣图"触发的代表我执行的指令
|
||||
注入指令结果:>runcoderaw py
|
||||
import json
|
||||
j = json.loads(r'''!::https://api.iyk0.com/bili_chart::1!''')
|
||||
print("run[CQ:image,file="+j["img"]+"]")
|
||||
随机b站404页趣图
|
||||
```
|
||||

|
||||
|
||||
- **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat"`
|
||||
- [x] [BOT名字]
|
||||
- [x] [戳一戳BOT]
|
||||
- [x] 空调开
|
||||
- [x] 空调关
|
||||
- [x] 群温度
|
||||
- [x] 设置温度[正整数]
|
||||
- [x] @Bot mua | 啾咪 | 摸 | 上你 | 傻 | 裸 | 贴 | 老婆 | 抱 | 亲 | 一下 | 咬 | 操 | 123 | 进去 | 调教 | 搓 | 让 | 捏 | 挤 | 略 | 呐 | 原味 | 胖次 | 内裤 | 内衣 | 衣服 | ghs | 批 | 憨批 | kkp | 咕 | 骚 | 喜欢 | suki | 好き | 看 | 不能 | 砸了 | 透 | 口我 | 草我 | 自慰 | onani | オナニー | 炸了 | 色图 | 涩图 | 告白 | 对不起 | 回来 | 吻 | 软 | 壁咚 | 掰开 | 女友 | 是 | 喵 | 嗷呜 | 叫 | 拜 | 佬 | awsl | 臭 | 香 | 腿 | 张开 | 脚 | 脸 | 头发 | 手 | pr | 舔 | 小穴 | 腰 | 诶嘿嘿 | 可爱 | 扭蛋 | 鼻 | 眼 | 色气 | 推 | 床 | 举 | 手冲 | 饿 | 变 | 敲 | 爬 | 怕 | 冲 | 射 | 不穿 | 迫害 | 猫粮 | 揪尾巴 | 薄荷 | 早 | 晚安 | 揉 | 榨 | 掐 | 胸 | 奶子 | 欧派 | 嫩 | 蹭 | 牵手 | 握手 | 拍照 | w | 睡不着 | 欧尼酱 | 哥 | 爱你 | 过来 | 自闭 | 打不过 | 么么哒 | 很懂 | 膝枕 | 累了 | 安慰 | 洗澡 | 一起睡觉 | 一起 | 多大 | 姐姐 | 糖 | 嗦 | 牛子 | 🐂子 | 🐮子 | 嫌弃 | 紧 | baka | 笨蛋 | 插 | 插进来 | 屁股 | 翘 | 翘起来 | 抬 | 抬起 | 爸 | 傲娇 | rua | 咕噜咕噜 | 咕噜 | 上床 | 做爱 | 吃掉 | 吃 | 揪 | 种草莓 | 种草 | 掀 | 妹 | 病娇 | 嘻
|
||||
- **ATRI** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri"`
|
||||
- **词典匹配回复** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"`
|
||||
- [x] @Bot 关键词
|
||||
- **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"`
|
||||
- **群管** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/manager"`
|
||||
- [x] 禁言[@xxx][分钟]
|
||||
- [x] 解除禁言[@xxx]
|
||||
- [x] 我要自闭 | 禅定 x [分钟 | 小时 | 天]
|
||||
@@ -104,162 +161,191 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- [ ] 警告[@xxx]
|
||||
- [x] run[xxx]
|
||||
- 注:使用gist加群自动审批,请在群介绍添加以下说明,同时开启`需要回答问题并由管理员审核`:加群请在github新建一个gist,其文件名为本群群号的字符串的md5(小写),内容为一行,是当前unix时间戳(10分钟内有效)。然后请将您的用户名和gist哈希(小写)按照username/gisthash的格式填写到回答即可。
|
||||
- **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_github"`
|
||||
- **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/github"`
|
||||
- [x] >github [xxx]
|
||||
- [x] >github -p [xxx]
|
||||
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode"`
|
||||
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode"`
|
||||
- [x] > runcode [language] help
|
||||
- [x] > runcode [language] [code block]
|
||||
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music"`
|
||||
- [x] > runcoderaw [language] [code block]
|
||||
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/music"`
|
||||
- [x] 点歌[xxx]
|
||||
- [x] 网易点歌[xxx]
|
||||
- [x] 酷我点歌[xxx]
|
||||
- [x] 酷狗点歌[xxx]
|
||||
- **shindan** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan"`
|
||||
- **shindan** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan"`
|
||||
- [x] 今天是什么少女[@xxx]
|
||||
- [x] 异世界转生[@xxx]
|
||||
- [x] 卖萌[@xxx]
|
||||
- [x] 抽老婆[@xxx]
|
||||
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife"`
|
||||
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife"`
|
||||
- [x] waifu | 随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
|
||||
- **gif** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif"`
|
||||
- **gif** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif"`
|
||||
- [x] 爬[@xxx]
|
||||
- [x] 摸[@xxx]
|
||||
- [x] 搓[@xxx]
|
||||
- 注:更多指令见项目 --> https://github.com/FloatTech/ZeroBot-Plugin-Gif
|
||||
- **base16384加解密** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_b14"`
|
||||
- **base16384加解密** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14"`
|
||||
- [x] 加密xxx
|
||||
- [x] 解密xxx
|
||||
- [x] 用yyy加密xxx
|
||||
- [x] 用yyy解密xxx
|
||||
- **摸鱼** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu"`
|
||||
- [x] 添加摸鱼提醒
|
||||
- [x] 删除摸鱼提醒
|
||||
- **涩图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_setutime"`
|
||||
- **摸鱼** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu"`
|
||||
- [x] /启用 moyu
|
||||
- [x] /禁用 moyu
|
||||
- **摸鱼人日历** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar"`
|
||||
- [x] /启用 moyucalendar
|
||||
- [x] /禁用 moyucalendar
|
||||
- **涩图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime"`
|
||||
- [x] 来份[涩图/二次元/风景/车万]
|
||||
- [x] 添加[涩图/二次元/风景/车万][P站图片ID]
|
||||
- [x] 删除[涩图/二次元/风景/车万][P站图片ID]
|
||||
- [x] > setu status
|
||||
- **本地涩图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativesetu"`
|
||||
- **本地涩图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu"`
|
||||
- [x] 本地[xxx]
|
||||
- [x] 刷新本地[xxx]
|
||||
- [x] 设置本地setu绝对路径[xxx]
|
||||
- [x] 刷新所有本地setu
|
||||
- [x] 所有本地setu分类
|
||||
- 注:刷新文件夹较慢,请耐心等待刷新完成,会提示“成功”。
|
||||
- **lolicon** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon"`
|
||||
- **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"`
|
||||
- **搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao"`
|
||||
- [x] 以图搜图 | 搜索图片 | 以图识图[图片]
|
||||
- [x] 搜图[P站图片ID]
|
||||
- **搜番** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe"`
|
||||
- **搜番** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe"`
|
||||
- [x] 搜番 | 搜索番剧[图片]
|
||||
- **随机图片与AI点评** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage`
|
||||
- **百度一下** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu"`
|
||||
- [x] 百度下[xxx]
|
||||
- **随机图片与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`
|
||||
- **DeepDanbooru二次元图标签识别** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru`
|
||||
- [x] 鉴赏图片[图片]
|
||||
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_fortune`
|
||||
- **叔叔的AI二次元图片放大** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale"`
|
||||
- [x] 放大图片[图片]
|
||||
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/fortune`
|
||||
- [x] 运势 | 抽签
|
||||
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘]
|
||||
- **睡眠管理** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage`
|
||||
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘 东方归言录]
|
||||
- **睡眠管理** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage`
|
||||
- [x] 早安 | 晚安
|
||||
- **浅草寺求签** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji`
|
||||
- **浅草寺求签** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji`
|
||||
- [x] 求签 | 占卜
|
||||
- [x] 解签
|
||||
- **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili"`
|
||||
- **漂流瓶** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle"`
|
||||
- [x] (在群xxx)丢漂流瓶(到频道xxx) [消息]
|
||||
- [x] (从频道xxx)捡漂流瓶
|
||||
- [x] @BOT 创建频道 xxx
|
||||
- [x] 跳入(频道)海中
|
||||
- [x] 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global
|
||||
- **猜单词** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle"`
|
||||
- [x] 个人猜单词
|
||||
- [x] 团队猜单词
|
||||
- **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili"`
|
||||
- [x] >vup info [名字 | uid]
|
||||
- [x] >user info [名字 | uid]
|
||||
- [x] /开启粉丝日报
|
||||
- **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana"`
|
||||
- **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana"`
|
||||
- [x] 小作文
|
||||
- [x] 发大病
|
||||
- [x] 教你一篇小作文[作文]
|
||||
- [x] [回复]查重
|
||||
- **鬼东西** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wtf"`
|
||||
- **鬼东西** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf"`
|
||||
- [x] 鬼东西列表
|
||||
- [x] 查询鬼东西[序号][@xxx]
|
||||
- 注:由于需要科学,默认注释。
|
||||
- **AIfalse** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false"`
|
||||
- **AIfalse** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false"`
|
||||
- [x] 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]
|
||||
- [x] 清理缓存 (仅适用于 gocq 且需要 bot 的运行目录和 gocq 相同)
|
||||
- [ ] 简易语音
|
||||
- [ ] 爬图合成 [@xxx]
|
||||
- **抽wife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativewife"`
|
||||
- **抽wife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife"`
|
||||
- [x] 抽wife[@xxx]
|
||||
- [x] 添加wife[名字][图片]
|
||||
- [x] 删除wife[名字]
|
||||
- [x] [让 | 不让]所有人均可添加wife
|
||||
- 注:不同群添加后不会重叠
|
||||
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
|
||||
- [x] /mcstart xxx
|
||||
- [x] /mcstop xxx
|
||||
- [x] /mclist servername
|
||||
- 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
||||
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
|
||||
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs"`
|
||||
- [x] 搜卡[xxxx]
|
||||
- [x] [卡组代码xxx]
|
||||
- 注:更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp
|
||||
- **人工智能回复** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply"`
|
||||
- **人工智能回复** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply"`
|
||||
- [x] @Bot 任意文本(任意一句话回复)
|
||||
- [x] 设置回复模式[青云客 | 小爱]
|
||||
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
|
||||
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder"`
|
||||
- [x] 来张 [xxx]
|
||||
- **拼音首字母释义工具** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nbnhhsh"`
|
||||
- **拼音首字母释义工具** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh"`
|
||||
- [x] ?? [缩写]
|
||||
- **选择困难症帮手** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose"`
|
||||
- **选择困难症帮手** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose"`
|
||||
- [x] 选择[选择项1]还是[选项2]还是[更多选项]
|
||||
- **投胎** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn"`
|
||||
- **投胎** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn"`
|
||||
- [x] reborn
|
||||
- 注:本插件来源于[tgbot](https://github.com/YukariChiba/tgbot/blob/main/modules/Reborn.py)
|
||||
- **翻译** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_translation"`
|
||||
- **翻译** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation"`
|
||||
- [x] >TL 你好
|
||||
- **vtb语录** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation"`
|
||||
- **vtb语录** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation"`
|
||||
- [x] vtb语录
|
||||
- [x] 随机vtb
|
||||
- **书评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review"`
|
||||
- [x] 更新vtb
|
||||
- **书评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review"`
|
||||
- [x] 书评[xxx]
|
||||
- [x] 随机书评
|
||||
- **coser** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" `
|
||||
- **coser** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" `
|
||||
- [x] coser
|
||||
- **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" `
|
||||
- **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" `
|
||||
- [x] 小说[xxx]
|
||||
- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao"`
|
||||
- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao"`
|
||||
- [x] 哄我
|
||||
- [x] 渣我
|
||||
- [x] 来碗绿茶
|
||||
- [x] 发个朋友圈
|
||||
- [x] 来碗毒鸡汤
|
||||
- [x] 讲个段子
|
||||
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"`
|
||||
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny"`
|
||||
- [x] 讲个笑话[@xxx] | 讲个笑话[qq号]
|
||||
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua"`
|
||||
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua"`
|
||||
- [x] 抽象翻译[xxx]
|
||||
- **绝绝子** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi"`
|
||||
- **合成emoji** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix"`
|
||||
- [x] [emoji][emoji]
|
||||
- **绝绝子** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi"`
|
||||
- [x] 喝奶茶绝绝子 | 绝绝子吃饭
|
||||
- **藏头诗** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi"`
|
||||
- **藏头诗** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi"`
|
||||
- [x] 藏头诗[xxx]
|
||||
- [x] 藏尾诗[xxx]
|
||||
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory"`
|
||||
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory"`
|
||||
- [x] 组cp[@xxx][@xxx]
|
||||
- [x] 组cp大老师 雪乃
|
||||
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
|
||||
- [x] 磕cp大老师 雪乃
|
||||
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/score"`
|
||||
- [x] 签到
|
||||
- [x] 获得签到背景[@xxx] | 获得签到背景
|
||||
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"`
|
||||
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/curse"`
|
||||
- [x] 骂我
|
||||
- [x] 大力骂我
|
||||
- **b站推送** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push"`
|
||||
- **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"`
|
||||
- **网易云音乐热评** `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 | https://www.bilibili.com/video/bv1xx411c7BF
|
||||
- **煎蛋网无聊图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan"`
|
||||
- [x] 来份屌图
|
||||
- [x] 更新屌图
|
||||
- **月幕galgame图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`
|
||||
- [x] 随机galCG
|
||||
- [x] 随机gal表情包
|
||||
- [x] galCG[xxx]
|
||||
- [x] gal表情包[xxx]
|
||||
- [x] 更新gal
|
||||
- **TODO...**
|
||||
|
||||
## 使用方法
|
||||
@@ -314,7 +400,7 @@ GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o zerobot -trimpath
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o zerobot.exe -trimpath
|
||||
# armv6 Linux 平台 如树莓派 zero W
|
||||
GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build -ldflags "-s -w" -o zerobot -trimpath
|
||||
# (由于引入了github.com/logoove/sqlite,本项不再可用)mips Linux 平台 如 路由器 wndr4300
|
||||
# (由于引入了github.com/fumiama/sqlite3,本项不再可用)mips Linux 平台 如 路由器 wndr4300
|
||||
GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" -o zerobot -trimpath
|
||||
```
|
||||
|
||||
|
||||
2
data
2
data
Submodule data updated: abdfd11062...e084d72e9d
50
go.mod
50
go.mod
@@ -3,27 +3,30 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.2.4
|
||||
github.com/FloatTech/zbputils v1.2.4
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635
|
||||
github.com/FloatTech/sqlite v0.2.1
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fogleman/gg v1.3.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.2.1
|
||||
github.com/fumiama/go-registry v0.0.2
|
||||
github.com/fumiama/gofastTEA v0.0.6
|
||||
github.com/fumiama/go-base16384 v1.3.0
|
||||
github.com/fumiama/go-registry v0.1.1
|
||||
github.com/fumiama/gofastTEA v0.0.9
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/sqlite3 v1.14.6
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/logoove/sqlite v1.13.0
|
||||
github.com/mroth/weightedrand v0.4.1
|
||||
github.com/shirou/gopsutil/v3 v3.21.12
|
||||
github.com/pkumza/numcn v1.0.0
|
||||
github.com/shirou/gopsutil/v3 v3.22.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/tidwall/gjson v1.12.1
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
github.com/tidwall/gjson v1.14.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867
|
||||
)
|
||||
|
||||
require (
|
||||
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
|
||||
@@ -31,35 +34,22 @@ 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-sqlite3 v1.14.12 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.9 // indirect
|
||||
github.com/tklauser/numcpus v0.3.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
|
||||
golang.org/x/mod v0.5.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect
|
||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/tools v0.1.8 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
lukechampine.com/uint128 v1.1.1 // indirect
|
||||
modernc.org/cc/v3 v3.35.22 // indirect
|
||||
modernc.org/ccgo/v3 v3.14.0 // indirect
|
||||
modernc.org/libc v1.13.2 // indirect
|
||||
modernc.org/libc v1.14.6 // indirect
|
||||
modernc.org/mathutil v1.4.1 // indirect
|
||||
modernc.org/memory v1.0.5 // indirect
|
||||
modernc.org/opt v0.1.1 // indirect
|
||||
modernc.org/sqlite v1.14.4 // indirect
|
||||
modernc.org/strutil v1.1.1 // indirect
|
||||
modernc.org/token v1.0.0 // indirect
|
||||
)
|
||||
|
||||
161
go.sum
161
go.sum
@@ -1,20 +1,22 @@
|
||||
github.com/FloatTech/AnimeAPI v1.2.4 h1:lo5c8s/nj3ZdpFkWrjnyEv3b79b5mAGTPQmMiaGVKo0=
|
||||
github.com/FloatTech/AnimeAPI v1.2.4/go.mod h1:Ys5P/MadG6TT/5rWuPgxWgt+dDoDPKEBKCkLg4jn5uc=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635 h1:T7J1wLvSqn8PvkM7X98dgbafW+zG1l0LdX664HbrG0U=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635/go.mod h1:ZNhcnGEchvEjd09WbpLMlmxlmYy4trtLYEAJHRAoKaw=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/zbputils v1.2.4 h1:8wTqL0LwY++LdIakQ1cvCfYqQdTvlCGaL6RRTy6UMnA=
|
||||
github.com/FloatTech/zbputils v1.2.4/go.mod h1:mPVpKu2scTyBiitNmzCrxGc9aIKs9rwfb6iqz/+heck=
|
||||
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/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8=
|
||||
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307053255-29a0c0203693/go.mod h1:1nzt5KFkggpZaqkW0faY3y0X/qeMKTodqWc8wbVYhoY=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf h1:891FSWb/olANthyZpmsqLWc8Xqr9yKxNOlRjZeHF/c8=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf/go.mod h1:u+PiX1khNvtAgfRVTVP4hkA2oUnn5q5dTZSk1Cgp0Gw=
|
||||
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=
|
||||
@@ -22,7 +24,6 @@ github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6RO
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+JlV/f7JstZ4pitd4tHhpN+w+6I+LyOS7B4fyU=
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
|
||||
@@ -33,22 +34,28 @@ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzP
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
|
||||
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
|
||||
github.com/fumiama/go-base16384 v1.2.1 h1:6OGprW8g/95m2ocmryHi8mipZ7bx9StFMZDKEqLvMiA=
|
||||
github.com/fumiama/go-base16384 v1.2.1/go.mod h1:1HTC0QFL7BjS0DuO5Qm+fBYKQkHqmAapLbRpCxrhPXQ=
|
||||
github.com/fumiama/go-registry v0.0.2 h1:2EoZwZpqI7YhkQ1FnuAPvALYPpvUtbsCqk879+r7ehs=
|
||||
github.com/fumiama/go-registry v0.0.2/go.mod h1:QkcmmHuw1y6y/w7/HiH1c9yjBw5Zt+6EER6YJKl9xh8=
|
||||
github.com/fumiama/gofastTEA v0.0.6 h1:Yni3MXDbJVa/c4CecgdZDgCJK+fLdvGph+OBqY2mtiI=
|
||||
github.com/fumiama/gofastTEA v0.0.6/go.mod h1:+sBZ05nCA2skZkursHNvyr8kULlEetrYTM2y5kA4rQc=
|
||||
github.com/fumiama/go-base16384 v1.3.0 h1:J5Xtwh/3alGJt/z/0IFralo5UQA89iFWQqbxj5ZQZi8=
|
||||
github.com/fumiama/go-base16384 v1.3.0/go.mod h1:RGA715p34BiLoZvPRtaxuo2q25Kq9jFsgUsJb8dwy14=
|
||||
github.com/fumiama/go-registry v0.1.0/go.mod h1:iJT3DVgH7KXpJZs6waXEjnWtJPUBBGhF+ByJIMRfngk=
|
||||
github.com/fumiama/go-registry v0.1.1 h1:cmCRizjXHFW2ApwUHCXi8wKLJ6Gtt4GrShJlamGPbVI=
|
||||
github.com/fumiama/go-registry v0.1.1/go.mod h1:iJT3DVgH7KXpJZs6waXEjnWtJPUBBGhF+ByJIMRfngk=
|
||||
github.com/fumiama/gofastTEA v0.0.9 h1:adaWz+014vMShnLUNWIHLBs0Yv6JNUohcaXZNtct5J0=
|
||||
github.com/fumiama/gofastTEA v0.0.9/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
|
||||
github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6/Jc=
|
||||
github.com/fumiama/gotracemoe v0.0.3/go.mod h1:tyqahdUzHf0bQIAVY/GYmDWvYYe5ik1ZbhnGYh+zl40=
|
||||
github.com/fumiama/sqlite3 v1.14.6 h1:+e+iygyiDXQJVi7xeXIviBvR7hAc5y20WA9hRwfKn10=
|
||||
github.com/fumiama/sqlite3 v1.14.6/go.mod h1:Xx9a2/OtHuy9pBjow0N+bE/RhNeZ7zZz5xh25vqbA5A=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/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=
|
||||
@@ -61,16 +68,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=
|
||||
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
||||
@@ -79,25 +86,31 @@ 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/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
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=
|
||||
github.com/logoove/sqlite v1.13.0/go.mod h1:MRpE/o3qQhT7AgfIdnBue5c63+//xT+KXV0gHeVAUAg=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||
github.com/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-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
|
||||
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
|
||||
github.com/mattn/go-sqlite3 v1.14.12/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=
|
||||
@@ -105,16 +118,20 @@ 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/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkumza/numcn v1.0.0 h1:ZT5cf9IJkUZgRgEtCiNNykk0RwsrKXSTsvDHOwUTzgE=
|
||||
github.com/pkumza/numcn v1.0.0/go.mod h1:QSeH+al9dWCd8di5HZM/ZqHqhZmUKfph572e9Ev/ETc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/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/shirou/gopsutil/v3 v3.21.12 h1:VoGxEW2hpmz0Vt3wUvHIl9fquzYLNpVpgNNB7pGJimA=
|
||||
github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA=
|
||||
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.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks=
|
||||
github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
@@ -123,32 +140,32 @@ 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/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.14.0 h1:6aeJ0bzojgWLa82gDQHcx3S0Lr/O51I9bJ5nv6JFx5w=
|
||||
github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
|
||||
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
||||
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
|
||||
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
|
||||
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
|
||||
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
||||
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
|
||||
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1 h1:x56lA0u6hSRpD1YJ/4BDiLydJ8qp5mF50xYS8ZlbkWU=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220122162257-bc71c479f3d1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220304040741-8e53f210618c/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007 h1:yHCJCj8u3Y0JDgTlrUqPHxIO6KU0WK9+voECZ2im5lo=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007/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=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -156,14 +173,13 @@ 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-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/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-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867 h1:TcHcE0vrmgzNH1v3ppjcMGbhG5+9fMuvOmUYwNEF4q4=
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -172,14 +188,13 @@ 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-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s=
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
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=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -195,14 +210,18 @@ 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-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/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-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -212,25 +231,27 @@ 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/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=
|
||||
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
@@ -247,7 +268,6 @@ modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g
|
||||
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.35.20/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.35.22 h1:BzShpwCAP7TWzFppM4k2t03RhXhgYqaibROWkrWq7lE=
|
||||
modernc.org/cc/v3 v3.35.22/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
||||
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
||||
@@ -287,11 +307,10 @@ 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.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/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
|
||||
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
||||
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
|
||||
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
|
||||
@@ -331,9 +350,12 @@ 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/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak=
|
||||
modernc.org/libc v1.14.6 h1:SSiZiE5199iYsGM9gtkDj90xqcXVwubWG8CtoYE+Mnk=
|
||||
modernc.org/libc v1.14.6/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=
|
||||
@@ -342,13 +364,6 @@ modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6
|
||||
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
|
||||
modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
|
||||
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
|
||||
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
|
||||
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||
modernc.org/sqlite v1.14.4 h1:F3DRiVZKnCLqIQ0LhEGqBLnw9LcdADciCwCIHQ8bD5g=
|
||||
modernc.org/sqlite v1.14.4/go.mod h1:LWtcO8JtBrt29KKmTqNNXDjAn36vHa/3nHvOYoVIAjc=
|
||||
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
|
||||
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
||||
modernc.org/tcl v1.10.0/go.mod h1:WzWapmP/7dHVhFoyPpEaNSVTL8xtewhouN/cqSJ5A2s=
|
||||
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
|
||||
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
modernc.org/z v1.2.21/go.mod h1:uXrObx4pGqXWIMliC5MiKuwAyMrltzwpteOFUP1PWCc=
|
||||
|
||||
45
kanban/banner.go
Normal file
45
kanban/banner.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package kanban
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fumiama/go-registry"
|
||||
)
|
||||
|
||||
var (
|
||||
info = [...]string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.3.1 - 2022-03-07 13:40:58 +0800 CST",
|
||||
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
// Banner ...
|
||||
Banner = strings.Join(info[:], "\n")
|
||||
reg = registry.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
)
|
||||
|
||||
// PrintBanner ...
|
||||
func PrintBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", Banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", Kanban(), "\n",
|
||||
"============================================================\n\n",
|
||||
)
|
||||
}
|
||||
|
||||
// Kanban ...
|
||||
func Kanban() string {
|
||||
err := reg.Connect()
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
defer reg.Close()
|
||||
text, err := reg.Get("ZeroBot-Plugin/kanban")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return text
|
||||
}
|
||||
6
kanban/init.go
Normal file
6
kanban/init.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Package kanban 打印版本信息
|
||||
package kanban
|
||||
|
||||
func init() {
|
||||
PrintBanner()
|
||||
}
|
||||
251
main.go
251
main.go
@@ -3,99 +3,158 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
// 注:以下插件均可通过前面加 // 注释,注释后停用并不加载插件
|
||||
// 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner
|
||||
|
||||
// 插件控制
|
||||
// webctrl "github.com/FloatTech/zbputils/control/web" // web 后端控制
|
||||
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
|
||||
// ----------------------插件优先级按顺序从高到低---------------------- //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// ----------------------------高优先级区---------------------------- //
|
||||
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv高优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
|
||||
// vvvvvvvvvvvvvv高优先级区vvvvvvvvvvvvvv //
|
||||
// vvvvvvv高优先级区vvvvvvv //
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
// 词库类
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
// webctrl "github.com/FloatTech/zbputils/control/web" // web 后端控制
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat" // 基础词库
|
||||
|
||||
// 实用类
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_manager" // 群管
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage" // 统计睡眠时间
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage" // 统计睡眠时间
|
||||
|
||||
// 娱乐类
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wtf" // 鬼东西
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse" // 骂人
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/atri" // ATRI词库
|
||||
|
||||
// b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_push" // b站推送
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/manager" // 群管
|
||||
|
||||
// 二次元图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
|
||||
|
||||
// 以下为内置依赖,勿动
|
||||
"github.com/fumiama/go-registry"
|
||||
// ^^^^ //
|
||||
// ^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^高优先级区^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^高优先级区^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^高优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// ----------------------------高优先级区---------------------------- //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// ----------------------------中优先级区---------------------------- //
|
||||
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv中优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
|
||||
// vvvvvvvvvvvvvv中优先级区vvvvvvvvvvvvvv //
|
||||
// vvvvvvv中优先级区vvvvvvv //
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/acgimage" // 随机图片与AI点评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // 查询b站用户信息
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili_parse" // b站视频链接解析
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "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/github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/job" // 定时指令触发器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili_push" // b站推送
|
||||
|
||||
// ^^^^ //
|
||||
// ^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^中优先级区^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^中优先级区^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^中优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// ----------------------------中优先级区---------------------------- //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// ----------------------------低优先级区---------------------------- //
|
||||
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv低优先级区vvvvvvvvvvvvvvvvvvvvvvvvvvvv //
|
||||
// vvvvvvvvvvvvvv低优先级区vvvvvvvvvvvvvv //
|
||||
// vvvvvvv低优先级区vvvvvvv //
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/curse" // 骂人
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply" // 人工智能回复
|
||||
|
||||
// ^^^^ //
|
||||
// ^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^低优先级区^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^低优先级区^^^^^^^^^^^^^^ //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^低优先级区^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// ----------------------------低优先级区---------------------------- //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// -----------------------以下为内置依赖,勿动------------------------ //
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
// -----------------------以上为内置依赖,勿动------------------------ //
|
||||
)
|
||||
|
||||
var (
|
||||
contents = []string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.2.4 - 2022-01-14 20:05:43 +0800 CST",
|
||||
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
|
||||
banner = strings.Join(contents, "\n")
|
||||
token *string
|
||||
url *string
|
||||
adana *string
|
||||
prefix *string
|
||||
poolkey *string
|
||||
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
|
||||
token *string
|
||||
url *string
|
||||
adana *string
|
||||
prefix *string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -113,11 +172,10 @@ func init() {
|
||||
// 默认昵称
|
||||
adana = flag.String("n", "椛椛", "Set default nickname.")
|
||||
prefix = flag.String("p", "/", "Set command prefix.")
|
||||
poolkey = flag.String("pk", "", "Set imgpool key and enable listening.")
|
||||
|
||||
flag.Parse()
|
||||
if *h {
|
||||
printBanner()
|
||||
kanban.PrintBanner()
|
||||
fmt.Println("Usage:")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(0)
|
||||
@@ -130,49 +188,22 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
if *poolkey != "" {
|
||||
imgpool.RegisterListener(*poolkey, control.Register("imgpool", 1, &control.Options{}))
|
||||
}
|
||||
|
||||
// 启用 gui
|
||||
// webctrl.InitGui(*g)
|
||||
}
|
||||
|
||||
func printBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", getKanban(), "\n",
|
||||
"============================================================\n",
|
||||
)
|
||||
}
|
||||
|
||||
func getKanban() string {
|
||||
err := reg.Connect()
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
defer reg.Close()
|
||||
text, err := reg.Get("ZeroBot-Plugin/kanban")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
func main() {
|
||||
printBanner()
|
||||
rand.Seed(time.Now().UnixNano()) // 全局 seed,其他插件无需再 seed
|
||||
// 帮助
|
||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
ctx.SendChain(message.Text(kanban.Banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
})
|
||||
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(getKanban()))
|
||||
ctx.SendChain(message.Text(kanban.Kanban()))
|
||||
})
|
||||
zero.RunAndBlock(
|
||||
zero.Run(
|
||||
zero.Config{
|
||||
NickName: append([]string{*adana}, nicks...),
|
||||
CommandPrefix: *prefix,
|
||||
@@ -182,4 +213,6 @@ func main() {
|
||||
Driver: []zero.Driver{driver.NewWebSocketClient(*url, *token)},
|
||||
},
|
||||
)
|
||||
process.GlobalInitMutex.Unlock()
|
||||
select {}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Package order 各个插件的优先级
|
||||
package order
|
||||
|
||||
const (
|
||||
PrioChat = iota * 10
|
||||
PrioSleepManage
|
||||
PrioAtri
|
||||
PrioManager
|
||||
|
||||
PrioACGImage
|
||||
PrioAIFalse
|
||||
PrioAIWife
|
||||
PrioBase14
|
||||
PrioBilibili
|
||||
PrioBilibiliPush
|
||||
PrioBookReview
|
||||
PrioCangTouShi
|
||||
PrioChoose
|
||||
PrioChouXiangHua
|
||||
PrioCoser
|
||||
PrioCPStory
|
||||
PrioDanbooru
|
||||
PrioDiana
|
||||
PrioFansDaily
|
||||
PrioFortune
|
||||
PrioFunny
|
||||
PrioGIF
|
||||
PrioGithub
|
||||
PrioHS
|
||||
PrioImageFinder
|
||||
PrioJueJueZi
|
||||
PrioLolicon
|
||||
PrioMinecraft
|
||||
PrioMoyu
|
||||
PrioMusic
|
||||
PrioNativeSetu
|
||||
PrioNativeWife
|
||||
PrioNBNHHSH
|
||||
PrioNovel
|
||||
PrioOmikuji
|
||||
PrioReborn
|
||||
PrioRuncode
|
||||
PrioSauceNao
|
||||
PrioScore
|
||||
PrioSetuTime
|
||||
PrioShaDiao
|
||||
PrioShinDan
|
||||
PrioTraceMoe
|
||||
PrioTranslation
|
||||
PrioVtbQuotation
|
||||
PrioWtf
|
||||
|
||||
PrioCurse
|
||||
PrioMockingBird
|
||||
PrioAIReply
|
||||
PrioWangYiYun
|
||||
)
|
||||
@@ -4,18 +4,16 @@ package acgimage
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/classify"
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/AnimeAPI/classify"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
@@ -30,11 +28,10 @@ var (
|
||||
randapi = "&loli=true&r18=true"
|
||||
msgof = make(map[int64]message.MessageID)
|
||||
block = false
|
||||
limit = rate.NewManager(time.Minute, 5)
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("acgimage", order.PrioACGImage, &control.Options{
|
||||
engine := control.Register("acgimage", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "随机图片与AI点评\n" +
|
||||
"- 随机图片(评级大于6的图将私发)\n" +
|
||||
@@ -42,7 +39,7 @@ func init() { // 插件主体
|
||||
"- 设置随机图片网址[url]\n" +
|
||||
"- 太涩了(撤回最近发的图)\n" +
|
||||
"- 评价图片(发送一张图片让bot评分)",
|
||||
})
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
url := ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -54,14 +51,18 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
// 有保护的随机图片
|
||||
engine.OnFullMatch("随机图片", zero.OnlyPublic).SetBlock(true).
|
||||
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)
|
||||
class, dhash, _, err := classify.Classify(randapi, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
err = reply(ctx, class, dhash, classify.Comments[class])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("你太快啦!"))
|
||||
})
|
||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
||||
engine.OnFullMatch("直接随机", ctxext.UserOrGrpAdmin).SetBlock(true).
|
||||
@@ -76,7 +77,13 @@ func init() { // 插件主体
|
||||
} else {
|
||||
url = randapi
|
||||
}
|
||||
setLastMsg(ctx.Event.GroupID, ctx.SendChain(message.Image(url).Add("cache", "0")))
|
||||
setLastMsg(ctx.Event.GroupID, message.NewMessageID(
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID,
|
||||
message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(url).Add("cache", "0"),
|
||||
),
|
||||
}).Get("message_id").String()))
|
||||
block = false
|
||||
}
|
||||
})
|
||||
@@ -90,14 +97,16 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
// 上传一张图进行评价
|
||||
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyPublic, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
|
||||
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, ctxext.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
for _, url := range ctx.State["image_url"].([]string) {
|
||||
class, dhash, comment, _ := classify.Classify(url, true)
|
||||
replyClass(ctx, class, dhash, comment, true)
|
||||
break
|
||||
url := ctx.State["image_url"].([]string)[0]
|
||||
class, _, _, err := classify.Classify(url, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(classify.Comments[class]))
|
||||
})
|
||||
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -110,15 +119,11 @@ func init() { // 插件主体
|
||||
u = apihead + dhash
|
||||
}
|
||||
|
||||
m, err := imgpool.NewImage(ctx, dhash, u)
|
||||
var img message.MessageSegment
|
||||
err := pool.SendRemoteImageFromPool(dhash, u, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
img = message.Image(u)
|
||||
} else {
|
||||
img = message.Image(m.String())
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SendChain(img)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -127,10 +132,10 @@ func setLastMsg(id int64, msg message.MessageID) {
|
||||
msgof[id] = msg
|
||||
}
|
||||
|
||||
func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload bool) {
|
||||
func reply(ctx *zero.Ctx, class int, dhash string, comment string) error {
|
||||
b14, err := url.QueryUnescape(dhash)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
var u string
|
||||
@@ -140,28 +145,29 @@ func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload
|
||||
u = apihead + dhash
|
||||
}
|
||||
|
||||
m, err := imgpool.NewImage(ctx, b14, u)
|
||||
var img message.MessageSegment
|
||||
if err != nil {
|
||||
img = message.Image(u)
|
||||
var send ctxext.NoCtxSendMsg
|
||||
if class > 5 {
|
||||
send = ctxext.SendTo(ctx, ctx.Event.UserID)
|
||||
if dhash != "" {
|
||||
ctx.SendChain(message.Text(comment + "\n给你点提示哦:" + b14))
|
||||
} else {
|
||||
ctx.SendChain(message.Text(comment))
|
||||
}
|
||||
} else {
|
||||
img = message.Image(m.String())
|
||||
send = func(msg interface{}) int64 {
|
||||
return ctx.SendGroupForwardMessage(ctx.Event.GroupID, message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx, append(
|
||||
msg.(message.Message),
|
||||
message.Text(comment))...,
|
||||
),
|
||||
}).Get("message_id").Int()
|
||||
}
|
||||
}
|
||||
|
||||
if class > 5 {
|
||||
if dhash != "" && !isupload {
|
||||
ctx.SendChain(message.Text(comment + "\n给你点提示哦:" + b14))
|
||||
ctx.Event.GroupID = 0
|
||||
ctx.Event.DetailType = "private"
|
||||
ctx.SendChain(img)
|
||||
return
|
||||
return pool.SendRemoteImageFromPool(b14, u, send, func(i int64) zero.Message {
|
||||
if class > 5 {
|
||||
return ctxext.GetMessage(ctx)(i)
|
||||
}
|
||||
ctx.SendChain(message.Text(comment))
|
||||
return
|
||||
}
|
||||
if isupload {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(img, message.Text(comment))
|
||||
return ctxext.GetFirstMessageInForward(ctx)(i)
|
||||
})
|
||||
}
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aifalse", order.PrioAIFalse, &control.Options{
|
||||
engine := control.Register("aifalse", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "AIfalse\n" +
|
||||
"- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]",
|
||||
156
plugin/ai_reply/ai_tts.go
Normal file
156
plugin/ai_reply/ai_tts.go
Normal file
@@ -0,0 +1,156 @@
|
||||
package aireply
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/pkumza/numcn"
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/aireply"
|
||||
"github.com/FloatTech/AnimeAPI/tts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/baidutts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/mockingbird"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const ttsServiceName = "tts"
|
||||
|
||||
var (
|
||||
t = &ttsInstances{
|
||||
m: map[string]tts.TTS{
|
||||
"百度女声": baidutts.NewBaiduTTS(0),
|
||||
"百度男声": baidutts.NewBaiduTTS(1),
|
||||
"百度度逍遥": baidutts.NewBaiduTTS(3),
|
||||
"百度度丫丫": baidutts.NewBaiduTTS(4),
|
||||
"拟声鸟阿梓": mockingbird.NewMockingBirdTTS(0),
|
||||
"拟声鸟药水哥": mockingbird.NewMockingBirdTTS(1),
|
||||
},
|
||||
l: []string{"拟声鸟阿梓", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"},
|
||||
}
|
||||
re = regexp.MustCompile(`(\-|\+)?\d+(\.\d+)?`)
|
||||
)
|
||||
|
||||
type ttsInstances struct {
|
||||
sync.RWMutex
|
||||
m map[string]tts.TTS
|
||||
l []string
|
||||
}
|
||||
|
||||
func (t *ttsInstances) List() []string {
|
||||
t.RLock()
|
||||
cl := make([]string, len(t.l))
|
||||
_ = copy(cl, t.l)
|
||||
t.RUnlock()
|
||||
return cl
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.Register(ttsServiceName, order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "语音回复(包括拟声鸟和百度)\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" +
|
||||
"- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n",
|
||||
})
|
||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
r := aireply.NewAIReply(getReplyMode(ctx))
|
||||
tts := t.new(t.getSoundMode(ctx))
|
||||
ctx.SendChain(message.Record(tts.Speak(ctx.Event.UserID, func() string {
|
||||
reply := r.TalkPlain(msg, zero.BotConfig.NickName[0])
|
||||
reply = re.ReplaceAllStringFunc(reply, func(s string) string {
|
||||
f, err := strconv.ParseFloat(s, 64)
|
||||
if err != nil {
|
||||
log.Errorln("[tts]:", err)
|
||||
return s
|
||||
}
|
||||
return numcn.EncodeFromFloat64(f)
|
||||
})
|
||||
log.Println("[tts]:", reply)
|
||||
return reply
|
||||
})))
|
||||
})
|
||||
engine.OnRegex(`^设置语音模式(.*)$`, ctxext.FirstValueInList(t)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
err := t.setSoundMode(ctx, param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前模式为", param))
|
||||
})
|
||||
engine.OnRegex(`^设置默认语音模式(.*)$`, ctxext.FirstValueInList(t)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
t.setDefaultSoundMode(param)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,默认模式为", param))
|
||||
})
|
||||
}
|
||||
|
||||
// new 语音简单工厂
|
||||
func (t *ttsInstances) new(name string) tts.TTS {
|
||||
return t.m[name]
|
||||
}
|
||||
|
||||
func (t *ttsInstances) setSoundMode(ctx *zero.Ctx, name string) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
var index int64
|
||||
t.RLock()
|
||||
for i, s := range t.l {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
t.RUnlock()
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
if !ok {
|
||||
return errors.New("no such plugin")
|
||||
}
|
||||
return m.SetData(gid, index)
|
||||
}
|
||||
|
||||
func (t *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
if ok {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
index := m.GetData(gid)
|
||||
if int(index) < len(t.l) {
|
||||
return t.l[index]
|
||||
}
|
||||
}
|
||||
return "拟声鸟阿梓"
|
||||
}
|
||||
|
||||
func (t *ttsInstances) setDefaultSoundMode(name string) {
|
||||
var index int
|
||||
t.RLock()
|
||||
for _, s := range t.l {
|
||||
if s == name {
|
||||
break
|
||||
}
|
||||
index++
|
||||
}
|
||||
t.RUnlock()
|
||||
t.Lock()
|
||||
t.l[0], t.l[index] = t.l[index], t.l[0]
|
||||
t.Unlock()
|
||||
}
|
||||
@@ -7,35 +7,30 @@ import (
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/aireply"
|
||||
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/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceName = "aireply"
|
||||
replyServiceName = "aireply"
|
||||
)
|
||||
|
||||
var modes = [...]string{"青云客", "小爱"}
|
||||
var replyModes = [...]string{"青云客", "小爱"}
|
||||
|
||||
func init() { // 插件主体
|
||||
bucket := rate.NewManager(time.Minute, 20) // 接口回复限速器
|
||||
engine := control.Register(serviceName, order.PrioAIReply, &control.Options{
|
||||
engine := control.Register(replyServiceName, order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "人工智能回复\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
|
||||
})
|
||||
// 回复 @和包括名字
|
||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).
|
||||
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 zero.OnlyPublic(ctx) {
|
||||
@@ -64,7 +59,7 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
}
|
||||
var ok bool
|
||||
var index int64
|
||||
for i, s := range modes {
|
||||
for i, s := range replyModes {
|
||||
if s == name {
|
||||
ok = true
|
||||
index = int64(i)
|
||||
@@ -74,7 +69,7 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
if !ok {
|
||||
return errors.New("no such mode")
|
||||
}
|
||||
m, ok := control.Lookup(serviceName)
|
||||
m, ok := control.Lookup(replyServiceName)
|
||||
if !ok {
|
||||
return errors.New("no such plugin")
|
||||
}
|
||||
@@ -86,11 +81,11 @@ func getReplyMode(ctx *zero.Ctx) (name string) {
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m, ok := control.Lookup(serviceName)
|
||||
m, ok := control.Lookup(replyServiceName)
|
||||
if ok {
|
||||
index := m.GetData(gid)
|
||||
if int(index) < len(modes) {
|
||||
return modes[index]
|
||||
if int(index) < len(replyModes) {
|
||||
return replyModes[index]
|
||||
}
|
||||
}
|
||||
return "青云客"
|
||||
@@ -4,13 +4,13 @@ package aiwife
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,14 +18,11 @@ const (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
// TODO: 1.17 特性暂不增加
|
||||
// rand.Seed(time.Now().UnixMicro())
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
control.Register("aiwife", order.PrioAIWife, &control.Options{
|
||||
control.Register("aiwife", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "AIWife\n" +
|
||||
"- waifu | 随机waifu",
|
||||
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetBlock(true).
|
||||
}).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)))
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,7 +26,7 @@ const (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register(servicename, order.PrioAtri, &control.Options{
|
||||
engine := control.Register(servicename, order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "本插件基于 ATRI ,为 Golang 移植版\n" +
|
||||
"- ATRI醒醒\n- ATRI睡吧\n- 萝卜子\n- 喜欢 | 爱你 | 爱 | suki | daisuki | すき | 好き | 贴贴 | 老婆 | 亲一个 | mua\n" +
|
||||
@@ -11,16 +11,16 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("base16384", order.PrioBase14, &control.Options{
|
||||
en := control.Register("base16384", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "base16384加解密\n" +
|
||||
"- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
|
||||
})
|
||||
en.OnRegex(`^加密(.*)`).SetBlock(true).
|
||||
en.OnRegex(`^加密\s?(.*)`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["regex_matched"].([]string)[1]
|
||||
es, err := base14.UTF16be2utf8(base14.EncodeString(str))
|
||||
@@ -30,7 +30,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("加密失败!"))
|
||||
}
|
||||
})
|
||||
en.OnRegex("^解密([\u4e00-\u8e00]*[\u3d01-\u3d06]?)$").SetBlock(true).
|
||||
en.OnRegex(`^解密\s?([一-踀]*[㴁-㴆]?)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["regex_matched"].([]string)[1]
|
||||
es, err := base14.UTF82utf16be(helper.StringToBytes(str))
|
||||
@@ -40,7 +40,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("解密失败!"))
|
||||
}
|
||||
})
|
||||
en.OnRegex(`^用(.*)加密(.*)`).SetBlock(true).
|
||||
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)
|
||||
@@ -51,7 +51,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("加密失败!"))
|
||||
}
|
||||
})
|
||||
en.OnRegex("^用(.*)解密([\u4e00-\u8e00]*[\u3d01-\u3d06]?)$").SetBlock(true).
|
||||
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)
|
||||
27
plugin/baidu/search.go
Normal file
27
plugin/baidu/search.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Package baidu 百度一下
|
||||
package baidu
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("baidu", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "baidu\n" +
|
||||
"- 百度下[xxx]",
|
||||
}).OnPrefix("百度下").SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
txt := ctx.State["args"].(string)
|
||||
if txt != "" {
|
||||
ctx.SendChain(message.Text("https://buhuibaidu.me/?s=" + url.QueryEscape(txt)))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"time"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/fumiama/cron"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
type follower struct {
|
||||
@@ -27,7 +27,7 @@ type follower struct {
|
||||
// 开启日报推送
|
||||
func init() {
|
||||
fansDaily()
|
||||
en := control.Register("fansdaily", order.PrioFansDaily, &control.Options{
|
||||
en := control.Register("fansdaily", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "fansdaily\n- /开启粉丝日报\n- /关闭粉丝日报",
|
||||
})
|
||||
@@ -63,10 +63,9 @@ func init() {
|
||||
|
||||
// 定时任务每天晚上最后2分钟执行一次
|
||||
func fansDaily() {
|
||||
c := cron.New()
|
||||
_, err := c.AddFunc("58 23 * * *", func() { sendNotice() })
|
||||
if err == nil {
|
||||
c.Start()
|
||||
_, err := process.CronTab.AddFunc("58 23 * * *", func() { sendNotice() })
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var engine = control.Register("bilibili", order.PrioBilibili, &control.Options{
|
||||
var engine = control.Register("bilibili", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "bilibili\n" +
|
||||
"- >vup info [名字 | uid]\n" +
|
||||
@@ -22,7 +22,7 @@ var engine = control.Register("bilibili", order.PrioBilibili, &control.Options{
|
||||
|
||||
// 查成分的
|
||||
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)
|
||||
72
plugin/bilibili_parse/bilibili_parse.go
Normal file
72
plugin/bilibili_parse/bilibili_parse.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// Package bilibiliparse b站视频链接解析
|
||||
package bilibiliparse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
bilibiliRe = "https://www.bilibili.com/video/av[0-9]+|https://www.bilibili.com/video/BV[0-9a-zA-Z]+|https://b23.tv/[0-9a-zA-Z]+|https://www.bilibili.com/video/bv[0-9a-zA-Z]+"
|
||||
validRe = "https://www.bilibili.com/video/(BV[0-9a-zA-Z]+)"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("bilibiliparse", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "b站视频链接解析\n" +
|
||||
"- https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA | https://www.bilibili.com/video/bv1xx411c7BF",
|
||||
})
|
||||
|
||||
engine.OnRegex(bilibiliRe).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
bilibiliURL := ctx.State["regex_matched"].([]string)[0]
|
||||
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"))
|
||||
upName := strings.TrimSpace(htmlquery.FindOne(doc, "//*[@id='v_upinfo']/div[2]/div[1]/a[1]/text()").Data)
|
||||
fmt.Println(upName)
|
||||
fanNumber := htmlquery.InnerText(htmlquery.FindOne(doc, "//i[@class='van-icon-general_addto_s']").NextSibling.NextSibling)
|
||||
fmt.Println(fanNumber)
|
||||
m = append(m, message.Text("up:"+upName+",粉丝:"+fanNumber+"\n"))
|
||||
view := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='view']/text()").Data
|
||||
dm := htmlquery.FindOne(doc, "//*[@id='viewbox_report']/div/span[@class='dm']/text()").Data
|
||||
m = append(m, message.Text(view+dm+"\n"))
|
||||
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
|
||||
}
|
||||
@@ -10,17 +10,17 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -34,6 +34,9 @@ const (
|
||||
serviceName = "bilibilipush"
|
||||
)
|
||||
|
||||
// bdb bilibili推送数据库
|
||||
var bdb *bilibilipushdb
|
||||
|
||||
var (
|
||||
lastTime = map[int64]int64{}
|
||||
typeMsg = map[int64]string{
|
||||
@@ -57,7 +60,7 @@ var (
|
||||
|
||||
func init() {
|
||||
go bilibiliPushDaily()
|
||||
en := control.Register(serviceName, order.PrioBilibiliPush, &control.Options{
|
||||
en := control.Register(serviceName, order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "bilibilipush\n" +
|
||||
"- 添加订阅[uid]\n" +
|
||||
@@ -65,9 +68,18 @@ func init() {
|
||||
"- 取消动态订阅[uid]\n" +
|
||||
"- 取消直播订阅[uid]\n" +
|
||||
"- 推送列表",
|
||||
PrivateDataFolder: serviceName,
|
||||
})
|
||||
|
||||
en.OnRegex(`^添加订阅(\d+)$`, ctxext.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
// 加载数据库
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
dbfile := dbpath + "push.db"
|
||||
bdb = initialize(dbfile)
|
||||
log.Println("[bilibilipush]加载bilibilipush数据库")
|
||||
}()
|
||||
|
||||
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
|
||||
@@ -93,7 +105,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
|
||||
}
|
||||
})
|
||||
en.OnRegex(`^取消订阅(\d+)$`, ctxext.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
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
|
||||
@@ -119,7 +131,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("已取消" + name + "的订阅"))
|
||||
}
|
||||
})
|
||||
en.OnRegex(`^取消动态订阅(\d+)$`, ctxext.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
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
|
||||
@@ -145,7 +157,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("已取消" + name + "的动态订阅"))
|
||||
}
|
||||
})
|
||||
en.OnRegex(`^取消直播订阅(\d+)$`, ctxext.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
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
|
||||
@@ -198,11 +210,11 @@ func init() {
|
||||
}
|
||||
msg += " up主:" + upMap[v.BilibiliUID]
|
||||
}
|
||||
data, err := txt2img.RenderToBase64(msg, txt2img.FontFile, 600, 20)
|
||||
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 {
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
@@ -219,12 +231,12 @@ func bilibiliPushDaily() {
|
||||
}
|
||||
|
||||
func checkBuid(buid int64) (status int, name string) {
|
||||
data, err := web.ReqWith(fmt.Sprintf(infoURL, buid), "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), 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()
|
||||
status = int(gjson.Get(binary.BytesToString(data), "code").Int())
|
||||
name = gjson.Get(binary.BytesToString(data), "data.name").String()
|
||||
if status == 0 {
|
||||
bdb.insertBilibiliUp(buid, name)
|
||||
upMap[buid] = name
|
||||
@@ -277,11 +289,11 @@ func unsubscribeLive(buid, groupid int64) (err error) {
|
||||
}
|
||||
|
||||
func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
|
||||
data, err := web.ReqWith(fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
cardList = gjson.Get(helper.BytesToString(data), "data.cards").Array()
|
||||
cardList = gjson.Get(binary.BytesToString(data), "data.cards").Array()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -306,7 +318,7 @@ func getLiveList(uids ...int64) string {
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
return helper.BytesToString(data)
|
||||
return binary.BytesToString(data)
|
||||
}
|
||||
|
||||
func sendDynamic() {
|
||||
@@ -368,7 +380,7 @@ func sendDynamic() {
|
||||
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")
|
||||
cTime := time.Unix(gjson.Get(cOrigin, "pubdate").Int(), 0).Format("2006-01-02 15:04:05")
|
||||
msg = append(msg, message.Text(cName+"在"+cTime+typeMsg[cOrigType]+"\n"))
|
||||
cTitle := gjson.Get(cOrigin, "title").String()
|
||||
msg = append(msg, message.Text(cTitle))
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
_ "github.com/fumiama/sqlite3" // import sql
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/logoove/sqlite" // import sql
|
||||
)
|
||||
|
||||
// bilibilipushdb bili推送数据库
|
||||
@@ -5,29 +5,46 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("bookreview", order.PrioBookReview, &control.Options{
|
||||
engine := control.Register("bookreview", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
|
||||
PublicDataFolder: "BookReview",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "bookreview.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("bookreview", &book{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("bookreview")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[bookreview]读取%d条书评", n)
|
||||
}()
|
||||
|
||||
// 中文、英文、数字但不包括下划线等符号
|
||||
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, txt2img.FontFile, 400, 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.ID() == 0 {
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
@@ -35,11 +52,11 @@ func init() {
|
||||
engine.OnFullMatch("随机书评").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
br := getRandomBookReview()
|
||||
data, err := txt2img.RenderToBase64(br.BookReview, txt2img.FontFile, 400, 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.ID() == 0 {
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
@@ -1,10 +1,14 @@
|
||||
package bookreview
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type book struct {
|
||||
ID uint64 `db:"id"`
|
||||
BookReview string `db:"bookreview"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
// 暂时随机选择一个书评
|
||||
func getBookReviewByKeyword(keyword string) (b book) {
|
||||
_ = db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,12 +32,12 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("cangtoushi", order.PrioCangTouShi, &control.Options{
|
||||
engine := control.Register("cangtoushi", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "藏头诗\n" +
|
||||
"- 藏头诗[xxx]\n- 藏尾诗[xxx]",
|
||||
})
|
||||
engine.OnRegex("藏头诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).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")
|
||||
@@ -48,7 +48,7 @@ func init() {
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
|
||||
engine.OnRegex("藏尾诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).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")
|
||||
@@ -11,22 +11,15 @@ import (
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var (
|
||||
poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
|
||||
engine = control.Register("chat", order.PrioChat, &control.Options{
|
||||
engine = control.Register("chat", order.AcquirePrio(), &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- 设置温度[正整数]",
|
||||
})
|
||||
kimomap = make(kimo, 256)
|
||||
chatList = make([]string, 0, 256)
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
@@ -111,13 +104,4 @@ func init() { // 插件主体
|
||||
))
|
||||
}
|
||||
})
|
||||
initChatList(func() {
|
||||
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
key := ctx.MessageString()
|
||||
val := *kimomap[key]
|
||||
text := val[rand.Intn(len(val))]
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("choose", order.PrioChoose, &control.Options{
|
||||
engine := control.Register("choose", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "choose\n" +
|
||||
"- 选择可口可乐还是百事可乐\n" +
|
||||
@@ -2,18 +2,39 @@
|
||||
package chouxianghua
|
||||
|
||||
import (
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("chouxianghua", order.PrioChouXiangHua, &control.Options{
|
||||
en := control.Register("chouxianghua", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "抽象话\n- 抽象翻译xxx",
|
||||
}).OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$").SetBlock(true).
|
||||
PublicDataFolder: "ChouXiangHua",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "cxh.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("pinyin", &pinyin{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
}()
|
||||
|
||||
en.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))
|
||||
@@ -1,5 +1,7 @@
|
||||
package chouxianghua
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type pinyin struct {
|
||||
Word string `db:"word"`
|
||||
Pronun string `db:"pronunciation"`
|
||||
@@ -9,6 +11,8 @@ type emoji struct {
|
||||
Emoji string `db:"emoji"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func getPinyinByWord(word string) string {
|
||||
var p pinyin
|
||||
_ = db.Find("pinyin", &p, "where word = '"+word+"'")
|
||||
@@ -2,59 +2,41 @@
|
||||
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/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var (
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
|
||||
coserURL = "http://ovooa.com/API/cosplay/api.php"
|
||||
limit = rate.NewManager(time.Minute, 5)
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("coser", order.PrioCoser, &control.Options{
|
||||
control.Register("coser", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "三次元小姐姐\n- coser",
|
||||
}).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).
|
||||
}).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)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Println("err为:", err)
|
||||
}
|
||||
var m message.Message
|
||||
|
||||
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
text,
|
||||
))
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(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),
|
||||
)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(value.String())))
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -4,21 +4,41 @@ package cpstory
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("cpstory", order.PrioCPStory, &control.Options{
|
||||
engine := control.Register("cpstory", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 组cp大老师 雪乃",
|
||||
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
|
||||
PublicDataFolder: "CpStory",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "cp.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("cp_story", &cpstory{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("cp_story")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[cpstory]读取%d条故事", n)
|
||||
}()
|
||||
|
||||
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]))
|
||||
@@ -29,7 +49,7 @@ func init() {
|
||||
text = strings.ReplaceAll(text, cs.Shou, gong)
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
engine.OnPrefix("组cp").SetBlock(true).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 {
|
||||
@@ -1,5 +1,7 @@
|
||||
package cpstory
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type cpstory struct {
|
||||
ID int64 `db:"id"`
|
||||
Gong string `db:"gong"`
|
||||
@@ -7,6 +9,8 @@ type cpstory struct {
|
||||
Story string `db:"story"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func getRandomCpStory() (cs cpstory) {
|
||||
_ = db.Pick("cp_story", &cs)
|
||||
return
|
||||
@@ -2,16 +2,16 @@
|
||||
package curse
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,25 +20,34 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
limit := rate.NewManager(time.Minute, 30)
|
||||
engine := control.Register("curse", order.PrioCurse, &control.Options{
|
||||
engine := control.Register("curse", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
|
||||
PublicDataFolder: "Curse",
|
||||
})
|
||||
|
||||
engine.OnFullMatch("骂我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "curse.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = db.Create("curse", &curse{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c, _ := db.Count("curse")
|
||||
logrus.Infoln("[curse]加载", c, "条骂人语录")
|
||||
}()
|
||||
|
||||
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).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))
|
||||
@@ -1,11 +1,15 @@
|
||||
package curse
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type curse struct {
|
||||
ID uint32 `db:"id"`
|
||||
Text string `db:"text"`
|
||||
Level string `db:"level"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func getRandomCurseByLevel(level string) (c curse) {
|
||||
_ = db.Find("curse", &c, "where level = '"+level+"' ORDER BY RANDOM() limit 1")
|
||||
return
|
||||
@@ -4,35 +4,32 @@ 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"
|
||||
"github.com/FloatTech/zbputils/control/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{
|
||||
engine := control.Register("danbooru", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "二次元图片标签识别\n" +
|
||||
"- 鉴赏图片[图片]",
|
||||
PrivateDataFolder: "danbooru",
|
||||
})
|
||||
|
||||
cachefolder := engine.DataFolder()
|
||||
|
||||
// 上传一张图进行评价
|
||||
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyPublic, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
|
||||
engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyGroup, ctxext.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
for _, url := range ctx.State["image_url"].([]string) {
|
||||
@@ -41,7 +38,7 @@ func init() { // 插件主体
|
||||
if err != nil {
|
||||
name = "未知图片"
|
||||
} else {
|
||||
name = r.Title
|
||||
name = r[0].Title
|
||||
}
|
||||
t, err := danbooru.TagURL(name, url)
|
||||
if err != nil {
|
||||
@@ -49,9 +46,9 @@ func init() { // 插件主体
|
||||
return
|
||||
}
|
||||
digest := md5.Sum(helper.StringToBytes(url))
|
||||
f := cachefile + hex.EncodeToString(digest[:])
|
||||
f := cachefolder + hex.EncodeToString(digest[:])
|
||||
if file.IsNotExist(f) {
|
||||
_ = t.Canvas.SavePNG(f)
|
||||
_ = writer.SavePNG2Path(f, t)
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f))
|
||||
}
|
||||
@@ -2,32 +2,36 @@
|
||||
package diana
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
|
||||
)
|
||||
|
||||
var engine = control.Register("diana", order.PrioDiana, &control.Options{
|
||||
var engine = control.Register("diana", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "嘉然\n" +
|
||||
"- 小作文\n" +
|
||||
"- 发大病\n" +
|
||||
"- 教你一篇小作文[作文]\n" +
|
||||
"- [回复]查重",
|
||||
PublicDataFolder: "Diana",
|
||||
})
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
datapath := engine.DataFolder()
|
||||
dbfile := datapath + "text.db"
|
||||
data.LoadText(dbfile)
|
||||
}()
|
||||
|
||||
// 随机发送一篇上面的小作文
|
||||
engine.OnFullMatch("小作文").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
// 绕过第一行发病
|
||||
ctx.SendChain(message.Text(data.RandText()))
|
||||
})
|
||||
@@ -4,58 +4,38 @@ package data
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
binutils "github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
datapath = "data/Diana"
|
||||
dbfile = datapath + "/text.db"
|
||||
)
|
||||
|
||||
var db = sql.Sqlite{DBPath: dbfile}
|
||||
var db = sql.Sqlite{}
|
||||
|
||||
type text struct {
|
||||
ID int64 `db:"id"`
|
||||
Data string `db:"data"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
process.SleepAbout1sTo2s()
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = LoadText()
|
||||
if err == nil {
|
||||
err = db.Create("text", &text{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c, _ := db.Count("text")
|
||||
log.Printf("[Diana]读取%d条小作文", c)
|
||||
} else {
|
||||
log.Printf("[Diana]读取小作文错误:%v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// LoadText 加载小作文
|
||||
func LoadText() error {
|
||||
func LoadText(dbfile string) {
|
||||
_, err := file.GetLazyData(dbfile, false, false)
|
||||
return err
|
||||
db.DBPath = dbfile
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = db.Create("text", &text{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c, _ := db.Count("text")
|
||||
logrus.Printf("[Diana]读取%d条小作文", c)
|
||||
}
|
||||
|
||||
// AddText 添加小作文
|
||||
func AddText(txt string) error {
|
||||
s := md5.Sum(helper.StringToBytes(txt))
|
||||
s := md5.Sum(binutils.StringToBytes(txt))
|
||||
i := binary.LittleEndian.Uint64(s[:8])
|
||||
return db.Insert("text", &text{ID: int64(i), Data: txt})
|
||||
}
|
||||
53
plugin/drift_bottle/data.go
Normal file
53
plugin/drift_bottle/data.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package driftbottle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/crc64"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
)
|
||||
|
||||
type bottle struct {
|
||||
ID int64 `db:"id"` // ID qq_grp_name_msg 的 crc64
|
||||
QQ int64 `db:"qq"` // QQ 发送者 qq
|
||||
Grp int64 `db:"grp"` // Grp 限制抽出的群 / 人(负数)
|
||||
Name string `db:"name"` // Name 发送者 昵称
|
||||
Msg string `db:"msg"` // Msg 消息,纯文本
|
||||
}
|
||||
|
||||
var sea = &sql.Sqlite{}
|
||||
var seamu sync.RWMutex
|
||||
|
||||
func newBottle(qq, grp int64, name, msg string) *bottle {
|
||||
id := int64(crc64.Checksum(binary.StringToBytes(fmt.Sprintf("%d_%d_%s_%s", qq, grp, name, msg)), crc64.MakeTable(crc64.ISO)))
|
||||
return &bottle{ID: id, QQ: qq, Grp: grp, Name: name, Msg: msg}
|
||||
}
|
||||
|
||||
func (b *bottle) throw(db *sql.Sqlite, channel string) error {
|
||||
seamu.Lock()
|
||||
defer seamu.Unlock()
|
||||
return db.Insert(channel, b)
|
||||
}
|
||||
|
||||
func (b *bottle) destroy(db *sql.Sqlite, channel string) error {
|
||||
seamu.Lock()
|
||||
defer seamu.Unlock()
|
||||
return db.Del(channel, "WHERE id="+strconv.FormatInt(b.ID, 10))
|
||||
}
|
||||
|
||||
// fetchBottle grp != 0
|
||||
func fetchBottle(db *sql.Sqlite, channel string, grp int64) (*bottle, error) {
|
||||
seamu.RLock()
|
||||
defer seamu.RUnlock()
|
||||
b := new(bottle)
|
||||
return b, db.Find(channel, b, "WHERE grp=0 or grp="+strconv.FormatInt(grp, 10)+" ORDER BY RANDOM() limit 1")
|
||||
}
|
||||
|
||||
func createChannel(db *sql.Sqlite, channel string) error {
|
||||
seamu.Lock()
|
||||
defer seamu.Unlock()
|
||||
return db.Create(channel, &bottle{})
|
||||
}
|
||||
133
plugin/drift_bottle/main.go
Normal file
133
plugin/drift_bottle/main.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Package driftbottle 漂流瓶
|
||||
package driftbottle
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("driftbottle", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "漂流瓶\n- (在群xxx)丢漂流瓶(到频道xxx) [消息]\n- (从频道xxx)捡漂流瓶\n- @BOT 创建频道 xxx\n- 跳入(频道)海中\n- 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global",
|
||||
PrivateDataFolder: "driftbottle",
|
||||
})
|
||||
sea.DBPath = en.DataFolder() + "sea.db"
|
||||
err := sea.Open()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = createChannel(sea, "global")
|
||||
en.OnRegex(`^(在群\d+)?丢漂流瓶(到频道\w+)?\s+(.*)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msgs := ctx.State["regex_matched"].([]string)
|
||||
grp := ctx.Event.GroupID
|
||||
channel := "global"
|
||||
msg := msgs[3]
|
||||
var err error
|
||||
if msgs[1] != "" {
|
||||
grp, err = strconv.ParseInt(msgs[1][6:], 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("群号非法!"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if msgs[2] != "" {
|
||||
channel = msgs[2][9:]
|
||||
}
|
||||
if msg == "" {
|
||||
ctx.SendChain(message.Text("消息为空!"))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[driftbottle]", grp, channel, msg)
|
||||
err = newBottle(
|
||||
ctx.Event.UserID,
|
||||
grp,
|
||||
ctxext.CardOrNickName(ctx, ctx.Event.UserID),
|
||||
msg,
|
||||
).throw(sea, channel)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你将它扔进大海,希望有人捞到吧~")))
|
||||
})
|
||||
en.OnRegex(`^(从频道\w+)?捡漂流瓶$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msgs := ctx.State["regex_matched"].([]string)
|
||||
grp := ctx.Event.GroupID
|
||||
if grp == 0 {
|
||||
grp = -ctx.Event.UserID
|
||||
}
|
||||
if grp == 0 {
|
||||
ctx.SendChain(message.Text("找不到对象!"))
|
||||
return
|
||||
}
|
||||
channel := "global"
|
||||
if msgs[1] != "" {
|
||||
channel = msgs[1][9:]
|
||||
}
|
||||
logrus.Debugln("[driftbottle]", grp, channel)
|
||||
b, err := fetchBottle(sea, channel, grp)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
err = b.destroy(sea, channel)
|
||||
wg.Done()
|
||||
}()
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(
|
||||
ctx.Event.MessageID,
|
||||
message.Text("你在海边捡到了一个来自 ", b.Name, " 的漂流瓶,打开瓶子,里面有一张纸条,写着:"),
|
||||
message.Text(b.Msg),
|
||||
),
|
||||
)
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
en.OnPrefix("创建频道", zero.SuperUserPermission, zero.OnlyToMe).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
channel := strings.TrimRight(ctx.State["args"].(string), " ")
|
||||
if channel == "" {
|
||||
ctx.SendChain(message.Text("频道名为空!"))
|
||||
return
|
||||
}
|
||||
err := createChannel(sea, channel)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("成功~")))
|
||||
})
|
||||
en.OnRegex(`^跳入(\w+)?海中$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msgs := ctx.State["regex_matched"].([]string)
|
||||
channel := "global"
|
||||
if msgs[1] != "" {
|
||||
channel = msgs[1]
|
||||
}
|
||||
seamu.RLock()
|
||||
c, err := sea.Count(channel)
|
||||
seamu.RUnlock()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你缓缓走入大海,感受着海浪轻柔地拍打着你的小腿,膝盖……\n波浪卷着你的腰腹,你感觉有些把握不住平衡了……\n……\n你沉入海中,", c, " 个物体与你一同沉浮。\n不知何处涌来一股暗流,你失去了意识。")))
|
||||
})
|
||||
}
|
||||
249
plugin/emojimix/emoji.go
Normal file
249
plugin/emojimix/emoji.go
Normal file
@@ -0,0 +1,249 @@
|
||||
// Package emojimix 合成emoji
|
||||
package emojimix
|
||||
|
||||
var emojis = map[rune]int64{
|
||||
128516: 20201001, // 😄 grinning face with smiling eyes
|
||||
128512: 20201001, // 😀 grinning face
|
||||
128578: 20201001, // 🙂 slightly smiling face
|
||||
128579: 20201001, // 🙃 upside-down face
|
||||
128521: 20201001, // 😉 winking face
|
||||
128522: 20201001, // 😊 smiling face with smiling eyes
|
||||
128518: 20201001, // 😆 grinning squinting face
|
||||
128515: 20201001, // 😃 grinning face with big eyes
|
||||
128513: 20201001, // 😁 beaming face with smiling eyes
|
||||
129315: 20201001, // 🤣 rolling on the floor laughing
|
||||
128517: 20201001, // 😅 grinning face with sweat
|
||||
128514: 20201001, // 😂 face with tears of joy
|
||||
128519: 20201001, // 😇 smiling face with halo
|
||||
129392: 20201001, // 🥰 smiling face with hearts
|
||||
128525: 20201001, // 😍 smiling face with heart-eyes
|
||||
128536: 20201001, // 😘 face blowing a kiss
|
||||
129321: 20201001, // 🤩 star-struck
|
||||
128535: 20201001, // 😗 kissing face
|
||||
128538: 20201001, // 😚 kissing face with closed eyes
|
||||
128537: 20201001, // 😙 kissing face with smiling eyes
|
||||
128539: 20201001, // 😛 face with tongue
|
||||
128541: 20201001, // 😝 squinting face with tongue
|
||||
128523: 20201001, // 😋 face savoring food
|
||||
129394: 20201001, // 🥲 smiling face with tear
|
||||
129297: 20201001, // 🤑 money-mouth face
|
||||
128540: 20201001, // 😜 winking face with tongue
|
||||
129303: 20201001, // 🤗 smiling face with open hands hugs
|
||||
129323: 20201001, // 🤫 shushing face quiet whisper
|
||||
129300: 20201001, // 🤔 thinking face question hmmm
|
||||
129325: 20201001, // 🤭 face with hand over mouth embarrassed
|
||||
129320: 20201001, // 🤨 face with raised eyebrow question
|
||||
129296: 20201001, // 🤐 zipper-mouth face
|
||||
128528: 20201001, // 😐 neutral face
|
||||
128529: 20201001, // 😑 expressionless face
|
||||
128566: 20201001, // 😶 face without mouth
|
||||
129322: 20201001, // 🤪 zany face
|
||||
128527: 20201001, // 😏 smirking face suspicious
|
||||
128530: 20201001, // 😒 unamused face
|
||||
128580: 20201001, // 🙄 face with rolling eyes
|
||||
128556: 20201001, // 😬 grimacing face
|
||||
128558: 20210218, // 😮 face exhaling
|
||||
129317: 20201001, // 🤥 lying face
|
||||
128524: 20201001, // 😌 relieved face
|
||||
128532: 20201001, // 😔 pensive face
|
||||
128554: 20201001, // 😪 sleepy face
|
||||
129316: 20201001, // 🤤 drooling face
|
||||
128564: 20201001, // 😴 sleeping face
|
||||
128567: 20201001, // 😷 face with medical mask
|
||||
129298: 20201001, // 🤒 face with thermometer
|
||||
129301: 20201001, // 🤕 face with head-bandage
|
||||
129314: 20201001, // 🤢 nauseated face
|
||||
129326: 20201001, // 🤮 face vomiting throw
|
||||
129319: 20201001, // 🤧 sneezing face
|
||||
129397: 20201001, // 🥵 hot face warm
|
||||
129398: 20201001, // 🥶 cold face freezing ice
|
||||
128565: 20201001, // 😵 face with crossed-out eyes
|
||||
129396: 20201001, // 🥴 woozy face drunk tipsy drug high
|
||||
129327: 20201001, // 🤯 exploding head mindblow
|
||||
129312: 20201001, // 🤠 cowboy hat face
|
||||
129395: 20201001, // 🥳 partying face
|
||||
129400: 20201001, // 🥸 disguised face
|
||||
129488: 20201001, // 🧐 face with monocle glasses
|
||||
128526: 20201001, // 😎 smiling face with sunglasses
|
||||
128533: 20201001, // 😕 confused face
|
||||
128543: 20201001, // 😟 worried face
|
||||
128577: 20201001, // 🙁 slightly frowning face
|
||||
128559: 20201001, // 😯 hushed face
|
||||
128562: 20201001, // 😲 astonished face
|
||||
129299: 20201001, // 🤓 nerd face glasses
|
||||
128563: 20201001, // 😳 flushed face
|
||||
129402: 20201001, // 🥺 pleading face
|
||||
128551: 20201001, // 😧 anguished face
|
||||
128552: 20201001, // 😨 fearful face
|
||||
128550: 20201001, // 😦 frowning face with open mouth
|
||||
128560: 20201001, // 😰 anxious face with sweat
|
||||
128549: 20201001, // 😥 sad but relieved face
|
||||
128557: 20201001, // 😭 loudly crying face
|
||||
128553: 20201001, // 😩 weary face
|
||||
128546: 20201001, // 😢 crying face
|
||||
128547: 20201001, // 😣 persevering face
|
||||
128544: 20201001, // 😠 angry face
|
||||
128531: 20201001, // 😓 downcast face with sweat
|
||||
128534: 20201001, // 😖 confounded face
|
||||
129324: 20201001, // 🤬 face with symbols on mouth
|
||||
128542: 20201001, // 😞 disappointed face
|
||||
128555: 20201001, // 😫 tired face
|
||||
128548: 20201001, // 😤 face with steam from nose
|
||||
129393: 20201001, // 🥱 yawning face
|
||||
128169: 20201001, // 💩 pile of poo
|
||||
128545: 20201001, // 😡 pouting face
|
||||
128561: 20201001, // 😱 face screaming in fear
|
||||
128127: 20201001, // 👿 angry face with horns
|
||||
128128: 20201001, // 💀 skull
|
||||
128125: 20201001, // 👽 alien
|
||||
128520: 20201001, // 😈 smiling face with horns devil
|
||||
129313: 20201001, // 🤡 clown face
|
||||
128123: 20201001, // 👻 ghost
|
||||
129302: 20201001, // 🤖 robot
|
||||
128175: 20201001, // 💯 hundred points percent
|
||||
128064: 20201001, // 👀 eyes
|
||||
127801: 20201001, // 🌹 rose flower
|
||||
127804: 20201001, // 🌼 blossom flower
|
||||
127799: 20201001, // 🌷 tulip flower
|
||||
127797: 20201001, // 🌵 cactus
|
||||
127821: 20201001, // 🍍 pineapple
|
||||
127874: 20201001, // 🎂 birthday cake
|
||||
127751: 20210831, // 🌇 sunset
|
||||
129473: 20201001, // 🧁 cupcake muffin
|
||||
127911: 20210521, // 🎧 headphone earphone
|
||||
127800: 20210218, // 🌸 cherry blossom flower
|
||||
129440: 20201001, // 🦠 microbe germ bacteria virus covid corona
|
||||
128144: 20201001, // 💐 bouquet flowers
|
||||
127789: 20201001, // 🌭 hot dog food
|
||||
128139: 20201001, // 💋 kiss mark lips
|
||||
127875: 20201001, // 🎃 jack-o-lantern pumpkin
|
||||
129472: 20201001, // 🧀 cheese wedge
|
||||
9749: 20201001, // ☕ hot beverage coffee cup tea
|
||||
127882: 20201001, // 🎊 confetti ball
|
||||
127880: 20201001, // 🎈 balloon
|
||||
9924: 20201001, // ⛄ snowman without snow
|
||||
128142: 20201001, // 💎 gem stone crystal diamond
|
||||
127794: 20201001, // 🌲 evergreen tree
|
||||
129410: 20210218, // 🦂 scorpion
|
||||
128584: 20201001, // 🙈 see-no-evil monkey
|
||||
128148: 20201001, // 💔 broken heart
|
||||
128140: 20201001, // 💌 love letter heart
|
||||
128152: 20201001, // 💘 heart with arrow
|
||||
128159: 20201001, // 💟 heart decoration
|
||||
128158: 20201001, // 💞 revolving hearts
|
||||
128147: 20201001, // 💓 beating heart
|
||||
128149: 20201001, // 💕 two hearts
|
||||
128151: 20201001, // 💗 growing heart
|
||||
129505: 20201001, // 🧡 orange heart
|
||||
128155: 20201001, // 💛 yellow heart
|
||||
10084: 20210218, // ❤ mending heart
|
||||
128156: 20201001, // 💜 purple heart
|
||||
128154: 20201001, // 💚 green heart
|
||||
128153: 20201001, // 💙 blue heart
|
||||
129294: 20201001, // 🤎 brown heart
|
||||
129293: 20201001, // 🤍 white heart
|
||||
128420: 20201001, // 🖤 black heart
|
||||
128150: 20201001, // 💖 sparkling heart
|
||||
128157: 20201001, // 💝 heart with ribbon
|
||||
127873: 20211115, // 🎁 wrapped-gift
|
||||
129717: 20211115, // 🪵 wood
|
||||
127942: 20211115, // 🏆 trophy
|
||||
127838: 20210831, // 🍞 bread
|
||||
128240: 20201001, // 📰 newspaper
|
||||
128302: 20201001, // 🔮 crystal ball
|
||||
128081: 20201001, // 👑 crown
|
||||
128055: 20201001, // 🐷 pig face
|
||||
129412: 20210831, // 🦄 unicorn
|
||||
127771: 20201001, // 🌛 first quarter moon face
|
||||
129420: 20201001, // 🦌 deer
|
||||
129668: 20210521, // 🪄 magic wand
|
||||
128171: 20201001, // 💫 dizzy
|
||||
128049: 20201001, // 🐱 meow cat face
|
||||
129409: 20201001, // 🦁 lion
|
||||
128293: 20201001, // 🔥 fire
|
||||
128038: 20210831, // 🐦 bird
|
||||
129415: 20201001, // 🦇 bat
|
||||
129417: 20210831, // 🦉 owl
|
||||
127752: 20201001, // 🌈 rainbow
|
||||
128053: 20201001, // 🐵 monkey face
|
||||
128029: 20201001, // 🐝 honeybee bumblebee wasp
|
||||
128034: 20201001, // 🐢 turtle
|
||||
128025: 20201001, // 🐙 octopus
|
||||
129433: 20201001, // 🦙 llama alpaca
|
||||
128016: 20210831, // 🐐 goat
|
||||
128060: 20201001, // 🐼 panda
|
||||
128040: 20201001, // 🐨 koala
|
||||
129445: 20201001, // 🦥 sloth
|
||||
128059: 20210831, // 🐻 bear
|
||||
128048: 20201001, // 🐰 rabbit face
|
||||
129428: 20201001, // 🦔 hedgehog
|
||||
128054: 20211115, // 🐶 dog puppy
|
||||
128041: 20211115, // 🐩 poodle dog
|
||||
129437: 20211115, // 🦝 raccoon
|
||||
128039: 20211115, // 🐧 penguin
|
||||
128012: 20210218, // 🐌 snail
|
||||
128045: 20201001, // 🐭 mouse face rat
|
||||
128031: 20210831, // 🐟 fish
|
||||
127757: 20201001, // 🌍 globe showing Europe-Africa
|
||||
127774: 20201001, // 🌞 sun with face
|
||||
127775: 20201001, // 🌟 glowing star
|
||||
11088: 20201001, // ⭐ star
|
||||
127772: 20201001, // 🌜 last quarter moon face
|
||||
129361: 20201001, // 🥑 avocado
|
||||
127820: 20211115, // 🍌 banana
|
||||
127827: 20210831, // 🍓 strawberry
|
||||
127819: 20210521, // 🍋 lemon
|
||||
127818: 20211115, // 🍊 tangerine orange
|
||||
}
|
||||
|
||||
var qqface = map[int]rune{
|
||||
0: 128558, // 😮 face exhaling
|
||||
1: 128556, // 😬 grimacing face
|
||||
2: 128525, // 😍 smiling face with heart-eyes
|
||||
4: 128526, // 😎 smiling face with sunglasses
|
||||
5: 128557, // 😭 loudly crying face
|
||||
6: 129402, // 🥺 pleading face
|
||||
7: 129296, // 🤐 zipper-mouth face
|
||||
8: 128554, // 😪 sleepy face
|
||||
11: 128545, // 😡 pouting face
|
||||
12: 128539, // 😛 face with tongue
|
||||
13: 128513, // 😁 beaming face with smiling eyes
|
||||
14: 128578, // 🙂 slightly smiling face
|
||||
15: 128577, // 🙁 slightly frowning face
|
||||
16: 128526, // 😎 smiling face with sunglasses
|
||||
19: 129326, // 🤮 face vomiting throw
|
||||
20: 129325, // 🤭 face with hand over mouth embarrassed
|
||||
21: 128522, // 😊 smiling face with smiling eyes
|
||||
23: 128533, // 😕 confused face
|
||||
24: 128523, // 😋 face savoring food
|
||||
27: 128531, // 😓 downcast face with sweat
|
||||
28: 128516, // 😄 grinning face with smiling eyes
|
||||
31: 129324, // 🤬 face with symbols on mouth
|
||||
32: 129300, // 🤔 thinking face question hmmm
|
||||
33: 129323, // 🤫 shushing face quiet whisper
|
||||
34: 128565, // 😵 face with crossed-out eyes
|
||||
35: 128547, // 😣 persevering face
|
||||
37: 128128, // 💀 skull
|
||||
46: 128055, // 🐷 pig face
|
||||
53: 127874, // 🎂 birthday cake
|
||||
59: 128169, // 💩 pile of poo
|
||||
60: 9749, // ☕ hot beverage coffee cup tea
|
||||
63: 127801, // 🌹 rose flower
|
||||
66: 10084, // ❤ mending heart
|
||||
67: 128148, // 💔 broken heart
|
||||
69: 127873, // 🎁 wrapped-gift
|
||||
74: 127774, // 🌞 sun with face
|
||||
75: 127772, // 🌜 last quarter moon face
|
||||
96: 128517, // 😅 grinning face with sweat
|
||||
104: 129393, // 🥱 yawning face
|
||||
109: 128535, // 😗 kissing face
|
||||
110: 128562, // 😲 astonished face
|
||||
111: 129402, // 🥺 pleading face
|
||||
172: 128539, // 😛 face with tongue
|
||||
182: 128514, // 😂 face with tears of joy
|
||||
187: 128123, // 👻 ghost
|
||||
247: 128567, // 😷 face with medical mask
|
||||
272: 128579, // 🙃 upside-down face
|
||||
320: 129395, // 🥳 partying face
|
||||
325: 128561, // 😱 face screaming in fear
|
||||
}
|
||||
101
plugin/emojimix/mix.go
Normal file
101
plugin/emojimix/mix.go
Normal file
@@ -0,0 +1,101 @@
|
||||
// Package emojimix 合成emoji
|
||||
package emojimix
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const bed = "https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%x.png"
|
||||
|
||||
func init() {
|
||||
control.Register("emojimix", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "合成emoji\n" +
|
||||
"- [emoji][emoji]",
|
||||
}).OnMessage(match).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
r := ctx.State["emojimix"].([]rune)
|
||||
logrus.Debugln("[emojimix] match:", r)
|
||||
r1, r2 := r[0], r[1]
|
||||
u1 := fmt.Sprintf(bed, emojis[r1], r1, r1, r2)
|
||||
u2 := fmt.Sprintf(bed, emojis[r2], r2, r2, r1)
|
||||
logrus.Debugln("[emojimix] u1:", u1)
|
||||
logrus.Debugln("[emojimix] u2:", u2)
|
||||
resp1, err := http.Head(u1)
|
||||
if err == nil {
|
||||
resp1.Body.Close()
|
||||
if resp1.StatusCode == http.StatusOK {
|
||||
ctx.SendChain(message.Image(u1))
|
||||
return
|
||||
}
|
||||
}
|
||||
resp2, err := http.Head(u2)
|
||||
if err == nil {
|
||||
resp2.Body.Close()
|
||||
if resp2.StatusCode == http.StatusOK {
|
||||
ctx.SendChain(message.Image(u2))
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func match(ctx *zero.Ctx) bool {
|
||||
logrus.Debugln("[emojimix] msg:", ctx.Event.Message)
|
||||
if len(ctx.Event.Message) == 2 {
|
||||
r1 := face2emoji(ctx.Event.Message[0])
|
||||
if _, ok := emojis[r1]; !ok {
|
||||
return false
|
||||
}
|
||||
r2 := face2emoji(ctx.Event.Message[1])
|
||||
if _, ok := emojis[r2]; !ok {
|
||||
return false
|
||||
}
|
||||
ctx.State["emojimix"] = []rune{r1, r2}
|
||||
return true
|
||||
}
|
||||
|
||||
r := []rune(ctx.Event.RawMessage)
|
||||
logrus.Debugln("[emojimix] raw msg:", ctx.Event.RawMessage)
|
||||
if len(r) == 2 {
|
||||
if _, ok := emojis[r[0]]; !ok {
|
||||
return false
|
||||
}
|
||||
if _, ok := emojis[r[1]]; !ok {
|
||||
return false
|
||||
}
|
||||
ctx.State["emojimix"] = r
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func face2emoji(face message.MessageSegment) rune {
|
||||
if face.Type == "text" {
|
||||
r := []rune(face.Data["text"])
|
||||
if len(r) != 1 {
|
||||
return 0
|
||||
}
|
||||
return r[0]
|
||||
}
|
||||
if face.Type != "face" {
|
||||
return 0
|
||||
}
|
||||
id, err := strconv.Atoi(face.Data["id"])
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
if r, ok := qqface[id]; ok {
|
||||
return r
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -19,14 +19,14 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -41,9 +41,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// 底图类型列表:车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌
|
||||
// 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师
|
||||
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘"}
|
||||
// 底图类型列表
|
||||
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘", "东方归言录"}
|
||||
// 映射底图与 index
|
||||
index = make(map[string]uint8)
|
||||
// 签文
|
||||
@@ -51,38 +50,37 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
for i, s := range table {
|
||||
index[s] = uint8(i)
|
||||
}
|
||||
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", order.PrioFortune, &control.Options{
|
||||
en := control.Register("fortune", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "每日运势: \n" +
|
||||
"- 运势 | 抽签\n" +
|
||||
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘]",
|
||||
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘 | 东方归言录]",
|
||||
PublicDataFolder: "Fortune",
|
||||
})
|
||||
en.OnRegex(`^设置底图(.*)`).SetBlock(true).
|
||||
go func() {
|
||||
for i, s := range table {
|
||||
index[s] = uint8(i)
|
||||
}
|
||||
_ = 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.OnRegex(`^设置底图\s?(.*)`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid <= 0 {
|
||||
@@ -93,7 +91,7 @@ func init() {
|
||||
if ok {
|
||||
c, ok := control.Lookup("fortune")
|
||||
if ok {
|
||||
err = c.SetData(gid, int64(i)&0xff)
|
||||
err := c.SetData(gid, int64(i)&0xff)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("设置失败:", err))
|
||||
return
|
||||
@@ -125,7 +123,7 @@ func init() {
|
||||
}
|
||||
// 检查背景图片是否存在
|
||||
zipfile := images + kind + ".zip"
|
||||
_, err = file.GetLazyData(zipfile, false, false)
|
||||
_, err := file.GetLazyData(zipfile, false, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -147,37 +145,19 @@ func init() {
|
||||
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
|
||||
cachefile := cache + hex.EncodeToString(digest[:])
|
||||
|
||||
m, err := imgpool.GetImage(ctx, cachefile)
|
||||
if err != nil {
|
||||
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, err = imgpool.NewImage(ctx, cachefile, file.BOTPATH+"/"+cachefile)
|
||||
process.SleepAbout1sTo2s() // 防止风控
|
||||
err = pool.SendImageFromPool(cachefile, cachefile, func() error {
|
||||
f, err := os.Create(cachefile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + cachefile))
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, err = draw(background, title, text, f)
|
||||
_ = f.Close()
|
||||
return err
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 发送图片
|
||||
ctx.SendChain(message.Image(m.String()))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -192,8 +172,8 @@ func randimage(path string, seed int64) (im image.Image, index int, err error) {
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
rand.Seed(seed)
|
||||
index = rand.Intn(len(reader.File))
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
index = r.Intn(len(reader.File))
|
||||
file := reader.File[index]
|
||||
f, err := file.Open()
|
||||
if err != nil {
|
||||
@@ -210,9 +190,9 @@ func randimage(path string, seed int64) (im image.Image, index int, err error) {
|
||||
// @param seed 随机数种子
|
||||
// @return 签名 & 签文 & 错误信息
|
||||
func randtext(seed int64) (string, string) {
|
||||
rand.Seed(seed)
|
||||
r := rand.Intn(len(omikujis))
|
||||
return omikujis[r]["title"], omikujis[r]["content"]
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
i := r.Intn(len(omikujis))
|
||||
return omikujis[i]["title"], omikujis[i]["content"]
|
||||
}
|
||||
|
||||
// @function draw 绘制运势图
|
||||
@@ -221,7 +201,7 @@ func randtext(seed int64) (string, string) {
|
||||
// @param title 签名
|
||||
// @param text 签文
|
||||
// @return 错误信息
|
||||
func draw(back image.Image, title, text string, f io.Writer) (int64, error) {
|
||||
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)
|
||||
// 写标题
|
||||
@@ -238,7 +218,7 @@ func draw(back image.Image, title, text string, f io.Writer) (int64, error) {
|
||||
}
|
||||
tw, th := canvas.MeasureString("测")
|
||||
tw, th = tw+10, th+10
|
||||
r := []rune(text)
|
||||
r := []rune(txt)
|
||||
xsum := rowsnum(len(r), 9)
|
||||
switch xsum {
|
||||
default:
|
||||
@@ -262,7 +242,7 @@ func draw(back image.Image, title, text string, f io.Writer) (int64, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return txt2img.TxtCanvas{Canvas: canvas}.WriteTo(f)
|
||||
return writer.WriteTo(canvas.Image(), f)
|
||||
}
|
||||
|
||||
func offest(total, now int, distance float64) float64 {
|
||||
60
plugin/funny/laugh.go
Normal file
60
plugin/funny/laugh.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Package funny 冷笑话
|
||||
package funny
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
type joke struct {
|
||||
ID uint32 `db:"id"`
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func init() {
|
||||
en := control.Register("funny", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "讲个笑话\n" +
|
||||
"- 讲个笑话[@xxx] | 讲个笑话[qq号]",
|
||||
PublicDataFolder: "Funny",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "jokes.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = db.Create("jokes", &joke{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c, _ := db.Count("jokes")
|
||||
logrus.Infoln("[funny]加载", c, "个笑话")
|
||||
}()
|
||||
|
||||
en.OnPrefix("讲个笑话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
// 获取名字
|
||||
name := ctxext.NickName(ctx)
|
||||
var j joke
|
||||
err := db.Pick("jokes", &j)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(strings.ReplaceAll(j.Text, "%name", name)))
|
||||
})
|
||||
}
|
||||
85
plugin/gif/context.go
Normal file
85
plugin/gif/context.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type context struct {
|
||||
usrdir string
|
||||
headimgsdir []string
|
||||
}
|
||||
|
||||
func dlchan(name string, s *string, wg *sync.WaitGroup, exit func(error)) {
|
||||
defer wg.Done()
|
||||
target := datapath + `materials/` + name
|
||||
var err error
|
||||
if file.IsNotExist(target) {
|
||||
err = file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[gif] dl", name, "to", target, "succeeded")
|
||||
} else {
|
||||
logrus.Debugln("[gif] dl", name, "exists at", target)
|
||||
}
|
||||
*s = target
|
||||
}
|
||||
|
||||
func dlblock(name string) (string, error) {
|
||||
target := datapath + `materials/` + name
|
||||
if file.IsNotExist(target) {
|
||||
err := file.DownloadTo(`https://codechina.csdn.net/u011570312/imagematerials/-/raw/main/`+name, target, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
logrus.Debugln("[gif] dl", name, "to", target, "succeeded")
|
||||
} else {
|
||||
logrus.Debugln("[gif] dl", name, "exists at", target)
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
|
||||
func dlrange(prefix string, end int, wg *sync.WaitGroup, exit func(error)) []string {
|
||||
if file.IsNotExist(datapath + `materials/` + prefix) {
|
||||
err := os.MkdirAll(datapath+`materials/`+prefix, 0755)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
c := make([]string, end)
|
||||
for i := range c {
|
||||
wg.Add(1)
|
||||
go dlchan(prefix+"/"+strconv.Itoa(i)+".png", &c[i], wg, exit)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// 新的上下文
|
||||
func newContext(user int64) *context {
|
||||
c := new(context)
|
||||
c.usrdir = datapath + "users/" + strconv.FormatInt(user, 10) + `/`
|
||||
_ = os.MkdirAll(c.usrdir, 0755)
|
||||
c.headimgsdir = make([]string, 2)
|
||||
c.headimgsdir[0] = c.usrdir + "0.gif"
|
||||
c.headimgsdir[1] = c.usrdir + "1.gif"
|
||||
return c
|
||||
}
|
||||
|
||||
func loadFirstFrames(paths []string, size int) (imgs []*img.ImgFactory, err error) {
|
||||
imgs = make([]*img.ImgFactory, size)
|
||||
for i := range imgs {
|
||||
imgs[i], err = img.LoadFirstFrame(paths[i], 0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return imgs, nil
|
||||
}
|
||||
345
plugin/gif/gif.go
Normal file
345
plugin/gif/gif.go
Normal file
@@ -0,0 +1,345 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
)
|
||||
|
||||
// A摸
|
||||
func (cc *context) A摸() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "摸.gif"
|
||||
c := dlrange("mo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
mo := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 80, 80, 32, 32).Im,
|
||||
imgs[1].InsertBottom(tou, 70, 90, 42, 22).Im,
|
||||
imgs[2].InsertBottom(tou, 75, 85, 37, 27).Im,
|
||||
imgs[3].InsertBottom(tou, 85, 75, 27, 37).Im,
|
||||
imgs[4].InsertBottom(tou, 90, 70, 22, 42).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, mo))
|
||||
}
|
||||
|
||||
// A搓
|
||||
func (cc *context) A搓() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "搓.gif"
|
||||
c := dlrange("cuo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(110, 110)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
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)
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
cuo := []*image.NRGBA{
|
||||
imgs[0].InsertBottomC(tou, 0, 0, 75, 130).Im,
|
||||
imgs[1].InsertBottomC(m1.Im, 0, 0, 75, 130).Im,
|
||||
imgs[2].InsertBottomC(m2.Im, 0, 0, 75, 130).Im,
|
||||
imgs[3].InsertBottomC(m3.Im, 0, 0, 75, 130).Im,
|
||||
imgs[4].InsertBottomC(m4.Im, 0, 0, 75, 130).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(5, cuo))
|
||||
}
|
||||
|
||||
// A敲
|
||||
func (cc *context) A敲() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "敲.gif"
|
||||
c := dlrange("qiao", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(40, 40)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
qiao := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 40, 33, 57, 52).Im,
|
||||
imgs[1].InsertUp(tou, 38, 36, 58, 50).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, qiao))
|
||||
}
|
||||
|
||||
// A吃
|
||||
func (cc *context) A吃() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "吃.gif"
|
||||
c := dlrange("chi", 3, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(32, 32)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 3)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
chi := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
imgs[1].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
imgs[2].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, chi))
|
||||
}
|
||||
|
||||
// A蹭
|
||||
func (cc *context) A蹭() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "蹭.gif"
|
||||
c := dlrange("ceng", 6, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou2, err := cc.getLogo2(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 6)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ceng := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 75, 77, 40, 88).InsertUp(tou2, 77, 103, 102, 81).Im,
|
||||
imgs[1].InsertUp(tou, 75, 77, 46, 100).InsertUp(img.Rotate(tou2, 10, 62, 127).Im, 0, 0, 92, 40).Im,
|
||||
imgs[2].InsertUp(tou, 75, 77, 67, 99).InsertUp(tou2, 76, 117, 90, 8).Im,
|
||||
imgs[3].InsertUp(tou, 75, 77, 52, 83).InsertUp(img.Rotate(tou2, -40, 94, 94).Im, 0, 0, 53, -20).Im,
|
||||
imgs[4].InsertUp(tou, 75, 77, 56, 110).InsertUp(img.Rotate(tou2, -66, 132, 80).Im, 0, 0, 78, 40).Im,
|
||||
imgs[5].InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, ceng))
|
||||
}
|
||||
|
||||
// A啃
|
||||
func (cc *context) A啃() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "啃.gif"
|
||||
c := dlrange("ken", 16, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 16)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ken := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 90, 90, 105, 150).Im,
|
||||
imgs[1].InsertBottom(tou, 90, 83, 96, 172).Im,
|
||||
imgs[2].InsertBottom(tou, 90, 90, 106, 148).Im,
|
||||
imgs[3].InsertBottom(tou, 88, 88, 97, 167).Im,
|
||||
imgs[4].InsertBottom(tou, 90, 85, 89, 179).Im,
|
||||
imgs[5].InsertBottom(tou, 90, 90, 106, 151).Im,
|
||||
imgs[6].Im,
|
||||
imgs[7].Im,
|
||||
imgs[8].Im,
|
||||
imgs[9].Im,
|
||||
imgs[10].Im,
|
||||
imgs[11].Im,
|
||||
imgs[12].Im,
|
||||
imgs[13].Im,
|
||||
imgs[14].Im,
|
||||
imgs[15].Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, ken))
|
||||
}
|
||||
|
||||
// A拍
|
||||
func (cc *context) A拍() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "拍.gif"
|
||||
c := dlrange("pai", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(30, 30)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
pai := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 0, 0, 1, 47).Im,
|
||||
imgs[1].InsertUp(tou, 0, 0, 1, 67).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, pai))
|
||||
}
|
||||
|
||||
// A冲
|
||||
func (cc *context) A冲() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "冲.gif"
|
||||
c := dlrange("xqe", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
chong := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 30, 30, 15, 53).Im,
|
||||
imgs[1].InsertUp(tou, 30, 30, 40, 53).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, chong))
|
||||
}
|
||||
|
||||
// A丢
|
||||
func (cc *context) A丢() (string, error) {
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "丢.gif"
|
||||
c := dlrange("diu", 8, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 8)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
diu := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 32, 32, 108, 36).Im,
|
||||
imgs[1].InsertUp(tou, 32, 32, 122, 36).Im,
|
||||
imgs[2].Im,
|
||||
imgs[3].InsertUp(tou, 123, 123, 19, 129).Im,
|
||||
imgs[4].InsertUp(tou, 185, 185, -50, 200).InsertUp(tou, 33, 33, 289, 70).Im,
|
||||
imgs[5].InsertUp(tou, 32, 32, 280, 73).Im,
|
||||
imgs[6].InsertUp(tou, 35, 35, 259, 31).Im,
|
||||
imgs[7].InsertUp(tou, 175, 175, -50, 220).Im,
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, diu))
|
||||
}
|
||||
41
plugin/gif/logo.go
Normal file
41
plugin/gif/logo.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"image"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
)
|
||||
|
||||
func (cc *context) prepareLogos(s ...string) error {
|
||||
for i, v := range s {
|
||||
_, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
err = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.usrdir+strconv.Itoa(i)+".gif", true)
|
||||
} else {
|
||||
err = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.usrdir+strconv.Itoa(i)+".gif", true)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cc *context) getLogo(w int, h int) (*image.NRGBA, error) {
|
||||
frame, err := img.LoadFirstFrame(cc.headimgsdir[0], w, h)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return frame.Circle(0).Im, nil
|
||||
}
|
||||
|
||||
func (cc *context) getLogo2(w int, h int) (*image.NRGBA, error) {
|
||||
frame, err := img.LoadFirstFrame(cc.headimgsdir[1], w, h)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return frame.Circle(0).Im, nil
|
||||
}
|
||||
108
plugin/gif/png.go
Normal file
108
plugin/gif/png.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
)
|
||||
|
||||
// A爬
|
||||
func (cc *context) A爬() (string, error) {
|
||||
name := cc.usrdir + `爬.png`
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// 随机爬图序号
|
||||
rand := rand.Intn(60) + 1
|
||||
if file.IsNotExist(datapath + "materials/pa") {
|
||||
err = os.MkdirAll(datapath+"materials/pa", 0755)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
f, err := dlblock(`pa/` + strconv.Itoa(rand) + `.png`)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgf, err := img.LoadFirstFrame(f, 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgf.InsertBottom(tou, 100, 100, 0, 400).Im)
|
||||
}
|
||||
|
||||
// A撕
|
||||
func (cc *context) A撕() (string, error) {
|
||||
name := cc.usrdir + `撕.png`
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im1 := img.Rotate(tou, 20, 380, 380)
|
||||
im2 := img.Rotate(tou, -12, 380, 380)
|
||||
if file.IsNotExist(datapath + "materials/si") {
|
||||
err = os.MkdirAll(datapath+"materials/si", 0755)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
f, err := dlblock(`si/0.png`)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgf, err := img.LoadFirstFrame(f, 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgf.InsertBottom(im1.Im, im1.W, im1.H, -3, 370).InsertBottom(im2.Im, im2.W, im2.H, 653, 310).Im)
|
||||
}
|
||||
|
||||
// 简单
|
||||
func (cc *context) other(value ...string) (string, error) {
|
||||
name := cc.usrdir + value[0] + `.png`
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var imgnrgba *image.NRGBA
|
||||
switch value[0] {
|
||||
case "上翻", "下翻":
|
||||
imgnrgba = im.FlipV().Im
|
||||
case "左翻", "右翻":
|
||||
imgnrgba = im.FlipH().Im
|
||||
case "反色":
|
||||
imgnrgba = im.Invert().Im
|
||||
case "灰度":
|
||||
imgnrgba = im.Grayscale().Im
|
||||
case "负片":
|
||||
imgnrgba = im.Invert().Grayscale().Im
|
||||
case "浮雕":
|
||||
imgnrgba = im.Convolve3x3().Im
|
||||
case "打码":
|
||||
imgnrgba = im.Blur(10).Im
|
||||
case "旋转":
|
||||
r, _ := strconv.ParseFloat(value[1], 64)
|
||||
imgnrgba = img.Rotate(im.Im, r, 0, 0).Im
|
||||
case "变形":
|
||||
w, err := strconv.Atoi(value[1])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
h, err := strconv.Atoi(value[2])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba = img.Size(im.Im, w, h).Im
|
||||
default:
|
||||
return "", errors.New("no such method")
|
||||
}
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
56
plugin/gif/run.go
Normal file
56
plugin/gif/run.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Package gif 制图
|
||||
package gif
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
control "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/zbputils/control/order"
|
||||
)
|
||||
|
||||
var (
|
||||
cmds = []string{"搓", "冲", "摸", "拍", "丢", "吃", "敲", "啃", "蹭", "爬", "撕",
|
||||
"灰度", "上翻", "下翻", "左翻", "右翻", "反色", "浮雕", "打码", "负片"}
|
||||
datapath string
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
en := control.Register("gif", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "制图\n- " + strings.Join(cmds, "\n- "),
|
||||
PrivateDataFolder: "gif",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
datapath = file.BOTPATH + "/" + en.DataFolder()
|
||||
en.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)
|
||||
err := c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
var picurl string
|
||||
if len([]rune(list[1])) == 1 {
|
||||
r := reflect.ValueOf(c).MethodByName("A" + list[1]).Call(nil)
|
||||
picurl = r[0].String()
|
||||
if !r[1].IsNil() {
|
||||
err = r[1].Interface().(error)
|
||||
}
|
||||
} else {
|
||||
picurl, err = c.other(list[1]) // "灰度", "上翻", "下翻", "左翻", "右翻", "反色", "倒放", "浮雕", "打码", "负片"
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(picurl))
|
||||
})
|
||||
}
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
control.Register("github", order.PrioGithub, &control.Options{
|
||||
control.Register("github", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "GitHub仓库搜索\n" +
|
||||
"- >github [xxx]\n" +
|
||||
@@ -13,17 +13,15 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var (
|
||||
cachedir = file.BOTPATH + "/data/hs/"
|
||||
reqconf = [...]string{"GET", "https://hs.fbigame.com",
|
||||
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36"}
|
||||
)
|
||||
var reqconf = [...]string{"GET", "https://hs.fbigame.com",
|
||||
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36"}
|
||||
|
||||
const (
|
||||
hs = `https://hs.fbigame.com/ajax.php?`
|
||||
@@ -45,19 +43,15 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
os.RemoveAll(cachedir)
|
||||
err := os.MkdirAll(cachedir, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
engine := control.Register("hs", order.PrioHS, &control.Options{
|
||||
engine := control.Register("hs", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "炉石\n" +
|
||||
"- 搜卡[xxxx]\n" +
|
||||
"- [卡组代码xxx]\n" +
|
||||
"- 更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp",
|
||||
})
|
||||
PrivateDataFolder: "hs",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
cachedir := file.BOTPATH + "/" + engine.DataFolder()
|
||||
engine.OnRegex(`^搜卡(.+)$`).
|
||||
SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
List := ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -71,9 +65,8 @@ func init() {
|
||||
for i := 0; i < t && i < 5; i++ {
|
||||
cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String()
|
||||
cachefile := cachedir + cid
|
||||
imgcq := `[CQ:image,file=` + "file:///" + cachefile + `]`
|
||||
if file.IsNotExist(cachefile) {
|
||||
data, err := web.ReqWith(
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(),
|
||||
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
|
||||
gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(),
|
||||
reqconf[0], reqconf[1], reqconf[2])
|
||||
@@ -81,17 +74,10 @@ func init() {
|
||||
err = os.WriteFile(cachefile, data, 0644)
|
||||
}
|
||||
if err != nil {
|
||||
imgcq = err.Error()
|
||||
continue
|
||||
}
|
||||
}
|
||||
sk = append(
|
||||
sk,
|
||||
message.CustomNode(
|
||||
zero.BotConfig.NickName[0],
|
||||
ctx.Event.SelfID,
|
||||
imgcq, // 图片
|
||||
),
|
||||
)
|
||||
sk = append(sk, ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+cachefile)))
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
@@ -112,10 +98,10 @@ func init() {
|
||||
}
|
||||
|
||||
func sh(s string) string {
|
||||
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return helper.BytesToString(r)
|
||||
}
|
||||
@@ -124,10 +110,10 @@ func sh(s string) string {
|
||||
}
|
||||
|
||||
func kz(s string) string {
|
||||
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "mod=general_deck_image&deck_code=" + s + "&deck_text=&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return "base64://" + gjson.Get(helper.BytesToString(r), "img").String()
|
||||
}
|
||||
82
plugin/image_finder/keyword.go
Normal file
82
plugin/image_finder/keyword.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// Package imagefinder 关键字搜图
|
||||
package imagefinder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
type resultjson struct {
|
||||
Data struct {
|
||||
Illusts []struct {
|
||||
ID int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
AltTitle string `json:"altTitle"`
|
||||
Description string `json:"description"`
|
||||
Sanity int `json:"sanity"`
|
||||
} `json:"illusts"`
|
||||
} `json:"data"`
|
||||
Error bool `json:"error"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
control.Register("imgfinder", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "关键字搜图\n" +
|
||||
"- 来张 [xxx]",
|
||||
}).OnRegex(`^来张\s?(.*)$`, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
soutujson, err := soutuapi(keyword)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
rannum := rand.Intn(len(soutujson.Data.Illusts))
|
||||
illust, err := pixiv.Works(soutujson.Data.Illusts[rannum].ID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
u := illust.ImageUrls[0]
|
||||
n := u[strings.LastIndex(u, "/")+1 : len(u)-4]
|
||||
f := illust.Path(0)
|
||||
|
||||
err = pool.SendImageFromPool(n, f, func() error {
|
||||
// 下载图片
|
||||
return illust.DownloadToCache(0)
|
||||
}, ctxext.SendFakeForwardToGroup(ctx), ctxext.GetFirstMessageInForward(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// soutuapi 请求api
|
||||
func soutuapi(keyword string) (r resultjson, err error) {
|
||||
data, err := web.GetData("https://copymanga.azurewebsites.net/api/pixivel?" + url.QueryEscape(keyword) + "?page=0")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &r)
|
||||
if err == nil && r.Error {
|
||||
err = errors.New(r.Message)
|
||||
}
|
||||
return
|
||||
}
|
||||
24
plugin/jandan/data.go
Normal file
24
plugin/jandan/data.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package jandan
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
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
|
||||
}
|
||||
108
plugin/jandan/jandan.go
Normal file
108
plugin/jandan/jandan.go
Normal file
@@ -0,0 +1,108 @@
|
||||
// Package jandan 煎蛋网无聊图
|
||||
package jandan
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/crc64"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/antchfx/htmlquery"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
api = "http://jandan.net/pic"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("jandan", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "煎蛋网无聊图\n- 来份屌图\n- 更新屌图\n",
|
||||
PublicDataFolder: "Jandan",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "pics.db"
|
||||
_, _ = file.GetLazyData(db.DBPath, false, false)
|
||||
err := db.Create("picture", &picture{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("picture")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[jandan]读取%d张图片", 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("更新完成!")
|
||||
})
|
||||
}
|
||||
541
plugin/job/main.go
Normal file
541
plugin/job/main.go
Normal file
@@ -0,0 +1,541 @@
|
||||
// Package job 定时指令触发器
|
||||
package job
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"hash/crc64"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/vevent"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/fumiama/cron"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
lo map[int64]vevent.Loop
|
||||
entries = map[int64]cron.EntryID{} // id entryid
|
||||
matchers = map[int64]*zero.Matcher{}
|
||||
mu sync.Mutex
|
||||
limit = rate.NewLimiter(time.Second*2, 1)
|
||||
en = control.Register("job", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "定时指令触发器\n- 记录以\"完全匹配关键词\"触发的指令\n- 取消以\"完全匹配关键词\"触发的指令\n- 记录在\"cron\"触发的指令\n- 取消在\"cron\"触发的指令\n- 查看所有触发指令\n- 查看在\"cron\"触发的指令\n- 查看以\"完全匹配关键词\"触发的指令\n- 注入指令结果:任意指令\n- 执行指令:任意指令",
|
||||
PrivateDataFolder: "job",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
db.DBPath = en.DataFolder() + "job.db"
|
||||
err := db.Open()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
process.GlobalInitMutex.Lock()
|
||||
process.SleepAbout1sTo2s()
|
||||
lo = make(map[int64]vevent.Loop, len(zero.BotConfig.Driver))
|
||||
for _, drv := range zero.BotConfig.Driver {
|
||||
id := drv.SelfID()
|
||||
ids := strconv.FormatInt(id, 36)
|
||||
c := &cmd{}
|
||||
lo[id] = vevent.NewLoop(id)
|
||||
err := db.Create(ids, c)
|
||||
logrus.Infoln("[job]创建表", ids)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = db.FindFor(ids, c, "", func() error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if strings.HasPrefix(c.Cron, "fm:") {
|
||||
m := en.OnFullMatch(c.Cron[3:] /* skip fm: */).SetBlock(true)
|
||||
m.Handle(generalhandler(c))
|
||||
matchers[c.ID] = getmatcher(m)
|
||||
return nil
|
||||
}
|
||||
if strings.HasPrefix(c.Cron, "sm:") {
|
||||
m := en.OnFullMatch(c.Cron[3:] /* skip fm: */).SetBlock(true)
|
||||
m.Handle(superuserhandler(c))
|
||||
matchers[c.ID] = getmatcher(m)
|
||||
return nil
|
||||
}
|
||||
eid, err := process.CronTab.AddFunc(c.Cron, inject(id, []byte(c.Cmd)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
entries[c.ID] = eid
|
||||
return nil
|
||||
})
|
||||
}
|
||||
logrus.Infoln("[job]本地环回初始化完成")
|
||||
process.GlobalInitMutex.Unlock()
|
||||
}()
|
||||
en.OnRegex(`^记录在"(.*)"触发的指令$`, ctxext.UserOrGrpAdmin, islonotnil, isfirstregmatchnotnil, logevent).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
command := ctx.State["job_raw_event"].(string)
|
||||
c := &cmd{
|
||||
ID: idof(cron, command),
|
||||
Cron: cron,
|
||||
Cmd: command,
|
||||
}
|
||||
err := addcmd(ctx.Event.SelfID, c)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnRegex(`^记录以"(.*)"触发的指令$`, zero.SuperUserPermission, islonotnil, isfirstregmatchnotnil, logevent).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := "fm:" + ctx.State["regex_matched"].([]string)[1]
|
||||
command := ctx.State["job_new_event"].(gjson.Result).Get("message").Raw
|
||||
logrus.Debugln("[job] get cmd:", command)
|
||||
c := &cmd{
|
||||
ID: idof(cron, command),
|
||||
Cron: cron,
|
||||
Cmd: command,
|
||||
}
|
||||
err := registercmd(ctx.Event.SelfID, c)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnRegex(`^记录以"(.*)"触发的代表我执行的指令$`, zero.SuperUserPermission, islonotnil, isfirstregmatchnotnil, logevent).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := "sm:" + ctx.State["regex_matched"].([]string)[1]
|
||||
command := ctx.State["job_raw_event"].(string)
|
||||
logrus.Debugln("[job] get cmd:", command)
|
||||
c := &cmd{
|
||||
ID: idof(cron, command),
|
||||
Cron: cron,
|
||||
Cmd: command,
|
||||
}
|
||||
err := registercmd(ctx.Event.SelfID, c)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnRegex(`^取消在"(.*)"触发的指令$`, ctxext.UserOrGrpAdmin, islonotnil, isfirstregmatchnotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
err := rmcmd(ctx.Event.SelfID, ctx.Event.UserID, cron)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnRegex(`^取消以"(.*)"触发的(代表我执行的)?指令$`, zero.SuperUserPermission, islonotnil, isfirstregmatchnotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
issu := ctx.State["regex_matched"].([]string)[2] != ""
|
||||
cron := ""
|
||||
if issu {
|
||||
cron = "sm:"
|
||||
} else {
|
||||
cron = "fm:"
|
||||
}
|
||||
cron += ctx.State["regex_matched"].([]string)[1]
|
||||
err := delcmd(ctx.Event.SelfID, cron)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnFullMatch("查看所有触发指令", zero.SuperUserPermission, islonotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c := &cmd{}
|
||||
ids := strconv.FormatInt(ctx.Event.SelfID, 36)
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, err := db.Count(ids)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
lst := make([]string, 0, n)
|
||||
err = db.FindFor(ids, c, "GROUP BY cron", func() error {
|
||||
lst = append(lst, c.Cron+"\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(lst))
|
||||
})
|
||||
en.OnRegex(`^查看在"(.*)"触发的指令$`, zero.SuperUserPermission, islonotnil, isfirstregmatchnotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c := &cmd{}
|
||||
ids := strconv.FormatInt(ctx.Event.SelfID, 36)
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, err := db.Count(ids)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
lst := make([]string, 0, n)
|
||||
err = db.FindFor(ids, c, "WHERE cron='"+cron+"'", func() error {
|
||||
lst = append(lst, c.Cmd+"\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(lst))
|
||||
})
|
||||
en.OnRegex(`^查看以"(.*)"触发的(代表我执行的)?指令$`, zero.SuperUserPermission, islonotnil, isfirstregmatchnotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c := &cmd{}
|
||||
ids := strconv.FormatInt(ctx.Event.SelfID, 36)
|
||||
issu := ctx.State["regex_matched"].([]string)[2] != ""
|
||||
cron := ""
|
||||
if issu {
|
||||
cron = "sm:"
|
||||
} else {
|
||||
cron = "fm:"
|
||||
}
|
||||
cron += ctx.State["regex_matched"].([]string)[1]
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, err := db.Count(ids)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
lst := make([]string, 0, n)
|
||||
err = db.FindFor(ids, c, "WHERE cron='"+cron+"'", func() error {
|
||||
lst = append(lst, c.Cmd+"\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(lst))
|
||||
})
|
||||
en.OnPrefix("执行指令:", ctxext.UserOrGrpAdmin, islonotnil, func(ctx *zero.Ctx) bool {
|
||||
return ctx.State["args"].(string) != ""
|
||||
}, parseArgs).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
ev := strings.ReplaceAll(ctx.Event.RawEvent.Raw, "执行指令:", "")
|
||||
logrus.Debugln("[job] inject:", ev)
|
||||
inject(ctx.Event.SelfID, binary.StringToBytes(ev))()
|
||||
})
|
||||
en.OnPrefix("注入指令结果:", ctxext.UserOrGrpAdmin, islonotnil, func(ctx *zero.Ctx) bool {
|
||||
return ctx.State["args"].(string) != ""
|
||||
}, parseArgs).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
vevent.NewLoopOf(vevent.NewAPICallerHook(ctx, func(rsp zero.APIResponse, err error) {
|
||||
if err == nil {
|
||||
logrus.Debugln("[job] CallerHook returned")
|
||||
id := message.NewMessageID(rsp.Data.Get("message_id").String())
|
||||
if id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:未获取到返回结果"))
|
||||
return
|
||||
}
|
||||
msg := ctx.GetMessage(id)
|
||||
ctx.Event.NativeMessage = json.RawMessage("\"" + msg.Elements.String() + "\"")
|
||||
ctx.Event.RawMessageID = json.RawMessage(msg.MessageId.String())
|
||||
ctx.Event.RawMessage = msg.Elements.String()
|
||||
time.Sleep(time.Second * 5) // 防止风控
|
||||
ctx.Event.Time = time.Now().Unix()
|
||||
ctx.DeleteMessage(id)
|
||||
vev, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
err = json.NewEncoder(w).Encode(ctx.Event)
|
||||
})
|
||||
if err != nil {
|
||||
cl()
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[job] inject:", binary.BytesToString(vev))
|
||||
inject(ctx.Event.SelfID, vev)()
|
||||
cl()
|
||||
}
|
||||
})).Echo(binary.StringToBytes(strings.ReplaceAll(ctx.Event.RawEvent.Raw, "注入指令结果:", "")))
|
||||
})
|
||||
}
|
||||
|
||||
func islonotnil(ctx *zero.Ctx) bool {
|
||||
return len(lo) > 0
|
||||
}
|
||||
|
||||
func isfirstregmatchnotnil(ctx *zero.Ctx) bool {
|
||||
return ctx.State["regex_matched"].([]string)[1] != ""
|
||||
}
|
||||
|
||||
func inject(bot int64, response []byte) func() {
|
||||
return func() {
|
||||
if limit.Acquire() {
|
||||
lo[bot].Echo(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func idof(cron, cmd string) int64 {
|
||||
return int64(crc64.Checksum(binary.StringToBytes(cron+cmd), crc64.MakeTable(crc64.ISO)))
|
||||
}
|
||||
|
||||
func addcmd(bot int64, c *cmd) error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
eid, err := process.CronTab.AddFunc(c.Cron, inject(bot, []byte(c.Cmd)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
entries[c.ID] = eid
|
||||
return db.Insert(strconv.FormatInt(bot, 36), c)
|
||||
}
|
||||
|
||||
func registercmd(bot int64, c *cmd) error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
m := en.OnFullMatch(c.Cron[3:] /* skip fm: or sm: */).SetBlock(true)
|
||||
if strings.HasPrefix(c.Cron, "sm:") {
|
||||
m.Handle(superuserhandler(c))
|
||||
} else {
|
||||
m.Handle(generalhandler(c))
|
||||
}
|
||||
matchers[c.ID] = getmatcher(m)
|
||||
return db.Insert(strconv.FormatInt(bot, 36), c)
|
||||
}
|
||||
|
||||
func generalhandler(c *cmd) zero.Handler {
|
||||
return func(ctx *zero.Ctx) {
|
||||
ctx.Event.NativeMessage = json.RawMessage(c.Cmd) // c.Cmd only have message
|
||||
ctx.Event.Time = time.Now().Unix()
|
||||
var err error
|
||||
vev, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
err = json.NewEncoder(w).Encode(ctx.Event)
|
||||
})
|
||||
if err != nil {
|
||||
cl()
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[job] inject:", binary.BytesToString(vev))
|
||||
inject(ctx.Event.SelfID, vev)()
|
||||
cl()
|
||||
}
|
||||
}
|
||||
|
||||
func superuserhandler(c *cmd) zero.Handler {
|
||||
e := &zero.Event{Sender: new(zero.User)}
|
||||
err := json.Unmarshal(binary.StringToBytes(c.Cmd), e)
|
||||
return func(ctx *zero.Ctx) {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.Event.UserID = e.UserID
|
||||
ctx.Event.RawMessage = e.RawMessage
|
||||
ctx.Event.Sender = e.Sender
|
||||
ctx.Event.NativeMessage = e.NativeMessage
|
||||
vev, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
err = json.NewEncoder(w).Encode(ctx.Event)
|
||||
})
|
||||
if err != nil {
|
||||
cl()
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[job] inject:", binary.BytesToString(vev))
|
||||
inject(ctx.Event.SelfID, vev)()
|
||||
cl()
|
||||
}
|
||||
}
|
||||
|
||||
func rmcmd(bot, caller int64, cron string) error {
|
||||
c := &cmd{}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
bots := strconv.FormatInt(bot, 36)
|
||||
e := new(zero.Event)
|
||||
var delcmd []string
|
||||
err := db.FindFor(bots, c, "WHERE cron='"+cron+"'", func() error {
|
||||
err := json.Unmarshal(binary.StringToBytes(c.Cmd), e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if e.UserID != caller {
|
||||
return nil
|
||||
}
|
||||
eid, ok := entries[c.ID]
|
||||
if ok {
|
||||
process.CronTab.Remove(eid)
|
||||
delete(entries, c.ID)
|
||||
delcmd = append(delcmd, "id="+strconv.FormatInt(c.ID, 10))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(delcmd) > 0 {
|
||||
return db.Del(bots, "WHERE "+strings.Join(delcmd, " or "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func delcmd(bot int64, cron string) error {
|
||||
c := &cmd{}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
bots := strconv.FormatInt(bot, 36)
|
||||
var delcmd []string
|
||||
err := db.FindFor(bots, c, "WHERE cron='"+cron+"'", func() error {
|
||||
m, ok := matchers[c.ID]
|
||||
if ok {
|
||||
m.Delete()
|
||||
delete(matchers, c.ID)
|
||||
delcmd = append(delcmd, "id="+strconv.FormatInt(c.ID, 10))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(delcmd) > 0 {
|
||||
return db.Del(bots, "WHERE "+strings.Join(delcmd, " or "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseArgs(ctx *zero.Ctx) bool {
|
||||
cmds := ctx.State["args"].(string)
|
||||
if !strings.Contains(cmds, "?::") && !strings.Contains(cmds, "!::") {
|
||||
return true
|
||||
}
|
||||
args := make(map[int]string)
|
||||
for strings.Contains(ctx.Event.RawEvent.Raw, "?::") {
|
||||
start := strings.Index(ctx.Event.RawEvent.Raw, "?::")
|
||||
msgend := strings.Index(ctx.Event.RawEvent.Raw[start+3:], "::")
|
||||
if msgend < 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的::"))
|
||||
return false
|
||||
}
|
||||
msgend += start + 3
|
||||
numend := strings.Index(ctx.Event.RawEvent.Raw[msgend+2:], "!")
|
||||
if numend <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的!"))
|
||||
return false
|
||||
}
|
||||
numend += msgend + 2
|
||||
logrus.Debugln("[job]", start, msgend, numend)
|
||||
msg := ctx.Event.RawEvent.Raw[start+3 : msgend]
|
||||
arg, err := strconv.Atoi(ctx.Event.RawEvent.Raw[msgend+2 : numend])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
arr, ok := args[arg]
|
||||
if !ok {
|
||||
var id message.MessageID
|
||||
if msg == "" {
|
||||
id = ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入参数", arg))
|
||||
} else {
|
||||
id = ctx.SendChain(message.At(ctx.Event.UserID), message.Text("[", arg, "] ", msg))
|
||||
}
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.Send(message.ReplyWithMessage(id, message.Text("参数读取超时")))
|
||||
if msg[0] != '?' {
|
||||
return false
|
||||
}
|
||||
case e := <-zero.NewFutureEvent("message", 0, true, zero.CheckUser(ctx.Event.UserID)).Next():
|
||||
args[arg] = e.Message.String()
|
||||
arr = args[arg]
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Reply(e.MessageID), message.Text("已记录"))
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
}
|
||||
ctx.Event.RawEvent.Raw = ctx.Event.RawEvent.Raw[:start] + arr + ctx.Event.RawEvent.Raw[numend+1:]
|
||||
}
|
||||
args = make(map[int]string)
|
||||
for strings.Contains(ctx.Event.RawEvent.Raw, "!::") {
|
||||
start := strings.Index(ctx.Event.RawEvent.Raw, "!::")
|
||||
msgend := strings.Index(ctx.Event.RawEvent.Raw[start+3:], "::")
|
||||
if msgend < 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的::"))
|
||||
return false
|
||||
}
|
||||
msgend += start + 3
|
||||
numend := strings.Index(ctx.Event.RawEvent.Raw[msgend+2:], "!")
|
||||
if numend <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的!"))
|
||||
return false
|
||||
}
|
||||
numend += msgend + 2
|
||||
logrus.Debugln("[job]", start, msgend, numend)
|
||||
u := ctx.Event.RawEvent.Raw[start+3 : msgend]
|
||||
if u == "" {
|
||||
return false
|
||||
}
|
||||
arg, err := strconv.Atoi(ctx.Event.RawEvent.Raw[msgend+2 : numend])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
arr, ok := args[arg]
|
||||
if !ok {
|
||||
isnilable := u[0] == '?'
|
||||
if isnilable {
|
||||
u = u[1:]
|
||||
if u == "" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
b, err := web.GetData(u)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
if !isnilable {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if len(b) > 0 {
|
||||
type fakejson struct {
|
||||
Arg string `json:"arg"`
|
||||
}
|
||||
f := fakejson{Arg: binary.BytesToString(b)}
|
||||
w := binary.SelectWriter()
|
||||
defer binary.PutWriter(w)
|
||||
json.NewEncoder(w).Encode(&f)
|
||||
arr = w.String()[8 : w.Len()-3]
|
||||
args[arg] = arr
|
||||
}
|
||||
}
|
||||
w := binary.SelectWriter()
|
||||
w.WriteString(ctx.Event.RawEvent.Raw[:start])
|
||||
w.WriteString(arr)
|
||||
w.WriteString(ctx.Event.RawEvent.Raw[numend+1:])
|
||||
ctx.Event.RawEvent.Raw = string(w.Bytes())
|
||||
binary.PutWriter(w)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func logevent(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("您的下一条指令将被记录,在", ctx.State["regex_matched"].([]string)[1], "时触发"))
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Text("指令记录超时"))
|
||||
return false
|
||||
case e := <-zero.NewFutureEvent("message", 0, true, zero.CheckUser(ctx.Event.UserID)).Next():
|
||||
ctx.State["job_raw_event"] = e.RawEvent.Raw
|
||||
ctx.State["job_new_event"] = e.RawEvent
|
||||
return true
|
||||
}
|
||||
}
|
||||
16
plugin/job/matcher.go
Normal file
16
plugin/job/matcher.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
)
|
||||
|
||||
type matcherinstance struct {
|
||||
m *zero.Matcher
|
||||
}
|
||||
|
||||
func getmatcher(m control.Matcher) *zero.Matcher {
|
||||
return (*matcherinstance)(unsafe.Pointer(&m)).m
|
||||
}
|
||||
11
plugin/job/model.go
Normal file
11
plugin/job/model.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package job
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type cmd struct {
|
||||
ID int64 `db:"id"`
|
||||
Cron string `db:"cron"`
|
||||
Cmd string `db:"cmd"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
@@ -6,17 +6,16 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,19 +24,12 @@ const (
|
||||
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", order.PrioJueJueZi, &control.Options{
|
||||
control.Register("juejuezi", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "绝绝子生成器\n" +
|
||||
"- 喝奶茶绝绝子 | 绝绝子吃饭",
|
||||
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).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:
|
||||
@@ -11,12 +11,13 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,11 +30,11 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("lolicon", order.PrioLolicon, &control.Options{
|
||||
control.Register("lolicon", order.AcquirePrio(), &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++ {
|
||||
@@ -56,9 +57,10 @@ func init() {
|
||||
url := json.Get("data.0.urls.original").Str
|
||||
url = strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")
|
||||
name := url[strings.LastIndex(url, "/")+1 : len(url)-4]
|
||||
m, err := imgpool.GetImage(ctx, name)
|
||||
if err != nil {
|
||||
m, err = imgpool.NewImage(ctx, name, url)
|
||||
m, err := pool.GetImage(name)
|
||||
if err != nil && err != pool.ErrImgFileAsync {
|
||||
m.SetFile(url)
|
||||
_, err = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
if err == nil {
|
||||
@@ -69,10 +71,16 @@ func init() {
|
||||
}
|
||||
}()
|
||||
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))
|
||||
case img := <-queue:
|
||||
id := ctx.SendChain(message.Image(img))
|
||||
if id.ID() == 0 {
|
||||
id = ctx.SendChain(message.Image(img).Add("cache", "0"))
|
||||
if id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:图片发送失败,可能被风控了~"))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package manager
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -12,23 +11,21 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/manager/timer"
|
||||
)
|
||||
|
||||
const (
|
||||
datapath = "data/manager/"
|
||||
confile = datapath + "config.db"
|
||||
hint = "====群管====\n" +
|
||||
hint = "====群管====\n" +
|
||||
"- 禁言@QQ 1分钟\n" +
|
||||
"- 解除禁言 @QQ\n" +
|
||||
"- 我要自闭 1分钟\n" +
|
||||
@@ -51,25 +48,25 @@ const (
|
||||
"- 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 设置欢迎语XXX\n" +
|
||||
"- 设置欢迎语XXX(可加{at}在欢迎时@对方)\n" +
|
||||
"- 测试欢迎语\n" +
|
||||
"- [开启 | 关闭]入群验证"
|
||||
)
|
||||
|
||||
var (
|
||||
db = &sql.Sqlite{DBPath: confile}
|
||||
limit = rate.NewManager(time.Minute*5, 2)
|
||||
db = &sql.Sqlite{}
|
||||
clock timer.Clock
|
||||
)
|
||||
|
||||
var engine = control.Register("manager", order.PrioManager, &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: hint,
|
||||
})
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("manager", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: hint,
|
||||
PrivateDataFolder: "manager",
|
||||
})
|
||||
|
||||
go func() {
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(datapath, 0755)
|
||||
db.DBPath = engine.DataFolder() + "config.db"
|
||||
clock = timer.NewClock(db)
|
||||
err := db.Create("welcome", &welcome{})
|
||||
if err != nil {
|
||||
@@ -80,6 +77,7 @@ func init() { // 插件主体
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
// 升为管理
|
||||
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -212,6 +210,10 @@ func init() { // 插件主体
|
||||
// 修改名片
|
||||
engine.OnRegex(`^修改名片.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if len(ctx.State["regex_matched"].([]string)[2]) > 60 {
|
||||
ctx.SendChain(message.Text("名字太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupCard(
|
||||
ctx.Event.GroupID,
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人
|
||||
@@ -222,6 +224,10 @@ func init() { // 插件主体
|
||||
// 修改头衔
|
||||
engine.OnRegex(`^修改头衔.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if len(ctx.State["regex_matched"].([]string)[1]) > 18 {
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人
|
||||
@@ -232,6 +238,10 @@ func init() { // 插件主体
|
||||
// 申请头衔
|
||||
engine.OnRegex(`^申请头衔(.*)`, zero.OnlyGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if len(ctx.State["regex_matched"].([]string)[1]) > 18 {
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
ctx.Event.UserID, // 被修改群头衔的人
|
||||
@@ -332,12 +342,8 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text(clock.ListTimers(ctx.Event.GroupID)))
|
||||
})
|
||||
// 随机点名
|
||||
engine.OnFullMatchGroup([]string{"翻牌"}, zero.OnlyGroup).SetBlock(true).
|
||||
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,
|
||||
@@ -348,7 +354,6 @@ func init() { // 插件主体
|
||||
return temp[i].Get("last_sent_time").Int() < temp[j].Get("last_sent_time").Int()
|
||||
})
|
||||
temp = temp[math.Max(0, len(temp)-10):]
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
who := temp[rand.Intn(len(temp))]
|
||||
if who.Get("user_id").Int() == ctx.Event.SelfID {
|
||||
ctx.SendChain(message.Text("幸运儿居然是我自己"))
|
||||
@@ -376,7 +381,7 @@ func init() { // 插件主体
|
||||
var w welcome
|
||||
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text(w.Msg))
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]")))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("欢迎~"))
|
||||
}
|
||||
@@ -443,6 +448,17 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("出错啦: ", err))
|
||||
}
|
||||
})
|
||||
// 测试欢迎语
|
||||
engine.OnFullMatch("测试欢迎语", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var w welcome
|
||||
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(strings.ReplaceAll(w.Msg, "{at}", "[CQ:at,qq="+strconv.FormatInt(ctx.Event.UserID, 10)+"]")))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("欢迎~"))
|
||||
}
|
||||
})
|
||||
// 入群后验证开关
|
||||
engine.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -496,11 +512,8 @@ func init() { // 插件主体
|
||||
// 运行 CQ 码
|
||||
engine.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var cmd = ctx.State["regex_matched"].([]string)[1]
|
||||
cmd = strings.ReplaceAll(cmd, "[", "[")
|
||||
cmd = strings.ReplaceAll(cmd, "]", "]")
|
||||
// 可注入,权限为主人
|
||||
ctx.Send(cmd)
|
||||
ctx.Send(message.UnescapeCQCodeText(ctx.State["regex_matched"].([]string)[1]))
|
||||
})
|
||||
// 根据 gist 自动同意加群
|
||||
// 加群请在github新建一个gist,其文件名为本群群号的字符串的md5(小写),内容为一行,是当前unix时间戳(10分钟内有效)。
|
||||
@@ -1,7 +1,7 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
// Timer 计时器
|
||||
@@ -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 时钟
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -8,11 +8,10 @@ import (
|
||||
reg "github.com/fumiama/go-registry"
|
||||
)
|
||||
|
||||
var sr = reg.NewRegedit("reilia.fumiama.top:32664", "fumiama", "--")
|
||||
var sr = reg.NewRegedit("reilia.westeurope.cloudapp.azure.com:32664", "fumiama", "--")
|
||||
|
||||
func TestGetHoliday(t *testing.T) {
|
||||
registry.Connect()
|
||||
holidaymap = make(map[string]*Holiday)
|
||||
h := GetHoliday("元旦")
|
||||
registry.Close()
|
||||
t.Fatal(h)
|
||||
@@ -28,7 +27,7 @@ func TestSetHoliday(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("春节", 7, 2022, 1, 31)
|
||||
err = SetHoliday("春节", 7, 2023, 1, 21)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -21,29 +21,20 @@ func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday
|
||||
return &Holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24}
|
||||
}
|
||||
|
||||
var (
|
||||
registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
holidaymap map[string]*Holiday
|
||||
)
|
||||
var registry = reg.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
|
||||
// GetHoliday 从 reg 服务器获取节日
|
||||
func GetHoliday(name string) *Holiday {
|
||||
var dur, year int
|
||||
var month time.Month
|
||||
var day int
|
||||
h, ok := holidaymap[name]
|
||||
if ok {
|
||||
return h
|
||||
}
|
||||
ret, err := registry.Get("holiday/" + name)
|
||||
if err != nil {
|
||||
return NewHoliday(name+err.Error(), 0, 0, 0, 0)
|
||||
}
|
||||
fmt.Sscanf(ret, "%d_%d_%d_%d", &dur, &year, &month, &day)
|
||||
logrus.Debugln("[moyu]获取节日:", name, dur, year, month, day)
|
||||
h = NewHoliday(name, dur, year, month, day)
|
||||
holidaymap[name] = h
|
||||
return h
|
||||
return NewHoliday(name, dur, year, month, day)
|
||||
}
|
||||
|
||||
// String 获取两个时间相差
|
||||
69
plugin/moyu/run.go
Normal file
69
plugin/moyu/run.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Package moyu 摸鱼
|
||||
package moyu
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
control.Register("moyu", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "moyu\n" +
|
||||
"- /启用 moyu\n" +
|
||||
"- /禁用 moyu",
|
||||
})
|
||||
|
||||
// 定时任务每天10点执行一次
|
||||
_, err := process.CronTab.AddFunc("0 10 * * *", func() { sendNotice() })
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据拼接消息链并发送
|
||||
func sendNotice() {
|
||||
m, ok := control.Lookup("moyu")
|
||||
if ok {
|
||||
if registry.Connect() != nil {
|
||||
return
|
||||
}
|
||||
msg := message.Message{
|
||||
message.Text(time.Now().Format("2006-01-02")),
|
||||
message.Text("上午好,摸鱼人!\n工作再累,一定不要忘记摸鱼哦!有事没事起身去茶水间,去厕所,去廊道走走别老在工位上坐着,钱是老板的,但命是自己的。\n"),
|
||||
message.Text(weekend()),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("元旦")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("春节")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("清明节")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("劳动节")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("端午节")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("中秋节")),
|
||||
message.Text("\n"),
|
||||
message.Text(GetHoliday("国庆节")),
|
||||
message.Text("\n"),
|
||||
message.Text("上班是帮老板赚钱,摸鱼是赚老板的钱!最后,祝愿天下所有摸鱼人,都能愉快的渡过每一天…"),
|
||||
}
|
||||
_ = registry.Close()
|
||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
||||
for _, g := range ctx.GetGroupList().Array() {
|
||||
grp := g.Get("group_id").Int()
|
||||
if m.IsEnabledIn(grp) {
|
||||
ctx.SendGroupMessage(grp, msg)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
226
plugin/moyu_calendar/calendar.go
Normal file
226
plugin/moyu_calendar/calendar.go
Normal file
@@ -0,0 +1,226 @@
|
||||
// Package moyucalendar 摸鱼人日历
|
||||
package moyucalendar
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
xpath "github.com/antchfx/htmlquery"
|
||||
)
|
||||
|
||||
var ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
|
||||
var weixin = regexp.MustCompile(`url \+= '(.+)';`)
|
||||
|
||||
var client = &http.Client{}
|
||||
|
||||
func init() {
|
||||
control.Register("moyucalendar", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "摸鱼人日历\n" +
|
||||
"- /启用 moyucalendar\n" +
|
||||
"- /禁用 moyucalendar",
|
||||
}).OnFullMatch("摸鱼人日历").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
title := fmt.Sprintf("摸鱼人日历 %d月%d日", time.Now().Month(), time.Now().Day())
|
||||
sg, cookies, err := sougou(title, "摸鱼人日历", ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
wx, err := redirect(sg, cookies, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
image, err := calendar(wx, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(image))
|
||||
})
|
||||
|
||||
// 定时任务每天8点30分执行一次
|
||||
_, err := process.CronTab.AddFunc("30 8 * * *", func() {
|
||||
m, ok := control.Lookup("moyucalendar")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
title := fmt.Sprintf("摸鱼人日历 %d月%d日", time.Now().Month(), time.Now().Day())
|
||||
sg, cookies, err := sougou(title, "摸鱼人日历", ua)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
wx, err := redirect(sg, cookies, ua)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
image, err := calendar(wx, ua)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
||||
for _, g := range ctx.GetGroupList().Array() {
|
||||
grp := g.Get("group_id").Int()
|
||||
if m.IsEnabledIn(grp) {
|
||||
ctx.SendGroupMessage(grp, message.Message{message.Image(image)})
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func sougou(title, publisher, ua string) (string, []*http.Cookie, error) {
|
||||
u, _ := url.Parse("https://weixin.sogou.com/weixin")
|
||||
u.RawQuery = url.Values{
|
||||
"type": []string{"2"},
|
||||
"s_from": []string{"input"},
|
||||
"query": []string{title},
|
||||
}.Encode()
|
||||
req, err := http.NewRequest("GET", u.String(), nil)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
req.Header.Set("User-Agent", ua)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", nil, errors.New("status not ok")
|
||||
}
|
||||
// 解析XPATH
|
||||
doc, err := xpath.Parse(resp.Body)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
// 取出每个返回的结果
|
||||
list := xpath.Find(doc, `//*[@class="news-list"]/li/div[@class="txt-box"]`)
|
||||
if len(list) == 0 {
|
||||
return "", nil, errors.New("sougou result not found")
|
||||
}
|
||||
var match string
|
||||
for i := range list {
|
||||
account := xpath.FindOne(list[i], `//div[@class="s-p"]/a[@class="account"]`)
|
||||
if account == nil {
|
||||
continue
|
||||
}
|
||||
if xpath.InnerText(account) != publisher {
|
||||
continue
|
||||
}
|
||||
target := xpath.FindOne(list[i], `//h3/a[@target="_blank"]`)
|
||||
if target == nil {
|
||||
continue
|
||||
}
|
||||
match = xpath.SelectAttr(target, "href")
|
||||
break
|
||||
}
|
||||
if match == "" {
|
||||
return "", nil, errors.New("sougou result not found")
|
||||
}
|
||||
return "https://weixin.sogou.com" + match, resp.Cookies(), nil
|
||||
}
|
||||
|
||||
func redirect(link string, cookies []*http.Cookie, ua string) (string, error) {
|
||||
req, err := http.NewRequest("GET", link, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
req.Header.Set("User-Agent", ua)
|
||||
var c = make([]string, 0, 4)
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name != "ABTEST" && cookie.Name != "SNUID" &&
|
||||
cookie.Name != "IPLOC" && cookie.Name != "SUID" {
|
||||
continue
|
||||
}
|
||||
c = append(c, cookie.Name+"="+cookie.Value)
|
||||
}
|
||||
req.Header.Set("Cookie", strings.Join(c, "; "))
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", errors.New("status not ok")
|
||||
}
|
||||
br := bufio.NewReader(resp.Body)
|
||||
var u = make([]string, 0)
|
||||
for {
|
||||
b, _, err := br.ReadLine()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
matcha := weixin.FindStringSubmatch(string(b))
|
||||
if len(matcha) < 2 {
|
||||
continue
|
||||
}
|
||||
u = append(u, strings.ReplaceAll(matcha[1], "@", ""))
|
||||
}
|
||||
if len(u) == 0 {
|
||||
return "", errors.New("weixin url not found")
|
||||
}
|
||||
return strings.Join(u, ""), nil
|
||||
}
|
||||
|
||||
func calendar(link, ua string) (string, error) {
|
||||
req, err := http.NewRequest("GET", link, nil)
|
||||
req.Header.Set("User-Agent", ua)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", errors.New("status not ok")
|
||||
}
|
||||
doc, err := xpath.Parse(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
html := xpath.OutputHTML(doc, false)
|
||||
if !strings.Contains(html, time.Now().Format("2006-01-02")) {
|
||||
return "", errors.New("calendar not today")
|
||||
}
|
||||
images := xpath.Find(doc, `//*[@id="js_content"]/p/img`)
|
||||
if images == nil {
|
||||
return "", errors.New("calendar not found")
|
||||
}
|
||||
var image string
|
||||
for i := range images {
|
||||
if xpath.SelectAttr(images[i], "data-w") != "540" {
|
||||
continue
|
||||
}
|
||||
image = xpath.SelectAttr(images[i], "data-src")
|
||||
break
|
||||
}
|
||||
if image == "" {
|
||||
return "", errors.New("image not found")
|
||||
}
|
||||
return image, nil
|
||||
}
|
||||
@@ -12,30 +12,24 @@ import (
|
||||
"time"
|
||||
|
||||
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"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var limit = rate.NewManager(time.Minute*3, 5)
|
||||
|
||||
func init() {
|
||||
control.Register("music", order.PrioMusic, &control.Options{
|
||||
control.Register("music", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "点歌\n" +
|
||||
"- 点歌[xxx]\n" +
|
||||
"- 网易点歌[xxx]\n" +
|
||||
"- 酷我点歌[xxx]\n" +
|
||||
"- 酷狗点歌[xxx]",
|
||||
}).OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).
|
||||
}).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 "酷我":
|
||||
@@ -5,16 +5,15 @@ import (
|
||||
"image"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/corona10/goimagehash"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
_ "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"
|
||||
)
|
||||
|
||||
// setuclass holds setus in a folder, which is the class name.
|
||||
@@ -24,44 +23,31 @@ 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{}}
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
process.SleepAbout1sTo2s()
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if file.IsExist(cfgfile) {
|
||||
b, err := os.ReadFile(cfgfile)
|
||||
if err == nil {
|
||||
setupath = helper.BytesToString(b)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
type nsetu struct {
|
||||
db *sql.Sqlite
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func scanall(path string) error {
|
||||
setuclasses = nil
|
||||
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
|
||||
@@ -69,12 +55,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
|
||||
@@ -86,17 +71,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 {
|
||||
@@ -112,10 +101,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
|
||||
}
|
||||
@@ -10,16 +10,11 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/rule"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
|
||||
const (
|
||||
datapath = "data/nsetu"
|
||||
dbfile = datapath + "/data.db"
|
||||
cfgfile = datapath + "/setupath.txt"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -27,7 +22,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("nativesetu", order.PrioNativeSetu, &control.Options{
|
||||
engine := control.Register("nativesetu", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "本地涩图\n" +
|
||||
"- 本地[xxx]\n" +
|
||||
@@ -35,25 +30,44 @@ func init() {
|
||||
"- 设置本地setu绝对路径[xxx]\n" +
|
||||
"- 刷新所有本地setu\n" +
|
||||
"- 所有本地setu分类",
|
||||
PrivateDataFolder: "nsetu",
|
||||
})
|
||||
engine.OnRegex(`^本地(.*)$`, func(ctx *zero.Ctx) bool { return rule.FirstValueInList(setuclasses)(ctx) }).SetBlock(true).
|
||||
|
||||
ns.db.DBPath = engine.DataFolder() + "data.db"
|
||||
cfgfile := engine.DataFolder() + "setupath.txt"
|
||||
if file.IsExist(cfgfile) {
|
||||
b, err := os.ReadFile(cfgfile)
|
||||
if err == nil {
|
||||
setupath = helper.BytesToString(b)
|
||||
logrus.Println("[nsetu] set setu dir to", setupath)
|
||||
}
|
||||
}
|
||||
|
||||
engine.OnRegex(`^本地(.*)$`, ctxext.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 {
|
||||
p := "file:///" + setupath + "/" + sc.Path
|
||||
if ctx.Event.GroupID != 0 {
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID, message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p),
|
||||
)})
|
||||
return
|
||||
}
|
||||
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).
|
||||
engine.OnRegex(`^刷新本地(.*)$`, ctxext.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 {
|
||||
@@ -72,7 +86,7 @@ func init() {
|
||||
})
|
||||
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 {
|
||||
@@ -82,9 +96,9 @@ func init() {
|
||||
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 {
|
||||
@@ -92,7 +106,7 @@ func init() {
|
||||
logrus.Errorln("[nsetu]", err)
|
||||
}
|
||||
}
|
||||
mu.RUnlock()
|
||||
ns.mu.RUnlock()
|
||||
ctx.SendChain(message.Text(msg))
|
||||
})
|
||||
}
|
||||
@@ -16,26 +16,21 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
const base = "data/nwife"
|
||||
|
||||
var baseuri = "file:///" + file.BOTPATH + "/" + base
|
||||
|
||||
func init() {
|
||||
err := os.MkdirAll(base, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
engine := control.Register("nwife", order.PrioNativeWife, &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
|
||||
engine := control.Register("nwife", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
|
||||
PrivateDataFolder: "nwife",
|
||||
})
|
||||
base := engine.DataFolder()
|
||||
baseuri := "file:///" + file.BOTPATH + "/" + base
|
||||
engine.OnPrefix("抽wife", zero.OnlyGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
grpf := strconv.FormatInt(ctx.Event.GroupID, 36)
|
||||
@@ -62,7 +57,7 @@ func init() {
|
||||
}
|
||||
})
|
||||
// 上传一张图
|
||||
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, ctxext.MustGiven).SetBlock(true).
|
||||
engine.OnPrefix("添加wife", zero.OnlyGroup, chkAddWifePermission, ctxext.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
name := ""
|
||||
for _, elem := range ctx.Event.Message {
|
||||
@@ -78,13 +73,13 @@ func init() {
|
||||
url := ctx.State["image_url"].([]string)[0]
|
||||
grpfolder := base + "/" + strconv.FormatInt(ctx.Event.GroupID, 36)
|
||||
if file.IsNotExist(grpfolder) {
|
||||
err = os.Mkdir(grpfolder, 0755)
|
||||
err := os.Mkdir(grpfolder, 0755)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("错误:", err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
err = file.DownloadTo(url, grpfolder+"/"+name, true)
|
||||
err := file.DownloadTo(url, grpfolder+"/"+name, true)
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功!"))
|
||||
} else {
|
||||
@@ -108,7 +103,7 @@ func init() {
|
||||
}
|
||||
if name != "" {
|
||||
grpfolder := base + "/" + strconv.FormatInt(ctx.Event.GroupID, 36)
|
||||
err = os.Remove(grpfolder + "/" + name)
|
||||
err := os.Remove(grpfolder + "/" + name)
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功!"))
|
||||
} else {
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("nbnhhsh", order.PrioNBNHHSH, &control.Options{
|
||||
control.Register("nbnhhsh", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "拼音首字母释义工具\n- ?? [缩写]",
|
||||
}).OnRegex(`^[??]{1,2} ?([a-z0-9]+)$`).SetBlock(false).
|
||||
@@ -9,20 +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"
|
||||
|
||||
ub "github.com/FloatTech/zbputils/binary"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,22 +37,14 @@ const (
|
||||
idReg = `/(\d+)/`
|
||||
)
|
||||
|
||||
var (
|
||||
gCurCookieJar *cookiejar.Jar
|
||||
engine = control.Register("novel", order.PrioNovel, &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "铅笔小说网搜索\n- 小说[xxx]",
|
||||
})
|
||||
limit = rate.NewManager(time.Minute, 5)
|
||||
)
|
||||
var gCurCookieJar *cookiejar.Jar
|
||||
|
||||
func init() {
|
||||
engine.OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
|
||||
control.Register("novel", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "铅笔小说网搜索\n- 小说[xxx]",
|
||||
}).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]
|
||||
@@ -70,7 +61,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]"))
|
||||
@@ -86,9 +77,9 @@ 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, txt2img.FontFile, 400, 20)
|
||||
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
log.Println("err:", err)
|
||||
}
|
||||
101
plugin/nsfw/main.go
Normal file
101
plugin/nsfw/main.go
Normal 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/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("nsfw", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "nsfw图片识别\n- nsfw打分[图片]",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
// 上传一张图进行评价
|
||||
engine.OnKeywordGroup([]string{"nsfw打分"}, zero.OnlyGroup, ctxext.MustProvidePicture).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.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: true,
|
||||
Help: "nsfw图片自动识别\n- 当图片属于非 neutral 类别时自动发送评价",
|
||||
})
|
||||
en.OnMessage(ctxext.IsPicExists).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)))
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
package omikuji
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
type kuji struct {
|
||||
ID uint8 `db:"id"`
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
// 返回一个解签
|
||||
func getKujiByBango(id uint8) string {
|
||||
var s kuji
|
||||
@@ -13,24 +13,38 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
bed = "https://gitcode.net/u011570312/senso-ji-omikuji/-/raw/main/%d_%d.jpg"
|
||||
)
|
||||
const bed = "https://gitcode.net/u011570312/senso-ji-omikuji/-/raw/main/%d_%d.jpg"
|
||||
|
||||
var (
|
||||
engine = control.Register("omikuji", order.PrioOmikuji, &control.Options{
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("omikuji", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "浅草寺求签\n" +
|
||||
"- 求签 | 占卜\n- 解签",
|
||||
})
|
||||
)
|
||||
PublicDataFolder: "Omikuji",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "kuji.db"
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("kuji", &kuji{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("kuji")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[kuji]读取%d条签文", n)
|
||||
}()
|
||||
|
||||
func init() { // 插件主体
|
||||
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
miku := bangoToday(ctx.Event.UserID)
|
||||
@@ -42,7 +56,7 @@ func init() { // 插件主体
|
||||
})
|
||||
engine.OnFullMatchGroup([]string{"解签"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
kujiBytes, err := txt2img.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), txt2img.FontFile, 400, 20)
|
||||
kujiBytes, err := text.RenderToBase64(getKujiByBango(bangoToday(ctx.Event.UserID)), text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
log.Errorln("[omikuji]:", err)
|
||||
}
|
||||
@@ -4,7 +4,13 @@ import (
|
||||
wr "github.com/mroth/weightedrand"
|
||||
)
|
||||
|
||||
type rate []struct {
|
||||
Name string `json:"name"`
|
||||
Weight float64 `json:"weight"`
|
||||
}
|
||||
|
||||
var (
|
||||
areac *wr.Chooser
|
||||
gender, _ = wr.NewChooser(
|
||||
wr.Choice{Item: "男孩子", Weight: 50707},
|
||||
wr.Choice{Item: "女孩子", Weight: 48292},
|
||||
16
plugin/reborn/load.go
Normal file
16
plugin/reborn/load.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package reborn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
// load 加载rate数据
|
||||
func load(area *rate, jsonfile string) error {
|
||||
data, err := file.GetLazyData(jsonfile, true, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(data, area)
|
||||
}
|
||||
50
plugin/reborn/main.go
Normal file
50
plugin/reborn/main.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Package reborn 投胎 来自 https://github.com/YukariChiba/tgbot/blob/main/modules/Reborn.py
|
||||
package reborn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
wr "github.com/mroth/weightedrand"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("reborn", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "投胎\n- reborn",
|
||||
PublicDataFolder: "Reborn",
|
||||
})
|
||||
go func() {
|
||||
datapath := en.DataFolder()
|
||||
jsonfile := datapath + "rate.json"
|
||||
area := make(rate, 226)
|
||||
err := load(&area, jsonfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
choices := make([]wr.Choice, len(area))
|
||||
for i, a := range area {
|
||||
choices[i].Item = a.Name
|
||||
choices[i].Weight = uint(a.Weight * 1e9)
|
||||
}
|
||||
areac, err = wr.NewChooser(choices...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[Reborn]读取%d个国家/地区", len(area))
|
||||
}()
|
||||
en.OnFullMatch("reborn").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if rand.Int31() > 1<<27 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("投胎成功!\n您出生在 %s, 是 %s。", randcoun(), randgen())))
|
||||
} else {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("投胎失败!\n您没能活到出生,祝您下次好运!"))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -10,17 +10,16 @@ import (
|
||||
"time"
|
||||
|
||||
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/FloatTech/zbputils/control/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!\";",
|
||||
@@ -94,7 +93,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("runcode", order.PrioRuncode, &control.Options{
|
||||
control.Register("runcode", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "在线代码运行: \n" +
|
||||
">runcode [language] [code block]\n" +
|
||||
@@ -105,41 +104,41 @@ 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).
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnRegex(`^>runcode(raw)?\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..."))
|
||||
israw := ctx.State["regex_matched"].([]string)[1] != ""
|
||||
language := ctx.State["regex_matched"].([]string)[2]
|
||||
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 := message.UnescapeCQText(ctx.State["regex_matched"].([]string)[3])
|
||||
switch block {
|
||||
case "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" {
|
||||
// 输出模板
|
||||
default:
|
||||
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),
|
||||
)
|
||||
// 运行成功
|
||||
if israw {
|
||||
ctx.SendChain(message.Text(output))
|
||||
} else {
|
||||
// 运行成功
|
||||
ctx.SendChain(
|
||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||
message.Text(output),
|
||||
@@ -3,35 +3,26 @@ package saucenao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/ascii2d"
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/AnimeAPI/ascii2d"
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||
"github.com/FloatTech/AnimeAPI/yandex"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
var (
|
||||
datapath = file.BOTPATH + "/data/saucenao/"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
_ = os.RemoveAll(datapath)
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
engine := control.Register("saucenao", order.PrioSauceNao, &control.Options{
|
||||
engine := control.Register("saucenao", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "搜图\n" +
|
||||
"- 以图搜图 | 搜索图片 | 以图识图[图片]\n" +
|
||||
@@ -51,32 +42,27 @@ func init() { // 插件主体
|
||||
if illust.Pid > 0 {
|
||||
name := strconv.FormatInt(illust.Pid, 10)
|
||||
var imgs message.Message
|
||||
for i, u := range illust.ImageUrls {
|
||||
for i := range illust.ImageUrls {
|
||||
f := file.BOTPATH + "/" + illust.Path(i)
|
||||
n := name + "_p" + strconv.Itoa(i)
|
||||
filepath := datapath + n
|
||||
f := ""
|
||||
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 = pixiv.Download(u, datapath, n)
|
||||
if err == nil {
|
||||
f = filepath
|
||||
}
|
||||
}
|
||||
if f != "" {
|
||||
m, err := imgpool.NewImage(ctx, n, f)
|
||||
var m *pool.Image
|
||||
if file.IsNotExist(f) {
|
||||
m, err = pool.GetImage(n)
|
||||
if err == nil {
|
||||
imgs = append(imgs, message.Image(m.String()))
|
||||
} else {
|
||||
imgs = append(imgs, message.Image("file:///"+f))
|
||||
continue
|
||||
}
|
||||
logrus.Debugln("[sausenao]开始下载", n)
|
||||
err1 := illust.DownloadToCache(i)
|
||||
if err != pool.ErrImgFileAsync && err1 == nil {
|
||||
m.SetFile(f)
|
||||
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||
}
|
||||
if err1 != nil {
|
||||
logrus.Debugln("[sausenao]下载err:", err1)
|
||||
}
|
||||
}
|
||||
imgs = append(imgs, message.Image("file:///"+f))
|
||||
}
|
||||
txt := message.Text(
|
||||
"标题:", illust.Title, "\n",
|
||||
@@ -97,7 +83,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
// 以图搜图
|
||||
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, ctxext.CmdMatch, ctxext.MustGiven).SetBlock(true).
|
||||
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, zero.OnlyGroup, ctxext.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 开始搜索图片
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
@@ -109,26 +95,26 @@ 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 {
|
||||
if result, err := yandex.Yandex(pic); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else {
|
||||
// 返回Ascii2d的结果
|
||||
ctx.SendChain(
|
||||
message.Text("也许是这个?"),
|
||||
message.Text(
|
||||
"大概是这个?", "\n",
|
||||
"\n",
|
||||
"标题:", result.Title, "\n",
|
||||
"插画ID:", result.Pid, "\n",
|
||||
"画师:", result.UserName, "\n",
|
||||
@@ -136,7 +122,32 @@ func init() { // 插件主体
|
||||
"直链:", "https://pixivel.moe/detail?id=", result.Pid,
|
||||
),
|
||||
)
|
||||
}
|
||||
// 不论结果如何都执行 ascii2d 搜索
|
||||
if result, err := ascii2d.Ascii2d(pic); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
} else {
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
for i := 0; i < len(result) && i < 5; i++ {
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s",
|
||||
result[i].Name,
|
||||
result[i].Type,
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
))),
|
||||
)
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
msg,
|
||||
).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
151
plugin/scale/main.go
Normal file
151
plugin/scale/main.go
Normal file
@@ -0,0 +1,151 @@
|
||||
// Package scale 叔叔的AI二次元图片放大
|
||||
package scale
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
_ "image/gif" // import gif decoding
|
||||
_ "image/jpeg" // import jpg decoding
|
||||
_ "image/png" // import png decoding
|
||||
|
||||
_ "golang.org/x/image/webp" // import webp decoding
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/nsfw"
|
||||
"github.com/FloatTech/AnimeAPI/scale"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("scale", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "叔叔的AI二次元图片放大\n- 放大图片[图片]",
|
||||
PrivateDataFolder: "scale",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
cachedir := engine.DataFolder()
|
||||
// 上传一张图进行评价
|
||||
engine.OnKeywordGroup([]string{"放大图片"}, zero.OnlyGroup, ctxext.MustProvidePicture, getPara).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
url := ctx.State["image_url"].([]string)
|
||||
if len(url) > 0 {
|
||||
datachan := make(chan []byte, 1)
|
||||
var errsub error
|
||||
go func() {
|
||||
var d []byte
|
||||
d, errsub = web.GetData(url[0])
|
||||
datachan <- d
|
||||
}()
|
||||
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
|
||||
}
|
||||
|
||||
data := <-datachan
|
||||
if errsub != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", errsub))
|
||||
return
|
||||
}
|
||||
im, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
px := im.Bounds().Size().X * im.Bounds().Size().Y
|
||||
paras := ctx.State["scale_paras"].([2]int)
|
||||
|
||||
if px > 512*512 {
|
||||
px = int(math.Pow(float64(px), 0.5) + 0.5)
|
||||
x := im.Bounds().Size().X * 512 / px
|
||||
y := im.Bounds().Size().Y * 512 / px
|
||||
ctx.SendChain(message.Text("图片", im.Bounds().Size().X, "x", im.Bounds().Size().Y, "过大,调整图片至", x, "x", y))
|
||||
im = img.Size(im, x, y).Im
|
||||
w := binary.SelectWriter()
|
||||
defer binary.PutWriter(w)
|
||||
_, err = writer.WriteTo(im, w)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
data, err = scale.Post(bytes.NewReader(w.Bytes()), paras[0], paras[1], 2)
|
||||
} else {
|
||||
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++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,13 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
_ "github.com/fumiama/sqlite3" // import sql
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/logoove/sqlite" // import sql
|
||||
)
|
||||
|
||||
// sdb 得分数据库
|
||||
var sdb *scoredb
|
||||
|
||||
// scoredb 分数数据库
|
||||
type scoredb gorm.DB
|
||||
|
||||
@@ -12,15 +12,16 @@ import (
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,15 +33,32 @@ const (
|
||||
SCOREMAX = 120
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("score", order.PrioScore, &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景",
|
||||
})
|
||||
levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
|
||||
)
|
||||
var levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
|
||||
|
||||
func init() {
|
||||
engine := control.Register("score", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景",
|
||||
PrivateDataFolder: "score",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
go func() {
|
||||
os.RemoveAll(cachePath)
|
||||
err := os.MkdirAll(cachePath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = file.GetLazyData(text.BoldFontFile, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = file.GetLazyData(text.FontFile, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sdb = initialize(engine.DataFolder() + "score.db")
|
||||
log.Println("[score]加载score数据库")
|
||||
}()
|
||||
engine.OnFullMatch("签到", zero.OnlyGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
@@ -71,6 +89,10 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = img.Limit(back, 1280, 720)
|
||||
|
||||
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
canvas.Clear()
|
||||
@@ -78,7 +100,7 @@ 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 {
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
@@ -86,7 +108,7 @@ func init() {
|
||||
canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2)
|
||||
canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2)
|
||||
nickName := ctxext.CardOrNickName(ctx, uid)
|
||||
if err = canvas.LoadFontFace(txt2img.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
@@ -118,18 +140,14 @@ func init() {
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", score, nextLevelScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
|
||||
f, err := os.Create(drawedFile)
|
||||
txtc := txt2img.TxtCanvas{Canvas: canvas}
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
canvasBase64, err := txtc.ToBase64()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + helper.BytesToString(canvasBase64)))
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
return
|
||||
}
|
||||
_, err = txtc.WriteTo(f)
|
||||
_, err = writer.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
@@ -185,12 +203,12 @@ func getLevel(count int) int {
|
||||
|
||||
func initPic(picFile string) {
|
||||
if file.IsNotExist(picFile) {
|
||||
data, err := web.ReqWith(backgroundURL, "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
picURL := gjson.Get(string(data), "pic").String()
|
||||
data, err = web.ReqWith(picURL, "GET", "", ua)
|
||||
data, err = web.GetDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
240
plugin/setutime/setu_geter.go
Normal file
240
plugin/setutime/setu_geter.go
Normal file
@@ -0,0 +1,240 @@
|
||||
// Package setutime 来份涩图
|
||||
package setutime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
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/img/pool"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
// Pools 图片缓冲池
|
||||
type imgpool struct {
|
||||
db *sql.Sqlite
|
||||
dbmu sync.RWMutex
|
||||
path string
|
||||
max int
|
||||
pool map[string][]*message.MessageSegment
|
||||
poolmu sync.Mutex
|
||||
}
|
||||
|
||||
func (p *imgpool) List() (l []string) {
|
||||
var err error
|
||||
p.dbmu.RLock()
|
||||
defer p.dbmu.RUnlock()
|
||||
l, err = p.db.ListTables()
|
||||
if err != nil {
|
||||
l = []string{"涩图", "二次元", "风景", "车万"}
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
var pool = &imgpool{
|
||||
db: &sql.Sqlite{},
|
||||
path: pixiv.CacheDir,
|
||||
max: 10,
|
||||
pool: make(map[string][]*message.MessageSegment),
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("setutime", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "涩图\n" +
|
||||
"- 来份[涩图/二次元/风景/车万]\n" +
|
||||
"- 添加[涩图/二次元/风景/车万][P站图片ID]\n" +
|
||||
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
|
||||
"- >setu status",
|
||||
PublicDataFolder: "SetuTime",
|
||||
})
|
||||
|
||||
go func() {
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
_, _ = 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.OnRegex(`^来份(.*)$`, ctxext.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("ERROR: 等待填充,请稍后再试......"))
|
||||
return
|
||||
}
|
||||
}
|
||||
// 从缓冲池里抽一张
|
||||
if id := ctx.SendChain(*pool.pop(imgtype)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
|
||||
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+)$`, ctxext.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]"}
|
||||
pool.dbmu.RLock()
|
||||
defer pool.dbmu.RUnlock()
|
||||
for _, imgtype := range pool.List() {
|
||||
num, err := pool.db.Count(imgtype)
|
||||
if err != nil {
|
||||
num = 0
|
||||
}
|
||||
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])
|
||||
}
|
||||
|
||||
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)
|
||||
var msg message.MessageSegment
|
||||
f := fileutil.BOTPATH + "/" + illust.Path(0)
|
||||
if err != nil {
|
||||
if fileutil.IsNotExist(f) {
|
||||
// 下载图片
|
||||
if err := illust.DownloadToCache(0); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
if err != imagepool.ErrImgFileAsync {
|
||||
m.SetFile(f)
|
||||
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||
}
|
||||
msg = message.Image("file:///" + f)
|
||||
} else {
|
||||
msg = message.Image(m.String())
|
||||
if ctxext.SendToSelf(ctx)(msg) == 0 {
|
||||
msg = msg.Add("cache", "0")
|
||||
}
|
||||
}
|
||||
p.poolmu.Lock()
|
||||
p.pool[imgtype] = append(p.pool[imgtype], &msg)
|
||||
p.poolmu.Unlock()
|
||||
}
|
||||
|
||||
func (p *imgpool) pop(imgtype string) (msg *message.MessageSegment) {
|
||||
p.poolmu.Lock()
|
||||
defer p.poolmu.Unlock()
|
||||
if p.size(imgtype) == 0 {
|
||||
return
|
||||
}
|
||||
msg = p.pool[imgtype][0]
|
||||
p.pool[imgtype] = p.pool[imgtype][1:]
|
||||
return
|
||||
}
|
||||
|
||||
// fill 补充池子
|
||||
func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) {
|
||||
times := math.Min(p.max-p.size(imgtype), 2)
|
||||
p.dbmu.RLock()
|
||||
defer p.dbmu.RUnlock()
|
||||
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 {
|
||||
p.dbmu.Lock()
|
||||
defer p.dbmu.Unlock()
|
||||
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
|
||||
}
|
||||
err = imagepool.SendImageFromPool(strconv.FormatInt(illust.Pid, 10)+"_p0", illust.Path(0), func() error {
|
||||
return illust.DownloadToCache(0)
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 添加插画到对应的数据库table
|
||||
if err := p.db.Insert(imgtype, illust); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *imgpool) remove(imgtype string, id int64) error {
|
||||
p.dbmu.Lock()
|
||||
defer p.dbmu.Unlock()
|
||||
return p.db.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id))
|
||||
}
|
||||
@@ -5,15 +5,13 @@ 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).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
|
||||
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -5,15 +5,13 @@ 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).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
|
||||
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -5,15 +5,13 @@ 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).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
|
||||
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -2,12 +2,9 @@
|
||||
package shadiao
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,10 +23,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("shadiao", order.PrioShaDiao, &control.Options{
|
||||
engine = control.Register("shadiao", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "沙雕app\n" +
|
||||
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
|
||||
})
|
||||
limit = rate.NewManager(time.Minute, 60)
|
||||
)
|
||||
@@ -6,15 +6,13 @@ 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).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
|
||||
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -23,11 +21,8 @@ func init() {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||
})
|
||||
|
||||
engine.OnFullMatch("渣我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
|
||||
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -8,15 +8,13 @@ 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).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
|
||||
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -2,29 +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"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
)
|
||||
|
||||
var (
|
||||
// 限制调用频率
|
||||
limit = rate.NewManager(time.Minute*5, 5)
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("shindan", order.PrioShinDan, &control.Options{
|
||||
engine := control.Register("shindan", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "shindan\n" +
|
||||
"- 今天是什么少女[@xxx]\n" +
|
||||
@@ -32,29 +24,25 @@ func init() {
|
||||
"- 卖萌[@xxx]\n" +
|
||||
"- 抽老婆[@xxx]",
|
||||
})
|
||||
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Handle(handle)
|
||||
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Handle(handle)
|
||||
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Handle(handle)
|
||||
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).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, txt2img.FontFile, 400, 20)
|
||||
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
log.Errorln("[shindan]:", err)
|
||||
}
|
||||
@@ -62,7 +50,7 @@ func handle(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
default:
|
||||
ctx.Send(text)
|
||||
ctx.Send(txt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
_ "github.com/fumiama/sqlite3" // use sql
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/logoove/sqlite" // use sql
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user