koishi-plugin-eqserver-connect 0.0.2 → 0.0.3

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
@@ -11,6 +11,7 @@ export interface Config {
11
11
  minReward: number;
12
12
  maxReward: number;
13
13
  currencyField: string;
14
+ currencyName: string;
14
15
  }
15
16
  export declare const Config: Schema<Config>;
16
17
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -35,7 +35,8 @@ const Config = import_koishi.Schema.object({
35
35
  timezoneOffset: import_koishi.Schema.number().default(8).description("\u7B7E\u5230\u65F6\u533A\u504F\u79FB\uFF08\u5C0F\u65F6\uFF09\uFF0C\u9ED8\u8BA4 +8\u3002"),
36
36
  minReward: import_koishi.Schema.number().default(100).description("\u7B7E\u5230\u6700\u5C0F\u5956\u52B1\u3002"),
37
37
  maxReward: import_koishi.Schema.number().default(500).description("\u7B7E\u5230\u6700\u5927\u5956\u52B1\u3002"),
38
- currencyField: import_koishi.Schema.string().default("credits").description("\u7B7E\u5230\u5956\u52B1\u5199\u5165\u7684 store_players \u8D27\u5E01\u5B57\u6BB5\u3002")
38
+ currencyField: import_koishi.Schema.string().default("credits").description("\u7B7E\u5230\u5956\u52B1\u5199\u5165\u7684 store_players \u8D27\u5E01\u5B57\u6BB5\u3002"),
39
+ currencyName: import_koishi.Schema.string().default("\u6069\u60C5\u5E01").description("\u7B7E\u5230\u5956\u52B1\u663E\u793A\u7684\u8D27\u5E01\u540D\u79F0\u3002")
39
40
  });
40
41
  const HOUR_MS = 60 * 60 * 1e3;
41
42
  function getSignDay(now, timezoneOffset) {
@@ -82,6 +83,10 @@ function normalizeColumnName(columnName) {
82
83
  function quoteIdentifier(identifier) {
83
84
  return `"${identifier.replace(/"/g, '""')}"`;
84
85
  }
86
+ function normalizeCurrencyName(currencyName) {
87
+ const text = typeof currencyName === "string" ? currencyName.trim() : "";
88
+ return text || "\u6069\u60C5\u5E01";
89
+ }
85
90
  function isUniqueViolation(error) {
86
91
  if (!error || typeof error !== "object") return false;
87
92
  return error.code === "23505";
@@ -120,6 +125,7 @@ function apply(ctx, config) {
120
125
  const [minReward, maxReward] = getRewardRange(config.minReward, config.maxReward);
121
126
  const currencyField = normalizeColumnName(config.currencyField || "credits");
122
127
  const currencyFieldSql = quoteIdentifier(currencyField);
128
+ const currencyName = normalizeCurrencyName(config.currencyName);
123
129
  let initialized = false;
124
130
  let initializeTask = null;
125
131
  async function initDatabase() {
@@ -284,7 +290,7 @@ function apply(ctx, config) {
284
290
  );
285
291
  if (existed.rowCount) {
286
292
  await client.query("ROLLBACK");
287
- return `\u4ECA\u5929\u5DF2\u7ECF\u7B7E\u5230\u8FC7\u4E86\uFF0C\u4E0A\u6B21\u83B7\u5F97 ${existed.rows[0].reward} \u6069\u60C5\u5E01\u3002`;
293
+ return `\u4ECA\u5929\u5DF2\u7ECF\u7B7E\u5230\u8FC7\u4E86\uFF0C\u4E0A\u6B21\u83B7\u5F97 ${existed.rows[0].reward} ${currencyName}\u3002`;
288
294
  }
289
295
  await client.query(
290
296
  `
@@ -306,7 +312,7 @@ function apply(ctx, config) {
306
312
  throw new Error(`\u672A\u627E\u5230\u73A9\u5BB6 ID\uFF1A${String(bind.player_id)}`);
307
313
  }
308
314
  await client.query("COMMIT");
309
- return `\u7B7E\u5230\u6210\u529F\uFF0C\u83B7\u5F97 ${reward} \u6069\u60C5\u5E01\u3002\u5F53\u524D \u6069\u60C5\u5E01\uFF1A${String(creditResult.rows[0].credits)}`;
315
+ return `\u7B7E\u5230\u6210\u529F\uFF0C\u83B7\u5F97 ${reward} ${currencyName}\u3002\u5F53\u524D ${currencyName}\uFF1A${String(creditResult.rows[0].credits)}`;
310
316
  } catch (error) {
311
317
  await client.query("ROLLBACK").catch(() => null);
312
318
  if (isUniqueViolation(error)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-eqserver-connect",
3
3
  "description": "EQ server PostgreSQL connector with register + daily signin",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -15,6 +15,7 @@ The plugin expects an existing table:
15
15
  - `store_players(id, authid, credits, ...)`
16
16
 
17
17
  Set `currencyField` to use a different currency column, for example `shop_credits`.
18
+ Set `currencyName` to change the display name in sign-in messages, for example `商店积分`.
18
19
 
19
20
  It auto-creates:
20
21