koishi-plugin-prism-neo 0.0.17 → 0.0.18
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 +1 -0
- package/lib/index.js +17 -16
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -182,7 +182,8 @@ var name = "prism-neo";
|
|
|
182
182
|
var kv = /* @__PURE__ */ new Map();
|
|
183
183
|
var Config = import_koishi.Schema.object({
|
|
184
184
|
url: import_koishi.Schema.string().required(),
|
|
185
|
-
admin: import_koishi.Schema.string().default("authority:3")
|
|
185
|
+
admin: import_koishi.Schema.string().default("authority:3"),
|
|
186
|
+
currency: import_koishi.Schema.string().default("月饼").description("货币名称")
|
|
186
187
|
});
|
|
187
188
|
async function getUserName(session, userId) {
|
|
188
189
|
if (userId) {
|
|
@@ -223,7 +224,7 @@ var formatDateTime = /* @__PURE__ */ __name((dateStr) => {
|
|
|
223
224
|
const s = date.getSeconds().toString().padStart(2, "0");
|
|
224
225
|
return `${y}/${m}/${d} ${h2}:${min}:${s}`;
|
|
225
226
|
}, "formatDateTime");
|
|
226
|
-
var formatBilling = /* @__PURE__ */ __name((res) => {
|
|
227
|
+
var formatBilling = /* @__PURE__ */ __name((res, currency) => {
|
|
227
228
|
const message = [];
|
|
228
229
|
message.push("--- 账单详情 ---");
|
|
229
230
|
message.push(`入场: ${formatDateTime(res.session.createdAt)}`);
|
|
@@ -245,18 +246,18 @@ var formatBilling = /* @__PURE__ */ __name((res) => {
|
|
|
245
246
|
if (res.session.costOverwrite) {
|
|
246
247
|
finalCost = res.session.costOverwrite;
|
|
247
248
|
}
|
|
248
|
-
message.push(`计费价: ${originalCost}
|
|
249
|
+
message.push(`计费价: ${originalCost} ${currency}`);
|
|
249
250
|
if (res.discount && res.discount.appliedLogs.length > 0) {
|
|
250
251
|
res.discount.appliedLogs.forEach((log) => {
|
|
251
|
-
message.push(` -「${log.asset}」: -${log.saved}
|
|
252
|
+
message.push(` -「${log.asset}」: -${log.saved} ${currency}`);
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
message.push(`结算价: ${finalCost}
|
|
255
|
+
message.push(`结算价: ${finalCost} ${currency}`);
|
|
255
256
|
message.push("---");
|
|
256
257
|
const currentBalance = res.wallet.total.available;
|
|
257
258
|
const finalBalance = currentBalance - finalCost;
|
|
258
|
-
message.push(`当前余额: ${currentBalance}
|
|
259
|
-
message.push(`扣款后: ${finalBalance}
|
|
259
|
+
message.push(`当前余额: ${currentBalance} ${currency}`);
|
|
260
|
+
message.push(`扣款后: ${finalBalance} ${currency}`);
|
|
260
261
|
message.push("---");
|
|
261
262
|
message.push("计费区间:");
|
|
262
263
|
if (res.billing.segments.length > 0) {
|
|
@@ -287,7 +288,7 @@ var formatBilling = /* @__PURE__ */ __name((res) => {
|
|
|
287
288
|
message.push(`- ${seg.ruleName}`);
|
|
288
289
|
message.push(` 时段: ${timeString}`);
|
|
289
290
|
message.push(` 时长: ${segDurationStr}`);
|
|
290
|
-
message.push(` 费用: ${seg.cost}
|
|
291
|
+
message.push(` 费用: ${seg.cost} ${currency} ${seg.isCapped ? "(已封顶)" : ""}`);
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
294
|
} else {
|
|
@@ -339,11 +340,11 @@ async function handleLogoutCmd(context, user) {
|
|
|
339
340
|
messagePrefix,
|
|
340
341
|
`入场时间: ${formatDateTime(res.session.createdAt)}`,
|
|
341
342
|
`离场时间: ${formatDateTime(res.session.closedAt)}`,
|
|
342
|
-
`消费: ${res.session.finalCost}
|
|
343
|
+
`消费: ${res.session.finalCost} ${context.config.currency}`
|
|
343
344
|
].join("\n");
|
|
344
345
|
} else {
|
|
345
346
|
const billingRes = await billing(context, targetUserId);
|
|
346
|
-
const billingMessage = formatBilling(billingRes);
|
|
347
|
+
const billingMessage = formatBilling(billingRes, context.config.currency);
|
|
347
348
|
kv.set(targetUserId, now);
|
|
348
349
|
if (user) {
|
|
349
350
|
return `以下是用户 ${await getUserName(context.session, targetUserId)} 的账单预览:
|
|
@@ -389,21 +390,21 @@ async function handleWalletCmd(context, user) {
|
|
|
389
390
|
const targetUserId = user ? userId : void 0;
|
|
390
391
|
message.push(targetUserId ? `--- 用户 ${await getUserName(context.session, targetUserId)} 的钱包余额 ---` : "--- 钱包余额 ---");
|
|
391
392
|
message.push(
|
|
392
|
-
`可用: ${res.total.available}
|
|
393
|
+
`可用: ${res.total.available} ${context.config.currency} (共 ${res.total.all})`,
|
|
393
394
|
` - 付费: ${res.paid.available}`,
|
|
394
395
|
` - 免费: ${res.free.available}`
|
|
395
396
|
);
|
|
396
397
|
const unavailable = res.total.all - res.total.available;
|
|
397
398
|
if (unavailable > 0) {
|
|
398
399
|
message.push(`
|
|
399
|
-
您还有 ${unavailable}
|
|
400
|
+
您还有 ${unavailable} ${context.config.currency}未到可用时间。`);
|
|
400
401
|
}
|
|
401
402
|
const expiringFreeAssets = res.free.details?.available?.filter((asset) => asset.expireAt) || [];
|
|
402
403
|
if (expiringFreeAssets.length > 0) {
|
|
403
404
|
expiringFreeAssets.sort((a, b) => new Date(a.expireAt).getTime() - new Date(b.expireAt).getTime());
|
|
404
405
|
const soonestToExpire = expiringFreeAssets[0];
|
|
405
406
|
message.push(`
|
|
406
|
-
注意:您有 ${soonestToExpire.count}
|
|
407
|
+
注意:您有 ${soonestToExpire.count} 免费${context.config.currency}将于 ${formatDateTime(soonestToExpire.expireAt)} 过期。`);
|
|
407
408
|
}
|
|
408
409
|
const availablePasses = res.passes?.details?.available || [];
|
|
409
410
|
if (availablePasses.length > 0) {
|
|
@@ -430,7 +431,7 @@ async function handleBillingCmd(context, user) {
|
|
|
430
431
|
const { error, userId } = await getTargetUserId(context, user);
|
|
431
432
|
if (error) return error;
|
|
432
433
|
const res = await billing(context, userId);
|
|
433
|
-
const billingMessage = formatBilling(res);
|
|
434
|
+
const billingMessage = formatBilling(res, context.config.currency);
|
|
434
435
|
if (user) {
|
|
435
436
|
return `用户 ${await getUserName(context.session, userId)} 的账单:
|
|
436
437
|
|
|
@@ -505,7 +506,7 @@ async function handleWalletAdd(context, user, amount) {
|
|
|
505
506
|
if (!amount) return "请输入数量";
|
|
506
507
|
const res = await walletAdd(context, parseInt(amount), userId);
|
|
507
508
|
return [
|
|
508
|
-
`为用户 ${await getUserName(context.session, userId)}
|
|
509
|
+
`为用户 ${await getUserName(context.session, userId)} 增加${context.config.currency}成功`,
|
|
509
510
|
`增加前: ${res.originalBalance}`,
|
|
510
511
|
`增加后: ${res.finalBalance}`
|
|
511
512
|
].join("\n");
|
|
@@ -517,7 +518,7 @@ async function handleWalletDeduct(context, user, amount) {
|
|
|
517
518
|
if (!amount) return "请输入数量";
|
|
518
519
|
const res = await walletDel(context, parseInt(amount), userId);
|
|
519
520
|
return [
|
|
520
|
-
`为用户 ${userId}
|
|
521
|
+
`为用户 ${userId} 扣除${context.config.currency}成功`,
|
|
521
522
|
`扣款前: ${res.originalBalance}`,
|
|
522
523
|
`扣款后: ${res.finalBalance}`
|
|
523
524
|
].join("\n");
|