koishi-plugin-prism 0.1.27 → 0.1.29
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/README.md +4 -4
- package/lib/index.js +29 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
* 🎮 **玩家入场与结算**:通过 `/login` 和 `/logout` 指令开启或结算计费场次,支持 `/入场` 别名;命令回复会引用触发消息,结账账单可私聊通知管理员与指定用户。
|
|
10
10
|
* 💳 **账户钱包与资产管理**:支持查询钱包余额(`/wallet`)和持有的道具资产(`/items`)。
|
|
11
|
-
* 🀄 **麻将桌位集成**:包含 `/mahjong <tableId>`、`/上桌 <桌号>`、自动识别当前桌位的 `/下桌`,以及用于查看桌名、别名和状态的 `/麻将列表`。`上桌` 仅允许已通过 `login`/`入场`
|
|
11
|
+
* 🀄 **麻将桌位集成**:包含 `/mahjong <tableId>`、`/上桌 <桌号>`、自动识别当前桌位的 `/下桌`,以及用于查看桌名、别名和状态的 `/麻将列表`。`上桌` 仅允许已通过 `login`/`入场` 开启默认入场会话的玩家使用。支持在桌位未满但已开局时进行中途补位(直接开始计费上桌),且玩家下桌时会自动显示剩余游玩人数。`list` 按 session 标签分组:有非音乐游戏 session 的玩家归入最新的非音乐标签,纯音乐玩家归入音乐标签;麻将桌额外显示当前人数和容量。已开局桌位会从后端活跃 session 自动恢复,未满桌候座仍由机器人进程暂存,重启后不会保留。
|
|
12
12
|
* 🔌 **硬件设备状态与电源管理**:可直接在聊天中查看设备状态(`/show`)、远程开启/关闭电源(`/on`、`/off`)、远程投币(`/coin`)和模拟刷卡(`/scan`)。
|
|
13
13
|
* 🎟️ **礼物兑换码**:使用 `/redeem <code>` 兑换系统发放的福利礼包。
|
|
14
14
|
* 🛠️ **管理员快捷指令**:允许管理员为指定平台用户增加或扣除余额,并覆盖结账金额后立即结账。
|
|
@@ -57,7 +57,7 @@ pricingConfigIds: [pricing-mahjong-a]
|
|
|
57
57
|
* `logout` - 结算当前玩家的计费场次。
|
|
58
58
|
玩家在未产生任何费用时退场,机器人会简洁显示“本次未产生费用”和当前余额;存在收费或优惠明细时仍显示完整结算账单。
|
|
59
59
|
结账成功回执中的余额为后端已经完成扣款后的余额;只有 `/billing` 预览会显示当前余额与预计结账后余额。
|
|
60
|
-
|
|
60
|
+
方案内区间封顶直接计入对应计时费用;全局封顶按日期和时段逐条列出,不合并、不截断,并直接形成计费总价,不作为优惠。若旧后端未返回结构化封顶窗口,插件会用封顶历史恢复原价与计入金额,不会显示内部 adjustment 差额。只作用于整次结账的资产优惠直接列在计费总价下方,不显示额外标题或 emoji,也不会误归属到最后一个 session。
|
|
61
61
|
结账成功后,机器人会向 `staffUserIds` 与 `logoutNotifyUserIds` 中的用户私聊同一份账单,账单会明确显示结账玩家身份。
|
|
62
62
|
同一玩家在前一次退场结账尚未完成时重复发送 `/logout` 或 `/退场`,机器人会复用同一次结账请求与账单,避免重复扣款。
|
|
63
63
|
账单和管理员代操作回执均使用“平台昵称(QQ:号码)”称呼玩家;平台暂时无法提供昵称时显示“未知昵称(QQ:号码)”,不会显示内部玩家 ID。
|
|
@@ -74,8 +74,8 @@ pricingConfigIds: [pricing-mahjong-a]
|
|
|
74
74
|
* `coin <deviceId> [count]` - 请求向指定设备投币指定枚数。
|
|
75
75
|
* `scan <deviceId> <subject>` - 请求向设备发送模拟刷卡。
|
|
76
76
|
* `redeem <code>` - 兑换礼物码。
|
|
77
|
-
* `mahjong <tableId>` / `上桌 [tableId]` - 加入指定麻将桌;`/上桌` 未提供桌号时会引导查看 `/麻将列表`。仅允许已通过 `login`/`入场`
|
|
78
|
-
* `下桌` -
|
|
77
|
+
* `mahjong <tableId>` / `上桌 [tableId]` - 加入指定麻将桌;`/上桌` 未提供桌号时会引导查看 `/麻将列表`。仅允许已通过 `login`/`入场` 开启默认入场会话的玩家使用。支持在桌位未满但已开局时进行中途补位(即直接开始计费上桌)。
|
|
78
|
+
* `下桌` - 自动离开当前所在麻将桌,下桌后会停止计费,并显示该麻将桌的剩余游玩人数。
|
|
79
79
|
* `麻将列表` - 查看已配置机器的桌名、命令别名,以及空闲、等位或游玩中状态。
|
|
80
80
|
* `api测速 [次数]` - 连续查询自己的钱包,显示 Bot 到 PRiSM API 的最小、平均与最大延迟(默认 3 次,最多 10 次)。
|
|
81
81
|
|
package/lib/index.js
CHANGED
|
@@ -415,8 +415,23 @@ class PrismKoishiService {
|
|
|
415
415
|
return `你已经在 ${existing},无需重复上桌。`;
|
|
416
416
|
const state = this.mahjongTables.get(tableKey) ?? { waiting: [], activeSessions: {} };
|
|
417
417
|
this.mahjongTables.set(tableKey, state);
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
const activeCount = Object.keys(state.activeSessions).length;
|
|
419
|
+
const tableSize = this.config.mahjongTableSize ?? 4;
|
|
420
|
+
if (activeCount >= tableSize) {
|
|
421
|
+
return `「${tableSubject}」正在游玩中(${activeCount}/${tableSize}),请等待本局结束后再上桌。`;
|
|
422
|
+
}
|
|
423
|
+
if (activeCount > 0) {
|
|
424
|
+
const label = tableConfig.displayName || `${this.config.mahjongLabelPrefix ?? "麻将桌"} ${tableKey}`;
|
|
425
|
+
const result = (await this.client.startSessionByIdentity(this.identity(sender), {
|
|
426
|
+
pricingConfigIds: tableConfig.pricingConfigIds,
|
|
427
|
+
label,
|
|
428
|
+
}));
|
|
429
|
+
const session = (result?.session ?? {});
|
|
430
|
+
const sessionId = String(session.id ?? "");
|
|
431
|
+
if (sessionId) {
|
|
432
|
+
state.activeSessions[playerId] = sessionId;
|
|
433
|
+
}
|
|
434
|
+
return `已加入 ${tableSubject},补位成功,麻将计费已开始。当前 ${activeCount + 1}/${tableSize} 人。`;
|
|
420
435
|
}
|
|
421
436
|
state.waiting.push({
|
|
422
437
|
playerId,
|
|
@@ -424,7 +439,6 @@ class PrismKoishiService {
|
|
|
424
439
|
displayName: sender.name || playerId,
|
|
425
440
|
identity: this.identity(sender),
|
|
426
441
|
});
|
|
427
|
-
const tableSize = this.config.mahjongTableSize ?? 4;
|
|
428
442
|
if (state.waiting.length < tableSize) {
|
|
429
443
|
return `已加入 ${tableSubject},当前 ${state.waiting.length}/${tableSize} 人。`;
|
|
430
444
|
}
|
|
@@ -465,8 +479,10 @@ class PrismKoishiService {
|
|
|
465
479
|
if (!sessionId)
|
|
466
480
|
return "你当前未在任何麻将桌上。";
|
|
467
481
|
delete state.activeSessions[playerId];
|
|
482
|
+
const remainingCount = Object.keys(state.activeSessions).length;
|
|
483
|
+
const tableSize = this.config.mahjongTableSize ?? 4;
|
|
468
484
|
await this.client.stopSessionByIdentity(this.identity(sender), sessionId);
|
|
469
|
-
return `已离开 ${tableSubject}
|
|
485
|
+
return `已离开 ${tableSubject},麻将计费已停止。当前还剩 ${remainingCount}/${tableSize} 人。`;
|
|
470
486
|
}
|
|
471
487
|
async listMahjongTables() {
|
|
472
488
|
const activeResult = (await this.client.listActiveSessions());
|
|
@@ -950,7 +966,7 @@ class PrismKoishiService {
|
|
|
950
966
|
if (startDt && endDt) {
|
|
951
967
|
const minutes = Math.floor((endDt.getTime() - startDt.getTime()) / 60_000);
|
|
952
968
|
lines.push(`游玩时段:${formatHM(startDt)}-${formatHM(endDt)}`);
|
|
953
|
-
lines.push(`游玩时长:${formatDurationValue(minutes)}
|
|
969
|
+
lines.push(`游玩时长:${formatDurationValue(minutes)}|计价:${formatNumber(sTotal)}${currency}`);
|
|
954
970
|
}
|
|
955
971
|
else if (startDt) {
|
|
956
972
|
lines.push(`入场:${formatHM(startDt)} (${status === "active" ? "计费中" : "已关闭"})`);
|
|
@@ -987,7 +1003,14 @@ class PrismKoishiService {
|
|
|
987
1003
|
else {
|
|
988
1004
|
for (const adjustment of appliedCapAdjustments) {
|
|
989
1005
|
const label = firstDefined(adjustment, "label", "name", "source") ?? "封顶时段";
|
|
990
|
-
|
|
1006
|
+
const history = adjustment?.pricingCapHistory ?? {};
|
|
1007
|
+
const amountApplied = toNumber(history?.amount);
|
|
1008
|
+
const currentAmount = amountApplied - toNumber(adjustment?.amount ?? 0);
|
|
1009
|
+
const anchorAt = parseDateTime(history?.capAnchorAt);
|
|
1010
|
+
const datedLabel = anchorAt ? `${formatMD(anchorAt)} ${label}` : label;
|
|
1011
|
+
lines.push(amountApplied > 0
|
|
1012
|
+
? `- ${datedLabel}:${formatNumber(currentAmount)} → ${formatNumber(amountApplied)}${currency}`
|
|
1013
|
+
: `- ${datedLabel}:${formatNumber(adjustment?.amount ?? 0)}${currency}`);
|
|
991
1014
|
}
|
|
992
1015
|
}
|
|
993
1016
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-prism",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "PRiSM Next 计费与设备管理系统的 Koishi 机器人集成插件",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
"test": "bun test test",
|
|
49
49
|
"typecheck": "tsc -p tsconfig.json"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|