koishi-plugin-prism-neo 0.0.23 → 0.0.25

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.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface Config {
4
4
  url: string;
5
5
  admin: string;
6
6
  broadcasts: string[];
7
+ pmOnLogout: string[];
7
8
  currency: string;
8
9
  autoLockOnLogin: boolean;
9
10
  logoutConfirmation: boolean;
package/lib/index.js CHANGED
@@ -187,6 +187,9 @@ var Config = import_koishi.Schema.object({
187
187
  broadcasts: import_koishi.Schema.array(
188
188
  import_koishi.Schema.string()
189
189
  ),
190
+ pmOnLogout: import_koishi.Schema.array(
191
+ import_koishi.Schema.string()
192
+ ),
190
193
  currency: import_koishi.Schema.string().default("月饼").description("货币名称"),
191
194
  autoLockOnLogin: import_koishi.Schema.boolean().default(true).description("登录时自动获取门锁密码"),
192
195
  logoutConfirmation: import_koishi.Schema.boolean().default(true).description("登出时需要二次确认"),
@@ -370,9 +373,12 @@ async function handleLogoutCmd(context, user) {
370
373
  if (error) return error;
371
374
  if (!context.config.logoutConfirmation) {
372
375
  const res = await logout(context, targetUserId);
373
- let message = user ? `✅ 已为用户 ${await getUserName(context.session, targetUserId)} 退场` : "✅ 退场成功";
376
+ let name2 = await getUserName(context.session, targetUserId);
377
+ let message = user ? `✅ 已为用户 ${name2} 退场` : "✅ 退场成功";
374
378
  message += "\n";
375
379
  message += formatBilling(res, context.config.currency);
380
+ await context.session.bot.broadcast(context.config.pmOnLogout, `${name2}
381
+ ${message}`);
376
382
  return message;
377
383
  }
378
384
  const pendingLogout = kv.get(targetUserId);
@@ -528,6 +534,7 @@ async function handleMachineOff(context, alias) {
528
534
  if (!alias) return "请输入设备名";
529
535
  let isAdmin = await context.ctx.permissions.check(context.config.admin, context.session);
530
536
  const res = await machinePowerOff(context, alias, context.session.userId, !isAdmin);
537
+ if (alias === "all") return `全部机器关闭成功`;
531
538
  return `${res.machine} 关闭成功`;
532
539
  }
533
540
  __name(handleMachineOff, "handleMachineOff");
@@ -666,12 +673,12 @@ function apply(ctx, config) {
666
673
  let machines = await getAllMachinePower({ ctx, config });
667
674
  let turnOff = false;
668
675
  machines.forEach((m) => {
669
- if (m.state.state) {
676
+ if (m.state.state !== "off") {
670
677
  turnOff = true;
671
678
  }
672
679
  });
673
680
  if (turnOff) {
674
- let res = await machinePowerOff({ ctx, config }, "all", null);
681
+ let res = await machinePowerOff({ ctx, config }, "all", "system", false);
675
682
  ctx.broadcast(config.broadcasts, "窝里目前有 0 人,自动关闭所有机器");
676
683
  }
677
684
  return;
package/lib/service.d.ts CHANGED
@@ -16,13 +16,13 @@ export declare function machinePowerOff({ ctx, config }: ActionContext, machineN
16
16
  export declare function getAllMachinePower({ ctx, config, session }: ActionContext): Promise<{
17
17
  machine: string;
18
18
  state: {
19
- state: boolean;
19
+ state: string;
20
20
  };
21
21
  }[]>;
22
22
  export declare function getMachinePower({ ctx, config, session }: ActionContext, machineName: string): Promise<{
23
23
  machine: string;
24
24
  state: {
25
- state: boolean;
25
+ state: string;
26
26
  };
27
27
  }>;
28
28
  export declare function walletAdd({ ctx, config }: ActionContext, amount: number, userId: string): Promise<any>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-prism-neo",
3
3
  "description": "prism koishi前端",
4
- "version": "0.0.23",
4
+ "version": "0.0.25",
5
5
  "main": "lib/index.js",
6
6
  "files": [
7
7
  "lib",