koishi-plugin-msbao 0.0.13 → 0.0.15

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.
Files changed (2) hide show
  1. package/lib/index.js +4 -13
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -30,8 +30,6 @@ var import_tms = require("maplestory-openapi/tms");
30
30
  var import_url = require("url");
31
31
  var import_path = require("path");
32
32
  var import_fs = require("fs");
33
- var import_url2 = require("url");
34
- var import_meta = {};
35
33
  var Config = import_koishi.Schema.object({
36
34
  enabled: import_koishi.Schema.boolean().description("插件开关").default(true),
37
35
  whitelistMode: import_koishi.Schema.boolean().description("是否开启白名单模式(开启后仅白名单群生效)").default(true),
@@ -73,14 +71,7 @@ var name = "msbao";
73
71
  function apply(ctx, config) {
74
72
  if (!config.enabled) return;
75
73
  const isAdmin = /* @__PURE__ */ __name((session) => config.admins.includes(session.userId), "isAdmin");
76
- let __dirname;
77
- if (import_meta.url) {
78
- const __filename = (0, import_url2.fileURLToPath)(import_meta.url);
79
- __dirname = (0, import_path.dirname)(__filename);
80
- } else {
81
- __dirname = process.cwd();
82
- }
83
- const dataFile = config.ms.dataPath && config.ms.dataPath.trim() !== "" ? (0, import_path.resolve)(config.ms.dataPath) : (0, import_path.resolve)(__dirname, "../../../data/bindings.json");
74
+ const dataFile = config.ms.dataPath && config.ms.dataPath.trim() !== "" ? (0, import_path.resolve)(config.ms.dataPath, "bindings.json") : (0, import_path.resolve)(process.cwd(), "data", "msbao", "bindings.json");
84
75
  const dataDir = (0, import_path.dirname)(dataFile);
85
76
  if (!(0, import_fs.existsSync)(dataDir)) {
86
77
  (0, import_fs.mkdirSync)(dataDir, { recursive: true });
@@ -190,7 +181,7 @@ https://maplescouter.com/info?name=${encoded}`;
190
181
  if (err.constructor.name === "MapleStoryApiError") {
191
182
  return `查询失败,请检查角色名(仅限TMS)`;
192
183
  }
193
- return "查询失败,请稍后再试或联系开发者(布丁@2482457432 )";
184
+ return `查询失败,请稍后再试或联系开发者(布丁@2482457432 )`;
194
185
  }
195
186
  });
196
187
  ctx.command("%绑定 <gameId:string>", "绑定QQ号与角色名").alias("%綁定").action(async ({ session }, gameId) => {
@@ -310,7 +301,7 @@ https://maplescouter.com/info?name=${encoded}`;
310
301
  (如若升级则不计算日均增长,可能出现预计数据报错)
311
302
  (当日数据可能不准确,下午6点完成更新)`;
312
303
  const candidates = config.ms.images?.map((s) => s.trim()).filter(Boolean) || [];
313
- const existFiles = candidates.map((f) => (0, import_path.resolve)(__dirname, f)).filter((f) => (0, import_fs.existsSync)(f));
304
+ const existFiles = candidates.map((f) => (0, import_path.resolve)(process.cwd(), f)).filter((f) => (0, import_fs.existsSync)(f));
314
305
  if (existFiles.length) {
315
306
  const picked = existFiles[Math.floor(Math.random() * existFiles.length)];
316
307
  return [
@@ -398,7 +389,7 @@ https://maplescouter.com/info?name=${encoded}`;
398
389
  (如若升级则不计算日均增长,可能出现预计数据报错)
399
390
  (当日数据可能不准确,下午6点完成更新)`;
400
391
  const candidates = config.ms.images?.map((s) => s.trim()).filter(Boolean) || [];
401
- const existFiles = candidates.map((f) => (0, import_path.resolve)(__dirname, f)).filter((f) => (0, import_fs.existsSync)(f));
392
+ const existFiles = candidates.map((f) => (0, import_path.resolve)(process.cwd(), f)).filter((f) => (0, import_fs.existsSync)(f));
402
393
  if (existFiles.length) {
403
394
  const picked = existFiles[Math.floor(Math.random() * existFiles.length)];
404
395
  return [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-msbao",
3
3
  "description": "Pudding's plugin",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "contributors": [
6
6
  "MilkteaDoll <https://github.com/MilkteaDoll>"
7
7
  ],