koishi-plugin-prism-neo 0.0.18 → 0.0.19

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,8 @@ export interface Config {
4
4
  url: string;
5
5
  admin: string;
6
6
  currency: string;
7
+ autoLockOnLogin: boolean;
8
+ logoutConfirmation: boolean;
7
9
  }
8
10
  export declare const Config: Schema<Config>;
9
11
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -183,7 +183,9 @@ var kv = /* @__PURE__ */ new Map();
183
183
  var Config = import_koishi.Schema.object({
184
184
  url: import_koishi.Schema.string().required(),
185
185
  admin: import_koishi.Schema.string().default("authority:3"),
186
- currency: import_koishi.Schema.string().default("月饼").description("货币名称")
186
+ currency: import_koishi.Schema.string().default("月饼").description("货币名称"),
187
+ autoLockOnLogin: import_koishi.Schema.boolean().default(true).description("登录时自动获取门锁密码"),
188
+ logoutConfirmation: import_koishi.Schema.boolean().default(true).description("登出时需要二次确认")
187
189
  });
188
190
  async function getUserName(session, userId) {
189
191
  if (userId) {
@@ -322,14 +324,27 @@ async function handleLoginCmd(context, user) {
322
324
  const { error, userId } = await getTargetUserId(context, user);
323
325
  if (error) return error;
324
326
  await login(context, userId);
325
- let lockMessage = await handleLockCmd(context);
326
- let message = "✅ 入场成功\n\n" + lockMessage;
327
+ let message = "✅ 入场成功";
328
+ if (context.config.autoLockOnLogin) {
329
+ let lockMessage = await handleLockCmd(context);
330
+ message += "\n\n" + lockMessage;
331
+ }
327
332
  return message;
328
333
  }
329
334
  __name(handleLoginCmd, "handleLoginCmd");
330
335
  async function handleLogoutCmd(context, user) {
331
336
  const { error, userId: targetUserId } = await getTargetUserId(context, user);
332
337
  if (error) return error;
338
+ if (!context.config.logoutConfirmation) {
339
+ const res = await logout(context, targetUserId);
340
+ const messagePrefix = user ? `✅ 已为用户 ${await getUserName(context.session, targetUserId)} 退场` : "✅ 退场成功";
341
+ return [
342
+ messagePrefix,
343
+ `入场时间: ${formatDateTime(res.session.createdAt)}`,
344
+ `离场时间: ${formatDateTime(res.session.closedAt)}`,
345
+ `消费: ${res.session.finalCost} ${context.config.currency}`
346
+ ].join("\n");
347
+ }
333
348
  const pendingLogout = kv.get(targetUserId);
334
349
  const now = Date.now();
335
350
  if (pendingLogout && now - pendingLogout < 60 * 1e3) {
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.18",
4
+ "version": "0.0.19",
5
5
  "main": "lib/index.js",
6
6
  "files": [
7
7
  "lib",