koishi-plugin-ccb-plus 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +19 -17
- package/package.json +1 -1
- package/readme.md +57 -4
package/lib/index.js
CHANGED
|
@@ -358,7 +358,7 @@ __name(updateCCBRecord, "updateCCBRecord");
|
|
|
358
358
|
|
|
359
359
|
// src/commands/ccb.ts
|
|
360
360
|
function applyCcbCommand(ctx, config, state) {
|
|
361
|
-
ctx.command("ccb [target:user]", "给群友注入生命因子").option("off", "--off [user:string]
|
|
361
|
+
ctx.command("ccb [target:user]", "给群友注入生命因子").option("off", "--off [user:string] 开启保护模式(禁止被ccb),可指定用户").option("on", "--on [user:string] 关闭保护模式(允许被ccb),默认所有用户处于保护状态").action(async ({ session, options }, target) => {
|
|
362
362
|
const checkResult = state.checkGroupCommand(session);
|
|
363
363
|
if (checkResult) return checkResult;
|
|
364
364
|
const senderId = session.userId;
|
|
@@ -423,11 +423,11 @@ function applyCcbCommand(ctx, config, state) {
|
|
|
423
423
|
return newOptOut ? "已开启全局保护模式,阻止你被ccb。" : "已关闭全局保护模式,允许你被ccb。";
|
|
424
424
|
} else {
|
|
425
425
|
const targetId = targetUserStr;
|
|
426
|
-
const
|
|
427
|
-
|
|
426
|
+
const overrides2 = { ...userSetting?.overrides || {} };
|
|
427
|
+
overrides2[targetId] = !isOff;
|
|
428
428
|
await ctx.database.upsert("ccb_setting", [{
|
|
429
429
|
userId: senderId,
|
|
430
|
-
overrides,
|
|
430
|
+
overrides: overrides2,
|
|
431
431
|
optOut: userSetting?.optOut ?? false,
|
|
432
432
|
lastToggleTime: userSetting?.lastToggleTime || 0,
|
|
433
433
|
// 不改变全局旧字段
|
|
@@ -438,8 +438,9 @@ function applyCcbCommand(ctx, config, state) {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
const [senderSetting] = await ctx.database.get("ccb_setting", { userId: senderId });
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
const senderOptOut = senderSetting?.optOut ?? true;
|
|
442
|
+
if (senderOptOut) {
|
|
443
|
+
return "你已开启保护模式,无法ccb他人。请先使用 ccb --on 解除保护。";
|
|
443
444
|
}
|
|
444
445
|
const actorId = senderId;
|
|
445
446
|
const now = Date.now() / 1e3;
|
|
@@ -475,23 +476,24 @@ function applyCcbCommand(ctx, config, state) {
|
|
|
475
476
|
}
|
|
476
477
|
if (config.whiteList.includes(targetUserId)) {
|
|
477
478
|
const nickname = await state.getUserNickname(session, targetUserId) || targetUserId;
|
|
478
|
-
return `${nickname}
|
|
479
|
+
return `${nickname} 已开启保护模式,拒绝了和你ccb。`;
|
|
479
480
|
}
|
|
480
481
|
if (senderSetting?.overrides?.[targetUserId] === false) {
|
|
481
482
|
const nickname = await state.getUserNickname(session, targetUserId) || targetUserId;
|
|
482
483
|
return `你已禁止与 ${nickname} 进行ccb。`;
|
|
483
484
|
}
|
|
484
485
|
const [targetSetting] = await ctx.database.get("ccb_setting", { userId: targetUserId });
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
486
|
+
const targetOptOut = targetSetting?.optOut ?? true;
|
|
487
|
+
const overrides = targetSetting?.overrides || {};
|
|
488
|
+
const isInitialState = !targetSetting;
|
|
489
|
+
if (overrides[actorId] === false) {
|
|
490
|
+
const nickname = await state.getUserNickname(session, targetUserId) || targetUserId;
|
|
491
|
+
return `${nickname} 已开启针对你的保护,拒绝了和你ccb。`;
|
|
492
|
+
}
|
|
493
|
+
if (overrides[actorId] !== true && targetOptOut) {
|
|
494
|
+
const nickname = await state.getUserNickname(session, targetUserId) || targetUserId;
|
|
495
|
+
const message2 = isInitialState ? `${nickname} 还未开启ccb功能。请让ta使用 ccb --on 来开启。` : `${nickname} 已开启保护模式,拒绝了和你ccb。请让ta使用 ccb --on 来允许被ccb。`;
|
|
496
|
+
return message2;
|
|
495
497
|
}
|
|
496
498
|
if (targetUserId === actorId && !config.selfCcb) {
|
|
497
499
|
return "怎么还能对自己下手啊(恼)";
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -2,10 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/koishi-plugin-ccb-plus)
|
|
4
4
|
|
|
5
|
-
Koishi插件,与群友发生ccb
|
|
5
|
+
Koishi 插件,与群友发生 ccb 行为。移植自 [astrbot_plugin_ccb_plus](https://github.com/Koikokokokoro/astrbot_plugin_ccb_plus)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 功能特性
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- 🎲 随机生成 ccb 时长和注入量
|
|
10
|
+
- 💥 暴击机制
|
|
11
|
+
- 🛡️ 保护模式(默认开启,需手动关闭)
|
|
12
|
+
- 👥 支持全局/针对性开关
|
|
13
|
+
- 📊 排行榜和个人数据查询
|
|
14
|
+
- 💾 数据库持久化存储
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install koishi-plugin-ccb-plus
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 使用说明
|
|
23
|
+
|
|
24
|
+
### 基础命令
|
|
25
|
+
|
|
26
|
+
- `ccb [@用户]` - 对指定用户进行 ccb(需要双方都关闭保护模式)
|
|
27
|
+
- `ccb.rank` - 查看群内 ccb 排行榜
|
|
28
|
+
- `ccb.info [@用户]` - 查看指定用户的 ccb 数据
|
|
29
|
+
- `ccb.charm` - 查看自己的魅力值
|
|
30
|
+
|
|
31
|
+
### 保护模式
|
|
32
|
+
|
|
33
|
+
**默认所有用户处于保护模式,需要手动关闭才能参与。**
|
|
34
|
+
|
|
35
|
+
#### 全局开关
|
|
36
|
+
- `ccb --on` - 关闭保护模式,允许所有人对你 ccb
|
|
37
|
+
- `ccb --off` - 开启保护模式,禁止所有人对你 ccb
|
|
38
|
+
|
|
39
|
+
#### 针对性开关(优先级更高)
|
|
40
|
+
- `ccb --on @用户` - 允许指定用户对你 ccb
|
|
41
|
+
- `ccb --off @用户` - 禁止指定用户对你 ccb
|
|
42
|
+
|
|
43
|
+
**注意:** 处于保护模式的用户无法 ccb 他人,需先使用 `ccb --on` 解除。
|
|
44
|
+
|
|
45
|
+
## 配置项
|
|
46
|
+
|
|
47
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
48
|
+
|--------|------|--------|------|
|
|
49
|
+
| `selfCcb` | boolean | false | 是否允许自己 ccb 自己 |
|
|
50
|
+
| `critProb` | number | 0.1 | 暴击概率 (0-1) |
|
|
51
|
+
| `ywWindow` | number | 60 | 阳痿检测时间窗口(秒)|
|
|
52
|
+
| `ywThreshold` | number | 5 | 阳痿检测次数阈值 |
|
|
53
|
+
| `ywBanDuration` | number | 300 | 阳痿惩罚时长(秒)|
|
|
54
|
+
| `ywProbability` | number | 0.05 | 炸膛概率 (0-1) |
|
|
55
|
+
| `toggleCooldown` | number | 10 | 开关冷却时间(秒)|
|
|
56
|
+
| `whiteList` | string[] | [] | 永久保护名单(用户ID)|
|
|
57
|
+
|
|
58
|
+
## 许可证
|
|
59
|
+
|
|
60
|
+
MIT
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
> 使用 Claude Opus 4.6 协助开发
|