mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 23:30:20 +00:00
Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85f5fb2d87 | ||
|
|
8674c14754 | ||
|
|
6c2fc1b4c2 | ||
|
|
5d94980e7c | ||
|
|
9bed71a99f | ||
|
|
6faa2b65e2 | ||
|
|
98812b103e | ||
|
|
deb655de36 | ||
|
|
8d1c18cb4a | ||
|
|
88824126f7 | ||
|
|
68a9ecf995 | ||
|
|
57404b2dcd | ||
|
|
29705c63c9 | ||
|
|
5a854d9715 | ||
|
|
eb1cbeae3f | ||
|
|
b6246cfee6 | ||
|
|
0619000f9a | ||
|
|
01361781c8 | ||
|
|
3c03a308b3 | ||
|
|
7895e48420 | ||
|
|
ba15713b99 | ||
|
|
bd98fa3aed | ||
|
|
fce75a9475 | ||
|
|
7616d5759f | ||
|
|
ea2c81a9c7 | ||
|
|
37cff9ff31 | ||
|
|
b8d3d6af9b | ||
|
|
fdf90a72cc | ||
|
|
ba0c05a774 | ||
|
|
3250ec14ac | ||
|
|
ce2f390361 | ||
|
|
71434232fe | ||
|
|
852629fa2e | ||
|
|
f10676d16d | ||
|
|
d43ea7df1d | ||
|
|
21712c6299 | ||
|
|
2fc47a38fa | ||
|
|
cbb4408668 | ||
|
|
a0df41b859 | ||
|
|
494c1b33b4 | ||
|
|
2034d91912 |
288
README.md
288
README.md
@@ -26,7 +26,9 @@
|
||||
| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s |
|
||||
| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) | [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg |
|
||||
| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama |
|
||||
|
||||
|
||||
[](https://seladb.github.io/StarTrack-js/#/preload?r=FloatTech,ZeroBot-Plugin)
|
||||
|
||||
</div>
|
||||
|
||||
> 如果您不知道什么是 [OneBot](https://github.com/howmanybots/onebot) 或不希望运行多个程序,还可以直接前往 [gocqzbp](https://github.com/FloatTech/gocqzbp) 的 [Release](https://github.com/FloatTech/gocqzbp/releases) 页面下载单一可执行文件或前往 [Packages](https://github.com/FloatTech/gocqzbp/pkgs/container/gocqzbp) 页面使用`docker`,运行后按提示登录即可。
|
||||
@@ -36,16 +38,19 @@
|
||||
## 命令行参数
|
||||
> `[]`代表是可选参数
|
||||
```bash
|
||||
zerobot [-c config.json] [-h] [-s config.json] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [qq1 qq2 qq3 ...] [&]
|
||||
zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&]
|
||||
```
|
||||
- **-c config.json**: 从`config.json`加载`bot`配置
|
||||
- **-h**: 显示帮助
|
||||
- **-s config.json**: 保存现在`bot`配置到`config.json`
|
||||
- **-n nickname**: 设置默认昵称,默认为`椛椛`
|
||||
- **-t token**: 设置`AccessToken`,默认为空
|
||||
- **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700`
|
||||
- **-n nickname**: 设置默认昵称,默认为`椛椛`
|
||||
- **-p prefix**: 设置命令前缀,默认为`/`
|
||||
- **-d|w**: 开启 debug | warning 级别及以上日志输出
|
||||
- **-c config.json**: 从`config.json`加载`bot`配置
|
||||
- **-s config.json**: 保存现在`bot`配置到`config.json`
|
||||
- **-l latency**: 全局处理延时 (ms)
|
||||
- **-r ringlen**: 接收消息环缓冲区大小
|
||||
- **-x max process time**: 最大处理时间 (min)
|
||||
- **qqs**: superusers 的 qq 号
|
||||
- **&**: 驻留在后台,必须放在最后,仅`Linux`下有效
|
||||
|
||||
@@ -61,7 +66,10 @@ zerobot [-c config.json] [-h] [-s config.json] [-t token] [-u url] [-n nickname]
|
||||
"アトリ"
|
||||
],
|
||||
"command_prefix": "/",
|
||||
"super_users": []
|
||||
"super_users": [],
|
||||
"ring_len": 4096,
|
||||
"latency": 233000000,
|
||||
"max_process_time": 240000000000
|
||||
},
|
||||
"ws": [
|
||||
{
|
||||
@@ -220,6 +228,12 @@ zerobot [-c config.json] [-h] [-s config.json] [-t token] [-u url] [-n nickname]
|
||||
|
||||
- [x] [开启 | 关闭]gist加群自动审批
|
||||
|
||||
- [x] 对信息回复:[设置 | 取消]精华
|
||||
|
||||
- [x] 取消精华 [信息ID]
|
||||
|
||||
- [x] /精华列表
|
||||
|
||||
- [ ] 同意好友请求
|
||||
|
||||
- [ ] 撤回[@xxx] [xxx]
|
||||
@@ -354,13 +368,19 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx
|
||||
|
||||
- [x] [ ai高级绘图 | 高级生成色图 | 高级生成涩图 | ai高级画图 ] xxx
|
||||
|
||||
- [x] [ 以图绘图 | 以图生图 | 以图画图 ] xxx [图片]|@xxx|[qq号]
|
||||
|
||||
- [ ] 设置ai绘图配置 [server] [token]
|
||||
- [x] 设置ai绘图配置 [server] [token]
|
||||
|
||||
例1: 设置ai绘图配置 http://91.216.169.75:5010 abc
|
||||
- [x] 设置ai绘图撤回时间90s
|
||||
|
||||
- [x] 查看ai绘图配置
|
||||
|
||||
例: 设置ai绘图配置 http://91.216.169.75:5010 abc
|
||||
|
||||
例2: 设置ai绘图配置 http://91.217.139.190:5010 abc
|
||||
参考服务器 http://91.217.139.190:5010, http://91.216.169.75:5010, http://185.80.202.180:5010
|
||||
|
||||
通过 http://91.217.139.190:5010/token 获取token
|
||||
|
||||
@@ -403,6 +423,51 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- [x] 百度下[xxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>百度内容审核</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit"`
|
||||
|
||||
- [x] 获取BDAkey
|
||||
|
||||
- [x] 配置BDAKey [API Key] [Secret Key]
|
||||
|
||||
- [x] 获取BDAkey
|
||||
|
||||
- [x] [开启|关闭]内容审核
|
||||
|
||||
- [x] [开启|关闭]撤回提示
|
||||
|
||||
- [x] [开启|关闭]详细提示
|
||||
|
||||
- [x] [开启|关闭]撤回禁言
|
||||
|
||||
- [x] [开启|关闭]禁言累加
|
||||
|
||||
- [x] [开启|关闭]文本检测
|
||||
|
||||
- [x] [开启|关闭]图像检测
|
||||
|
||||
- [x] 设置最大禁言时间[分钟,默认:60,最大43200]
|
||||
|
||||
- [x] 设置每次累加时间[分钟,默认:1]
|
||||
|
||||
- [x] 设置撤回禁言时间[分钟,默认:1]
|
||||
|
||||
- [x] 查看检测类型
|
||||
|
||||
- [x] 查看检测配置
|
||||
|
||||
- [x] 测试文本检测[文本内容]
|
||||
|
||||
- [x] 测试图像检测[图片]
|
||||
|
||||
- [x] 设置检测类型[类型编号]
|
||||
|
||||
- [x] 设置不检测类型[类型编号]
|
||||
|
||||
检测类型编号列表:[1:违禁违规|2:文本色情|3:敏感信息|4:恶意推广|5:低俗辱骂|6:恶意推广-联系方式|7:恶意推广-软文推广]
|
||||
</details>
|
||||
<details>
|
||||
<summary>base64卦加解密</summary>
|
||||
|
||||
@@ -572,41 +637,9 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle"`
|
||||
|
||||
- [x] (在群xxx)丢漂流瓶(到频道xxx) [消息]
|
||||
- [x] @Bot pick (随机捞一个漂流瓶)
|
||||
|
||||
- [x] (从频道xxx)捡漂流瓶
|
||||
|
||||
- [x] @BOT 创建频道 xxx
|
||||
|
||||
- [x] 跳入(频道)海中
|
||||
|
||||
- [x] 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>一群一天一夫一妻制群老婆</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife"`
|
||||
|
||||
- 引入好感度系统,好感度越高,自由恋爱成功率越高
|
||||
|
||||
- [x] 设置CD为xx小时
|
||||
|
||||
- [x] 允许/禁止自由恋爱
|
||||
|
||||
- [x] 允许/禁止牛头人
|
||||
|
||||
- [x] 娶群友
|
||||
|
||||
- [x] (娶|嫁)[@对方QQ]
|
||||
|
||||
- [x] 当[对方Q号|@对方QQ]的小三
|
||||
|
||||
- [x] 做媒 @攻方QQ @受方QQ
|
||||
|
||||
- [x] 群老婆列表
|
||||
|
||||
- [x] 重置花名册
|
||||
- [x] @Bot throw xxx (投递内容xxx,支持图片文字,投递内容需要大于10个字符或者带有图片)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -789,6 +822,16 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 更新[屌|弔|吊]图
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>兽语加密(嗷呜~)</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami"`
|
||||
|
||||
- [x] 兽语加密xxx
|
||||
|
||||
- [x] 兽语解密xxx
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>小鸡词典</summary>
|
||||
@@ -837,6 +880,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
来份萝莉
|
||||
```
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>MagicPrompt-Stable-Diffusion吟唱提示</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt"`
|
||||
|
||||
- [x] 吟唱提示[xxxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>简易midi音乐制作</summary>
|
||||
@@ -962,6 +1013,8 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo"`
|
||||
|
||||
- [x] 日语语法 [xxx] (使用tag随机)
|
||||
|
||||
- [x] 搜索日语语法 [xxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -991,6 +1044,43 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 解签
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>一群一天一夫一妻制群老婆</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife"`
|
||||
|
||||
- 引入好感度系统,好感度越高,自由恋爱成功率越高
|
||||
|
||||
- [x] 设置CD为xx小时
|
||||
|
||||
- [x] [允许|禁止]自由恋爱
|
||||
|
||||
- [x] [允许|禁止]牛头人
|
||||
|
||||
- [x] 娶群友
|
||||
|
||||
- [x] [娶|嫁][@对方QQ]
|
||||
|
||||
- [x] 当[对方Q号|@对方QQ]的小三
|
||||
|
||||
- [x] 做媒 @攻方QQ @受方QQ
|
||||
|
||||
- [x] 买礼物给[对方Q号|@对方QQ]
|
||||
|
||||
- [x] 群老婆列表
|
||||
|
||||
- [x] 重置花名册
|
||||
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>Real-CUGAN清晰术</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan"`
|
||||
|
||||
- [x] 清晰术(双重吟唱|三重吟唱|四重吟唱)(强力术式|中等术式|弱术式|不变式|原式)[图片]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>投胎</summary>
|
||||
@@ -1041,6 +1131,11 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 签到
|
||||
- [x] 获得签到背景[@xxx] | 获得签到背景
|
||||
- [x] 查看等级排名
|
||||
- 注:跨群排行
|
||||
- [x] 查看我的钱包
|
||||
- [x] 查看钱包排名
|
||||
- 注:本群排行,若群人数太多不建议使用该功能!!!
|
||||
|
||||
</details>
|
||||
<details>
|
||||
@@ -1083,6 +1178,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- [x] 解塔罗牌[牌名]
|
||||
- [x] [塔罗|大阿卡纳|小阿卡纳|混合]牌阵[圣三角|时间之流|四要素|五牌阵|吉普赛十字|马蹄|六芒星]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>舔狗日记</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou"`
|
||||
|
||||
- [x] 舔狗日记
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>搜番</summary>
|
||||
@@ -1091,20 +1194,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 搜番 | 搜索番剧[图片]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>猜单词</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle"`
|
||||
|
||||
- [x] 个人猜单词
|
||||
|
||||
- [x] 团队猜单词
|
||||
|
||||
- [x] 团队六阶猜单词
|
||||
|
||||
- [x] 团队七阶猜单词
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>翻译</summary>
|
||||
@@ -1113,6 +1202,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] >TL 你好
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>vits猫雷</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru"`
|
||||
|
||||
- [x] 让猫雷说[xxxx]
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>vtb语录</summary>
|
||||
@@ -1133,23 +1230,61 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 来份网易云热评
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>天气/拼音查询-名言</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben"`
|
||||
|
||||
- [x] xx天气
|
||||
|
||||
- [x] xx拼音
|
||||
|
||||
- [x] 每日情话/一言/鸡汤
|
||||
|
||||
- [x] 绕口令
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>百度文心AI画图</summary>
|
||||
<summary>百度文心AI</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI"`
|
||||
|
||||
- 基于百度文心的免费AI画图插件(因为是免费的,图片质量你懂的)
|
||||
基于百度文心API的一些功能
|
||||
|
||||
- key申请链接:https://wenxin.baidu.com/moduleApi/key
|
||||
|
||||
- [x] 为[自己/本群/QQ号/群+群号]设置AI画图key [API Key] [Secret Key]
|
||||
|
||||
- 例:“为10086设置AI画图key 123 456”;“为群10010设置AI画图key 789 101”
|
||||
key申请链接:https://wenxin.baidu.com/moduleApi/key
|
||||
|
||||
- [x] 为[自己/本群/QQ号/群+群号]设置文心key [API Key] [Secret Key]
|
||||
|
||||
- [x] 为[自己/本群/QQ号/群+群号]设置画图key [API Key] [Secret Key]
|
||||
|
||||
例:“为10086设置画图key 123 456”;“为群10010设置画图key 789 101”
|
||||
|
||||
文心key和画图key的API key 可以是相同的,只是文心key日限为200,画图日限为50,以此作区别。
|
||||
|
||||
- [x] 文心作文 (x字的)[作文题目]
|
||||
|
||||
- [x] 文心提案 (x字的)[文案标题]
|
||||
|
||||
- [x] 文心摘要 (x字的)[文章内容]
|
||||
|
||||
- [x] 文心小说 (x字的)[小说上文]
|
||||
|
||||
- [x] 文心对联 [上联]
|
||||
|
||||
- [x] 文心问答 [问题]
|
||||
|
||||
- [x] 文心补全 [带“_”的填空题]
|
||||
|
||||
- [x] 文心自定义 [prompt]
|
||||
|
||||
- [x] [bot名称]画几张[图片描述]的[图片类型][图片尺寸]
|
||||
|
||||
- 指令示例:
|
||||
指令示例:
|
||||
|
||||
- 文心作文 我的椛椛机器人
|
||||
|
||||
- 文心作文 300字的我的椛椛机器人
|
||||
|
||||
- 椛椛帮我画几张金凤凰,背景绚烂,高饱和,古风,仙境,高清,4K,古风的油画方图
|
||||
|
||||
@@ -1169,14 +1304,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 更新gal
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>舔狗日记</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou"`
|
||||
|
||||
- [x] 舔狗日记
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>聊天热词</summary>
|
||||
@@ -1185,6 +1312,20 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 热词 [群号] [消息数目]|热词 123456 1000
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>猜单词</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle"`
|
||||
|
||||
- [x] 个人猜单词
|
||||
|
||||
- [x] 团队猜单词
|
||||
|
||||
- [x] 团队六阶猜单词
|
||||
|
||||
- [x] 团队七阶猜单词
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>鬼东西</summary>
|
||||
@@ -1219,7 +1360,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- [x] @Bot 任意文本(任意一句话回复)
|
||||
|
||||
- [x] 设置回复模式[青云客 | 小爱]
|
||||
|
||||
</details>
|
||||
|
||||
## 三种使用方法,推荐第一种
|
||||
|
||||
16
go.mod
16
go.mod
@@ -3,20 +3,22 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1
|
||||
github.com/Coloured-glaze/gg v1.3.4
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221015060924-fe2f85a3cf45
|
||||
github.com/FloatTech/floatbox v0.0.0-20221011153549-68005767c531
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221105044443-0c9004b2f051
|
||||
github.com/FloatTech/floatbox v0.0.0-20221029160423-446812ec82d9
|
||||
github.com/FloatTech/sqlite v0.5.0
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
|
||||
github.com/FloatTech/zbpctrl v1.5.2-0.20221011153929-4834c6911511
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221011154037-734498125e07
|
||||
github.com/FloatTech/zbpctrl v1.5.2
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221107030239-f8dd8b9a6e24
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc
|
||||
github.com/antchfx/htmlquery v1.2.5
|
||||
github.com/corona10/goimagehash v1.1.0
|
||||
github.com/fumiama/ahsai v0.1.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.6.1
|
||||
github.com/fumiama/go-registry v0.1.6
|
||||
github.com/fumiama/go-registry v0.2.1
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/sqlite3 v1.14.6
|
||||
github.com/fumiama/unibase2n v0.0.0-20221003115227-e7db987de949
|
||||
@@ -31,18 +33,18 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/tidwall/gjson v1.14.3
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20221011153413-16c9a77ce4f0
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.3
|
||||
gitlab.com/gomidi/midi/v2 v2.0.25
|
||||
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc // indirect
|
||||
github.com/antchfx/xpath v1.2.1 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
|
||||
github.com/faiface/beep v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
|
||||
github.com/fumiama/gofastTEA v0.0.10 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
|
||||
28
go.sum
28
go.sum
@@ -1,19 +1,21 @@
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhvrx4cw=
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Coloured-glaze/gg v1.3.4 h1:l31zIF/HaVwkzjrj+A56RGQoSKyKuR1IWtIrqXGFStI=
|
||||
github.com/Coloured-glaze/gg v1.3.4/go.mod h1:Ih5NLNNDHOy3RJbB0EPqGTreIzq/H02TGThIagh8HJg=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221015060924-fe2f85a3cf45 h1:XbNlD0irJELgdR304TvqmFrxdH7hsxA/Ah9xLHFP3eQ=
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221015060924-fe2f85a3cf45/go.mod h1:RgcMDA1S7C81bq7HQjygMEEo+EXwAlsutvKMv7DafgY=
|
||||
github.com/FloatTech/floatbox v0.0.0-20221011153549-68005767c531 h1:Z0yn6LFhEyC12hj+TBXc2P7/kWlCd/jlwv4JFndgpnw=
|
||||
github.com/FloatTech/floatbox v0.0.0-20221011153549-68005767c531/go.mod h1:4tfIeB74L1RzhNp3nNjaTw8m3IEnc+q/k6k/MhL07ks=
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221105044443-0c9004b2f051 h1:NEW8HzBNybMXAV0NrDpMF31n/e9BFGvNiGkDPGSkouc=
|
||||
github.com/FloatTech/AnimeAPI v1.5.2-0.20221105044443-0c9004b2f051/go.mod h1:Z+Q4kIPNo/OX4RWw6WGQOQcaNsbkv/wPmPDw8p4aQIY=
|
||||
github.com/FloatTech/floatbox v0.0.0-20221029160423-446812ec82d9 h1:HYJ7lwaqaOKmbYooPUMWxMhXRTp+JItoyeqa320ARD4=
|
||||
github.com/FloatTech/floatbox v0.0.0-20221029160423-446812ec82d9/go.mod h1:w+ND28mRaJvxUJ6pRXS6i4cLzutpXsWyroutCzBdL78=
|
||||
github.com/FloatTech/sqlite v0.5.0 h1:U7J5Omc534PqmH6csfu+ypCo3DS8L91l5lTsxUu3b/U=
|
||||
github.com/FloatTech/sqlite v0.5.0/go.mod h1:i33d92OtR8jcp5fBUvQtospf27+MkfUxnGwnZ95E/dA=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/FloatTech/zbpctrl v1.5.2-0.20221011153929-4834c6911511 h1:i2+JjTRR7gW8n1KivMKj3NEsCEEllYp8jneeOyg1Lz0=
|
||||
github.com/FloatTech/zbpctrl v1.5.2-0.20221011153929-4834c6911511/go.mod h1:TC5RkmSwKJvkDV+7vlTpcY+rnviB5gBq6JNOKnfZXHc=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221011154037-734498125e07 h1:nG1q2NJZPehyV0xk88WHtqgwsOohkEDMFu/8v9rN1/o=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221011154037-734498125e07/go.mod h1:UYuWZBInYdGZOXxEazrvaJE8nYGRB4xxoaacX6nKosk=
|
||||
github.com/FloatTech/zbpctrl v1.5.2 h1:5ap0t2KgROpfTVHqMd9vHKXLeLmRFGI3ZrTPASgFP6s=
|
||||
github.com/FloatTech/zbpctrl v1.5.2/go.mod h1:BVPivMDJCBImPSdwgizb6sqb7rcDaRE65ZjfgthoC7g=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221107030239-f8dd8b9a6e24 h1:6d9o83ZFI3LSPf4isDUmShiaU9CXqqggFwKFuof2Ghs=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20221107030239-f8dd8b9a6e24/go.mod h1:KDPJDu4KHeB4Gdyt8sqR5+QnIsIDW6XXsFfT1kD7okw=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
|
||||
@@ -50,8 +52,10 @@ github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
|
||||
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
|
||||
github.com/fumiama/go-base16384 v1.6.1 h1:4yb4JgmBJDnQtq3XGXXdLrVwEnRpjhMUt4eAcsNeA30=
|
||||
github.com/fumiama/go-base16384 v1.6.1/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.1.6 h1:Ee/tXCCIR/xt8celhbbw0W/xDMdhAXLwy2YFBB/LWFk=
|
||||
github.com/fumiama/go-registry v0.1.6/go.mod h1:dIUVbiOgfk9oZcsgwDvNLC72i+ctibVukSXR/9bLviI=
|
||||
github.com/fumiama/go-registry v0.2.1 h1:PCu4d1OIYkLmoSufyxov3QXRul4lXrAfXfK1pVS2wrQ=
|
||||
github.com/fumiama/go-registry v0.2.1/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
|
||||
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
|
||||
github.com/fumiama/gofastTEA v0.0.10/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
|
||||
github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6/Jc=
|
||||
@@ -189,8 +193,8 @@ github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//
|
||||
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20221011153413-16c9a77ce4f0 h1:IKWX0c7b3URoFDt5ezD6wa0AZIQ0EY0GbPVhYfuzXug=
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.2-0.20221011153413-16c9a77ce4f0/go.mod h1:shG/ruauisKaVcov4amrFJtkeDl7nl+Q00IXB2PqFsc=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.3 h1:Xf+rM8fR9Etc7ydcGHuqCk0ulAAn7Oa7nD9Zy/qZ6Pk=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.3/go.mod h1:shG/ruauisKaVcov4amrFJtkeDl7nl+Q00IXB2PqFsc=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
var (
|
||||
// Banner ...
|
||||
Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version 1.5.1 - 2022-10-16 12:58:18 +0800 CST\n" +
|
||||
"* Version 1.5.2 - 2022-11-09 15:15:01 +0800 CST\n" +
|
||||
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
|
||||
22
main.go
22
main.go
@@ -65,6 +65,7 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
@@ -94,10 +95,12 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
@@ -111,6 +114,7 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
@@ -123,8 +127,10 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
@@ -198,6 +204,9 @@ func init() {
|
||||
prefix := flag.String("p", "/", "Set command prefix.")
|
||||
runcfg := flag.String("c", "", "Run from config file.")
|
||||
save := flag.String("s", "", "Save default config to file and exit.")
|
||||
late := flag.Uint("l", 233, "Response latency (ms).")
|
||||
rsz := flag.Uint("r", 4096, "Receiving buffer ring size.")
|
||||
maxpt := flag.Uint("x", 4, "Max process time (min).")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@@ -247,10 +256,13 @@ func init() {
|
||||
|
||||
config.W = []*driver.WSClient{driver.NewWebSocketClient(*url, *token)}
|
||||
config.Z = zero.Config{
|
||||
NickName: append([]string{*adana}, "ATRI", "atri", "亚托莉", "アトリ"),
|
||||
CommandPrefix: *prefix,
|
||||
SuperUsers: sus,
|
||||
Driver: []zero.Driver{config.W[0]},
|
||||
NickName: append([]string{*adana}, "ATRI", "atri", "亚托莉", "アトリ"),
|
||||
CommandPrefix: *prefix,
|
||||
SuperUsers: sus,
|
||||
RingLen: *rsz,
|
||||
Latency: time.Duration(*late) * time.Millisecond,
|
||||
MaxProcessTime: time.Duration(*maxpt) * time.Minute,
|
||||
Driver: []zero.Driver{config.W[0]},
|
||||
}
|
||||
|
||||
if *save != "" {
|
||||
@@ -279,5 +291,5 @@ func main() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(kanban.Kanban()))
|
||||
})
|
||||
zero.RunAndBlock(config.Z, process.GlobalInitMutex.Unlock)
|
||||
zero.RunAndBlock(&config.Z, process.GlobalInitMutex.Unlock)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("ahsai", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "ahsai tts\n- 使[伊織弓鶴|紲星あかり|結月ゆかり|京町セイカ|東北きりたん|東北イタコ|ついなちゃん標準語|ついなちゃん関西弁|音街ウナ|琴葉茜|吉田くん|民安ともえ|桜乃そら|月読アイ|琴葉葵|東北ずん子|月読ショウタ|水奈瀬コウ]说(日语)\n",
|
||||
Brief: "フリーテキスト音声合成",
|
||||
Help: "- 使[伊織弓鶴|紲星あかり|結月ゆかり|京町セイカ|東北きりたん|東北イタコ|ついなちゃん標準語|ついなちゃん関西弁|音街ウナ|琴葉茜|吉田くん|民安ともえ|桜乃そら|月読アイ|琴葉葵|東北ずん子|月読ショウタ|水奈瀬コウ]说(日语)\n",
|
||||
PrivateDataFolder: "ahsai",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "AIfalse\n" +
|
||||
"- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" +
|
||||
Brief: "自检, 全局限速",
|
||||
Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" +
|
||||
"- 设置默认限速为每 m [分钟 | 秒] n 次触发",
|
||||
})
|
||||
c, ok := control.Lookup("aifalse")
|
||||
|
||||
@@ -152,7 +152,7 @@ func newttsmode() *ttsmode {
|
||||
tts := &ttsmode{}
|
||||
tts.Lock()
|
||||
defer tts.Unlock()
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
m, ok := control.Lookup("tts")
|
||||
tts.mode = make(map[int64]int64, 2*len(soundList))
|
||||
tts.mode[-2905] = 1
|
||||
if ok {
|
||||
@@ -229,7 +229,7 @@ func (tts *ttsmode) setDefaultSoundMode(name string) error {
|
||||
}
|
||||
tts.Lock()
|
||||
defer tts.Unlock()
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
m, ok := control.Lookup("tts")
|
||||
if !ok {
|
||||
return errors.New("[tts] service not found")
|
||||
}
|
||||
|
||||
@@ -17,28 +17,23 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
replyServiceName = "aireply"
|
||||
ttsServiceName = "tts"
|
||||
)
|
||||
|
||||
var replyModes = [...]string{"青云客", "小爱"}
|
||||
|
||||
func init() { // 插件主体
|
||||
enOftts := control.Register(ttsServiceName, &ctrl.Options[*zero.Ctx]{
|
||||
enOftts := control.Register("tts", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "语音回复(大家一起来炼丹)\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n" +
|
||||
Brief: "人工智能语音回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[原神人物]\n" +
|
||||
"- 设置默认语音模式[原神人物]\n" +
|
||||
"- 恢复成默认语音模式\n" +
|
||||
"当前适用的原神人物含有以下:\n" + list(soundList[:], 5),
|
||||
})
|
||||
tts := newttsmode()
|
||||
enOfreply := control.Register(replyServiceName, &ctrl.Options[*zero.Ctx]{
|
||||
enOfreply := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "人工智能回复\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
|
||||
Brief: "人工智能回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
|
||||
})
|
||||
/*************************************************************
|
||||
*******************************AIreply************************
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
@@ -50,35 +51,41 @@ func (r *result) String() string {
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aipaint", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "ai绘图\n" +
|
||||
"- [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx\n" +
|
||||
Brief: "ai绘图",
|
||||
Help: "- [ ai绘图 | 生成色图 | 生成涩图 | ai画图 ] xxx\n" +
|
||||
"- [ ai高级绘图 | 高级生成色图 | 高级生成涩图 | ai高级画图 ] [prompt]\n" +
|
||||
"- [ 以图绘图 | 以图生图 | 以图画图 ] xxx [图片]|@xxx|[qq号]\n" +
|
||||
"- 设置ai绘图配置 [server] [token]\n" +
|
||||
"例1: 设置ai绘图配置 http://91.216.169.75:5010 abc\n" +
|
||||
"例2: 设置ai绘图配置 http://91.217.139.190:5010 abc\n" +
|
||||
"通过 http://91.217.139.190:5010/token 获取token",
|
||||
"- 设置ai绘图撤回时间90s\n" +
|
||||
"- 查看ai绘图配置\n" +
|
||||
"例: 设置ai绘图配置 http://91.217.139.190:5010 abc\n" +
|
||||
"参考服务器 http://91.217.139.190:5010, http://91.216.169.75:5010, http://185.80.202.180:5010\n" +
|
||||
"通过 http://91.217.139.190:5010/token 获取token\n" +
|
||||
"[prompt]参数如下\n" +
|
||||
"tags:tag词条\nntags:ntag词条\nshape:[Portrait|Landscape|Square]\nscale:[6:20]\nseed:种子\n" +
|
||||
"参数与参数内容用:连接,每个参数之间用回车分割",
|
||||
PrivateDataFolder: "aipaint",
|
||||
})
|
||||
datapath = file.BOTPATH + "/" + engine.DataFolder()
|
||||
engine.OnPrefixGroup([]string{`ai绘图`, `生成色图`, `生成涩图`, `ai画图`}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
server, token, err := cfg.load()
|
||||
err := cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
args := ctx.State["args"].(string)
|
||||
data, err := web.GetData(server + fmt.Sprintf(aipaintTxt2ImgURL, token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20")))))
|
||||
data, err := web.GetData(cfg.BaseURL + fmt.Sprintf(aipaintTxt2ImgURL, cfg.Token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20")))))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sendAiImg(ctx, data)
|
||||
sendAiImg(ctx, data, cfg.Interval)
|
||||
})
|
||||
engine.OnRegex(`^(以图绘图|以图生图|以图画图)[\s\S]*?(\[CQ:(image\,file=([0-9a-zA-Z]{32}).*|at.+?(\d{5,11}))\].*|(\d+))$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
server, token, err := cfg.load()
|
||||
err := cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -96,7 +103,7 @@ func init() { // 插件主体
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
postURL := server + fmt.Sprintf(aipaintImg2ImgURL, token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20"))))
|
||||
postURL := cfg.BaseURL + fmt.Sprintf(aipaintImg2ImgURL, cfg.Token, url.QueryEscape(strings.TrimSpace(strings.ReplaceAll(args, " ", "%20"))))
|
||||
|
||||
f, err := os.Open(c.headimgsdir[0])
|
||||
if err != nil {
|
||||
@@ -131,21 +138,108 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sendAiImg(ctx, data)
|
||||
sendAiImg(ctx, data, cfg.Interval)
|
||||
})
|
||||
engine.OnRegex(`^设置ai绘图配置\s(.*[^\s$])\s(.+)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnPrefixGroup([]string{`ai高级绘图`, `高级生成色图`, `高级生成涩图`, `ai高级画图`}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
regexMatched := ctx.State["regex_matched"].([]string)
|
||||
err := cfg.save(regexMatched[1], regexMatched[2])
|
||||
err := cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功设置server为", regexMatched[1], ", token为", regexMatched[2]))
|
||||
tags := make(map[string]string)
|
||||
args := strings.Split(ctx.State["args"].(string), "\n")
|
||||
if len(args) < 1 {
|
||||
ctx.SendChain(message.Text("ERROR: 请输入正确的参数"))
|
||||
return
|
||||
}
|
||||
for _, info := range args {
|
||||
value := strings.Split(info, ":")
|
||||
if len(value) > 1 {
|
||||
if value[0] == "R18" && value[1] == "1" {
|
||||
value[1] = "0"
|
||||
ctx.SendChain(message.Text("不准涩涩! 已将R18设置为0. "))
|
||||
}
|
||||
tags[value[0]] = strings.Join(value[1:], ":")
|
||||
}
|
||||
}
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
apiurl := "/got_image?token=" + cfg.Token
|
||||
if _, ok := tags["tags"]; ok {
|
||||
apiurl += "&tags=" + url.QueryEscape(strings.ReplaceAll(strings.TrimSpace(tags["tags"]), " ", "%20"))
|
||||
}
|
||||
if _, ok := tags["ntags"]; ok {
|
||||
apiurl += "&ntags=" + url.QueryEscape(strings.ReplaceAll(strings.TrimSpace(tags["ntags"]), " ", "%20"))
|
||||
}
|
||||
if _, ok := tags["R18"]; ok {
|
||||
apiurl += "&R18=" + url.QueryEscape(strings.TrimSpace(tags["R18"]))
|
||||
}
|
||||
if _, ok := tags["shape"]; ok {
|
||||
apiurl += "&shape=" + url.QueryEscape(strings.TrimSpace(tags["shape"]))
|
||||
}
|
||||
if _, ok := tags["scale"]; ok {
|
||||
apiurl += "&scale=" + url.QueryEscape(strings.TrimSpace(tags["scale"]))
|
||||
}
|
||||
if _, ok := tags["seed"]; ok {
|
||||
apiurl += "&seed=" + url.QueryEscape(strings.TrimSpace(tags["seed"]))
|
||||
}
|
||||
data, err := web.GetData(cfg.BaseURL + apiurl)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sendAiImg(ctx, data, cfg.Interval)
|
||||
})
|
||||
engine.OnRegex(`^设置ai绘图配置\s(.*[^\s$])\s(.+)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
regexMatched := ctx.State["regex_matched"].([]string)
|
||||
err := cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = cfg.update(regexMatched[1], regexMatched[2], cfg.Interval)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf("成功设置\nbase_url: %v\ntoken: %v\ninterval: %v\n", cfg.BaseURL, cfg.Token, cfg.Interval)
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
engine.OnRegex(`^设置ai绘图撤回时间(\d{1,3})s$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
regexMatched := ctx.State["regex_matched"].([]string)
|
||||
interval, err := strconv.Atoi(regexMatched[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = cfg.update(cfg.BaseURL, cfg.Token, interval)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf("成功设置\nbase_url: %v\ntoken: %v\ninterval: %v\n", cfg.BaseURL, cfg.Token, cfg.Interval)
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
engine.OnFullMatch(`查看ai绘图配置`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
err := cfg.load()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf("base_url: %v\ntoken: %v\ninterval: %v\n", cfg.BaseURL, cfg.Token, cfg.Interval)
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
}
|
||||
|
||||
func sendAiImg(ctx *zero.Ctx, data []byte) {
|
||||
func sendAiImg(ctx *zero.Ctx, data []byte, interval int) {
|
||||
var loadData string
|
||||
if predictRe.MatchString(binary.BytesToString(data)) {
|
||||
loadData = predictRe.FindStringSubmatch(binary.BytesToString(data))[0]
|
||||
@@ -157,11 +251,21 @@ func sendAiImg(ctx *zero.Ctx, data []byte) {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
r.Uc, err = url.QueryUnescape(r.Uc)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
encodeStr := base64.StdEncoding.EncodeToString(data)
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("base64://"+encodeStr))}
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(r.String())))
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
if mid := ctx.Send(m); mid.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
} else if interval > 0 {
|
||||
go func(i message.MessageID) {
|
||||
time.Sleep(time.Duration(interval) * time.Second)
|
||||
ctx.DeleteMessage(i)
|
||||
}(mid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
|
||||
// 配置结构体
|
||||
type serverConfig struct {
|
||||
BaseURL string `json:"base_url"`
|
||||
Token string `json:"token"`
|
||||
file string
|
||||
BaseURL string `json:"base_url"`
|
||||
Token string `json:"token"`
|
||||
Interval int `json:"interval"`
|
||||
file string
|
||||
}
|
||||
|
||||
func newServerConfig(file string) *serverConfig {
|
||||
@@ -21,9 +22,14 @@ func newServerConfig(file string) *serverConfig {
|
||||
}
|
||||
}
|
||||
|
||||
func (cfg *serverConfig) save(baseURL, token string) (err error) {
|
||||
cfg.BaseURL = baseURL
|
||||
cfg.Token = token
|
||||
func (cfg *serverConfig) update(baseURL, token string, interval int) (err error) {
|
||||
if baseURL != "" {
|
||||
cfg.BaseURL = baseURL
|
||||
}
|
||||
if token != "" {
|
||||
cfg.Token = token
|
||||
}
|
||||
cfg.Interval = interval
|
||||
reader, err := os.Create(cfg.file)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -32,10 +38,8 @@ func (cfg *serverConfig) save(baseURL, token string) (err error) {
|
||||
return json.NewEncoder(reader).Encode(cfg)
|
||||
}
|
||||
|
||||
func (cfg *serverConfig) load() (aipaintServer, token string, err error) {
|
||||
if cfg.BaseURL != "" && cfg.Token != "" {
|
||||
aipaintServer = cfg.BaseURL
|
||||
token = cfg.Token
|
||||
func (cfg *serverConfig) load() (err error) {
|
||||
if cfg.BaseURL != "" && cfg.Token != "" && cfg.Interval != 0 {
|
||||
return
|
||||
}
|
||||
if file.IsNotExist(cfg.file) {
|
||||
@@ -48,7 +52,5 @@ func (cfg *serverConfig) load() (aipaintServer, token string, err error) {
|
||||
}
|
||||
defer reader.Close()
|
||||
err = json.NewDecoder(reader).Decode(cfg)
|
||||
aipaintServer = cfg.BaseURL
|
||||
token = cfg.Token
|
||||
return
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ const (
|
||||
func init() { // 插件主体
|
||||
control.Register("aiwife", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "AIWife\n" +
|
||||
"- waifu | 随机waifu",
|
||||
Brief: "ai随机生成老婆",
|
||||
Help: "- waifu | 随机waifu",
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
miku := rand.Intn(100000) + 1
|
||||
|
||||
@@ -17,9 +17,9 @@ const (
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("alipayvoice", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "支付宝到账语音\n" +
|
||||
"- 支付宝到账 1",
|
||||
DisableOnDefault: false,
|
||||
Brief: "支付宝到账语音",
|
||||
Help: "- 支付宝到账 1",
|
||||
PrivateDataFolder: "alipayvoice",
|
||||
})
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ func onDel(uid int64, _ struct{}) {
|
||||
func init() {
|
||||
engine := control.Register("antiabuse", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "违禁词检测\n- /[添加|删除|查看]违禁词",
|
||||
Brief: "违禁词检测",
|
||||
Help: "- /[添加|删除|查看]违禁词",
|
||||
PrivateDataFolder: "anti_abuse",
|
||||
})
|
||||
|
||||
|
||||
@@ -17,16 +17,12 @@ import (
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
)
|
||||
|
||||
const (
|
||||
// 服务名
|
||||
servicename = "atri"
|
||||
// ATRI 表情的 codechina 镜像
|
||||
res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/"
|
||||
)
|
||||
const res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/"
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.Register("atri", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "atri人格文本回复",
|
||||
Help: "本插件基于 ATRI ,为 Golang 移植版\n" +
|
||||
"- ATRI醒醒\n- ATRI睡吧\n- 萝卜子\n- 喜欢 | 爱你 | 爱 | suki | daisuki | すき | 好き | 贴贴 | 老婆 | 亲一个 | mua\n" +
|
||||
"- 草你妈 | 操你妈 | 脑瘫 | 废柴 | fw | 废物 | 战斗 | 爬 | 爪巴 | sb | SB | 傻B\n- 早安 | 早哇 | 早上好 | ohayo | 哦哈哟 | お早う | 早好 | 早 | 早早早\n" +
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("base16384", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "base16384加解密\n" +
|
||||
"- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
|
||||
Brief: "base16384加解密",
|
||||
Help: "- 加密xxx\n- 解密xxx\n- 用yyy加密xxx\n- 用yyy解密xxx",
|
||||
})
|
||||
en.OnRegex(`^加密\s*(.+)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
func init() {
|
||||
control.Register("baidu", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "baidu\n" +
|
||||
"- 百度下[xxx]",
|
||||
Brief: "不会百度吗",
|
||||
Help: "- 百度下[xxx]",
|
||||
}).OnPrefix("百度下").SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
txt := ctx.State["args"].(string)
|
||||
|
||||
502
plugin/baiduaudit/audit.go
Normal file
502
plugin/baiduaudit/audit.go
Normal file
@@ -0,0 +1,502 @@
|
||||
// Package baiduaudit 百度内容审核
|
||||
package baiduaudit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/Baidu-AIP/golang-sdk/aip/censor"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
// 服务网址:https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index
|
||||
// 返回参数说明:https://cloud.baidu.com/doc/ANTIPORN/s/Nk3h6xbb2
|
||||
type baiduRes struct {
|
||||
LogID int `json:"log_id"` // 请求唯一id
|
||||
Conclusion string `json:"conclusion"` // 审核结果,可取值:合规、不合规、疑似、审核失败
|
||||
ConclusionType int `json:"conclusionType"` // 审核结果类型,可取值1.合规,2.不合规,3.疑似,4.审核失败
|
||||
Data []auditData `json:"data"`
|
||||
ErrorCode int `json:"error_code"` // 错误提示码,失败才返回,成功不返回
|
||||
ErrorMsg string `json:"error_msg"` // 错误提示信息,失败才返回,成功不返回
|
||||
}
|
||||
|
||||
type auditData struct {
|
||||
Type int `json:"type"` // 审核主类型,11:百度官方违禁词库、12:文本反作弊、13:自定义文本黑名单、14:自定义文本白名单
|
||||
SubType int `json:"subType"` // 审核子类型,0:含多种类型,具体看官方链接,1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
Conclusion string `json:"conclusion"` // 审核结果,可取值:合规、不合规、疑似、审核失败
|
||||
ConclusionType int `json:"conclusionType"` // 审核结果类型,可取值1.合规,2.不合规,3.疑似,4.审核失败
|
||||
Msg string `json:"msg"` // 不合规项描述信息
|
||||
Hits []hit `json:"hits"`
|
||||
} // 不合规/疑似/命中白名单项详细信息。响应成功并且conclusion为疑似或不合规或命中白名单时才返回,响应失败或conclusion为合规且未命中白名单时不返回。
|
||||
|
||||
type hit struct {
|
||||
DatasetName string `json:"datasetName"` // 违规项目所属数据集名称
|
||||
Words []string `json:"words"` // 送检文本命中词库的关键词(备注:建议参考新字段“wordHitPositions”,包含信息更丰富:关键词以及对应的位置及标签信息)
|
||||
Probability float64 `json:"probability,omitempty"` // 不合规项置信度
|
||||
} // 送检文本违规原因的详细信息
|
||||
type keyConfig struct {
|
||||
Key1 string `json:"key1"` // 百度云服务内容审核key存储
|
||||
Key2 string `json:"key2"` // 百度云服务内容审核key存储
|
||||
Groups map[int64]group `json:"groups"` // 群配置存储
|
||||
}
|
||||
|
||||
type group struct {
|
||||
Enable EnableMark // 是否启用内容审核
|
||||
TextAudit EnableMark // 文本检测
|
||||
ImageAudit EnableMark // 图像检测
|
||||
DMRemind EnableMark // 撤回提示
|
||||
MoreRemind EnableMark // 详细违规提示
|
||||
DMBAN EnableMark // 撤回后禁言
|
||||
BANTimeAddEnable EnableMark // 禁言累加
|
||||
BANTime int64 // 标准禁言时间,禁用累加,但开启禁言的的情况下采用该值
|
||||
MaxBANTimeAddRange int64 // 最大禁言时间累加范围,最高禁言时间
|
||||
BANTimeAddTime int64 // 禁言累加时间,该值是开启禁累加功能后,再次触发时,根据被禁次数X该值计算出的禁言时间
|
||||
WhiteListType [8]bool // 类型白名单,处于白名单类型的违规,不会被触发 0:含多种类型,具体看官方链接,1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广
|
||||
AuditHistory map[int64]auditHistory // 被封禁用户列表
|
||||
}
|
||||
|
||||
// EnableMark 启用:●,禁用:○
|
||||
type EnableMark bool
|
||||
|
||||
// String 打印启用状态
|
||||
func (em EnableMark) String() string {
|
||||
if em {
|
||||
return "开启"
|
||||
}
|
||||
return "关闭"
|
||||
}
|
||||
|
||||
type auditHistory struct {
|
||||
Count int64 `json:"key2"` // 被禁次数
|
||||
ResList []baiduRes `json:"reslist"` // 禁言原因
|
||||
}
|
||||
|
||||
var bdcli *censor.ContentCensorClient // 百度云审核服务Client
|
||||
var typetext = [8]string{
|
||||
0: "默认违禁词库",
|
||||
1: "违禁违规",
|
||||
2: "文本色情",
|
||||
3: "敏感信息",
|
||||
4: "恶意推广",
|
||||
5: "低俗辱骂",
|
||||
6: "恶意推广-联系方式",
|
||||
7: "恶意推广-软文推广",
|
||||
} // 文本类型
|
||||
|
||||
var (
|
||||
config keyConfig // 插件配置
|
||||
configinit bool // 配置初始化
|
||||
configpath string // 配置路径
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("baiduaudit", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "百度内容审核",
|
||||
Help: "##该功能来自百度内容审核,需购买相关服务,并创建app##\n" +
|
||||
"- 获取BDAKey\n" +
|
||||
"- 配置BDAKey [API key] [Secret Key]\n" +
|
||||
"- 开启/关闭内容审核\n" +
|
||||
"- 开启/关闭撤回提示\n" +
|
||||
"- 开启/关闭详细提示\n" +
|
||||
"- 开启/关闭撤回禁言\n" +
|
||||
"##禁言时间设置## 禁言时间计算方式为:禁言次数*每次禁言累加时间,当达到最大禁言时间时,再次触发按最大禁言时间计算\n" +
|
||||
"- 开启/关闭禁言累加\n" +
|
||||
"- 设置撤回禁言时间[分钟,默认:1]\n" +
|
||||
"- 设置最大禁言时间[分钟,默认:60,最大43200]\n" +
|
||||
"- 设置每次累加时间[分钟,默认:1]\n" +
|
||||
"##检测类型设置## 类型编号列表:[1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广]\n" +
|
||||
"- 查看检测类型\n" +
|
||||
"- 查看检测配置\n" +
|
||||
"- 设置检测类型[类型编号]\n" +
|
||||
"- 设置不检测类型[类型编号]\n" +
|
||||
"- 开启/关闭文本检测\n" +
|
||||
"- 开启/关闭图像检测\n" +
|
||||
"##测试功能##\n" +
|
||||
"- 测试文本检测[文本内容]\n" +
|
||||
"- 测试图像检测[图片]\n",
|
||||
PrivateDataFolder: "baiduaudit",
|
||||
})
|
||||
configpath = engine.DataFolder() + "config.json"
|
||||
loadConfig()
|
||||
if configinit {
|
||||
bdcli = censor.NewClient(config.Key1, config.Key2)
|
||||
}
|
||||
engine.OnFullMatch("获取BDAKey", zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("接口key创建网址:\n" +
|
||||
"https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index\n" +
|
||||
"免费8w次数领取地址:\n" +
|
||||
"https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/resource/getFree"))
|
||||
})
|
||||
|
||||
engine.OnRegex("^查看检测(类型|配置)$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 获取群配置
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
var msgs string
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
if k1 == "类型" {
|
||||
msgs += "本群检测类型:"
|
||||
find := false
|
||||
// 遍历群检测类型名单
|
||||
for i, v := range group.WhiteListType {
|
||||
if !v {
|
||||
find = true
|
||||
msgs += fmt.Sprint("\n", i, ".", typetext[i])
|
||||
}
|
||||
}
|
||||
if !find {
|
||||
msgs += "无"
|
||||
}
|
||||
|
||||
} else {
|
||||
// 生成配置文本
|
||||
msgs = fmt.Sprintf("本群配置:\n"+
|
||||
"内容审核:%s\n"+
|
||||
"-文本:%s\n"+
|
||||
"-图像:%s\n"+
|
||||
"撤回提示:%s\n"+
|
||||
"-详细提示:%s\n"+
|
||||
"撤回禁言:%s\n"+
|
||||
"-禁言累加:%s\n"+
|
||||
"-撤回禁言时间:%v分钟\n"+
|
||||
"-每次累加时间:%v分钟\n"+
|
||||
"-最大禁言时间:%v分钟", group.Enable, group.TextAudit, group.ImageAudit, group.DMRemind, group.MoreRemind, group.DMBAN, group.BANTimeAddEnable, group.BANTime, group.BANTimeAddTime, group.MaxBANTimeAddRange)
|
||||
}
|
||||
b, err := text.RenderToBase64(msgs, text.FontFile, 300, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
|
||||
})
|
||||
engine.OnRegex("^设置(不)?检测类型([01234567])$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
inputType, _ := strconv.Atoi(k2)
|
||||
if k1 == "不" {
|
||||
group.WhiteListType[inputType] = true //不检测:则进入类型白名单
|
||||
} else {
|
||||
group.WhiteListType[inputType] = false //检测:则退出白名单
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群将%s检测%s类型内容", k1, typetext[inputType])))
|
||||
})
|
||||
engine.OnRegex("^设置(最大|每次|撤回)(累加|禁言)时间(\\d{1,5})$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k3 := ctx.State["regex_matched"].([]string)[3]
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
time, _ := strconv.ParseInt(k1, 10, 64)
|
||||
switch k1 {
|
||||
case "最大":
|
||||
group.MaxBANTimeAddRange = time
|
||||
case "每次":
|
||||
group.BANTimeAddTime = time
|
||||
case "撤回":
|
||||
group.BANTime = time
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s禁言累加时间已设置为%s", k3, k1)))
|
||||
})
|
||||
engine.OnRegex("^(开启|关闭)(内容审核|撤回提示|撤回禁言|禁言累加|详细提示|文本检测|图像检测)$", zero.AdminPermission, clientCheck).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
defer jsonSave(config, configpath)
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
isEnable := EnableMark(false)
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
if k1 == "开启" {
|
||||
isEnable = true
|
||||
}
|
||||
switch k2 {
|
||||
case "内容审核":
|
||||
group.Enable = isEnable
|
||||
case "撤回提示":
|
||||
group.DMRemind = isEnable
|
||||
case "撤回禁言":
|
||||
group.DMBAN = isEnable
|
||||
case "禁言累加":
|
||||
group.BANTimeAddEnable = isEnable
|
||||
case "详细提示":
|
||||
group.MoreRemind = isEnable
|
||||
case "文本检测":
|
||||
group.TextAudit = isEnable
|
||||
case "图像检测":
|
||||
group.ImageAudit = isEnable
|
||||
}
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("本群%s已%s", k2, k1)))
|
||||
})
|
||||
engine.OnRegex(`^配置BDAKey\s*(.*)\s*(.*)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
k1 := ctx.State["regex_matched"].([]string)[1]
|
||||
k2 := ctx.State["regex_matched"].([]string)[2]
|
||||
bdcli = censor.NewClient(k1, k2)
|
||||
config.Key1 = k1
|
||||
config.Key2 = k2
|
||||
if bdcli != nil {
|
||||
jsonSave(config, configpath)
|
||||
ctx.SendChain(message.Text("配置成功"))
|
||||
}
|
||||
})
|
||||
engine.OnMessage().SetBlock(false).Handle(func(ctx *zero.Ctx) {
|
||||
group, ok := config.Groups[ctx.Event.GroupID]
|
||||
// 如果没该配置,或者审核功能未开启直接跳过
|
||||
if !ok || !bool(group.Enable) {
|
||||
return
|
||||
}
|
||||
for _, elem := range ctx.Event.Message {
|
||||
switch elem.Type {
|
||||
case "image":
|
||||
if !group.ImageAudit {
|
||||
return
|
||||
}
|
||||
res := bdcli.ImgCensorUrl(elem.Data["url"], nil)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
banCheck(ctx, bdres)
|
||||
|
||||
case "text":
|
||||
if !group.TextAudit {
|
||||
return
|
||||
}
|
||||
res := bdcli.TextCensor(elem.Data["text"])
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
banCheck(ctx, bdres)
|
||||
}
|
||||
}
|
||||
})
|
||||
engine.OnPrefix("文本检测", clientCheck).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if bdcli == nil {
|
||||
ctx.SendChain(message.Text("Key未配置"))
|
||||
return
|
||||
}
|
||||
args := ctx.ExtractPlainText()
|
||||
res := bdcli.TextCensor(args)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
ctx.SendChain(buildResp(bdres, group)...)
|
||||
})
|
||||
engine.OnPrefix("^图像检测", clientCheck).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var urls []string
|
||||
for _, elem := range ctx.Event.Message {
|
||||
if elem.Type == "image" {
|
||||
if elem.Data["url"] != "" {
|
||||
urls = append(urls, elem.Data["url"])
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(urls) == 0 {
|
||||
return
|
||||
}
|
||||
res := bdcli.ImgCensorUrl(urls[0], nil)
|
||||
bdres, err := jsonToBaiduRes(res)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", bdres.ErrorMsg, "(", bdres.ErrorCode, ")"))
|
||||
return
|
||||
}
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
ctx.SendChain(buildResp(bdres, group)...)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 禁言检测
|
||||
func banCheck(ctx *zero.Ctx, bdres baiduRes) {
|
||||
// 如果返回类型为2(不合规),0为合规,3为疑似
|
||||
if bdres.ConclusionType == 2 {
|
||||
// 创建消息ID
|
||||
mid := message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64))
|
||||
// 获取群配置
|
||||
group := getGroup(ctx.Event.GroupID)
|
||||
// 检测群配置里的不检测类型白名单,忽略掉不检测的违规类型
|
||||
for i, b := range group.WhiteListType {
|
||||
if i == bdres.Data[0].SubType && b {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 生成回复文本
|
||||
res := buildResp(bdres, group)
|
||||
// 撤回消息
|
||||
ctx.DeleteMessage(mid)
|
||||
// 查看是否启用撤回后禁言
|
||||
if group.DMBAN {
|
||||
// 从历史违规记录中获取指定用户
|
||||
user := group.getUser(ctx.Event.UserID)
|
||||
// 用户违规次数自增
|
||||
user.Count++
|
||||
// 用户违规原因记录
|
||||
user.ResList = append(user.ResList, bdres)
|
||||
// 覆写该用户到群违规记录中
|
||||
group.AuditHistory[ctx.Event.UserID] = user
|
||||
// 覆写该群信息
|
||||
config.Groups[ctx.Event.GroupID] = group
|
||||
// 保存到json
|
||||
jsonSave(config, configpath)
|
||||
var bantime int64
|
||||
// 查看是否开启禁言累加功能,并计算禁言时间
|
||||
if group.BANTimeAddEnable {
|
||||
bantime = user.Count * group.BANTimeAddTime * 60
|
||||
} else {
|
||||
bantime = group.BANTime * 60
|
||||
}
|
||||
//执行禁言
|
||||
ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime)
|
||||
}
|
||||
//查看是否开启撤回提示
|
||||
if group.DMRemind {
|
||||
res = append(res, message.At(ctx.Event.Sender.ID))
|
||||
ctx.SendChain(res...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取群配置
|
||||
func getGroup(groupID int64) group {
|
||||
g, ok := config.Groups[groupID]
|
||||
if ok {
|
||||
return g
|
||||
}
|
||||
if config.Groups == nil {
|
||||
config.Groups = make(map[int64]group)
|
||||
}
|
||||
g = group{
|
||||
TextAudit: true,
|
||||
ImageAudit: true,
|
||||
BANTime: 1,
|
||||
MaxBANTimeAddRange: 60,
|
||||
BANTimeAddTime: 1,
|
||||
WhiteListType: [8]bool{},
|
||||
AuditHistory: map[int64]auditHistory{},
|
||||
}
|
||||
config.Groups[groupID] = g
|
||||
return g
|
||||
}
|
||||
|
||||
// 从群历史违规记录中获取用户
|
||||
func (group *group) getUser(userID int64) auditHistory {
|
||||
audit, ok := group.AuditHistory[userID]
|
||||
if ok {
|
||||
return audit
|
||||
}
|
||||
// 如果没有用户,则创建一个并返回
|
||||
if group.AuditHistory == nil {
|
||||
group.AuditHistory = make(map[int64]auditHistory)
|
||||
}
|
||||
audit = auditHistory{0, []baiduRes{}}
|
||||
group.AuditHistory[userID] = audit
|
||||
return audit
|
||||
}
|
||||
|
||||
// 客户端是否初始化检测
|
||||
func clientCheck(ctx *zero.Ctx) bool {
|
||||
if bdcli == nil {
|
||||
ctx.SendChain(message.Text("Key未配置"))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 加载JSON配置文件
|
||||
func loadConfig() {
|
||||
if file.IsExist(configpath) {
|
||||
data, err := os.OpenFile(configpath, os.O_RDONLY, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.NewDecoder(data).Decode(&config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
configinit = true
|
||||
} else {
|
||||
config = keyConfig{}
|
||||
configinit = false
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置文件
|
||||
func jsonSave(v keyConfig, path string) {
|
||||
jsf, _ := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
defer func(file *os.File) {
|
||||
err := file.Close()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}(jsf) // 结束时关闭句柄,释放资源
|
||||
err := json.NewEncoder(jsf).Encode(v)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// JSON反序列化
|
||||
func jsonToBaiduRes(resjson string) (baiduRes, error) {
|
||||
var bdres baiduRes
|
||||
err := json.Unmarshal(binary.StringToBytes(resjson), &bdres)
|
||||
return bdres, err
|
||||
}
|
||||
|
||||
// 生成回复文本
|
||||
func buildResp(bdres baiduRes, group group) []message.MessageSegment {
|
||||
// 建立消息段
|
||||
msgs := make([]message.MessageSegment, 0, 8)
|
||||
// 生成简略审核结果回复
|
||||
msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
|
||||
// 查看是否开启详细审核内容提示,并确定审核内容值为疑似,或者不合规
|
||||
if !group.MoreRemind {
|
||||
return msgs
|
||||
}
|
||||
// 遍历返回的不合规数据,生成详细违规内容
|
||||
for i, datum := range bdres.Data {
|
||||
msgs = append(msgs, message.Text("[", i, "]:", datum.Msg, "\n"))
|
||||
// 检查命中词条是否大于0
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
// 遍历打印命中的违规词条
|
||||
for _, hit := range datum.Hits {
|
||||
if len(datum.Hits) == 0 {
|
||||
return msgs
|
||||
}
|
||||
msgs = append(msgs, message.Text("("))
|
||||
for i4, i3 := range hit.Words {
|
||||
// 检查是否是最后一个要打印的词条,如果是则不加上逗号
|
||||
if i4 != len(hit.Words)-1 {
|
||||
msgs = append(msgs, message.Text(i3, ","))
|
||||
} else {
|
||||
msgs = append(msgs, message.Text(i3))
|
||||
}
|
||||
}
|
||||
msgs = append(msgs, message.Text(")"))
|
||||
}
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("base64gua", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "base64gua加解密\n" +
|
||||
"- 六十四卦加密xxx\n- 六十四卦解密xxx\n- 六十四卦用yyy加密xxx\n- 六十四卦用yyy解密xxx",
|
||||
Brief: "六十四卦加解密",
|
||||
Help: "- 六十四卦加密xxx\n- 六十四卦解密xxx\n- 六十四卦用yyy加密xxx\n- 六十四卦用yyy解密xxx",
|
||||
})
|
||||
en.OnRegex(`^六十四卦加密\s*(.+)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("baseamasiro", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "base天城文加解密\n" +
|
||||
"- 天城文加密xxx\n- 天城文解密xxx\n- 天城文用yyy加密xxx\n- 天城文用yyy解密xxx",
|
||||
Brief: "天城文加解密",
|
||||
Help: "- 天城文加密xxx\n- 天城文解密xxx\n- 天城文用yyy加密xxx\n- 天城文用yyy解密xxx",
|
||||
})
|
||||
en.OnRegex(`^天城文加密\s*(.+)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -48,13 +48,14 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("bilibili", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "bilibili (412就是拦截的意思,建议私聊把cookie设全)\n" +
|
||||
"- >vup info [xxx]\n" +
|
||||
Brief: "b站查成分查弹幕",
|
||||
Help: "- >vup info [xxx]\n" +
|
||||
"- >user info [xxx]\n" +
|
||||
"- 查成分 [xxx]\n" +
|
||||
"- 查弹幕 [xxx]\n" +
|
||||
"- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" +
|
||||
"- 更新vup",
|
||||
"- 更新vup" +
|
||||
"Tips: (412就是拦截的意思,建议私聊把cookie设全)\n",
|
||||
PublicDataFolder: "Bilibili",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
|
||||
@@ -29,8 +29,8 @@ var (
|
||||
func init() {
|
||||
en := control.Register("bilibiliparse", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "b站动态、专栏、视频、直播解析\n" +
|
||||
"- t.bilibili.com/642277677329285174 | bilibili.com/read/cv17134450 | bilibili.com/video/BV13B4y1x7pS | live.bilibili.com/22603245 ",
|
||||
Brief: "b站链接解析",
|
||||
Help: "例:- t.bilibili.com/642277677329285174\n- bilibili.com/read/cv17134450\n- bilibili.com/video/BV13B4y1x7pS\n- live.bilibili.com/22603245 ",
|
||||
})
|
||||
en.OnRegex(`((b23|acg).tv|bili2233.cn)/[0-9a-zA-Z]+`).SetBlock(true).Limit(limit.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -22,10 +22,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
|
||||
referer = "https://www.bilibili.com/"
|
||||
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v"
|
||||
serviceName = "bilibilipush"
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
|
||||
referer = "https://www.bilibili.com/"
|
||||
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v"
|
||||
)
|
||||
|
||||
// bdb bilibili推送数据库
|
||||
@@ -38,16 +37,18 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register(serviceName, &ctrl.Options[*zero.Ctx]{
|
||||
en := control.Register("bilibilipush", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "bilibilipush,需要配合job一起使用\n" +
|
||||
"- 添加b站订阅[uid|name]\n" +
|
||||
Brief: "b站推送",
|
||||
Help: "- 添加b站订阅[uid|name]\n" +
|
||||
"- 取消b站订阅[uid|name]\n" +
|
||||
"- 取消b站动态订阅[uid|name]\n" +
|
||||
"- 取消b站直播订阅[uid|name]\n" +
|
||||
"- b站推送列表\n" +
|
||||
"- 拉取b站推送 (使用job执行定时任务------记录在\"@every 10s\"触发的指令)",
|
||||
PrivateDataFolder: serviceName,
|
||||
"Tips: 需要配合job一起使用, 全局只需要设置一个, 无视响应状态推送, 下为例子\n" +
|
||||
"记录在\"@every 5m\"触发的指令)\n" +
|
||||
"拉取b站推送",
|
||||
PrivateDataFolder: "bilibilipush",
|
||||
})
|
||||
|
||||
// 加载bilibili推送数据库
|
||||
@@ -274,7 +275,7 @@ func sendDynamic(ctx *zero.Ctx) error {
|
||||
ct := cardList[i].Get("desc.timestamp").Int()
|
||||
if ct > t && ct > time.Now().Unix()-600 {
|
||||
lastTime[buid] = ct
|
||||
m, ok := control.Lookup(serviceName)
|
||||
m, ok := control.Lookup("bilibilipush")
|
||||
if ok {
|
||||
groupList := bdb.getAllGroupByBuidAndDynamic(buid)
|
||||
dc, err := bz.LoadDynamicDetail(cardList[i].Raw)
|
||||
@@ -323,7 +324,7 @@ func sendLive(ctx *zero.Ctx) error {
|
||||
oldStatus := liveStatus[key.Int()]
|
||||
if newStatus != oldStatus && newStatus == 1 {
|
||||
liveStatus[key.Int()] = newStatus
|
||||
m, ok := control.Lookup(serviceName)
|
||||
m, ok := control.Lookup("bilibilipush")
|
||||
if ok {
|
||||
groupList := bdb.getAllGroupByBuidAndLive(key.Int())
|
||||
roomID := value.Get("short_id").Int()
|
||||
|
||||
@@ -18,7 +18,8 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("bookreview", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "哀伤雪刃推书记录\n- 书评[xxx]\n- 随机书评",
|
||||
Brief: "哀伤雪刃推书书评",
|
||||
Help: "- 书评[xxx]\n- 随机书评",
|
||||
PublicDataFolder: "BookReview",
|
||||
})
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ var sm syncx.Map[int64, string]
|
||||
func init() {
|
||||
engine := control.Register("breakrepeat", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "打断复读\n- 打断" + strconv.Itoa(throttle) + "次以上复读\n",
|
||||
Brief: "打断复读",
|
||||
Help: "- 打断" + strconv.Itoa(throttle) + "次以上复读\n",
|
||||
})
|
||||
engine.On("message/group", zero.OnlyGroup, func(ctx *zero.Ctx) bool {
|
||||
return !zero.HasPicture(ctx)
|
||||
|
||||
@@ -32,8 +32,8 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("cangtoushi", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "藏头诗\n" +
|
||||
"- 藏头诗[xxx]\n- 藏尾诗[xxx]",
|
||||
Brief: "藏头诗, 藏尾诗",
|
||||
Help: "- 藏头诗[xxx]\n- 藏尾诗[xxx]",
|
||||
})
|
||||
engine.OnRegex(`藏头诗\s?([一-龥]{3,10})$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
kw := ctx.State["regex_matched"].([]string)[1]
|
||||
|
||||
@@ -17,6 +17,7 @@ var (
|
||||
poke = rate.NewManager[int64](time.Minute*5, 8) // 戳一戳
|
||||
engine = control.Register("chat", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "基础反应, 群空调",
|
||||
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]",
|
||||
})
|
||||
)
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("choose", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "choose\n" +
|
||||
"- 选择可口可乐还是百事可乐\n" +
|
||||
"- 选择肯德基还是麦当劳还是必胜客",
|
||||
Brief: "选择困难症帮手",
|
||||
Help: "例: 选择可口可乐还是百事可乐\n" +
|
||||
"选择肯德基还是麦当劳还是必胜客",
|
||||
})
|
||||
engine.OnPrefix("选择").SetBlock(true).Handle(handle)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("chouxianghua", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "抽象话\n- 抽象翻译xxx",
|
||||
Brief: "翻译为抽象话",
|
||||
Help: "- 抽象翻译xxx",
|
||||
PublicDataFolder: "ChouXiangHua",
|
||||
})
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ func init() {
|
||||
// 初始化engine
|
||||
engine := control.Register("chrev", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "字符翻转\n- 翻转 I love you",
|
||||
Brief: "英文字符翻转",
|
||||
Help: "例: 翻转 I love you",
|
||||
})
|
||||
// 处理字符翻转指令
|
||||
engine.OnRegex(`^翻转\s*([A-Za-z\s]*)$`).SetBlock(true).
|
||||
|
||||
@@ -25,7 +25,8 @@ var (
|
||||
func init() {
|
||||
control.Register("coser", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "三次元小姐姐\n- coser",
|
||||
Brief: "三次元coser",
|
||||
Help: "- coser",
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser").SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
|
||||
@@ -18,7 +18,8 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("cpstory", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
|
||||
Brief: "cp短打", // 这里也许有更好的名字
|
||||
Help: "- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
|
||||
PublicDataFolder: "CpStory",
|
||||
})
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ const (
|
||||
func init() {
|
||||
engine := control.Register("curse", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
|
||||
Brief: "骂人反击",
|
||||
Help: "- 骂我\n- 大力骂我",
|
||||
PublicDataFolder: "Curse",
|
||||
})
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import (
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("danbooru", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "二次元图片标签识别\n" +
|
||||
"- 鉴赏图片[图片]",
|
||||
DisableOnDefault: false,
|
||||
Brief: "二次元图片标签识别",
|
||||
Help: "- 鉴赏图片[图片]",
|
||||
PrivateDataFolder: "danbooru",
|
||||
})
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
|
||||
var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "嘉然\n" +
|
||||
"- 小作文\n" +
|
||||
Brief: "嘉然相关", // 也许使用常用功能当Brief更好
|
||||
Help: "- 小作文\n" +
|
||||
"- 发大病\n" +
|
||||
"- 教你一篇小作文[作文]",
|
||||
PublicDataFolder: "Diana",
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package driftbottle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/crc64"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
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{})
|
||||
}
|
||||
@@ -2,132 +2,108 @@
|
||||
package driftbottle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/crc64"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
type sea struct {
|
||||
ID int64 `db:"id"` // ID qq_grp_name_msg 的 crc64 hashCheck.
|
||||
QQ int64 `db:"qq"` // Get current user(Who sends this)
|
||||
Name string `db:"Name"` // his or her name at that time:P
|
||||
Msg string `db:"msg"` // What he or she sent to bot?
|
||||
Grp int64 `db:"grp"` // which group sends this msg?
|
||||
Time string `db:"time"` // we need to know the current time,master>
|
||||
}
|
||||
|
||||
var seaSide = &sql.Sqlite{}
|
||||
var seaLocker sync.RWMutex
|
||||
|
||||
// We need a container to inject what we need :(
|
||||
|
||||
func init() {
|
||||
en := control.Register("driftbottle", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "漂流瓶\n- (在群xxx)丢漂流瓶(到频道xxx) [消息]\n- (从频道xxx)捡漂流瓶\n- @BOT 创建频道 xxx\n- 跳入(频道)海中\n- 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global",
|
||||
Brief: "漂流瓶",
|
||||
Help: "- @bot pick" + "- @bot throw xxx (xxx为投递内容)",
|
||||
PrivateDataFolder: "driftbottle",
|
||||
})
|
||||
sea.DBPath = en.DataFolder() + "sea.db"
|
||||
err := sea.Open(time.Hour * 24)
|
||||
seaSide.DBPath = en.DataFolder() + "sea.db"
|
||||
err := seaSide.Open(time.Hour * 24)
|
||||
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,
|
||||
ctx.CardOrNickName(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不知何处涌来一股暗流,你失去了意识。")))
|
||||
})
|
||||
|
||||
_ = createChannel(seaSide)
|
||||
en.OnFullMatch("pick", zero.OnlyToMe, zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
be, err := fetchBottle(seaSide)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERR:", err))
|
||||
}
|
||||
idstr := strconv.Itoa(int(be.ID))
|
||||
qqstr := strconv.Itoa(int(be.QQ))
|
||||
grpstr := strconv.Itoa(int(be.Grp))
|
||||
botname := zero.BotConfig.NickName[0]
|
||||
msg := message.Message{message.CustomNode(botname, ctx.Event.SelfID, botname+"试着帮你捞出来了这个~\nID:"+idstr+"\n投递人: "+be.Name+"("+qqstr+")"+"\n群号: "+grpstr+"\n时间: "+be.Time+"\n内容: \n"+be.Msg)}
|
||||
ctx.Send(msg)
|
||||
})
|
||||
|
||||
en.OnRegex(`throw.*?(.*)`, zero.OnlyToMe, zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
senderFormatTime := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
|
||||
rawSenderMessage := ctx.State["regex_matched"].([]string)[1]
|
||||
rawMessageCallBack := message.UnescapeCQCodeText(rawSenderMessage)
|
||||
keyWordsNum := utf8.RuneCountInString(rawMessageCallBack)
|
||||
if keyWordsNum < 10 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("需要投递的内容过少( "))
|
||||
return
|
||||
}
|
||||
// check current needs and prepare to throw drift_bottle.
|
||||
err = globalbottle(
|
||||
ctx.Event.UserID,
|
||||
ctx.Event.GroupID,
|
||||
senderFormatTime,
|
||||
ctx.CardOrNickName(ctx.Event.UserID),
|
||||
rawMessageCallBack,
|
||||
).throw(seaSide)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("已经帮你丢出去了哦~")))
|
||||
})
|
||||
}
|
||||
|
||||
func globalbottle(qq, grp int64, time, name, msg string) *sea { // Check as if the User is available and collect information to store.
|
||||
id := int64(crc64.Checksum(binary.StringToBytes(fmt.Sprintf("%d_%d_%s_%s_%s", grp, qq, time, name, msg)), crc64.MakeTable(crc64.ISO)))
|
||||
return &sea{ID: id, Grp: grp, Time: time, QQ: qq, Name: name, Msg: msg}
|
||||
}
|
||||
|
||||
func (be *sea) throw(db *sql.Sqlite) error {
|
||||
seaLocker.Lock()
|
||||
defer seaLocker.Unlock()
|
||||
return db.Insert("global", be)
|
||||
}
|
||||
|
||||
func fetchBottle(db *sql.Sqlite) (*sea, error) {
|
||||
seaLocker.Lock()
|
||||
defer seaLocker.Unlock()
|
||||
be := new(sea)
|
||||
return be, db.Pick("global", be)
|
||||
}
|
||||
|
||||
func createChannel(db *sql.Sqlite) error {
|
||||
seaLocker.Lock()
|
||||
defer seaLocker.Unlock()
|
||||
return db.Create("global", &sea{})
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ const bed = "https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%
|
||||
func init() {
|
||||
control.Register("emojimix", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "合成emoji\n" +
|
||||
"- [emoji][emoji]",
|
||||
Brief: "合成emoji",
|
||||
Help: "- [emoji][emoji]",
|
||||
}).OnMessage(match).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
r := ctx.State["emojimix"].([]rune)
|
||||
|
||||
@@ -13,10 +13,7 @@ import (
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
)
|
||||
|
||||
const (
|
||||
servicename = "epidemic"
|
||||
txurl = "https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=statisGradeCityDetail,diseaseh5Shelf"
|
||||
)
|
||||
const txurl = "https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=statisGradeCityDetail,diseaseh5Shelf"
|
||||
|
||||
// result 疫情查询结果
|
||||
type result struct {
|
||||
@@ -50,10 +47,10 @@ type area struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.Register("epidemic", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "城市疫情查询\n" +
|
||||
"- xxx疫情\n",
|
||||
Brief: "城市疫情查询",
|
||||
Help: "- xxx疫情\n",
|
||||
})
|
||||
engine.OnSuffix("疫情").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -17,10 +17,10 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("event", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "好友申请以及群聊邀请事件处理,默认发送给主人列表第一位\n" +
|
||||
"- [开启|关闭]自动同意[申请|邀请|主人]\n" +
|
||||
Brief: "好友申请和群聊邀请事件处理",
|
||||
Help: "- [开启|关闭]自动同意[申请|邀请|主人]\n" +
|
||||
"- [同意|拒绝][申请|邀请][flag]\n" +
|
||||
"flag跟随事件一起发送, 默认同意主人的事件",
|
||||
"Tips: 信息默认发送给主人列表第一位, 默认同意所有主人的事件, flag跟随事件一起发送",
|
||||
})
|
||||
engine.On("request/group/invite").SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -14,7 +14,8 @@ import (
|
||||
func init() {
|
||||
control.Register("font", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "渲染任意文字到图片\n- (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx",
|
||||
Brief: "渲染任意文字到图片",
|
||||
Help: "- (用[字体])渲染文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]",
|
||||
}).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
fnt := ctx.State["regex_matched"].([]string)[1]
|
||||
txt := ctx.State["regex_matched"].([]string)[2]
|
||||
|
||||
@@ -51,8 +51,8 @@ func init() {
|
||||
// 插件主体
|
||||
en := control.Register("fortune", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "每日运势: \n" +
|
||||
"- 运势 | 抽签\n" +
|
||||
Brief: "每日运势",
|
||||
Help: "- 运势 | 抽签\n" +
|
||||
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘 | 东方归言录 | 奇异恩典 | 夏日口袋 | ASoul]",
|
||||
PublicDataFolder: "Fortune",
|
||||
})
|
||||
|
||||
@@ -26,8 +26,8 @@ var db = &sql.Sqlite{}
|
||||
func init() {
|
||||
en := control.Register("funny", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "讲个笑话\n" +
|
||||
"- 讲个笑话[@xxx|qq号|人名] | 夸夸[@xxx|qq号|人名] ",
|
||||
Brief: "讲个笑话",
|
||||
Help: "- 讲个笑话[@xxx|qq号|人名] | 夸夸[@xxx|qq号|人名] ",
|
||||
PublicDataFolder: "Funny",
|
||||
})
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("genshin", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "原神抽卡\n- 原神十连\n- 切换原神卡池",
|
||||
Brief: "原神模拟抽卡",
|
||||
Help: "- 原神十连\n- 切换原神卡池",
|
||||
PublicDataFolder: "Genshin",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
|
||||
@@ -128,7 +128,8 @@ func init() { // 插件主体
|
||||
}
|
||||
en := control.Register("gif", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "GIF制图,命令后艾特群友/QQ号/一张图方可触发命令\n其中XXX可以为任何文字,可以不写\n对机器人操作请先艾特机器人再执行命令\n" +
|
||||
Brief: "制图",
|
||||
Help: "下为制图命令: " +
|
||||
"- 搓|-冲|-摸|-拍|-丢|-吃|-敲|-啃|-蹭|-爬|-撕|-灰度|-上翻|-下翻\n" +
|
||||
"- 左翻|-右翻|-反色|-浮雕|- 打码|- 负片|- 旋转|- 变形|- 亲\n" +
|
||||
"- 结婚申请|结婚登记|- 阿尼亚喜欢XXX|- 像只|- 我永远喜欢XXX\n" +
|
||||
@@ -141,7 +142,10 @@ func init() { // 插件主体
|
||||
"- 抬棺|- 远离|- 我老婆|- 小天使XXX|- 你的XXX|- 不要看\n" +
|
||||
"- 玩一下XXX|- 给我变|- 揍|- 吞|- 膜拜|- 诶嘿|- 2蹭|- 你犯法了\n" +
|
||||
"- 砰|- 注意力涣散|- 蒙蔽|- 踩|- 好玩|- 2转|- 踢球|- 2舔|\n" +
|
||||
"- 可莉吃|- 胡桃啃|- 怀|- 一直(支持动图)",
|
||||
"- 可莉吃|- 胡桃啃|- 怀|- 一直(支持动图)\n" +
|
||||
"例: 制图命令XXX[@用户|QQ号|图片]" +
|
||||
"Tips: XXX可以为限制长度的任何文字\n" +
|
||||
"对Bot使用为 @Bot制图命令[XXX]@Bot",
|
||||
PrivateDataFolder: "gif",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
datapath = file.BOTPATH + "/" + en.DataFolder()
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
func init() { // 插件主体
|
||||
control.Register("github", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "GitHub仓库搜索\n" +
|
||||
"- >github [xxx]\n" +
|
||||
Brief: "GitHub仓库搜索",
|
||||
Help: "- >github [xxx]\n" +
|
||||
"- >github -p [xxx]",
|
||||
}).OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -32,8 +32,6 @@ import (
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
const servicename = "guessmusic"
|
||||
|
||||
var (
|
||||
filelist []listinfo
|
||||
musictypelist = "mp3;MP3;wav;WAV;amr;AMR;3gp;3GP;3gpp;3GPP;acc;ACC"
|
||||
@@ -42,26 +40,27 @@ var (
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register(servicename, &ctrl.Options[*zero.Ctx]{
|
||||
engine := control.Register("guessmusic", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "猜歌插件(该插件依赖ffmpeg)\n" +
|
||||
"由于不可抗因素无法获取网易云歌单内容,\n插件改为本地猜歌了,但保留了下歌功能\n" +
|
||||
Brief: "猜歌插件",
|
||||
Help: "由于不可抗因素无法获取网易云歌单内容, 插件改为本地猜歌了, 但保留了下歌功能\n" +
|
||||
"------bot主人指令------\n" +
|
||||
"- 设置猜歌歌库路径 [绝对路径]\n" +
|
||||
"-(指令仅歌词有效) 猜歌[开启/关闭][歌单/歌词]自动下载\n" +
|
||||
"-(指令已失效) 添加歌单 [网易云歌单链接/ID] [歌单名称]\n" +
|
||||
"- (指令仅歌词有效) 猜歌[开启/关闭][歌单/歌词]自动下载\n" +
|
||||
"- (指令已失效) 添加歌单 [网易云歌单链接/ID] [歌单名称]\n" +
|
||||
"- 下载歌曲 [歌曲名称/网易云歌曲ID] [歌单名称]\n" +
|
||||
"- 删除歌单 [网易云歌单ID/歌单名称]\n" +
|
||||
"注:\n删除网易云歌单ID仅只是解除绑定\n删除歌单名称是将本地数据全部删除,慎用\n" +
|
||||
"注: 删除网易云歌单ID仅只是解除绑定\n删除歌单名称是将本地数据全部删除, 慎用\n" +
|
||||
"------管 理 员 指 令------\n" +
|
||||
"- 设置猜歌默认歌单 [歌单名称]\n" +
|
||||
"------公 用 指 令------\n" +
|
||||
"- 歌单列表\n" +
|
||||
"- [个人/团队]猜歌\n" +
|
||||
"注:默认歌库为歌单列表第一个\n如果设置了默认歌单变为指定的歌单\n" +
|
||||
"可在“[个人/团队]猜歌指令”后面添加[-歌单名称]进行指定歌单猜歌\n" +
|
||||
"注: 默认歌库为歌单列表第一个, 如果设置了默认歌单变为指定的歌单\n" +
|
||||
"可在\"[个人/团队]猜歌指令\"后面添加[-歌单名称]进行指定歌单猜歌\n" +
|
||||
"猜歌内容必须以[-]开头才会识别\n" +
|
||||
"本地歌曲命名规则为:\n歌名 - 歌手 - 其他(歌曲出处之类)",
|
||||
"本地歌曲命名规则为:\n歌名 - 歌手 - 其他(歌曲出处之类)\n" +
|
||||
"重要事项: 本插件依赖ffmpeg",
|
||||
PrivateDataFolder: "guessmusic",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
@@ -73,7 +72,7 @@ func init() { // 插件主体
|
||||
)
|
||||
}),
|
||||
))
|
||||
serviceErr := "[" + servicename + "]"
|
||||
serviceErr := "[guessmusic]"
|
||||
// 用于存放歌曲三个片段的文件夹
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
err := os.MkdirAll(cachePath, 0777)
|
||||
@@ -165,7 +164,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text(serviceErr, "ERROR:\n", err))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^猜歌(开启|关闭)(歌单|歌词)自动下载`).SetBlock(true).
|
||||
engine.OnRegex(`^猜歌(开启|关闭)(歌单|歌词)自动下载`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
swtich := ctx.State["regex_matched"].([]string)[1]
|
||||
option := ctx.State["regex_matched"].([]string)[1]
|
||||
|
||||
@@ -27,8 +27,8 @@ var (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("heisi", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "黑丝\n" +
|
||||
"- 来点黑丝\n- 来点白丝\n- 来点jk\n- 来点巨乳\n- 来点足控\n- 来点网红",
|
||||
Brief: "黑丝",
|
||||
Help: "- 来点黑丝\n- 来点白丝\n- 来点jk\n- 来点巨乳\n- 来点足控\n- 来点网红",
|
||||
PublicDataFolder: "Heisi",
|
||||
})
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ const (
|
||||
func init() {
|
||||
engine := control.Register("hs", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "炉石\n" +
|
||||
"- 搜卡[xxxx]\n" +
|
||||
Brief: "炉石搜卡",
|
||||
Help: "- 搜卡[xxxx]\n" +
|
||||
"- [卡组代码xxx]\n" +
|
||||
"- 更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp",
|
||||
PrivateDataFolder: "hs",
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
const bed = "https://gitcode.net/u011570312/OguraHyakuninIsshu/-/raw/master/"
|
||||
|
||||
//nolint: asciicheck
|
||||
// nolint: asciicheck
|
||||
type line struct {
|
||||
番号, 歌人, 上の句, 下の句, 上の句ひらがな, 下の句ひらがな string
|
||||
}
|
||||
@@ -56,8 +56,8 @@ var lines [100]*line
|
||||
func init() {
|
||||
engine := control.Register("hyaku", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "百人一首\n" +
|
||||
"- 百人一首(随机发一首)\n" +
|
||||
Brief: "百人一首",
|
||||
Help: "- 百人一首(随机发一首)\n" +
|
||||
"- 百人一首之n",
|
||||
PrivateDataFolder: "hyaku",
|
||||
})
|
||||
|
||||
@@ -64,8 +64,8 @@ var hrefre = regexp.MustCompile(`<a href=".*">`)
|
||||
func init() {
|
||||
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "关键字搜图\n" +
|
||||
"- 来张 [xxx]",
|
||||
Brief: "关键字搜图",
|
||||
Help: "- 来张 [xxx]",
|
||||
}).OnRegex(`^来张\s?(.*)$`, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("inject", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "注入指令\n" +
|
||||
"- run[CQ码]",
|
||||
Brief: "注入指令",
|
||||
Help: "- run[CQ码]",
|
||||
})
|
||||
// 运行 CQ 码
|
||||
en.OnPrefix("run", zero.SuperUserPermission).SetBlock(true).
|
||||
|
||||
@@ -25,7 +25,8 @@ const (
|
||||
func init() {
|
||||
engine := control.Register("jandan", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "煎蛋网无聊图\n- 来份[屌|弔|吊]图\n- 更新[屌|弔|吊]图\n",
|
||||
Brief: "煎蛋网无聊图",
|
||||
Help: "- 来份[屌|弔|吊]图\n- 更新[屌|弔|吊]图\n",
|
||||
PublicDataFolder: "Jandan",
|
||||
})
|
||||
|
||||
|
||||
65
plugin/jiami/jiami.go
Normal file
65
plugin/jiami/jiami.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// Package jiami 兽语加密与解密
|
||||
package jiami
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址
|
||||
jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址
|
||||
|
||||
)
|
||||
|
||||
type nmd struct { // struct解析格式大概是
|
||||
Data struct {
|
||||
Message string
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("jiami", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "兽语加解密",
|
||||
Help: "兽语加解密\n" +
|
||||
"- 兽语加密xxx\n- 兽语解密xxx",
|
||||
})
|
||||
en.OnRegex(`^兽语加密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["regex_matched"].([]string)[1]
|
||||
es, err := web.GetData(fmt.Sprintf(jiami1, str)) // 将网站返回结果赋值
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
var r nmd // r数组
|
||||
err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(r.Data.Message)) // 输出提取后的结果
|
||||
})
|
||||
|
||||
en.OnRegex(`^兽语解密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["regex_matched"].([]string)[1]
|
||||
es, err := web.GetData(fmt.Sprintf(jiami2, str)) // 将网站返回结果赋值
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
var n nmd // r数组
|
||||
err = json.Unmarshal(es, &n) // 填api返回结果,struct地址
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(n.Data.Message)) // 输出提取后的结果
|
||||
})
|
||||
}
|
||||
@@ -32,12 +32,11 @@ type value struct {
|
||||
|
||||
func init() {
|
||||
// 初始化engine
|
||||
engine := control.Register(
|
||||
"jikipedia",
|
||||
&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "小鸡词典\n -[查梗|小鸡词典][梗]",
|
||||
},
|
||||
engine := control.Register("jikipedia", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "小鸡词典",
|
||||
Help: "- [查梗|小鸡词典][梗]",
|
||||
},
|
||||
)
|
||||
engine.OnPrefixGroup([]string{"小鸡词典", "查梗"}).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("jptingroom", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "日语听力学习材料\n" +
|
||||
"- 随机日语听力\n" +
|
||||
Brief: "日语听力学习材料",
|
||||
Help: "- 随机日语听力\n" +
|
||||
"- 随机日语歌曲\n" +
|
||||
"- 日语听力 xxx\n" +
|
||||
"- 日语歌曲 xxx\n",
|
||||
|
||||
@@ -25,8 +25,8 @@ const (
|
||||
func init() {
|
||||
control.Register("juejuezi", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "绝绝子生成器\n" +
|
||||
"- 喝奶茶绝绝子 | 绝绝子吃饭",
|
||||
Brief: "绝绝子生成器",
|
||||
Help: "例: 喝奶茶绝绝子\n绝绝子吃饭",
|
||||
}).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) {
|
||||
|
||||
@@ -34,8 +34,8 @@ var (
|
||||
func init() {
|
||||
en := control.Register("lolicon", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "lolicon\n" +
|
||||
"- 随机图片\n" +
|
||||
Brief: "随机图片",
|
||||
Help: "- 随机图片\n" +
|
||||
"- 随机图片 萝莉|少女\n" +
|
||||
"- 设置随机图片地址[http...]",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
91
plugin/magicprompt/magicprompt.go
Normal file
91
plugin/magicprompt/magicprompt.go
Normal file
@@ -0,0 +1,91 @@
|
||||
// Package magicprompt MagicPrompt-Stable-Diffusion吟唱提示
|
||||
package magicprompt
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
hf "github.com/FloatTech/AnimeAPI/huggingface"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/RomiChan/websocket"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
magicpromptRepo = "Gustavosta/MagicPrompt-Stable-Diffusion"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("magicprompt", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "MagicPrompt-Stable-Diffusion吟唱提示",
|
||||
Help: "- 吟唱提示 xxx",
|
||||
PrivateDataFolder: "magicprompt",
|
||||
})
|
||||
|
||||
// 开启
|
||||
engine.OnPrefixGroup([]string{`吟唱提示`, "吟唱补全"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
_ctx, _cancel := context.WithTimeout(context.Background(), hf.TimeoutMax*time.Second)
|
||||
defer _cancel()
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
|
||||
magicpromptURL := fmt.Sprintf(hf.WssJoinPath, magicpromptRepo)
|
||||
args := ctx.State["args"].(string)
|
||||
c, _, err := websocket.DefaultDialer.Dial(magicpromptURL, nil)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
r := hf.PushRequest{
|
||||
FnIndex: 0,
|
||||
Data: []interface{}{args},
|
||||
}
|
||||
b, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
err = c.WriteMessage(websocket.TextMessage, b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
t := time.NewTicker(time.Second * 1)
|
||||
defer t.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
_, data, err := c.ReadMessage()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
j := gjson.ParseBytes(data)
|
||||
if j.Get("msg").String() == hf.WssCompleteStatus {
|
||||
m := message.Message{}
|
||||
for _, v := range strings.Split(j.Get("output.data.0").String(), "\n\n") {
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(v)))
|
||||
}
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
return
|
||||
}
|
||||
case <-_ctx.Done():
|
||||
ctx.SendChain(message.Text("ERROR: 吟唱提示指令超时"))
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -47,11 +47,15 @@ const (
|
||||
"- 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}] {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}]\n" +
|
||||
"- 测试欢迎语\n" +
|
||||
"- 设置告别辞 参数同设置欢迎语\n" +
|
||||
"- 测试告别辞\n" +
|
||||
"- [开启 | 关闭]入群验证"
|
||||
"- [开启 | 关闭]入群验证\n" +
|
||||
"- 对信息回复:[设置 | 取消]精华\n" +
|
||||
"- 取消精华 [信息ID]\n" +
|
||||
"- /精华列表\n" +
|
||||
"Tips: {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -62,6 +66,7 @@ var (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("manager", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "群管插件",
|
||||
Help: hint,
|
||||
PrivateDataFolder: "manager",
|
||||
})
|
||||
@@ -577,6 +582,72 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
})
|
||||
// 设精
|
||||
engine.OnRegex(`^\[CQ:reply,id=(\d+)\].*(设置|取消)精华$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
essenceID, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||
option := ctx.State["regex_matched"].([]string)[2]
|
||||
var rsp zero.APIResponse
|
||||
switch option {
|
||||
case "设置":
|
||||
rsp = ctx.SetGroupEssenceMessage(essenceID)
|
||||
case "取消":
|
||||
rsp = ctx.DeleteGroupEssenceMessage(essenceID)
|
||||
}
|
||||
if rsp.RetCode == 0 {
|
||||
ctx.SendChain(message.Text(option, "成功"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text(option, "失败, 信息: ", rsp.Msg, "解释: ", rsp.Wording))
|
||||
}
|
||||
})
|
||||
engine.OnCommand("精华列表", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
list := ctx.GetGroupEssenceMessageList(ctx.Event.GroupID).Array()
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("本群精华列表:"))}
|
||||
n := len(list)
|
||||
if n > 30 {
|
||||
ctx.SendChain(message.Text("精华内容太多,仅显示前30个"))
|
||||
n = 30
|
||||
}
|
||||
for _, info := range list[:n] {
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Text(fmt.Sprintf(
|
||||
"信息ID: %d\n发送者昵称: %s\n发送者QQ 号: %d\n消息发送时间: %s\n操作者昵称: %s\n操作者QQ 号: %d\n精华设置时间: %s",
|
||||
info.Get("message_id").Int(),
|
||||
info.Get("sender_nick").String(),
|
||||
info.Get("sender_id").Int(),
|
||||
time.Unix(info.Get("sender_time").Int(), 0).Format("2006/01/02 15:04:05"),
|
||||
info.Get("operator_nick").String(),
|
||||
info.Get("operator_id").Int(),
|
||||
time.Unix(info.Get("operator_time").Int(), 0).Format("2006/01/02 15:04:05"),
|
||||
))),
|
||||
)
|
||||
msgData := ctx.GetMessage(message.NewMessageIDFromInteger(info.Get("message_id").Int())).Elements
|
||||
if msgData != nil {
|
||||
msg = append(msg,
|
||||
message.CustomNode(info.Get("sender_nick").String(), info.Get("sender_id").Int(), msgData),
|
||||
)
|
||||
} else {
|
||||
msg = append(msg,
|
||||
message.CustomNode(info.Get("sender_nick").String(), info.Get("sender_id").Int(), "[error]信息久远,无法获取,如需查看原始内容请在“精华信息”中查看"),
|
||||
)
|
||||
}
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
engine.OnPrefix("取消精华", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
essenceID, err := strconv.ParseInt(strings.TrimSpace(ctx.State["args"].(string)), 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: 请输入正确的设精ID"))
|
||||
return
|
||||
}
|
||||
rsp := ctx.DeleteGroupEssenceMessage(essenceID)
|
||||
if rsp.RetCode == 0 {
|
||||
ctx.SendChain(message.Text("取消成功"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("取消失败, 信息: ", rsp.Msg, "解释: ", rsp.Wording))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 传入 ctx 和 welcome格式string 返回cq格式string 使用方法:welcometocq(ctx,w.Msg)
|
||||
|
||||
@@ -30,13 +30,15 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("midicreate", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "midi音乐制作, 该插件需要安装timidity, linux安装脚本可参考https://gitcode.net/anto_july/midi/-/raw/master/timidity.sh, windows安装脚本可参考https://gitcode.net/anto_july/midi/-/raw/master/timidity.bat?inline=false, windows需要管理员模式运行\n" +
|
||||
"- midi制作 CCGGAAGR FFEEDDCR GGFFEEDR GGFFEEDR CCGGAAGR FFEEDDCR\n" +
|
||||
Brief: "midi音乐制作",
|
||||
Help: "- midi制作 CCGGAAGR FFEEDDCR GGFFEEDR GGFFEEDR CCGGAAGR FFEEDDCR\n" +
|
||||
"- 个人听音练习\n" +
|
||||
"- 团队听音练习\n" +
|
||||
"- *.mid (midi 转 txt)\n" +
|
||||
"- midi制作*.txt (txt 转 midi)\n" +
|
||||
"- 设置音色40 (0~127)",
|
||||
"- 设置音色40 (0~127)\n" +
|
||||
"重要事项: 该插件依赖timidity\n" +
|
||||
"linux安装脚本可参考https://gitcode.net/anto_july/midi/-/raw/master/timidity.sh\nwindows安装脚本可参考https://gitcode.net/anto_july/midi/-/raw/master/timidity.bat?inline=false, windows需要管理员模式运行",
|
||||
PrivateDataFolder: "midicreate",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
|
||||
@@ -28,8 +28,8 @@ var speakers = map[string]uint{
|
||||
func init() {
|
||||
en := control.Register("moegoe", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "moegoe\n" +
|
||||
"- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
Brief: "日韩中 VITS 模型拟声",
|
||||
Help: "- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" +
|
||||
"- 让[派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏]说(中文)",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
@@ -43,11 +43,11 @@ func TestSetHoliday(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("中秋节", 1, 2022, 9, 10)
|
||||
err = SetHoliday("中秋节", 1, 2023, 9, 29)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = SetHoliday("国庆节", 7, 2022, 10, 1)
|
||||
err = SetHoliday("国庆节", 7, 2023, 10, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ var (
|
||||
func init() { // 插件主体
|
||||
control.Register("moyu", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "moyu\n" +
|
||||
"- /启用 moyu\n" +
|
||||
Brief: "摸鱼提醒",
|
||||
Help: "- /启用 moyu\n" +
|
||||
"- /禁用 moyu\n" +
|
||||
"- 记录在\"0 10 * * *\"触发的指令\n" +
|
||||
" - 摸鱼提醒",
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
func init() {
|
||||
control.Register("moyucalendar", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "摸鱼人日历\n" +
|
||||
"- /启用 moyucalendar\n" +
|
||||
Brief: "摸鱼人日历",
|
||||
Help: "- /启用 moyucalendar\n" +
|
||||
"- /禁用 moyucalendar\n" +
|
||||
"- 记录在\"30 8 * * *\"触发的指令\n" +
|
||||
" - 摸鱼人日历",
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
func init() {
|
||||
control.Register("music", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "点歌\n" +
|
||||
"- 点歌[xxx]\n" +
|
||||
Brief: "点歌",
|
||||
Help: "- 点歌[xxx]\n" +
|
||||
"- 网易点歌[xxx]\n" +
|
||||
"- 酷我点歌[xxx]\n" +
|
||||
"- 酷狗点歌[xxx]",
|
||||
|
||||
@@ -24,8 +24,8 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("nativesetu", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "本地涩图\n" +
|
||||
"- 本地[xxx]\n" +
|
||||
Brief: "本地涩图",
|
||||
Help: "- 本地[xxx]\n" +
|
||||
"- 刷新本地[xxx]\n" +
|
||||
"- 设置本地setu绝对路径[xxx]\n" +
|
||||
"- 刷新所有本地setu\n" +
|
||||
@@ -95,7 +95,8 @@ func init() {
|
||||
})
|
||||
engine.OnFullMatch("所有本地setu分类").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := "所有本地setu分类"
|
||||
msg := "本地setu分类一览"
|
||||
hasnotchange := true
|
||||
ns.mu.RLock()
|
||||
for i, c := range ns.List() {
|
||||
n, err := ns.db.Count(c)
|
||||
@@ -105,8 +106,12 @@ func init() {
|
||||
msg += fmt.Sprintf("\n%02d. %s(error)", i, c)
|
||||
logrus.Errorln("[nsetu]", err)
|
||||
}
|
||||
hasnotchange = false
|
||||
}
|
||||
ns.mu.RUnlock()
|
||||
if hasnotchange {
|
||||
msg += "\n空"
|
||||
}
|
||||
ctx.SendChain(message.Text(msg))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("nwife", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
|
||||
Brief: "本地老婆",
|
||||
Help: "- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让 | 不让]所有人均可添加wife",
|
||||
PrivateDataFolder: "nwife",
|
||||
})
|
||||
base := engine.DataFolder()
|
||||
|
||||
@@ -17,7 +17,8 @@ import (
|
||||
func init() {
|
||||
control.Register("nbnhhsh", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "拼音首字母释义工具\n- ?? [缩写]",
|
||||
Brief: "拼音首字母释义工具",
|
||||
Help: "- ?? [缩写]",
|
||||
}).OnRegex(`^[??]{1,2} ?([a-z0-9]+)$`).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
|
||||
@@ -25,6 +25,11 @@ func (g *grammar) string() string {
|
||||
var db = &sql.Sqlite{}
|
||||
|
||||
func getRandomGrammarByTag(tag string) (g grammar) {
|
||||
_ = db.Find("grammar", &g, "where tag LIKE '%"+tag+"%' ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("grammar", &g, "WHERE tag LIKE '%"+tag+"%' ORDER BY RANDOM() limit 1")
|
||||
return
|
||||
}
|
||||
|
||||
func getRandomGrammarByKeyword(keyword string) (g grammar) {
|
||||
_ = db.Find("grammar", &g, "WHERE (name LIKE '%"+keyword+"%' or pronunciation LIKE '%"+keyword+"%') ORDER BY RANDOM() limit 1")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("nihongo", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "日语学习\n- 日语语法[xxx](使用tag随机)",
|
||||
Brief: "日语学习",
|
||||
Help: "- 日语语法[xxx](使用tag随机)\n" +
|
||||
"搜索日语语法[xxx]",
|
||||
PublicDataFolder: "Nihongo",
|
||||
})
|
||||
|
||||
@@ -47,7 +49,7 @@ func init() {
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`^日语语法\s?([0-9A-Za-zぁ-んァ-ヶ]{1,6})$`, getdb).SetBlock(true).
|
||||
engine.OnRegex(`^日语语法\s?([0-9A-Za-zぁ-んァ-ヶ~]{1,6})$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
g := getRandomGrammarByTag(ctx.State["regex_matched"].([]string)[1])
|
||||
if g.ID == 0 {
|
||||
@@ -63,4 +65,20 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^搜索日语语法\s?([0-9A-Za-zぁ-んァ-ヶ~]{1,25})$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
g := getRandomGrammarByKeyword(ctx.State["regex_matched"].([]string)[1])
|
||||
if g.ID == 0 {
|
||||
ctx.SendChain(message.Text("未能找到", ctx.State["regex_matched"].([]string)[1], "相关标签的语法"))
|
||||
return
|
||||
}
|
||||
data, err := text.RenderToBase64(g.string(), text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ var gCurCookieJar *cookiejar.Jar
|
||||
func init() {
|
||||
control.Register("novel", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "铅笔小说网搜索\n- 小说[xxx]",
|
||||
Brief: "铅笔小说网搜索",
|
||||
Help: "- 小说[xxx]",
|
||||
}).OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
|
||||
@@ -16,7 +16,8 @@ const hso = "https://gchat.qpic.cn/gchatpic_new//--4234EDEC5F147A4C319A41149D7E0
|
||||
func init() {
|
||||
engine := control.Register("nsfw", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "nsfw图片识别\n- nsfw打分[图片]",
|
||||
Brief: "nsfw图片识别",
|
||||
Help: "- nsfw打分[图片]",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
// 上传一张图进行评价
|
||||
engine.OnKeywordGroup([]string{"nsfw打分"}, zero.OnlyGroup, zero.MustProvidePicture).SetBlock(true).
|
||||
@@ -34,7 +35,8 @@ func init() {
|
||||
})
|
||||
control.Register("nsfwauto", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "nsfw图片自动识别\n- 当图片属于非 neutral 类别时自动发送评价",
|
||||
Brief: "nsfw图片自动识别",
|
||||
Help: "- 当图片属于非 neutral 类别时自动发送评价",
|
||||
}).OnMessage(zero.HasPicture).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
url := ctx.State["image_url"].([]string)
|
||||
|
||||
@@ -22,8 +22,8 @@ const bed = "https://gitcode.net/u011570312/senso-ji-omikuji/-/raw/main/"
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("omikuji", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "浅草寺求签\n" +
|
||||
"- 求签 | 占卜\n- 解签",
|
||||
Brief: "浅草寺求签",
|
||||
Help: "- 求签 | 占卜\n- 解签",
|
||||
PublicDataFolder: "Omikuji",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import (
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
|
||||
// 货币系统
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
)
|
||||
|
||||
// nolint: asciicheck
|
||||
@@ -58,17 +61,19 @@ var (
|
||||
|
||||
func init() {
|
||||
engine := control.Register("qqwife", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
PrivateDataFolder: "qqwife",
|
||||
Help: "一群一天一夫一妻制群老婆\n(每天凌晨刷新CP)\n" +
|
||||
"- 娶群友\n- 群老婆列表\n- 允许/禁止自由恋爱\n- 允许/禁止牛头人\n- 设置CD为xx小时 →(默认12小时)\n- 重置花名册\n- 重置所有花名册(用于清除所有群数据及其设置)\n" +
|
||||
DisableOnDefault: false,
|
||||
Brief: "一群一天一夫一妻制群老婆",
|
||||
Help: "- 娶群友\n- 群老婆列表\n- [允许|禁止]自由恋爱\n- [允许|禁止]牛头人\n- 设置CD为xx小时 →(默认12小时)\n- 重置花名册\n- 重置所有花名册(用于清除所有群数据及其设置)\n" +
|
||||
"--------------------------------\n以下指令存在CD,不跨天刷新,前两个受指令开关\n--------------------------------\n" +
|
||||
"- (娶|嫁)@对方QQ\n自由选择对象,自由恋爱(好感度越高成功率越高,保底30%概率)\n" +
|
||||
"- 当[对方Q号|@对方QQ]的小三\n我和你才是真爱,为了你我愿意付出一切(好感度越高成功率越高,保底10%概率)\n" +
|
||||
"- 闹离婚\n你谁啊,给我滚(好感度越高成功率越低)\n" +
|
||||
"- 做媒 @攻方QQ @受方QQ\n身为管理,群友的xing福是要搭把手的(攻受双方好感度越高成功率越高,保底30%概率)\n" +
|
||||
"- (娶|嫁)@对方QQ\n自由选择对象, 自由恋爱(好感度越高成功率越高,保底30%概率)\n" +
|
||||
"- 当[对方Q号|@对方QQ]的小三\n我和你才是真爱, 为了你我愿意付出一切(好感度越高成功率越高,保底10%概率)\n" +
|
||||
"- 闹离婚\n你谁啊, 给我滚(好感度越高成功率越低)\n" +
|
||||
"- 买礼物给[对方Q号|@对方QQ]\n使用小熊饼干获取好感度\n" +
|
||||
"- 做媒 @攻方QQ @受方QQ\n身为管理, 群友的xing福是要搭把手的(攻受双方好感度越高成功率越高,保底30%概率)\n" +
|
||||
"--------------------------------\n好感度规则\n--------------------------------\n" +
|
||||
"‘娶群友’指令好感度随机增加1~5。\n‘A牛B的C’会导致C恨A,好感度-5;\nB为了报复A,好感度+5(什么柜子play)\nA为BC做媒,成功B、C对A好感度+1反之-1\n做媒成功BC好感度+1",
|
||||
"\"娶群友\"指令好感度随机增加1~5。\n\"A牛B的C\"会导致C恨A, 好感度-5;\nB为了报复A, 好感度+5(什么柜子play)\nA为BC做媒,成功B、C对A好感度+1反之-1\n做媒成功BC好感度+1" +
|
||||
"Tips: 群老婆列表过0点刷新",
|
||||
PrivateDataFolder: "qqwife",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
@@ -458,6 +463,75 @@ func init() {
|
||||
),
|
||||
)
|
||||
})
|
||||
// 礼物系统
|
||||
engine.OnRegex(`^买礼物给\s?(\[CQ:at,qq=(\d+)\]|(\d+))`, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
fiancee := ctx.State["regex_matched"].([]string)
|
||||
gay, _ := strconv.ParseInt(fiancee[2]+fiancee[3], 10, 64)
|
||||
// 获取CD
|
||||
cdTime, err := 民政局.getCDtime(gid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]获取该群技能CD错误(将以CD12H计算)\n", err))
|
||||
}
|
||||
ok, err := 民政局.compareCDtime(gid, uid, 5, cdTime)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]查询用户CD状态失败,请重试\n", err))
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
ctx.SendChain(message.Text("舔狗,今天你已经送过礼物了。"))
|
||||
return
|
||||
}
|
||||
// 获取好感度
|
||||
favor, err := 民政局.getFavorability(uid, gay)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]好感度库发生问题力\n", err))
|
||||
return
|
||||
}
|
||||
// 对接小熊饼干
|
||||
walletinfo := wallet.GetWalletOf(uid)
|
||||
if walletinfo < 1 {
|
||||
ctx.SendChain(message.Text("你钱包没钱啦!"))
|
||||
return
|
||||
}
|
||||
moneyToFavor := rand.Intn(math.Min(walletinfo, 100)) + 1
|
||||
// 计算钱对应的好感值
|
||||
newFavor := 1
|
||||
if favor > 50 {
|
||||
newFavor += moneyToFavor % 10 // 礼物厌倦
|
||||
} else {
|
||||
newFavor += rand.Intn(moneyToFavor)
|
||||
}
|
||||
// 随机对方心情
|
||||
mood := rand.Intn(5)
|
||||
if mood == 0 {
|
||||
newFavor = -newFavor
|
||||
}
|
||||
// 记录结果
|
||||
err = wallet.InsertWalletOf(uid, -moneyToFavor)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]钱包坏掉力:\n", err))
|
||||
return
|
||||
}
|
||||
lastfavor, err := 民政局.setFavorability(uid, gay, newFavor)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]好感度数据库发生问题力\n", err))
|
||||
return
|
||||
}
|
||||
// 写入CD
|
||||
err = 民政局.writeCDtime(gid, uid, 5)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.At(uid), message.Text("[qqwife]你的技能CD记录失败\n", err))
|
||||
}
|
||||
// 输出结果
|
||||
if mood == 0 {
|
||||
ctx.SendChain(message.Text("你花了", moneyToFavor, "ATRI币买了一件女装送给了ta,ta很不喜欢,你们的好感度降低至", lastfavor))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("你花了", moneyToFavor, "ATRI币买了一件女装送给了ta,ta很喜欢,你们的好感度升至", lastfavor))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatchGroup([]string{"闹离婚", "办离婚"}, zero.OnlyGroup, getdb, checkdivorce).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
// nolint: asciicheck
|
||||
// nolint: asciicheck
|
||||
type 婚姻登记 struct {
|
||||
db *sql.Sqlite
|
||||
dbmu sync.RWMutex
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// 结婚证信息
|
||||
@@ -55,8 +55,8 @@ type cdsheet struct {
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 开门时间(gid int64) (ok bool, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
ok = false
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
@@ -99,8 +99,8 @@ func (sql *婚姻登记) 开门时间(gid int64) (ok bool, err error) {
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 营业模式(gid int64) (canMatch, canNtr int, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
if err = sql.db.Drop("updateinfo"); err == nil {
|
||||
@@ -130,8 +130,8 @@ func (sql *婚姻登记) 营业模式(gid int64) (canMatch, canNtr int, err erro
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 修改模式(gid int64, mode string, stauts int) (err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
if err = sql.db.Drop("updateinfo"); err == nil {
|
||||
@@ -169,8 +169,8 @@ func (sql *婚姻登记) 修改模式(gid int64, mode string, stauts int) (err e
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 清理花名册(gid string) error {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
grouplist, err := sql.db.ListTables()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -209,8 +209,8 @@ func (sql *婚姻登记) 清理花名册(gid string) error {
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 查户口(gid, uid int64) (info userinfo, status string, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
uidstr := strconv.FormatInt(uid, 10)
|
||||
status = "单"
|
||||
@@ -232,8 +232,8 @@ func (sql *婚姻登记) 查户口(gid, uid int64) (info userinfo, status string
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 登记(gid, uid, target int64, username, targetname string) error {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
err := sql.db.Create(gidstr, &userinfo{})
|
||||
if err != nil {
|
||||
@@ -254,24 +254,24 @@ func (sql *婚姻登记) 登记(gid, uid, target int64, username, targetname str
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 离婚休妻(gid, wife int64) error {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
wifestr := strconv.FormatInt(wife, 10)
|
||||
return sql.db.Del(gidstr, "where target = "+wifestr)
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 离婚休夫(gid, husband int64) error {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
husbandstr := strconv.FormatInt(husband, 10)
|
||||
return sql.db.Del(gidstr, "where user = "+husbandstr)
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 花名册(gid int64) (list [][4]string, number int, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
err = sql.db.Create(gidstr, &userinfo{})
|
||||
if err != nil {
|
||||
@@ -322,8 +322,8 @@ func slicename(name string, canvas *gg.Context) (resultname string) {
|
||||
|
||||
// 获取好感度
|
||||
func (sql *婚姻登记) getFavorability(uid, target int64) (favor int, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("favorability", &favorability{})
|
||||
if err != nil {
|
||||
return
|
||||
@@ -345,8 +345,8 @@ func (sql *婚姻登记) getFavorability(uid, target int64) (favor int, err erro
|
||||
|
||||
// 设置好感度 正增负减
|
||||
func (sql *婚姻登记) setFavorability(uid, target int64, score int) (favor int, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("favorability", &favorability{})
|
||||
if err != nil {
|
||||
return
|
||||
@@ -360,7 +360,10 @@ func (sql *婚姻登记) setFavorability(uid, target int64, score int) (favor in
|
||||
Userinfo: uidstr + "+" + targstr + "+" + uidstr,
|
||||
Favor: score,
|
||||
})
|
||||
return score, err
|
||||
if err == nil {
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo glob '*"+uidstr+"+"+targstr+"*'")
|
||||
}
|
||||
return info.Favor, err
|
||||
}
|
||||
info.Favor += score
|
||||
if info.Favor > 100 {
|
||||
@@ -374,8 +377,8 @@ func (sql *婚姻登记) setFavorability(uid, target int64, score int) (favor in
|
||||
|
||||
// 获取技能时长
|
||||
func (sql *婚姻登记) getCDtime(gid int64) (skillCD float64, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
skillCD = 12
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
@@ -404,8 +407,8 @@ func (sql *婚姻登记) getCDtime(gid int64) (skillCD float64, err error) {
|
||||
|
||||
// 设置技能时长
|
||||
func (sql *婚姻登记) setCDtime(gid int64, cdTime float64) (err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err = sql.db.Create("updateinfo", &updateinfo{})
|
||||
if err != nil {
|
||||
if err = sql.db.Drop("updateinfo"); err == nil {
|
||||
@@ -435,8 +438,8 @@ func (sql *婚姻登记) setCDtime(gid int64, cdTime float64) (err error) {
|
||||
|
||||
// 记录CD
|
||||
func (sql *婚姻登记) writeCDtime(gid, uid, mun int64) error {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
err := sql.db.Create("cdsheet", &cdsheet{})
|
||||
if err != nil {
|
||||
if err = sql.db.Drop("cdsheet"); err == nil {
|
||||
@@ -457,8 +460,8 @@ func (sql *婚姻登记) writeCDtime(gid, uid, mun int64) error {
|
||||
|
||||
// 判断CD是否过时
|
||||
func (sql *婚姻登记) compareCDtime(gid, uid, mun int64, cdtime float64) (ok bool, err error) {
|
||||
sql.dbmu.Lock()
|
||||
defer sql.dbmu.Unlock()
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
ok = false
|
||||
err = sql.db.Create("cdsheet", &cdsheet{})
|
||||
if err != nil {
|
||||
|
||||
105
plugin/realcugan/realcugan.go
Normal file
105
plugin/realcugan/realcugan.go
Normal file
@@ -0,0 +1,105 @@
|
||||
// Package realcugan Real-CUGAN清晰术
|
||||
package realcugan
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"image"
|
||||
"strings"
|
||||
|
||||
hf "github.com/FloatTech/AnimeAPI/huggingface"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
realcuganRepo = "shichen1231/Real-CUGAN"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("realcugan", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "Real-CUGAN清晰术",
|
||||
Help: "- 清晰术(双重吟唱|三重吟唱|四重吟唱)(强力术式|中等术式|弱术式|不变式|原式)[图片]",
|
||||
PrivateDataFolder: "realcugan",
|
||||
})
|
||||
engine.OnPrefix("清晰术", zero.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
realcuganURL := fmt.Sprintf(hf.HTTPSPredictPath, realcuganRepo)
|
||||
for _, url := range ctx.State["image_url"].([]string) {
|
||||
imgdata, err := web.GetData(url)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
img, _, err := image.Decode(bytes.NewReader(imgdata))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 初始化参数
|
||||
var (
|
||||
fashu = ctx.Event.Message.ExtractPlainText()
|
||||
scale = 2
|
||||
con = "conservative"
|
||||
)
|
||||
switch {
|
||||
case strings.Contains(fashu, "双重吟唱"):
|
||||
scale = 2
|
||||
case strings.Contains(fashu, "三重吟唱") && img.Bounds().Dx()*img.Bounds().Dy() < 400000:
|
||||
scale = 3
|
||||
case strings.Contains(fashu, "四重吟唱") && img.Bounds().Dx()*img.Bounds().Dy() < 400000:
|
||||
scale = 4
|
||||
}
|
||||
switch {
|
||||
case strings.Contains(fashu, "强力术式"):
|
||||
con = "denoise3x"
|
||||
case strings.Contains(fashu, "中等术式"):
|
||||
con = "no-denoise"
|
||||
if scale == 2 {
|
||||
con = "denoise2x"
|
||||
}
|
||||
case strings.Contains(fashu, "弱术式"):
|
||||
con = "no-denoise"
|
||||
if scale == 2 {
|
||||
con = "denoise1x"
|
||||
}
|
||||
case strings.Contains(fashu, "不变式"):
|
||||
con = "no-denoise"
|
||||
case strings.Contains(fashu, "原式"):
|
||||
con = "conservative"
|
||||
}
|
||||
modelname := fmt.Sprintf("up%vx-latest-%v.pth", scale, con)
|
||||
encodeStr := base64.StdEncoding.EncodeToString(imgdata)
|
||||
encodeStr = "data:image/jpeg;base64," + encodeStr
|
||||
pr := hf.PushRequest{
|
||||
Data: []interface{}{encodeStr, modelname, 2},
|
||||
}
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
err = json.NewEncoder(buf).Encode(pr)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
data, err := web.PostData(realcuganURL, "application/json", buf)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
imgStr := gjson.ParseBytes(data).Get("data.0").String()
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(scale, "重唱", con, "分支大清晰术!")),
|
||||
ctxext.FakeSenderForwardNode(ctx, message.Image("base64://"+strings.TrimPrefix(imgStr, "data:image/png;base64,")))}
|
||||
if id := ctx.Send(m).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -17,7 +17,8 @@ import (
|
||||
func init() {
|
||||
en := control.Register("reborn", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "投胎\n- reborn",
|
||||
Brief: "投胎模拟器",
|
||||
Help: "- reborn",
|
||||
PublicDataFolder: "Reborn",
|
||||
})
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ var ro = runoob.NewRunOOB("b6365362a90ac2ac7098ba52c13e352b")
|
||||
func init() {
|
||||
control.Register("runcode", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "在线代码运行: \n" +
|
||||
">runcode [language] [code block]\n" +
|
||||
Brief: "在线代码运行",
|
||||
Help: ">runcode [language] [code block]\n" +
|
||||
"模板查看: \n" +
|
||||
">runcode [language] help\n" +
|
||||
"支持语种: \n" +
|
||||
|
||||
@@ -31,8 +31,8 @@ var (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("saucenao", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "搜图\n" +
|
||||
"- 以图搜图 | 搜索图片 | 以图识图[图片]\n" +
|
||||
Brief: "以图搜图",
|
||||
Help: "- 以图搜图 | 搜索图片 | 以图识图[图片]\n" +
|
||||
"- 搜图[P站图片ID]",
|
||||
PrivateDataFolder: "saucenao",
|
||||
})
|
||||
@@ -147,7 +147,7 @@ func init() { // 插件主体
|
||||
msg = append(msg, message.Image(pic))
|
||||
}
|
||||
msg = append(msg, message.Text("\n图源: ", result.Header.IndexName, binary.BytesToString(b)))
|
||||
ctx.Send(ctxext.FakeSenderForwardNode(ctx, msg...))
|
||||
ctx.Send(message.Message{ctxext.FakeSenderForwardNode(ctx, msg...)})
|
||||
if s > 80.0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("scale", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "叔叔的AI二次元图片放大\n- 放大图片[图片]",
|
||||
Brief: "二次元图片放大",
|
||||
Help: "- 放大图片[图片]",
|
||||
PrivateDataFolder: "scale",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
cachedir := engine.DataFolder()
|
||||
|
||||
@@ -107,7 +107,7 @@ func (sdb *scoredb) InsertOrUpdateSignInCountByUID(uid int64, count int) (err er
|
||||
if err = db.Model(&signintable{}).First(&si, "uid = ? ", uid).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Model(&signintable{}).Create(&si) // newUser not user
|
||||
err = db.Model(&signintable{}).Create(&si).Error // newUser not user
|
||||
}
|
||||
} else {
|
||||
err = db.Model(&signintable{}).Where("uid = ? ", uid).Update(
|
||||
|
||||
@@ -3,17 +3,13 @@ package score
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Coloured-glaze/gg"
|
||||
"github.com/golang/freetype"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
@@ -21,20 +17,29 @@ import (
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/golang/freetype"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
// 货币系统
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
)
|
||||
|
||||
const (
|
||||
backgroundURL = "https://img.moehu.org/pic.php?id=pc"
|
||||
signinMax = 1
|
||||
// SCOREMAX 分数上限定为120
|
||||
SCOREMAX = 120
|
||||
// SCOREMAX 分数上限定为1200
|
||||
SCOREMAX = 1200
|
||||
)
|
||||
|
||||
var (
|
||||
levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
|
||||
engine = control.Register("score", &ctrl.Options[*zero.Ctx]{
|
||||
rankArray = [...]int{0, 10, 20, 50, 100, 200, 350, 550, 750, 1000, 1200}
|
||||
engine = control.Register("score", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看分数排名",
|
||||
Brief: "签到",
|
||||
Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!",
|
||||
PrivateDataFolder: "score",
|
||||
})
|
||||
)
|
||||
@@ -49,25 +54,66 @@ func init() {
|
||||
}
|
||||
sdb = initialize(engine.DataFolder() + "score.db")
|
||||
}()
|
||||
zero.OnFullMatch("查看我的钱包").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
money := wallet.GetWalletOf(uid)
|
||||
ctx.SendChain(message.At(uid), message.Text("你的钱包当前有", money, "ATRI币"))
|
||||
})
|
||||
engine.OnFullMatch("签到").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
now := time.Now()
|
||||
today := now.Format("20060102")
|
||||
// 签到图片
|
||||
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
|
||||
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
|
||||
// 获取签到时间
|
||||
si := sdb.GetSignInByUID(uid)
|
||||
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
|
||||
drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png"
|
||||
|
||||
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
|
||||
|
||||
if si.Count >= signinMax && siUpdateTimeStr == today {
|
||||
switch {
|
||||
case si.Count >= signinMax && siUpdateTimeStr == today:
|
||||
// 如果签到时间是今天
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
}
|
||||
return
|
||||
case siUpdateTimeStr != today:
|
||||
// 如果是跨天签到就清数据
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, 0)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
err := initPic(picFile)
|
||||
// 更新签到次数
|
||||
err := sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新经验
|
||||
level := sdb.GetScoreByUID(uid).Score + 1
|
||||
if level > SCOREMAX {
|
||||
level = SCOREMAX
|
||||
ctx.SendChain(message.At(uid), message.Text("你的等级已经达到上限"))
|
||||
}
|
||||
err = sdb.InsertOrUpdateScoreByUID(uid, level)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// 更新钱包
|
||||
rank := getrank(level)
|
||||
add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高
|
||||
err = wallet.InsertWalletOf(uid, add)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
score := wallet.GetWalletOf(uid)
|
||||
// 绘图
|
||||
err = initPic(picFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -77,20 +123,12 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if siUpdateTimeStr != today {
|
||||
_ = sdb.InsertOrUpdateSignInCountByUID(uid, 0)
|
||||
}
|
||||
|
||||
_ = sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1)
|
||||
|
||||
// 避免图片过大,最大 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()
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
|
||||
monthWord := now.Format("01/02")
|
||||
hourWord := getHourWord(now)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
@@ -115,32 +153,23 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
add := 1
|
||||
canvas.DrawString(nickName+fmt.Sprintf(" 小熊饼干+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
|
||||
score := sdb.GetScoreByUID(uid).Score
|
||||
score += add
|
||||
if score > SCOREMAX {
|
||||
score = SCOREMAX
|
||||
ctx.SendChain(message.At(uid), message.Text("你获得的小熊饼干已经达到上限"))
|
||||
}
|
||||
_ = sdb.InsertOrUpdateScoreByUID(uid, score)
|
||||
level := getLevel(score)
|
||||
canvas.DrawString("当前小熊饼干:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
|
||||
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(level), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
|
||||
canvas.DrawString(nickName+fmt.Sprintf(" ATRI币+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
|
||||
canvas.DrawString("当前ATRI币:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
|
||||
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(rank), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
var nextLevelScore int
|
||||
if level < 10 {
|
||||
nextLevelScore = levelArray[level+1]
|
||||
var nextrankScore int
|
||||
if rank < 10 {
|
||||
nextrankScore = rankArray[rank+1]
|
||||
} else {
|
||||
nextLevelScore = SCOREMAX
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(score)/float64(nextLevelScore), float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(level)/float64(nextrankScore), float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
canvas.Fill()
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", score, nextLevelScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
@@ -174,7 +203,7 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile))
|
||||
})
|
||||
engine.OnFullMatch("查看分数排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
engine.OnFullMatch("查看等级排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
today := time.Now().Format("20060102")
|
||||
drawedFile := cachePath + today + "scoreRank.png"
|
||||
@@ -211,19 +240,111 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
bars := make([]chart.Value, len(st))
|
||||
for i, v := range st {
|
||||
bars[i].Value = float64(v.Score)
|
||||
bars[i].Label = ctx.CardOrNickName(v.UID)
|
||||
var bars []chart.Value
|
||||
for _, v := range st {
|
||||
if v.Score != 0 {
|
||||
bars = append(bars, chart.Value{
|
||||
Label: ctx.CardOrNickName(v.UID),
|
||||
Value: float64(v.Score),
|
||||
})
|
||||
}
|
||||
}
|
||||
err = chart.BarChart{
|
||||
Font: font,
|
||||
Title: "饼干排名",
|
||||
Title: "等级排名(1天只刷新1次)",
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
Top: 40,
|
||||
},
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Range: &chart.ContinuousRange{
|
||||
Min: 0,
|
||||
Max: math.Ceil(bars[0].Value/10) * 10,
|
||||
},
|
||||
},
|
||||
Height: 500,
|
||||
BarWidth: 50,
|
||||
Bars: bars,
|
||||
}.Render(chart.PNG, f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
_ = os.Remove(drawedFile)
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
engine.OnFullMatch("查看钱包排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||
today := time.Now().Format("20060102")
|
||||
drawedFile := cachePath + gid + today + "walletRank.png"
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
return
|
||||
}
|
||||
// 无缓存获取群员列表
|
||||
temp := ctx.GetThisGroupMemberListNoCache().Array()
|
||||
var usergroup []int64
|
||||
for _, info := range temp {
|
||||
usergroup = append(usergroup, info.Get("user_id").Int())
|
||||
}
|
||||
// 获取钱包信息
|
||||
st, err := wallet.GetGroupWalletOf(usergroup, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(st) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 当前没人获取过ATRI币"))
|
||||
return
|
||||
} else if len(st) > 10 {
|
||||
st = st[:10]
|
||||
}
|
||||
_, err = file.GetLazyData(text.FontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, err := os.ReadFile(text.FontFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
font, err := freetype.ParseFont(b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var bars []chart.Value
|
||||
for _, v := range st {
|
||||
if v.Money != 0 {
|
||||
bars = append(bars, chart.Value{
|
||||
Label: ctx.CardOrNickName(v.UID),
|
||||
Value: float64(v.Money),
|
||||
})
|
||||
}
|
||||
}
|
||||
err = chart.BarChart{
|
||||
Font: font,
|
||||
Title: "ATRI币排名(1天只刷新1次)",
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
Top: 40,
|
||||
},
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Range: &chart.ContinuousRange{
|
||||
Min: 0,
|
||||
Max: math.Ceil(bars[0].Value/10) * 10,
|
||||
},
|
||||
},
|
||||
Height: 500,
|
||||
BarWidth: 50,
|
||||
Bars: bars,
|
||||
@@ -256,8 +377,8 @@ func getHourWord(t time.Time) string {
|
||||
}
|
||||
}
|
||||
|
||||
func getLevel(count int) int {
|
||||
for k, v := range levelArray {
|
||||
func getrank(count int) int {
|
||||
for k, v := range rankArray {
|
||||
if count == v {
|
||||
return k
|
||||
} else if count < v {
|
||||
|
||||
@@ -53,8 +53,8 @@ var pool = &imgpool{
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("setutime", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "涩图\n" +
|
||||
"- 来份[涩图/二次元/风景/车万]\n" +
|
||||
Brief: "涩图",
|
||||
Help: "- 来份[涩图/二次元/风景/车万]\n" +
|
||||
"- 添加[涩图/二次元/风景/车万][P站图片ID]\n" +
|
||||
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
|
||||
"- >setu status",
|
||||
|
||||
@@ -12,15 +12,16 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
chpURL = "https://api.shadiao.app/chp"
|
||||
duURL = "https://api.shadiao.app/du"
|
||||
pyqURL = "https://api.shadiao.app/pyq"
|
||||
shadiaoURL = "https://api.shadiao.pro"
|
||||
chpURL = shadiaoURL + "/chp"
|
||||
duURL = shadiaoURL + "/du"
|
||||
pyqURL = shadiaoURL + "/pyq"
|
||||
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
|
||||
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
|
||||
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
|
||||
ergofabulousURL = "https://ergofabulous.org/luther/?"
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
||||
sdReferer = "https://api.shadiao.app/"
|
||||
sdReferer = shadiaoURL
|
||||
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
|
||||
loveliveReferer = "https://lovelive.tools/"
|
||||
)
|
||||
@@ -28,8 +29,8 @@ const (
|
||||
var (
|
||||
engine = control.Register("shadiao", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "沙雕app\n" +
|
||||
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子\n- 马丁路德骂我\n",
|
||||
Brief: "沙雕app", // 也许可以更好
|
||||
Help: "- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子\n- 马丁路德骂我\n",
|
||||
})
|
||||
sdMap = map[string]string{"哄我": chpURL, "来碗毒鸡汤": duURL, "发个朋友圈": pyqURL}
|
||||
)
|
||||
|
||||
@@ -16,11 +16,12 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("shindan", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "shindan\n" +
|
||||
"- 今天是什么少女[@xxx]\n" +
|
||||
Brief: "shindan测定",
|
||||
Help: "- 今天是什么少女[@xxx]\n" +
|
||||
"- 异世界转生[@xxx]\n" +
|
||||
"- 卖萌[@xxx]\n" +
|
||||
"- 抽老婆[@xxx]",
|
||||
"- 抽老婆[@xxx]\n" +
|
||||
"- 黄油角色[@xxx]",
|
||||
})
|
||||
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
|
||||
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
|
||||
|
||||
@@ -16,7 +16,8 @@ import (
|
||||
func init() {
|
||||
engine := control.Register("sleepmanage", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "sleepmanage\n- 早安\n- 晚安",
|
||||
Brief: "睡眠小助手",
|
||||
Help: "- 早安\n- 晚安",
|
||||
PrivateDataFolder: "sleep",
|
||||
})
|
||||
go func() {
|
||||
|
||||
@@ -4,14 +4,19 @@ package tarot
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -37,24 +42,32 @@ type formation struct {
|
||||
}
|
||||
type cardSet = map[string]card
|
||||
|
||||
var cardMap = make(cardSet, 80)
|
||||
var infoMap = make(map[string]cardInfo, 80)
|
||||
var formationMap = make(map[string]formation, 10)
|
||||
|
||||
var majorArcanaName = make([]string, 0, 80)
|
||||
var formationName = make([]string, 0, 10)
|
||||
var (
|
||||
cardMap = make(cardSet, 80)
|
||||
infoMap = make(map[string]cardInfo, 80)
|
||||
formationMap = make(map[string]formation, 10)
|
||||
majorArcanaName = make([]string, 0, 80)
|
||||
formationName = make([]string, 0, 10)
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("tarot", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "塔罗牌\n" +
|
||||
"- 抽[塔罗牌|大阿卡纳|小阿卡纳]\n" +
|
||||
Brief: "塔罗牌",
|
||||
Help: "- 抽[塔罗牌|大阿卡纳|小阿卡纳]\n" +
|
||||
"- 抽n张[塔罗牌|大阿卡纳|小阿卡纳]\n" +
|
||||
"- 解塔罗牌[牌名]\n" +
|
||||
"- [塔罗|大阿卡纳|小阿卡纳|混合]牌阵[圣三角|时间之流|四要素|五牌阵|吉普赛十字|马蹄|六芒星]",
|
||||
PublicDataFolder: "Tarot",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
cache := engine.DataFolder() + "cache"
|
||||
_ = os.RemoveAll(cache)
|
||||
err := os.MkdirAll(cache, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
getTarot := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
data, err := engine.GetLazyData("tarots.json", true)
|
||||
if err != nil {
|
||||
@@ -131,12 +144,32 @@ func init() {
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
if id := ctx.SendChain(
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n"),
|
||||
message.Image(bed+reverse[p]+card.ImgURL),
|
||||
message.Text("\n其释义为: ", description)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
imgurl := bed + reverse[p] + card.ImgURL
|
||||
imgname := ""
|
||||
if p == 1 {
|
||||
imgname = reverse[p][:len(reverse[p])-1] + name
|
||||
} else {
|
||||
imgname = name
|
||||
}
|
||||
imgpath := cache + "/" + imgname + ".png"
|
||||
err := pool.SendImageFromPool("pool"+imgname, imgpath, func() error {
|
||||
data, err := web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.Create(imgpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
return os.WriteFile(f.Name(), data, 0755)
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n其释义为: ", description))
|
||||
return
|
||||
}
|
||||
msg := make(message.Message, n)
|
||||
@@ -156,41 +189,61 @@ func init() {
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
tarotMsg := message.Message{
|
||||
message.Text(position[p], "的『", name, "』\n"),
|
||||
message.Image(bed + reverse[p] + card.ImgURL),
|
||||
message.Text("\n其释义为: ", description)}
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
|
||||
imgurl := bed + reverse[p] + card.ImgURL
|
||||
tarotmsg := message.Message{message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n")}
|
||||
var imgmsg message.MessageSegment
|
||||
var err error
|
||||
if p == 1 {
|
||||
imgmsg, err = poolimg(ctx, imgurl, reverse[p][:len(reverse[p])-1]+name, cache)
|
||||
} else {
|
||||
imgmsg, err = poolimg(ctx, imgurl, name, cache)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tarotmsg = append(tarotmsg, imgmsg)
|
||||
tarotmsg = append(tarotmsg, message.Text("\n其释义为: ", description))
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotmsg...)
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
ctx.Send(msg)
|
||||
})
|
||||
|
||||
engine.OnRegex(`^解塔罗牌\s?(.*)`, getTarot).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
|
||||
match := ctx.State["regex_matched"].([]string)[1]
|
||||
info, ok := infoMap[match]
|
||||
if ok {
|
||||
ctx.SendChain(
|
||||
message.Image(bed+info.ImgURL),
|
||||
message.Text("\n", match, "的含义是~"),
|
||||
message.Text("\n『正位』:", info.Description),
|
||||
message.Text("\n『逆位』:", info.ReverseDescription))
|
||||
} else {
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[:7], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[7:14], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[14:22], " "))
|
||||
build.WriteString("\n小阿尔卡纳:\n[圣杯|星币|宝剑|权杖] [0-10|侍从|骑士|王后|国王]")
|
||||
txt := build.String()
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
imgurl := bed + info.ImgURL
|
||||
var tarotmsg message.Message
|
||||
imgmsg, err := poolimg(ctx, imgurl, match, cache)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
tarotmsg = append(tarotmsg, imgmsg)
|
||||
tarotmsg = append(tarotmsg, message.Text("\n", match, "的含义是~\n『正位』:", info.Description, "\n『逆位』:", info.ReverseDescription))
|
||||
if id := ctx.Send(tarotmsg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
return
|
||||
}
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[:7], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[7:14], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[14:22], " "))
|
||||
build.WriteString("\n小阿尔卡纳:\n[圣杯|星币|宝剑|权杖] [0-10|侍从|骑士|王后|国王]")
|
||||
txt := build.String()
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
})
|
||||
engine.OnRegex(`^((塔罗|大阿(尔)?卡纳)|小阿(尔)?卡纳|混合)牌阵\s?(.*)`, getTarot).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
|
||||
cardType := ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -230,7 +283,20 @@ func init() {
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
tarotMsg := message.Message{message.Image(bed + reverse[p] + card.ImgURL)}
|
||||
var tarotmsg message.Message
|
||||
imgurl := bed + reverse[p] + card.ImgURL
|
||||
var imgmsg message.MessageSegment
|
||||
var err error
|
||||
if p == 1 {
|
||||
imgmsg, err = poolimg(ctx, imgurl, reverse[p][:len(reverse[p])-1]+name, cache)
|
||||
} else {
|
||||
imgmsg, err = poolimg(ctx, imgurl, name, cache)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tarotmsg = append(tarotmsg, imgmsg)
|
||||
build.WriteString(info.Represent[0][i])
|
||||
build.WriteString(":")
|
||||
build.WriteString(position[p])
|
||||
@@ -239,18 +305,54 @@ func init() {
|
||||
build.WriteString("』\n其释义为: \n")
|
||||
build.WriteString(description)
|
||||
build.WriteString("\n")
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotmsg...)
|
||||
}
|
||||
txt := build.String()
|
||||
formation, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
formation, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
msg[info.CardsNum] = ctxext.FakeSenderForwardNode(ctx, message.Message{message.Image("base64://" + binary.BytesToString(formation))}...)
|
||||
ctx.Send(msg)
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
} else {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~\n现有牌阵列表: \n", strings.Join(formationName, "\n")))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func poolimg(ctx *zero.Ctx, imgurl, imgname, cache string) (msg message.MessageSegment, err error) {
|
||||
imgfile := cache + "/" + imgname + ".png"
|
||||
aimgfile := file.BOTPATH + "/" + imgfile
|
||||
m, err := pool.GetImage("pool" + imgname)
|
||||
if err == nil {
|
||||
msg = message.Image(m.String())
|
||||
if ctxext.SendToSelf(ctx)(msg) == 0 {
|
||||
msg = msg.Add("cache", "0")
|
||||
}
|
||||
return
|
||||
}
|
||||
if file.IsNotExist(aimgfile) {
|
||||
var data []byte
|
||||
data, err = web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var f *os.File
|
||||
f, err = os.Create(imgfile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
err = os.WriteFile(f.Name(), data, 0755)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
m.SetFile(aimgfile)
|
||||
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||
msg = message.Image("file:///" + aimgfile)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ type kimo = map[string]*[]string
|
||||
func init() {
|
||||
engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "thesaurus\n- 词典匹配回复",
|
||||
Brief: "词典匹配回复",
|
||||
Help: "- 词典匹配回复",
|
||||
PublicDataFolder: "Chat",
|
||||
})
|
||||
go func() {
|
||||
|
||||
@@ -24,8 +24,8 @@ var db = &sql.Sqlite{}
|
||||
func init() {
|
||||
en := control.Register("tiangou", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "舔狗日记\n" +
|
||||
"- 舔狗日记",
|
||||
Brief: "舔狗日记",
|
||||
Help: "- 舔狗日记",
|
||||
PublicDataFolder: "Tiangou",
|
||||
})
|
||||
|
||||
|
||||
@@ -16,10 +16,11 @@ var (
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("tracemoe", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]",
|
||||
Brief: "以图搜番",
|
||||
Help: "- 以图搜番 | 搜番 | 搜索番剧[图片]",
|
||||
})
|
||||
// 以图搜图
|
||||
engine.OnKeywordGroup([]string{"搜番", "搜索番剧"}, zero.MustProvidePicture).SetBlock(true).
|
||||
engine.OnKeywordGroup([]string{"以图搜番", "搜番", "搜索番剧"}, zero.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 开始搜索图片
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
func init() {
|
||||
control.Register("translation", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "翻译\n" +
|
||||
">TL 你好",
|
||||
Brief: "单词翻译",
|
||||
Help: ">TL [好|good]",
|
||||
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := []string{ctx.State["regex_matched"].([]string)[2]}
|
||||
|
||||
141
plugin/vitsnyaru/vitsnyaru.go
Normal file
141
plugin/vitsnyaru/vitsnyaru.go
Normal file
@@ -0,0 +1,141 @@
|
||||
// Package vitsnyaru vits猫雷
|
||||
package vitsnyaru
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
hf "github.com/FloatTech/AnimeAPI/huggingface"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
vitsnyaruRepo = "innnky/vits-nyaru"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("vitsnyaru", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "vits猫雷",
|
||||
Help: "- 让猫雷说 xxx",
|
||||
PrivateDataFolder: "vitsnyaru",
|
||||
})
|
||||
|
||||
// 开启
|
||||
engine.OnPrefix(`让猫雷说`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
_ctx, _cancel := context.WithTimeout(context.Background(), hf.TimeoutMax*time.Second)
|
||||
defer _cancel()
|
||||
ch := make(chan []byte, 1)
|
||||
|
||||
args := ctx.State["args"].(string)
|
||||
pushURL := fmt.Sprintf(hf.HTTPSPushPath, vitsnyaruRepo)
|
||||
statusURL := fmt.Sprintf(hf.HTTPSStatusPath, vitsnyaruRepo)
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
var (
|
||||
pushReq hf.PushRequest
|
||||
pushRes hf.PushResponse
|
||||
statusReq hf.StatusRequest
|
||||
statusRes hf.StatusResponse
|
||||
data []byte
|
||||
)
|
||||
|
||||
// 获取clean后的文本
|
||||
pushReq = hf.PushRequest{
|
||||
Action: hf.DefaultAction,
|
||||
Data: []interface{}{args},
|
||||
FnIndex: 1,
|
||||
}
|
||||
pushRes, err := hf.Push(pushURL, pushReq)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
statusReq = hf.StatusRequest{
|
||||
Hash: pushRes.Hash,
|
||||
}
|
||||
|
||||
t := time.NewTicker(time.Second * 1)
|
||||
defer t.Stop()
|
||||
LOOP:
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
data, err = hf.Status(statusURL, statusReq)
|
||||
if err != nil {
|
||||
ch <- data
|
||||
break LOOP
|
||||
}
|
||||
if gjson.ParseBytes(data).Get("status").String() == hf.CompleteStatus {
|
||||
ch <- data
|
||||
break LOOP
|
||||
}
|
||||
case <-_ctx.Done():
|
||||
ch <- data
|
||||
break LOOP
|
||||
}
|
||||
}
|
||||
|
||||
data = <-ch
|
||||
err = json.Unmarshal(data, &statusRes)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 用clean的文本预测语音
|
||||
pushReq = hf.PushRequest{
|
||||
Action: hf.DefaultAction,
|
||||
Data: statusRes.Data.Data,
|
||||
FnIndex: 2,
|
||||
}
|
||||
pushRes, err = hf.Push(pushURL, pushReq)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
statusReq = hf.StatusRequest{
|
||||
Hash: pushRes.Hash,
|
||||
}
|
||||
|
||||
LOOP2:
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
data, err = hf.Status(statusURL, statusReq)
|
||||
if err != nil {
|
||||
ch <- data
|
||||
break LOOP2
|
||||
}
|
||||
if gjson.ParseBytes(data).Get("status").String() == hf.CompleteStatus {
|
||||
ch <- data
|
||||
break LOOP2
|
||||
}
|
||||
case <-_ctx.Done():
|
||||
ch <- data
|
||||
break LOOP2
|
||||
}
|
||||
}
|
||||
|
||||
data = <-ch
|
||||
err = json.Unmarshal(data, &statusRes)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 发送语音
|
||||
if len(statusRes.Data.Data) < 2 {
|
||||
ctx.SendChain(message.Text("ERROR: 未能获取语音"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("base64://" + strings.TrimPrefix(statusRes.Data.Data[1].(string), "data:audio/wav;base64,")))
|
||||
})
|
||||
}
|
||||
@@ -33,7 +33,8 @@ var reg = regexp.MustCompile(".*/(.*)")
|
||||
func init() {
|
||||
engine := control.Register("vtbquotation", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb\n- 更新vtb\n",
|
||||
Brief: "vtb语录",
|
||||
Help: "- vtb语录\n- 随机vtb\n- 更新vtb\n来源: vtbkeyboard.moe",
|
||||
PublicDataFolder: "VtbQuotation",
|
||||
})
|
||||
dbfile := engine.DataFolder() + "vtb.db"
|
||||
|
||||
@@ -20,7 +20,8 @@ const (
|
||||
func init() {
|
||||
control.Register("wangyiyun", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "wangyiyun \n- 来份网易云热评",
|
||||
Brief: "网易云热评",
|
||||
Help: "- 来份网易云热评",
|
||||
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
|
||||
112
plugin/wenben/wenben.go
Normal file
112
plugin/wenben/wenben.go
Normal file
@@ -0,0 +1,112 @@
|
||||
// Package wenben 文本链接
|
||||
package wenben
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
tianqi = "https://xiaobai.klizi.cn/API/other/weather_1.php?data=&msg=%v" // api地址
|
||||
pinyin = "http://ovooa.com/API/pinyin/api.php?type=text&msg=%v"
|
||||
yiyan = "https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i" // 动漫 漫画 游戏 文学 影视 诗词
|
||||
kouling = "http://ovooa.com/API/rao/api.php?type=text" //口令
|
||||
tang = "http://api.btstu.cn/yan/api.php?charset=utf-8&encode=text"
|
||||
qing = "https://xiaobai.klizi.cn/API/other/wtqh.php"
|
||||
)
|
||||
|
||||
type rspData struct {
|
||||
Hitokoto string `json:"hitokoto"`
|
||||
From string `json:"from"`
|
||||
FromWho string `json:"from_who"`
|
||||
}
|
||||
|
||||
func init() { // 主函数
|
||||
en := control.Register("tianqi", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "天气/拼音查询",
|
||||
Help: "文本命令大全\n" +
|
||||
"- 天气查询:xxx天气" +
|
||||
"- 拼音查询:xxx拼音" +
|
||||
"- 每日一言" +
|
||||
"- 每日鸡汤" +
|
||||
"- 每日情话" +
|
||||
"- 绕口令",
|
||||
})
|
||||
en.OnSuffix("天气").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["args"].(string)
|
||||
es, err := web.GetData(fmt.Sprintf(tianqi, str)) // 将网站返回结果赋值
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(str, "天气如下:\n", helper.BytesToString(es)))
|
||||
})
|
||||
en.OnSuffix("拼音").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
str := ctx.State["args"].(string)
|
||||
es, err := web.GetData(fmt.Sprintf(pinyin, str)) // 将网站返回结果赋值
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(str, "的拼音为:", helper.BytesToString(es)))
|
||||
})
|
||||
en.OnFullMatch("每日情话").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(qing)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("获取失败惹", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||
})
|
||||
en.OnFullMatch("每日鸡汤").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(tang)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("获取失败惹", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||
})
|
||||
en.OnFullMatch("绕口令").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(kouling)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("获取失败惹", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||
})
|
||||
en.OnFullMatch("每日一言").SetBlock(true).Handle(func(ctx *zero.Ctx) { //每日一言
|
||||
var rsp rspData
|
||||
data, err := web.GetData(yiyan)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Err:", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &rsp)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||
return
|
||||
}
|
||||
var msg strings.Builder
|
||||
msg.WriteString(rsp.Hitokoto)
|
||||
msg.WriteString("\n出自:")
|
||||
msg.WriteString(rsp.From)
|
||||
msg.WriteByte('\n')
|
||||
if len(rsp.FromWho) != 0 {
|
||||
msg.WriteString("作者:")
|
||||
msg.WriteString(rsp.FromWho)
|
||||
}
|
||||
ctx.SendChain(message.Text(msg.String()))
|
||||
})
|
||||
}
|
||||
@@ -1,397 +0,0 @@
|
||||
// Package ernie AI画图
|
||||
package ernie
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
// 数据库
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
// 百度文心AI画图API
|
||||
wenxin "github.com/FloatTech/AnimeAPI/wenxinAI/ernievilg"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceName = "AIdraw"
|
||||
serviceErr = "[" + serviceName + "]ERROR:\n"
|
||||
)
|
||||
|
||||
type keydb struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// db内容
|
||||
type apikey struct {
|
||||
ID int64 // 群号
|
||||
APIKey string // API Key
|
||||
SecretKey string // Secret Key
|
||||
Token string // AccessToken
|
||||
Updatetime int64 // token的有效时间
|
||||
MaxLimit int // 总使用次数
|
||||
DayLimit int // 当天的使用次数
|
||||
Lasttime string // 记录使用的时间,用于刷新使用次数
|
||||
}
|
||||
|
||||
var (
|
||||
groupinfo = &keydb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
limit = 50
|
||||
dtype = [...]string{
|
||||
"古风", "油画", "水彩画", "卡通画", "二次元", "浮世绘", "蒸汽波艺术", "low poly", "像素风格", "概念艺术", "未来主义", "赛博朋克", "写实风格", "洛丽塔风格", "巴洛克风格", "超现实主义",
|
||||
}
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register(serviceName, &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "AI画图\n" +
|
||||
"基于百度文心的免费AI画图插件,\n因为是免费的,图片质量你懂的。\n" +
|
||||
"key申请链接:https://wenxin.baidu.com/moduleApi/key\n" +
|
||||
"注意:每个apikey每日上限50次,总上限500次请求。次数超过了请自行更新apikey\n" +
|
||||
"- 为[自己/本群/QQ号/群+群号]设置AI画图key [API Key] [Secret Key]\n" +
|
||||
"例:\n[为10086设置AI画图key 123 456]\n[为群10010设置AI画图key 789 101]\n" +
|
||||
"- [bot名称]画几张[图片描述]的[图片类型][图片尺寸]\n" +
|
||||
"————————————————————\n" +
|
||||
"图片描述指南:\n图片主体,细节词(请用逗号连接)\n官方prompt指南:https://wenxin.baidu.com/wenxin/docs#Ol7ece95m\n" +
|
||||
"————————————————————\n" +
|
||||
"图片类型当前支持:" + strings.Join(dtype[:], "、") +
|
||||
"\n————————————————————\n" +
|
||||
"图片尺寸当前只支持:方图/长图/横图\n" +
|
||||
"————————————————————\n" +
|
||||
"指令示例:\n" +
|
||||
"椛椛帮我画几张金凤凰,背景绚烂,高饱和,古风,仙境,高清,4K,古风的油画方图",
|
||||
PrivateDataFolder: "ernievilg",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Break()
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text(zero.BotConfig.NickName[0], "正在给别人画图,请不要打扰哦"),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
groupinfo.db.DBPath = engine.DataFolder() + "keydb.db"
|
||||
err := groupinfo.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
// 画图
|
||||
engine.OnRegex(`画几张(.*[^的$])的(.*[^\s$])(方图|长图|横图)$`, zero.OnlyToMe, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := -ctx.Event.UserID
|
||||
gid := ctx.Event.GroupID
|
||||
// 获取个人和群的key
|
||||
userinfo, err1 := groupinfo.checkGroup(uid)
|
||||
info, err2 := groupinfo.checkGroup(gid)
|
||||
switch {
|
||||
// 如果是个人请求且报错
|
||||
case gid == 0 && err1 != nil:
|
||||
ctx.SendChain(message.Text(serviceErr, err1))
|
||||
return
|
||||
// 如果群报错而个人没有,就切换成个人的
|
||||
case err2 != nil && err1 == nil:
|
||||
gid = uid
|
||||
info = userinfo
|
||||
// 如果都报错就以群为优先级
|
||||
case err1 != nil && err2 != nil:
|
||||
ctx.SendChain(message.Text(serviceErr, err2))
|
||||
return
|
||||
}
|
||||
// 判断使用次数
|
||||
check := false
|
||||
switch {
|
||||
// 群和个人都没有次数了
|
||||
case info.DayLimit == 0 && userinfo.DayLimit == 0:
|
||||
ctx.SendChain(message.Text("我已经画了", limit, "张了!我累了!不画不画,就不画!"))
|
||||
return
|
||||
// 个人还有次数的话
|
||||
case info.DayLimit == 0 && userinfo.DayLimit != 0:
|
||||
check = true
|
||||
}
|
||||
switch {
|
||||
// 群和个人都没有总次数了
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit == 0:
|
||||
ctx.SendChain(message.Text("设置的key使用次数超过了限额,请更换key。"))
|
||||
return
|
||||
// 个人还有总次数的话
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit != 0:
|
||||
check = true
|
||||
}
|
||||
if check { // 如果只有个人有次数就切换回个人key
|
||||
gid = uid
|
||||
info = userinfo
|
||||
}
|
||||
// 创建任务
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
if len([]rune(keyword)) >= 64 { // 描述不能超过64个字
|
||||
ctx.SendChain(message.Text("要求太多了啦!减少点!"))
|
||||
return
|
||||
}
|
||||
picType := ctx.State["regex_matched"].([]string)[2]
|
||||
chooseSize := ctx.State["regex_matched"].([]string)[3]
|
||||
wtime := 3
|
||||
picSize := "1024*1024"
|
||||
switch chooseSize {
|
||||
case "长图":
|
||||
wtime = 5
|
||||
picSize = "1024*1536"
|
||||
case "横图":
|
||||
wtime = 5
|
||||
picSize = "1536*1024"
|
||||
}
|
||||
taskID, err := wenxin.BuildWork(info.Token, keyword, picType, picSize)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if taskID < 1 {
|
||||
ctx.SendChain(message.Text("要求太复杂力!想不出来..."))
|
||||
return
|
||||
}
|
||||
// 开始画图
|
||||
ctx.SendChain(message.Text(zero.BotConfig.NickName[0], "知道了,我可能需要", time.Duration(wtime*10)*time.Second, "左右才能画好哦,请等待..."))
|
||||
i := 0
|
||||
for range time.NewTicker(10 * time.Second).C {
|
||||
// 等待 wtime * 10秒
|
||||
i++
|
||||
if i <= wtime {
|
||||
continue
|
||||
}
|
||||
/*
|
||||
if i > 60{// 十分钟还不出图就放弃
|
||||
ctx.SendChain(message.Text("呜呜呜,要求太复杂力!画不出来..."))
|
||||
return
|
||||
}
|
||||
// 获取结果*/
|
||||
picURL, status, err := wenxin.GetPic(info.Token, taskID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if status == "0" {
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("我画好了!"))}
|
||||
for _, imginfo := range picURL {
|
||||
msg = append(msg,
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(imginfo.Image)))
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
err = groupinfo.update(gid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
}
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Text("累死了,今天我最多只能画", info.DayLimit-1, "张图哦"))
|
||||
})
|
||||
engine.OnRegex(`^为(群)?(自己|本群|\d+)设置AI画图key\s(.*[^\s$])\s(.+)$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
mode := ctx.State["regex_matched"].([]string)[1]
|
||||
user := ctx.State["regex_matched"].([]string)[2]
|
||||
aKey := ctx.State["regex_matched"].([]string)[3]
|
||||
sKey := ctx.State["regex_matched"].([]string)[4]
|
||||
dbID := -ctx.Event.UserID // 默认给自己
|
||||
switch {
|
||||
case mode != "": // 指定群的话
|
||||
gid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user == "本群": // 用于本群
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
ctx.SendChain(message.Text(serviceErr, "请指定群聊,或者使用指令;\n为群xxx设置AI画图key xxx xxx"))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user != "自己": // 给别人开key
|
||||
uid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
dbID = -uid
|
||||
}
|
||||
err := groupinfo.insert(dbID, aKey, sKey)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
}
|
||||
|
||||
// 登记group的key
|
||||
func (sql *keydb) insert(gid int64, akey, skey string) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err := sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 获取group信息
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
// 如果该group没有注册过
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where APIKey is '"+akey+"' and SecretKey is '"+skey+"'")
|
||||
if err == nil {
|
||||
// 如果key存在过将当前的数据迁移过去
|
||||
groupinfo.ID = gid
|
||||
} else {
|
||||
groupinfo = apikey{
|
||||
ID: gid,
|
||||
APIKey: akey,
|
||||
SecretKey: skey,
|
||||
MaxLimit: 500,
|
||||
}
|
||||
}
|
||||
return sql.db.Insert("groupinfo", &groupinfo)
|
||||
}
|
||||
// 进行更新
|
||||
groupinfo.APIKey = akey
|
||||
groupinfo.SecretKey = skey
|
||||
groupinfo.MaxLimit = 500
|
||||
return sql.db.Insert("groupinfo", &groupinfo)
|
||||
}
|
||||
|
||||
// 获取group信息
|
||||
func (sql *keydb) checkGroup(gid int64) (groupinfo apikey, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err = sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 先判断该群是否已经设置过key了
|
||||
if ok := sql.db.CanFind("groupinfo", "where ID is "+strconv.FormatInt(gid, 10)); !ok {
|
||||
if gid > 0 {
|
||||
err = errors.New("该群没有设置过apikey,请前往https://wenxin.baidu.com/moduleApi/key获取key值后,发送指令:\n为本群设置AI画图key [API Key] [Secret Key]")
|
||||
} else {
|
||||
err = errors.New("你没有设置过apikey,请前往https://wenxin.baidu.com/moduleApi/key获取key值后,发送指令:\n为自己设置AI画图key [API Key] [Secret Key]")
|
||||
}
|
||||
return
|
||||
}
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 如果隔天使用刷新次数
|
||||
if time.Now().Format("2006/01/02") != groupinfo.Lasttime {
|
||||
groupinfo.DayLimit = limit
|
||||
groupinfo.Lasttime = time.Now().Format("2006/01/02")
|
||||
}
|
||||
if err = sql.db.Insert("groupinfo", &groupinfo); err != nil {
|
||||
return
|
||||
}
|
||||
// 如果token有效期过期
|
||||
if time.Since(time.Unix(groupinfo.Updatetime, 0)).Hours() > 24 {
|
||||
token, err1 := wenxin.GetToken(groupinfo.APIKey, groupinfo.SecretKey)
|
||||
if err1 != nil {
|
||||
err = err1
|
||||
return
|
||||
}
|
||||
groupinfo.Token = token
|
||||
groupinfo.Updatetime = time.Now().Unix()
|
||||
err = sql.db.Insert("groupinfo", &groupinfo)
|
||||
if err == nil {
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
if err == nil {
|
||||
otherinfo.Token = groupinfo.Token
|
||||
otherinfo.Updatetime = groupinfo.Updatetime
|
||||
err = sql.db.Insert("groupinfo", &otherinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 记录次数(-1)
|
||||
func (sql *keydb) update(gid int64) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err := sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groupinfo.MaxLimit--
|
||||
groupinfo.DayLimit--
|
||||
err = sql.db.Insert("groupinfo", &groupinfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
if err == nil {
|
||||
otherinfo.MaxLimit = groupinfo.MaxLimit
|
||||
otherinfo.DayLimit = groupinfo.DayLimit
|
||||
otherinfo.Lasttime = groupinfo.Lasttime
|
||||
err = sql.db.Insert("groupinfo", &otherinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
680
plugin/wenxinAI/wenxinAI.go
Normal file
680
plugin/wenxinAI/wenxinAI.go
Normal file
@@ -0,0 +1,680 @@
|
||||
// Package wenxin 百度文心AI
|
||||
package wenxin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
// 数据库
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
// 百度文心大模型
|
||||
model "github.com/FloatTech/AnimeAPI/wenxinAI/erniemodle"
|
||||
// 百度文心AI画图API
|
||||
wenxin "github.com/FloatTech/AnimeAPI/wenxinAI/ernievilg"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceErr = "[wenxinvilg]ERROR:\n"
|
||||
modelErr = "[wenxinmodel]ERROR:\n"
|
||||
)
|
||||
|
||||
type keydb struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// db内容
|
||||
type apikey struct {
|
||||
ID int64 // 群号
|
||||
APIKey string // API Key
|
||||
SecretKey string // Secret Key
|
||||
Token string // AccessToken
|
||||
Updatetime int64 // token的有效时间
|
||||
MaxLimit int // 总使用次数
|
||||
DayLimit int // 当天的使用次数
|
||||
Lasttime string // 记录使用的时间,用于刷新使用次数
|
||||
}
|
||||
|
||||
var (
|
||||
name = "椛椛"
|
||||
limit int
|
||||
vilginfo = &keydb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
modelinfo = &keydb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
dtype = [...]string{
|
||||
"古风", "油画", "水彩画", "卡通画", "二次元", "浮世绘", "蒸汽波艺术", "low poly", "像素风格", "概念艺术", "未来主义", "赛博朋克", "写实风格", "洛丽塔风格", "巴洛克风格", "超现实主义",
|
||||
}
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
go func() {
|
||||
process.GlobalInitMutex.Lock()
|
||||
defer process.GlobalInitMutex.Unlock()
|
||||
name = zero.BotConfig.NickName[0]
|
||||
}()
|
||||
engine := control.Register("wenxinvilg", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "文心AI画图",
|
||||
Help: "基于百度文心的免费AI画图插件,\n因为是免费的,图片质量你懂的。\n" +
|
||||
"key申请链接:https://wenxin.baidu.com/moduleApi/key\n" +
|
||||
"key和erniemodel插件的key相同。\n" +
|
||||
"注意:每个apikey每日上限50次,总上限500次请求。次数超过了请自行更新apikey\n" +
|
||||
"- 为[自己/本群/QQ号/群+群号]设置画图key [API Key] [Secret Key]\n" +
|
||||
"例:\n为自己设置画图key 123 456\n为10086设置画图key 123 456\n为群10010设置画图key 789 101\n" +
|
||||
"- [bot名称]画几张[图片描述]的[图片类型][图片尺寸]\n" +
|
||||
"————————————————————\n" +
|
||||
"图片描述指南:\n图片主体,细节词(请用逗号连接)\n官方prompt指南:https://wenxin.baidu.com/wenxin/docs#Ol7ece95m\n" +
|
||||
"————————————————————\n" +
|
||||
"图片类型当前支持:" + strings.Join(dtype[:], "、") +
|
||||
"\n————————————————————\n" +
|
||||
"图片尺寸当前只支持:方图/长图/横图\n" +
|
||||
"————————————————————\n" +
|
||||
"指令示例:\n" +
|
||||
name + "帮我画几张金凤凰,背景绚烂,高饱和,古风,仙境,高清,4K,古风的油画方图",
|
||||
PrivateDataFolder: "wenxinAI",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Break()
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text(zero.BotConfig.NickName[0], "正在给别人画图,请不要打扰哦"),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
vilginfo.db.DBPath = engine.DataFolder() + "ernieVilg.db"
|
||||
err := vilginfo.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
// 画图
|
||||
engine.OnRegex(`画几张(.*[^的$])的(.*[^\s$])(方图|长图|横图)$`, zero.OnlyToMe, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := -ctx.Event.UserID
|
||||
gid := ctx.Event.GroupID
|
||||
// 获取个人和群的key
|
||||
userinfo, err1 := vilginfo.checkGroup(uid, "vilg")
|
||||
info, err2 := vilginfo.checkGroup(gid, "vilg")
|
||||
switch {
|
||||
// 如果是个人请求且报错
|
||||
case gid == 0 && err1 != nil:
|
||||
ctx.SendChain(message.Text(serviceErr, err1))
|
||||
return
|
||||
// 如果群报错而个人没有,就切换成个人的
|
||||
case err2 != nil && err1 == nil:
|
||||
gid = uid
|
||||
info = userinfo
|
||||
// 如果都报错就以群为优先级
|
||||
case err1 != nil && err2 != nil:
|
||||
ctx.SendChain(message.Text(serviceErr, err2))
|
||||
return
|
||||
}
|
||||
// 判断使用次数
|
||||
check := false
|
||||
switch {
|
||||
// 群和个人都没有次数了
|
||||
case info.DayLimit == 0 && userinfo.DayLimit == 0:
|
||||
ctx.SendChain(message.Text("我已经画了", limit, "张了!我累了!不画不画,就不画!"))
|
||||
return
|
||||
// 个人还有次数的话
|
||||
case info.DayLimit == 0 && userinfo.DayLimit != 0:
|
||||
check = true
|
||||
}
|
||||
switch {
|
||||
// 群和个人都没有总次数了
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit == 0:
|
||||
ctx.SendChain(message.Text("设置的key使用次数超过了限额,请更换key。"))
|
||||
return
|
||||
// 个人还有总次数的话
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit != 0:
|
||||
check = true
|
||||
}
|
||||
if check { // 如果只有个人有次数就切换回个人key
|
||||
gid = uid
|
||||
info = userinfo
|
||||
}
|
||||
// 创建任务
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
if len([]rune(keyword)) >= 64 { // 描述不能超过64个字
|
||||
ctx.SendChain(message.Text("要求太多了啦!减少点!"))
|
||||
return
|
||||
}
|
||||
picType := ctx.State["regex_matched"].([]string)[2]
|
||||
chooseSize := ctx.State["regex_matched"].([]string)[3]
|
||||
wtime := 3
|
||||
picSize := "1024*1024"
|
||||
switch chooseSize {
|
||||
case "长图":
|
||||
wtime = 5
|
||||
picSize = "1024*1536"
|
||||
case "横图":
|
||||
wtime = 5
|
||||
picSize = "1536*1024"
|
||||
}
|
||||
taskID, err := wenxin.BuildWork(info.Token, keyword, picType, picSize)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if taskID < 1 {
|
||||
ctx.SendChain(message.Text("要求太复杂力!想不出来..."))
|
||||
return
|
||||
}
|
||||
// 开始画图
|
||||
ctx.SendChain(message.Text(zero.BotConfig.NickName[0], "知道了,我可能需要", time.Duration(wtime*10)*time.Second, "左右才能画好哦,请等待..."))
|
||||
i := 0
|
||||
for range time.NewTicker(10 * time.Second).C {
|
||||
// 等待 wtime * 10秒
|
||||
i++
|
||||
if i <= wtime {
|
||||
continue
|
||||
}
|
||||
/*
|
||||
if i > 60{// 十分钟还不出图就放弃
|
||||
ctx.SendChain(message.Text("呜呜呜,要求太复杂力!画不出来..."))
|
||||
return
|
||||
}
|
||||
// 获取结果*/
|
||||
picURL, status, err := wenxin.GetPic(info.Token, taskID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if status == "0" {
|
||||
lastTime := time.Duration(i * 10 * int(time.Second))
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("我画好了!\n本次绘画用了", lastTime))}
|
||||
for _, imginfo := range picURL {
|
||||
msg = append(msg,
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(imginfo.Image)))
|
||||
}
|
||||
if id := ctx.Send(msg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
err = vilginfo.update(gid, 1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
}
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Text("累死了,今天我最多只能画", info.DayLimit-1, "张图哦"))
|
||||
})
|
||||
engine.OnRegex(`^为(群)?(自己|本群|\d+)设置画图key\s(.*[^\s$])\s(.+)$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
mode := ctx.State["regex_matched"].([]string)[1]
|
||||
user := ctx.State["regex_matched"].([]string)[2]
|
||||
aKey := ctx.State["regex_matched"].([]string)[3]
|
||||
sKey := ctx.State["regex_matched"].([]string)[4]
|
||||
dbID := -ctx.Event.UserID // 默认给自己
|
||||
switch {
|
||||
case mode != "": // 指定群的话
|
||||
gid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user == "本群": // 用于本群
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
ctx.SendChain(message.Text(serviceErr, "请指定群聊,或者使用指令;\n为群xxx设置AI画图key xxx xxx"))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user != "自己": // 给别人开key
|
||||
uid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
dbID = -uid
|
||||
}
|
||||
err := vilginfo.insert(dbID, "vilg", aKey, sKey)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
/*********************************************************/
|
||||
en := control.Register("wenxinmodel", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "文心AI文本处理",
|
||||
Help: "基于百度文心AI的API文本处理\n" +
|
||||
"key申请链接:https://wenxin.baidu.com/moduleApi/key\n" +
|
||||
"key和ernievilg插件的key相同。\n" +
|
||||
"注意:每个apikey每日上限200条,总上限2000条。次数超过了请自行更新apikey\n" +
|
||||
"- 为[自己/本群/QQ号/群+群号]设置文心key [API Key] [Secret Key]\n" +
|
||||
"例:\n为自己设置文心key 123 456\n为10086设置文心key 123 456\n为群10010设置文心key 789 101\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心作文 (x字的)[作文题目]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心提案 (x字的)[文案标题]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心摘要 (x字的)[文章内容]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心小说 (x字的)[小说上文]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心对联 [上联]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心问答 [问题]" +
|
||||
"————————————————————\n" +
|
||||
"- 文心补全 [带“_”的填空题]\n" +
|
||||
"————————————————————\n" +
|
||||
"- 文心自定义 [prompt]\n" +
|
||||
"prompt: [问题描述] [问题类型]:[题目] [解答类型]:[解题必带内容]\n" +
|
||||
"指令示例:\n" +
|
||||
"文心自定义 请写出下面这道题的解题过程。\\n题目:养殖场养鸭376只,养鸡的只数比鸭多258只,这个养殖场一共养鸭和鸡多少只?\\n解:\n" +
|
||||
"文心自定义 1+1=?\n" +
|
||||
"文心自定义 歌曲名:大风车转啊转\\n歌词:",
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Break()
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text(zero.BotConfig.NickName[0], "正在给别人编辑,请不要打扰哦"),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
getmodeldb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
modelinfo.db.DBPath = engine.DataFolder() + "ernieModel.db"
|
||||
err := modelinfo.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
en.OnRegex(`^为(群)?(自己|本群|\d+)设置文心key\s(.*[^\s$])\s(.+)$`, getmodeldb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
mode := ctx.State["regex_matched"].([]string)[1]
|
||||
user := ctx.State["regex_matched"].([]string)[2]
|
||||
aKey := ctx.State["regex_matched"].([]string)[3]
|
||||
sKey := ctx.State["regex_matched"].([]string)[4]
|
||||
dbID := -ctx.Event.UserID // 默认给自己
|
||||
switch {
|
||||
case mode != "": // 指定群的话
|
||||
gid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user == "本群": // 用于本群
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
ctx.SendChain(message.Text(modelErr, "请指定群聊,或者使用指令;\n为群xxx设置AI画图key xxx xxx"))
|
||||
return
|
||||
}
|
||||
dbID = gid
|
||||
case user != "自己": // 给别人开key
|
||||
uid, err := strconv.ParseInt(user, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
dbID = -uid
|
||||
}
|
||||
err := modelinfo.insert(dbID, "model", aKey, sKey)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
|
||||
var erniemodel = map[string]int{
|
||||
"作文": 1,
|
||||
"提案": 2,
|
||||
"摘要": 3,
|
||||
"对联": 4,
|
||||
"问答": 5,
|
||||
"小说": 6,
|
||||
"补全": 7,
|
||||
"自定义": 8}
|
||||
var erniePrompt = map[string]string{
|
||||
"作文": "zuowen",
|
||||
"提案": "adtext",
|
||||
"摘要": "Summarization",
|
||||
"对联": "couplet",
|
||||
"问答": "Dialogue",
|
||||
"小说": "novel",
|
||||
"补全": "cloze"}
|
||||
en.OnRegex(`^文心(作文|提案|摘要|小说)\s?((\d+)字的)?(.*)$`, getmodeldb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := -ctx.Event.UserID
|
||||
gid := ctx.Event.GroupID
|
||||
// 获取个人和群的key
|
||||
userinfo, err1 := modelinfo.checkGroup(uid, "model")
|
||||
info, err2 := modelinfo.checkGroup(gid, "model")
|
||||
switch {
|
||||
// 如果是个人请求且报错
|
||||
case gid == 0 && err1 != nil:
|
||||
ctx.SendChain(message.Text(modelErr, err1))
|
||||
return
|
||||
// 如果群报错而个人没有,就切换成个人的
|
||||
case err2 != nil && err1 == nil:
|
||||
gid = uid
|
||||
info = userinfo
|
||||
// 如果都报错就以群为优先级
|
||||
case err1 != nil && err2 != nil:
|
||||
ctx.SendChain(message.Text(modelErr, err2))
|
||||
return
|
||||
}
|
||||
// 判断使用次数
|
||||
check := false
|
||||
switch {
|
||||
// 群和个人都没有次数了
|
||||
case info.DayLimit == 0 && userinfo.DayLimit == 0:
|
||||
ctx.SendChain(message.Text("今日请求次数已到200次了,明天在玩吧"))
|
||||
return
|
||||
// 个人还有次数的话
|
||||
case info.DayLimit == 0 && userinfo.DayLimit != 0:
|
||||
check = true
|
||||
}
|
||||
switch {
|
||||
// 群和个人都没有总次数了
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit == 0:
|
||||
ctx.SendChain(message.Text("设置的key使用次数超过了限额,请更换key。"))
|
||||
return
|
||||
// 个人还有总次数的话
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit != 0:
|
||||
check = true
|
||||
}
|
||||
if check { // 如果只有个人有次数就切换回个人key
|
||||
gid = uid
|
||||
info = userinfo
|
||||
}
|
||||
// 调用API
|
||||
modelStr := ctx.State["regex_matched"].([]string)[1]
|
||||
mun := ctx.State["regex_matched"].([]string)[3]
|
||||
minlen := 1
|
||||
maxlen := 128
|
||||
if mun != "" {
|
||||
max, err := strconv.Atoi(mun)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
minlen = max
|
||||
if max > 128 {
|
||||
maxlen = max
|
||||
}
|
||||
}
|
||||
keyword := ctx.State["regex_matched"].([]string)[4]
|
||||
if len([]rune(keyword)) >= 1000 { // 描述不能超过1000
|
||||
ctx.SendChain(message.Text("是你写作文还是我写?减少点!"))
|
||||
return
|
||||
}
|
||||
result, err := model.GetResult(info.Token, erniemodel[modelStr], keyword, minlen, maxlen, erniePrompt[modelStr])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
if id := ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(keyword, ",", result))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 请求超时!"))
|
||||
}
|
||||
err = modelinfo.update(gid, 1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
}
|
||||
})
|
||||
en.OnRegex(`^文心(对联|问答|补全|自定义)\s?(.*)$`, getmodeldb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := -ctx.Event.UserID
|
||||
gid := ctx.Event.GroupID
|
||||
// 获取个人和群的key
|
||||
userinfo, err1 := modelinfo.checkGroup(uid, "model")
|
||||
info, err2 := modelinfo.checkGroup(gid, "model")
|
||||
switch {
|
||||
// 如果是个人请求且报错
|
||||
case gid == 0 && err1 != nil:
|
||||
ctx.SendChain(message.Text(modelErr, err1))
|
||||
return
|
||||
// 如果群报错而个人没有,就切换成个人的
|
||||
case err2 != nil && err1 == nil:
|
||||
gid = uid
|
||||
info = userinfo
|
||||
// 如果都报错就以群为优先级
|
||||
case err1 != nil && err2 != nil:
|
||||
ctx.SendChain(message.Text(modelErr, err2))
|
||||
return
|
||||
}
|
||||
// 判断使用次数
|
||||
check := false
|
||||
switch {
|
||||
// 群和个人都没有次数了
|
||||
case info.DayLimit == 0 && userinfo.DayLimit == 0:
|
||||
ctx.SendChain(message.Text("今日请求次数已到200次了,明天在玩吧"))
|
||||
return
|
||||
// 个人还有次数的话
|
||||
case info.DayLimit == 0 && userinfo.DayLimit != 0:
|
||||
check = true
|
||||
}
|
||||
switch {
|
||||
// 群和个人都没有总次数了
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit == 0:
|
||||
ctx.SendChain(message.Text("设置的key使用次数超过了限额,请更换key。"))
|
||||
return
|
||||
// 个人还有总次数的话
|
||||
case info.MaxLimit == 0 && userinfo.MaxLimit != 0:
|
||||
check = true
|
||||
}
|
||||
if check { // 如果只有个人有次数就切换回个人key
|
||||
gid = uid
|
||||
info = userinfo
|
||||
}
|
||||
// 创建任务
|
||||
modelStr := ctx.State["regex_matched"].([]string)[1]
|
||||
keyword := ctx.State["regex_matched"].([]string)[2]
|
||||
if len([]rune(keyword)) >= 1000 { // 描述不能超过1000
|
||||
ctx.SendChain(message.Text("你在写作文吗?减少点!"))
|
||||
return
|
||||
}
|
||||
result, err := model.GetResult(info.Token, erniemodel[modelStr], keyword, 1, 128, erniePrompt[modelStr])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
return
|
||||
}
|
||||
if id := ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(result))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 请求超时!"))
|
||||
}
|
||||
err = modelinfo.update(gid, 1)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 登记group的key
|
||||
func (sql *keydb) insert(gid int64, model, akey, skey string) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err := sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 获取group信息
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
// 如果该group没有注册过
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where APIKey is '"+akey+"' and SecretKey is '"+skey+"'")
|
||||
if err == nil {
|
||||
// 如果key存在过将当前的数据迁移过去
|
||||
groupinfo.ID = gid
|
||||
} else {
|
||||
groupinfo = apikey{
|
||||
ID: gid,
|
||||
APIKey: akey,
|
||||
SecretKey: skey,
|
||||
}
|
||||
switch model {
|
||||
case "vilg":
|
||||
groupinfo.MaxLimit = 500
|
||||
case "model":
|
||||
groupinfo.MaxLimit = 2000
|
||||
}
|
||||
}
|
||||
return sql.db.Insert("groupinfo", &groupinfo)
|
||||
}
|
||||
// 进行更新
|
||||
groupinfo.APIKey = akey
|
||||
groupinfo.SecretKey = skey
|
||||
groupinfo.Token = ""
|
||||
groupinfo.Updatetime = 0
|
||||
switch model {
|
||||
case "vilg":
|
||||
groupinfo.MaxLimit = 500
|
||||
case "model":
|
||||
groupinfo.MaxLimit = 2000
|
||||
}
|
||||
return sql.db.Insert("groupinfo", &groupinfo)
|
||||
}
|
||||
|
||||
// 获取group信息
|
||||
func (sql *keydb) checkGroup(gid int64, model string) (groupinfo apikey, err error) {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err = sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
switch model {
|
||||
case "vilg":
|
||||
limit = 50
|
||||
model = "画图"
|
||||
case "model":
|
||||
limit = 200
|
||||
model = "文心"
|
||||
}
|
||||
// 先判断该群是否已经设置过key了
|
||||
if ok := sql.db.CanFind("groupinfo", "where ID is "+strconv.FormatInt(gid, 10)); !ok {
|
||||
if gid > 0 {
|
||||
err = errors.New("该群没有设置过apikey,请前往https://wenxin.baidu.com/moduleApi/key获取key值后,发送指令:\n为本群设置" + model + "key [API Key] [Secret Key]\n或\n为自己设置" + model + "key [API Key] [Secret Key]")
|
||||
} else {
|
||||
err = errors.New("你没有设置过apikey,请前往https://wenxin.baidu.com/moduleApi/key获取key值后,发送指令:\n为自己设置" + model + "key [API Key] [Secret Key]")
|
||||
}
|
||||
return
|
||||
}
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 如果隔天使用刷新次数
|
||||
if time.Now().Format("2006/01/02") != groupinfo.Lasttime {
|
||||
groupinfo.DayLimit = limit
|
||||
groupinfo.Lasttime = time.Now().Format("2006/01/02")
|
||||
}
|
||||
if err = sql.db.Insert("groupinfo", &groupinfo); err != nil {
|
||||
return
|
||||
}
|
||||
// 如果token有效期过期
|
||||
if time.Since(time.Unix(groupinfo.Updatetime, 0)).Hours() > 24 || groupinfo.Token == "" {
|
||||
token, err1 := wenxin.GetToken(groupinfo.APIKey, groupinfo.SecretKey)
|
||||
if err1 != nil {
|
||||
err = err1
|
||||
return
|
||||
}
|
||||
groupinfo.Token = token
|
||||
groupinfo.Updatetime = time.Now().Unix()
|
||||
err = sql.db.Insert("groupinfo", &groupinfo)
|
||||
if err == nil {
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
if err == nil {
|
||||
otherinfo.Token = groupinfo.Token
|
||||
otherinfo.Updatetime = groupinfo.Updatetime
|
||||
err = sql.db.Insert("groupinfo", &otherinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 记录次数(-sub)
|
||||
func (sql *keydb) update(gid int64, sub int) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
// 给db文件创建表格(没有才创建),表格名称groupinfo,表格结构apikey
|
||||
err := sql.db.Create("groupinfo", &apikey{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groupinfo.MaxLimit -= sub
|
||||
groupinfo.DayLimit -= sub
|
||||
err = sql.db.Insert("groupinfo", &groupinfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
if err == nil {
|
||||
otherinfo.MaxLimit = groupinfo.MaxLimit
|
||||
otherinfo.DayLimit = groupinfo.DayLimit
|
||||
otherinfo.Lasttime = groupinfo.Lasttime
|
||||
err = sql.db.Insert("groupinfo", &otherinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -34,8 +34,8 @@ var (
|
||||
func init() {
|
||||
engine := control.Register("wordcount", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "聊天热词\n" +
|
||||
"- 热词 [群号] [消息数目]|热词 123456 1000",
|
||||
Brief: "聊天热词",
|
||||
Help: "- 热词 [群号] [消息数目]|热词 123456 1000",
|
||||
PublicDataFolder: "WordCount",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
|
||||
@@ -63,8 +63,8 @@ var words = make(dictionary)
|
||||
func init() {
|
||||
en := control.Register("wordle", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "猜单词\n" +
|
||||
"- 个人猜单词\n" +
|
||||
Brief: "猜单词",
|
||||
Help: "- 个人猜单词\n" +
|
||||
"- 团队猜单词\n" +
|
||||
"- 团队六阶猜单词\n" +
|
||||
"- 团队七阶猜单词",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user