koishi-plugin-prism 0.5.0 → 0.5.2
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 +21 -12
- package/lib/ha-watch.d.ts +3 -4
- package/lib/index.d.ts +0 -6
- package/lib/index.js +33 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
所有技术异常在聊天中只显示通用失败提示,不会包含后端名称、URL、网络状态、原始 `fetch` 错误或 HTTP 状态。完整原始异常会写入 Koishi 的 `prism` 日志,供管理员排查。
|
|
17
17
|
|
|
18
|
+
兑换码无效、尚未生效、过期、领完,以及礼物已领取或达到限领次数时,`/redeem` 返回对应的中文提示;锁争用超过后端等待预算时提示其他操作正在处理中。公共码并发等待和次数校验由平台执行,Bot 不自行重发兑换请求。命令返回文本只确认已交给 Koishi;真实群聊投递仍由聊天适配器完成。
|
|
19
|
+
|
|
18
20
|
## ⚙️ 配置说明
|
|
19
21
|
|
|
20
22
|
Koishi 里只填怎么连到店铺:
|
|
@@ -40,11 +42,11 @@ Koishi 里只填怎么连到店铺:
|
|
|
40
42
|
| 门锁 | `lock` 打开的门(带门锁能力的资源);店里只有一扇门时默认就是它。没有门时 `lock` 回复本店还没有设置。 |
|
|
41
43
|
| 入场后自动获取门锁密码 | 默认关闭。打开后 `login`/`入场` 成功时顺带生成一个 8 位 TTLock 临时密码(有效期 3 分钟)一并回复;门锁失败只多一行提示,不会让入场失败。没有门锁时不生效。 |
|
|
42
44
|
| 播报与提醒 | 只有一处设置:**播报群**(Koishi 的 `平台:频道` 格式,如群 `onebot:群号`、私聊 `onebot:private:QQ号`)和**提醒提前量**(分钟)。闲置提醒和店内动态都发到这一处,不再分成两个群。 |
|
|
43
|
-
| 播报这些 | 五个开关,各自默认关闭:设备闲置(关机前提醒,提前量为 0
|
|
45
|
+
| 播报这些 | 五个开关,各自默认关闭:设备闲置(关机前提醒,提前量为 0 时不提醒)、开机/关机(含闲置自动关机)、上机(刷卡或投币后开始占用机台)、刷卡、投币。刷卡或投币同时上机时只发一条:开了「上机」按上机播报,否则按刷卡/投币播报。这个 Bot 自己执行的命令已经回复过,不再播报;别的 Bot、网页和机台上发生的照常播报。下机不播报。 |
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
播报与闲置提醒直接通过对应平台的第一个在线机器人发送,不依赖 Koishi 的数据库、频道分配或 silent 标记,是否播报由 PRiSM 设置决定。群聊填写 `平台:频道`,私聊填写 `平台:private:用户ID`;频道 ID 内的冒号保持原样。连续播报不会修改缓存的频道列表,单个目标发送失败会记录目标及错误并继续其他目标和后续播报。相同平台有多个机器人时,第一个在线账号须能访问目标群;离线时不缓存补发。
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
HA 监听的健康心跳与 HA ping 均为每 60 秒一次,与机台 IO 对齐;平台仍使用 150 秒报告租约。电源变化由平台根据 HA 上报确认后分发 `shop.event`,Bot 按设置播报,不在本地另做电源判断。
|
|
48
50
|
|
|
49
51
|
**店员**是在这家店工作、并在网页里绑定了聊天平台身份的人:Bot 按「平台 + 账号」认人,`onebot:114514` 是店员不代表 `telegram:114514` 也是。**货币名称**取店铺的余额资产名,**麻将桌**和**门锁**取店铺的资源,都不需要在 Koishi 里重复填写。店铺没有整店计费开关。Bot 属于一个资源组,`login`/`入场` 开始的是这个资源组(或 Bot 资源专属)的计费方案;平台下发的 `billingEnabled` 只表示通过这个 Bot 入场是否计费。为 `false` 时 Bot 不请求平台,直接回复「这里不计费,无需入场」;平台拒绝时(例如资源组刚改成免费)回复同样的话。钱包、账单、结账、兑换、上下桌、`list` 等命令属于玩家或各自的资源,跟 Bot 所在资源组无关,一律交给平台处理。旧平台整店未启用计费时返回的 `BILLING_DISABLED` 仍提示「本店未启用计费」。
|
|
50
52
|
|
|
@@ -98,7 +100,7 @@ Bot 设置开启「账单私聊店员」时,玩家退场或店员覆盖结账
|
|
|
98
100
|
* `coin <设备名或别名> [count]` - 请求向后台配置的 Hinata IO 设备投币;需要玩家已入场。
|
|
99
101
|
* `scan <设备名或别名>` - 使用当前玩家后台绑定的 Aime 卡向设备刷卡,不在群聊中输入或显示卡号。
|
|
100
102
|
* `redeem <code>` - 兑换礼物码。
|
|
101
|
-
* `mahjong <桌号>` / `上桌 [桌号]` - 按桌名或别名(不区分大小写)坐上麻将桌;`/上桌` 未提供桌号时会引导查看
|
|
103
|
+
* `mahjong <桌号>` / `上桌 [桌号]` - 按桌名或别名(不区分大小写)坐上麻将桌;`/上桌` 未提供桌号时会引导查看 `/麻将列表`。不需要先入场:坐满时平台为全桌开始计费,已开局的桌补位后立即开始计费。直接加入另一桌即为换桌,无需先下桌;相同方案保持原计时,目标满桌或计费失败保留原桌。平台拒绝计费(例如不在麻将计费时段)时回复原因。
|
|
102
104
|
* `下桌 [桌号]` - 离开当前所在的麻将桌(也可以指明哪一桌),正在计费的会停止计费,并显示该桌剩余人数。
|
|
103
105
|
* `麻将列表` - 查看店里麻将桌的桌名、别名,以及空闲、等位或游玩中状态。
|
|
104
106
|
* `api测速 [次数]` - 走 HTTP 连续查询自己的钱包:首次(含建立连接)单独列出,之后显示最小、平均与最大延迟,并给出服务端处理时间和经过的 Cloudflare 节点(默认 5 次,最多 10 次)。
|
|
@@ -108,6 +110,9 @@ Bot 设置开启「账单私聊店员」时,玩家退场或店员覆盖结账
|
|
|
108
110
|
Bot 版本直接读取本 npm 包的 `package.json`,后端版本读取无需认证的 `GET /version`。插件发布遵循 SemVer;修复使用 patch、兼容新增功能使用 minor、不兼容改动使用 major,发布前通过 `npm version <patch|minor|major>` 自动更新包版本。
|
|
109
111
|
|
|
110
112
|
### 店员快捷指令
|
|
113
|
+
|
|
114
|
+
支持 `/上桌 a @玩家`、`/下桌 a @玩家`(`mahjong a @玩家` 同上桌),可直接代玩家上下桌或换桌,无需玩家先入场。与其他代操作相同,须开启店员命令且发送者是本店绑定了当前平台身份的店员。回复显示目标玩家。普通玩家省略 `@玩家` 操作自己。计费与座位由平台原子提交,Bot 不维护另一份桌位或计费状态。
|
|
115
|
+
|
|
111
116
|
Bot 设置开启「店员命令」后,店员(在网页绑定了当前聊天平台身份的店员)可使用:
|
|
112
117
|
* `add <target:user> <amount:number>` - 为目标用户增加余额。
|
|
113
118
|
* `del <target:user> <amount:number>` - 从目标用户扣除余额。
|
|
@@ -145,6 +150,8 @@ npm version minor --no-git-tag-version
|
|
|
145
150
|
|
|
146
151
|
也可以推送与 `package.json` 一致的 `v` 标签,或在 Actions 里手动运行 `Publish to npm`。
|
|
147
152
|
|
|
153
|
+
回退到 0.4.0 时,手动运行上述工作流会将 npm 的 `latest` 指回已发布的 0.4.0;需要 Trusted Publisher 已允许管理 dist-tag,不会重新发布或删除版本。
|
|
154
|
+
|
|
148
155
|
首次使用前,在 npm 包设置的 Trusted Publisher 中选择 GitHub Actions,填写仓库 `nerimoe/koishi-plugin-prism` 和工作流文件名 `publish.yml`,并允许 `npm publish`。
|
|
149
156
|
|
|
150
157
|
## 📄 开源协议
|
|
@@ -159,17 +166,13 @@ npm version minor --no-git-tag-version
|
|
|
159
166
|
|
|
160
167
|
绑定支持 Koishi 提供的各适配器标识,身份值保持字符串,不限定数字格式。店员和账单私聊按「平台标识 + 身份值」认人,相同号码的其他平台不会继承权限或通知。管理员代操作使用目标平台标识,禁止通过当前适配器误操作另一个平台。`/list` 只用当前平台的身份查询昵称,缺失时使用后台名称。源码和 npm 发行包需要分别核对版本。
|
|
161
168
|
|
|
162
|
-
### 0.5.
|
|
163
|
-
|
|
164
|
-
电源播报改为基于 Bot 本地监听到的 HA 状态变化,覆盖 HA 能感知的手动开关和自动化操作;首次快照和重连不误报,共享电源合并播报。需要先升级配套 PRiSM 后端,使 `integration/bot` 提供 `powerResources` 映射,再升级插件;旧后端缺少映射时不发电源播报,其他播报照常。
|
|
169
|
+
### 0.5.2
|
|
165
170
|
|
|
166
|
-
|
|
171
|
+
完整恢复 0.4.1/0.4.2 的修复:HA 心跳与 ping 每 60 秒一次;店内动态和闲置预告直接通过适配器发送,不依赖 Koishi 数据库,不修改频道列表,支持群聊/私聊及逐目标失败隔离。电源播报继续由平台根据 HA 事件分发。同时支持店员 `/上桌 a @玩家`、`/下桌 a @玩家`,保留 0.5.1 的兑换提示修复。
|
|
167
172
|
|
|
168
|
-
|
|
173
|
+
### 0.5.1
|
|
169
174
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Bot 作为 Home Assistant 监听者时的心跳从 30 秒改成 60 秒,与机台 IO 一致,平台因此用同一个租约(150 秒)衡量两者。同一个间隔也是向 Home Assistant 发的 `ping`,所以 Home Assistant 停止应答现在最多 60 秒后才发现(原来 30 秒)。
|
|
175
|
+
在 0.4.0 的基础上补齐兑换失败提示:区分无效、未生效、过期、领完、已领取、达到限领次数与操作争用,不再统一回复稍后重试。公共码并发保护由平台负责(PRiSM `b4871d8` 起);本次不恢复旧 0.5.0 的 HA 本地播报实现,电源播报仍由平台确认 HA 事件后分发给 Bot。npm 上已发布的 0.5.0 不可覆盖,因此此修复使用 0.5.1。
|
|
173
176
|
|
|
174
177
|
### 0.4.0
|
|
175
178
|
|
|
@@ -196,3 +199,9 @@ Koishi 配置只剩 `baseUrl` 和 `integrationToken`(`shopCode` 可选、已
|
|
|
196
199
|
## 时间展示
|
|
197
200
|
|
|
198
201
|
账单、历史与资产到期使用 API 时间字符串所带的店铺偏移,例如 `2026-10-03T10:08:00+08:00`,不依赖 Bot 服务器时区,也不手工加八小时。账单注明 UTC 偏移;时间排序及游玩时长按绝对时间计算,兼容旧 `Z` 时间戳。网页/Swift 的个人时间可按玩家设备时区展示,因此跨地区使用时显示时钟不同,但时长和金额一致。
|
|
202
|
+
|
|
203
|
+
当前上下桌功能使用平台 `integration/players/by-identity/mahjong`;平台不再兼容旧 Bot 通过指定方案的 `session/start` 模拟麻将计费。
|
|
204
|
+
|
|
205
|
+
### 0.4.1 / 0.4.2 修复恢复
|
|
206
|
+
|
|
207
|
+
回退 0.4.0 后发布的 0.5.1 漏带了两组修复:0.4.1 的 60 秒 HA 心跳和 ping,以及 0.4.2 的无数据库播报发送、群聊/私聊、逐目标失败隔离和连续播报回归测试。现已完整恢复,保留后续兑换与管理员上下桌改动。Bot 本地判断 HA 电源变化的已撤回实现不属于这些修复。
|
package/lib/ha-watch.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type EntityState = {
|
|
|
54
54
|
export declare function applyEvent(states: Map<string, EntityState>, event: unknown): string[];
|
|
55
55
|
export declare function statesFrame(term: number, connection: string, full: boolean, states: Map<string, EntityState>, ids: string[]): {
|
|
56
56
|
type: string;
|
|
57
|
-
method:
|
|
57
|
+
method: string;
|
|
58
58
|
params: {
|
|
59
59
|
term: number;
|
|
60
60
|
connection: string;
|
|
@@ -70,7 +70,7 @@ export declare function statesFrame(term: number, connection: string, full: bool
|
|
|
70
70
|
};
|
|
71
71
|
export declare function statusFrame(term: number, connection: string, connected: boolean, error: string | null): {
|
|
72
72
|
type: string;
|
|
73
|
-
method:
|
|
73
|
+
method: string;
|
|
74
74
|
params: {
|
|
75
75
|
term: number;
|
|
76
76
|
connection: string;
|
|
@@ -78,7 +78,6 @@ export declare function statusFrame(term: number, connection: string, connected:
|
|
|
78
78
|
error: string | null;
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
|
-
export type HaFrame = ReturnType<typeof statesFrame> | ReturnType<typeof statusFrame>;
|
|
82
81
|
/** `http(s)://host[:port]` to the WebSocket API address; null for anything else. */
|
|
83
82
|
export declare function websocketUrl(base: string): string | null;
|
|
84
83
|
/** The addresses in the order to try them: rotated to start at the one that worked last. */
|
|
@@ -97,7 +96,7 @@ export declare class HaWatcher {
|
|
|
97
96
|
private generation;
|
|
98
97
|
private readonly aborts;
|
|
99
98
|
private readonly waits;
|
|
100
|
-
constructor(open: SocketFactory, send: (frame:
|
|
99
|
+
constructor(open: SocketFactory, send: (frame: Record_) => void, logger?: Logger | undefined, timing?: HaTiming);
|
|
101
100
|
/** Watch what the platform asked for, in place of whatever was watched before. */
|
|
102
101
|
watch(watch: HaWatch): void;
|
|
103
102
|
/** Stop watching, and drop every Home Assistant connection. */
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -87,9 +87,9 @@ function applyPrismKoishiPlugin(ctx, config) {
|
|
|
87
87
|
ctx.command("prism.bind <code:string>", "绑定网页登录账号到当前平台身份(旧命令,同 bind)").action(bind);
|
|
88
88
|
ctx.command("login [target:user]", "开启玩家计费场次").action(effect(async (context, target) => service.loginForTarget(await service.sender(context), target, context.session?.bot), entry));
|
|
89
89
|
ctx.command("入场 [target:user]", "入场").action(effect(async (context, target) => service.loginForTarget(await service.sender(context), target, context.session?.bot), entry));
|
|
90
|
-
ctx.command("mahjong <tableId>", "加入指定麻将桌").action(effect(async (context, tableId) => service.
|
|
91
|
-
ctx.command("上桌 [tableId]", "加入指定麻将桌").action(effect(async (context, tableId) => service.
|
|
92
|
-
ctx.command("下桌 [tableId]", "离开当前所在麻将桌").action(effect(async (context, tableId) => service.
|
|
90
|
+
ctx.command("mahjong <tableId> [target:user]", "加入指定麻将桌").action(effect(async (context, tableId, target) => service.withTarget(await service.sender(context), target, async (sender, targeted) => (targeted ? `玩家 ${formatPlayerReference(sender)}\n` : "") + await service.mahjongJoin(sender, tableId), context.session?.bot)));
|
|
91
|
+
ctx.command("上桌 [tableId] [target:user]", "加入指定麻将桌").action(effect(async (context, tableId, target) => service.withTarget(await service.sender(context), target, async (sender, targeted) => (targeted ? `玩家 ${formatPlayerReference(sender)}\n` : "") + await service.mahjongJoin(sender, tableId), context.session?.bot)));
|
|
92
|
+
ctx.command("下桌 [tableId] [target:user]", "离开当前所在麻将桌").action(effect(async (context, tableId, target) => service.withTarget(await service.sender(context), target, async (sender, targeted) => (targeted ? `玩家 ${formatPlayerReference(sender)}\n` : "") + await service.mahjongLeave(sender, tableId), context.session?.bot)));
|
|
93
93
|
ctx.command("麻将列表", "查看麻将机状态与别名").action(wrap(async () => service.listMahjongTables()));
|
|
94
94
|
ctx.command("logout [target:user]", "结算玩家计费场次").action(effect(async (context, target) => service.withTarget(await service.sender(context), target, (sender) => service.logout(sender, context.session?.bot), context.session?.bot)));
|
|
95
95
|
ctx.command("billing [target:user]", "预览玩家结账费用").action(wrap(async (context, target) => service.withTarget(await service.sender(context), target, (sender) => service.billing(sender), context.session?.bot)));
|
|
@@ -595,8 +595,6 @@ class PrismKoishiService {
|
|
|
595
595
|
bot = null;
|
|
596
596
|
/** Announcements still being sent; each waits for the one before. */
|
|
597
597
|
announcing = Promise.resolve();
|
|
598
|
-
/** The current connection's baseline; a reconnect supplies a fresh full snapshot. */
|
|
599
|
-
powerStates = new Map();
|
|
600
598
|
/** The read in flight, shared by commands arriving together. */
|
|
601
599
|
reading = null;
|
|
602
600
|
reads = 0;
|
|
@@ -623,27 +621,20 @@ class PrismKoishiService {
|
|
|
623
621
|
// says nothing about Home Assistant: then there is no watching to offer.
|
|
624
622
|
const haOpen = options.haSocket ?? (options.socket ? null : open);
|
|
625
623
|
if (haOpen)
|
|
626
|
-
this.watcher = new ha_watch_js_1.HaWatcher(haOpen, (frame) =>
|
|
627
|
-
this.observePower(frame);
|
|
628
|
-
this.socket?.send(frame);
|
|
629
|
-
}, this.logger);
|
|
624
|
+
this.watcher = new ha_watch_js_1.HaWatcher(haOpen, (frame) => this.socket?.send(frame), this.logger);
|
|
630
625
|
this.socket = new PrismSocket(open, platformSocketUrl(options.baseUrl), options.integrationToken, () => this.hello(), (event) => {
|
|
631
626
|
if (event.event === "idle.reminder")
|
|
632
627
|
void this.remindIdle(event.data);
|
|
633
628
|
// One at a time, so the channels read them in the order they happened.
|
|
634
629
|
else if (event.event === "shop.event")
|
|
635
|
-
this.
|
|
630
|
+
this.announcing = this.announcing
|
|
631
|
+
.then(() => this.announce(event.data))
|
|
632
|
+
.catch((error) => this.logger?.warn("PRiSM event announcement failed", error));
|
|
636
633
|
}, this.logger, this.watcher
|
|
637
634
|
? {
|
|
638
635
|
// Only a bot whose settings allow it watches, whatever the platform asks.
|
|
639
|
-
onWatch: (watch) =>
|
|
640
|
-
|
|
641
|
-
if (watch && this.watching)
|
|
642
|
-
this.watcher.watch(watch);
|
|
643
|
-
else
|
|
644
|
-
this.watcher.stop();
|
|
645
|
-
},
|
|
646
|
-
onClose: () => { this.powerStates.clear(); this.watcher.stop(); },
|
|
636
|
+
onWatch: (watch) => (watch && this.watching ? this.watcher.watch(watch) : this.watcher.stop()),
|
|
637
|
+
onClose: () => this.watcher.stop(),
|
|
647
638
|
}
|
|
648
639
|
: undefined);
|
|
649
640
|
const post = options.httpPost ?? (async (url, headers, body) => {
|
|
@@ -748,9 +739,6 @@ class PrismKoishiService {
|
|
|
748
739
|
* command already.
|
|
749
740
|
*/
|
|
750
741
|
async announce(event) {
|
|
751
|
-
// Platform power events remain for older plugins; HA is the only trigger here.
|
|
752
|
-
if (event.kind === "power")
|
|
753
|
-
return;
|
|
754
742
|
const bot = this.bot;
|
|
755
743
|
const channels = bot?.settings.announceChannelIds ?? [];
|
|
756
744
|
if (!bot || !channels.length)
|
|
@@ -762,35 +750,6 @@ class PrismKoishiService {
|
|
|
762
750
|
return;
|
|
763
751
|
await this.broadcast(channels, message);
|
|
764
752
|
}
|
|
765
|
-
queueAnnouncement(send) {
|
|
766
|
-
this.announcing = this.announcing.then(send)
|
|
767
|
-
.catch((error) => this.logger?.warn("PRiSM event announcement failed", error));
|
|
768
|
-
}
|
|
769
|
-
observePower(frame) {
|
|
770
|
-
const { connection } = frame.params;
|
|
771
|
-
if (frame.method === "ha.status") {
|
|
772
|
-
if (!frame.params.connected)
|
|
773
|
-
this.powerStates.delete(connection);
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
const { full, states } = frame.params;
|
|
777
|
-
const previous = full ? new Map() : (this.powerStates.get(connection) ?? new Map());
|
|
778
|
-
for (const state of states) {
|
|
779
|
-
const before = previous.get(state.entity_id);
|
|
780
|
-
previous.set(state.entity_id, state.state);
|
|
781
|
-
if ((before !== "on" && before !== "off") || (state.state !== "on" && state.state !== "off") || before === state.state)
|
|
782
|
-
continue;
|
|
783
|
-
const bot = this.bot;
|
|
784
|
-
if (!bot?.settings.announcePower || !bot.settings.announceChannelIds.length)
|
|
785
|
-
continue;
|
|
786
|
-
const resources = bot.powerResources.filter((resource) => resource.connectionId === connection && resource.entityId === state.entity_id);
|
|
787
|
-
if (!resources.length)
|
|
788
|
-
continue;
|
|
789
|
-
const message = `${state.state === "on" ? "✅" : "🛑"} ${resources.map((resource) => resource.name).join("、")} 已${state.state === "on" ? "开机" : "关机"}`;
|
|
790
|
-
this.queueAnnouncement(() => this.broadcast(bot.settings.announceChannelIds, message));
|
|
791
|
-
}
|
|
792
|
-
this.powerStates.set(connection, previous);
|
|
793
|
-
}
|
|
794
753
|
/** Explicit targets need neither Koishi's channel database nor its mutable broadcast list. */
|
|
795
754
|
async broadcast(channels, message) {
|
|
796
755
|
for (const target of channels) {
|
|
@@ -827,6 +786,14 @@ class PrismKoishiService {
|
|
|
827
786
|
sessions: [{ playerDisplayName: event.player.displayName ?? undefined, identities: event.player.identities }],
|
|
828
787
|
}, provider);
|
|
829
788
|
};
|
|
789
|
+
if (event.kind === "power") {
|
|
790
|
+
if (!settings.announcePower)
|
|
791
|
+
return null;
|
|
792
|
+
if (event.by === "system")
|
|
793
|
+
return event.state === "off" ? `💤 ${place} 闲置,已自动关机` : `✅ ${place} 已开机`;
|
|
794
|
+
const by = event.player ? `(${await who()})` : "";
|
|
795
|
+
return event.state === "on" ? `✅ ${place} 已开机${by}` : `🛑 ${place} 已关机${by}`;
|
|
796
|
+
}
|
|
830
797
|
if (event.kind === "card") {
|
|
831
798
|
if (event.started && settings.announceStarts)
|
|
832
799
|
return `🎮 ${await who()} 在 ${place} 刷卡上机`;
|
|
@@ -940,8 +907,6 @@ class PrismKoishiService {
|
|
|
940
907
|
return `未找到麻将桌「${tableRef}」。可先使用 /麻将列表 查看可用桌位。`;
|
|
941
908
|
if (error.code === "MAHJONG_TABLE_FULL")
|
|
942
909
|
return `「${table.name}」已满桌,请等待本局结束后再上桌。`;
|
|
943
|
-
if (error.code === "MAHJONG_ALREADY_SEATED")
|
|
944
|
-
return "你已经在另一张麻将桌上,请先 /下桌。";
|
|
945
910
|
const message = platformMessage(error);
|
|
946
911
|
if (message)
|
|
947
912
|
return `上桌失败,${message}`;
|
|
@@ -1572,6 +1537,22 @@ class PrismKoishiService {
|
|
|
1572
1537
|
function humanReadableBotError(error) {
|
|
1573
1538
|
if (error.code === "INVALID_PLATFORM_IDENTITY")
|
|
1574
1539
|
return error.message;
|
|
1540
|
+
if (error.code === "OPERATION_IN_PROGRESS")
|
|
1541
|
+
return "其他操作正在处理中,请稍后再试。";
|
|
1542
|
+
if (error.code === "REDEEM_CODE_NOT_FOUND")
|
|
1543
|
+
return "兑换码无效,请检查后再试。";
|
|
1544
|
+
if (error.code === "REDEEM_CODE_NOT_ACTIVE")
|
|
1545
|
+
return "兑换码尚未生效。";
|
|
1546
|
+
if (error.code === "REDEEM_CODE_EXPIRED" || error.code === "PRESENT_EXPIRED")
|
|
1547
|
+
return "兑换码已过期。";
|
|
1548
|
+
if (error.code === "PRESENT_NOT_ACTIVE" || error.code === "PRESENT_ARCHIVED")
|
|
1549
|
+
return "这份礼物当前无法兑换。";
|
|
1550
|
+
if (error.code === "REDEEM_CODE_MAX_USE_REACHED")
|
|
1551
|
+
return "兑换码已被领完。";
|
|
1552
|
+
if (error.code === "PRESENT_ONCE_PER_PLAYER_REDEEMED")
|
|
1553
|
+
return "您已经领取过这份礼物,无需重复兑换。";
|
|
1554
|
+
if (error.code === "PRESENT_GRANT_LIMIT_REACHED")
|
|
1555
|
+
return "您已达到这份礼物的领取上限。";
|
|
1575
1556
|
if (error.code === "BOT_DISABLED")
|
|
1576
1557
|
return "Bot 已被店铺停用";
|
|
1577
1558
|
if (error.code === "BILLING_DISABLED")
|
|
@@ -1718,12 +1699,6 @@ function parseBotConfig(value) {
|
|
|
1718
1699
|
},
|
|
1719
1700
|
billingEnabled: record.billingEnabled !== false,
|
|
1720
1701
|
currencyName: cleanText(record.currencyName) || "余额",
|
|
1721
|
-
powerResources: (Array.isArray(record.powerResources) ? record.powerResources : [])
|
|
1722
|
-
.map((resource) => ({
|
|
1723
|
-
id: cleanText(resource?.id), name: cleanText(resource?.name) || cleanText(resource?.id),
|
|
1724
|
-
connectionId: cleanText(resource?.connectionId), entityId: cleanText(resource?.entityId),
|
|
1725
|
-
}))
|
|
1726
|
-
.filter((resource) => resource.id && resource.connectionId && resource.entityId),
|
|
1727
1702
|
staff: (Array.isArray(record.staff) ? record.staff : [])
|
|
1728
1703
|
.map((identity) => ({ provider: cleanText(identity?.provider).toLowerCase(), subject: cleanText(identity?.subject) }))
|
|
1729
1704
|
.filter((identity) => identity.provider && identity.subject),
|