@sjtdev/koishi-plugin-dota2tracker 1.3.0-pre.2 → 1.3.0-pre.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.
Files changed (2) hide show
  1. package/lib/index.js +11 -23
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -585,7 +585,7 @@ var require_en_US = __commonJS({
585
585
  // src/locales/zh-CN.command.yml
586
586
  var require_zh_CN_command = __commonJS({
587
587
  "src/locales/zh-CN.command.yml"(exports2, module2) {
588
- module2.exports = { commands: { subscribe: { description: "订阅后还需玩家在本群绑定SteamID", usage: "订阅后还需玩家在本群绑定SteamID,BOT将订阅本群中已绑定玩家的新比赛数据,在STRATZ比赛解析完成后将比赛数据生成为图片战报发布至本群中。", messages: { subscribed: "本群已订阅,无需重复订阅。", subscribe_success: "订阅成功。" } }, unsubscribe: { description: "取消订阅本群。", messages: { unsubscribe_success: "取消订阅成功。", not_subscribed: "本群尚未订阅,无需取消订阅。" } } } };
588
+ module2.exports = { commands: { subscribe: { description: "订阅后还需玩家在本群绑定SteamID", usage: "订阅后还需玩家在本群绑定SteamID,BOT将订阅本群中已绑定玩家的新比赛数据,在STRATZ比赛解析完成后将比赛数据生成为图片战报发布至本群中。", messages: { subscribed: "本群已订阅,无需重复订阅。", subscribe_success: "订阅成功。" } }, unsubscribe: { description: "取消订阅本群。", messages: { unsubscribe_success: "取消订阅成功。", not_subscribed: "本群尚未订阅,无需取消订阅。" } }, bind: { description: "绑定SteamID,并起一个别名(也可以不起)", usage: "将你的SteamID与你的账号绑定,若本群已订阅将会实时获取你的新比赛数据发布至群中。", examples: "绑定 123456789\n绑定 123456789 张三", messages: { steam_id_invalid: "SteamID无效。", bind_success: "绑定成功,\nID:{userId}\n别名:{nickName}\nSteamID:{steamId}", bind_failed: "绑定失败,{reason}", already_binded: "你已绑定,无需重复绑定。\n以下是你的个人信息:\nID:{userId}\n别名:{nickName}\nSteamID:{steamId}", nick_name_too_long: "别名过长,请限制在20个字符以内。(也可以留空)" } } } };
589
589
  }
590
590
  });
591
591
 
@@ -1051,10 +1051,11 @@ function winRateColor(value) {
1051
1051
  return `#${toHex(red)}${toHex(green)}${toHex(blue)}`;
1052
1052
  }
1053
1053
  __name(winRateColor, "winRateColor");
1054
- async function playerisValid(steamAccountId) {
1054
+ async function playerisValid(input) {
1055
1055
  try {
1056
+ const steamAccountId = parseInt(input);
1056
1057
  let queryRes = await query("VerifyingPlayer", { steamAccountId });
1057
- if (queryRes.data.player.matchCount != null) return { isValid: true };
1058
+ if (queryRes.player.matchCount != null) return { isValid: true };
1058
1059
  else return { isValid: false, reason: "SteamID无效或无任何场次。" };
1059
1060
  } catch (error) {
1060
1061
  console.error(error);
@@ -1254,10 +1255,10 @@ async function apply(ctx, config) {
1254
1255
  }
1255
1256
  } else session.send(session.text(".not_subscribed"));
1256
1257
  });
1257
- ctx.command("绑定 <steam_id> [nick_name]", "绑定SteamID,并起一个别名(也可以不起)").usage("将你的SteamID与你的账号绑定,若本群已订阅将会实时获取你的新比赛数据发布至群中。").example("绑定 123456789").example("绑定 123456789 张三").action(async ({ session }, steam_id, nick_name) => {
1258
+ ctx.command("bind <steam_id> [nick_name]").alias("绑定").action(async ({ session }, steam_id, nick_name) => {
1258
1259
  if (session.guild) {
1259
1260
  if (!steam_id || !/^\d{1,11}$/.test(steam_id)) {
1260
- session.send("SteamID无效。");
1261
+ session.send(session.text(".steam_id_invalid"));
1261
1262
  return;
1262
1263
  }
1263
1264
  let sessionPlayer = (await ctx.database.get("dt_subscribed_players", {
@@ -1266,38 +1267,25 @@ async function apply(ctx, config) {
1266
1267
  userId: session.event.user.id
1267
1268
  }))[0];
1268
1269
  if (sessionPlayer) {
1269
- session.send(
1270
- `
1271
- 你已绑定,无需重复绑定。
1272
- 以下是你的个人信息:
1273
- ID:${sessionPlayer.userId}
1274
- 别名:${sessionPlayer.nickName || ""}
1275
- SteamID:${sessionPlayer.steamId}`.replace(/\n\s+/g, " ")
1276
- );
1270
+ session.send(session.text(".already_binded", sessionPlayer));
1277
1271
  return;
1278
1272
  }
1279
1273
  let verifyRes = await playerisValid(steam_id);
1280
1274
  if (!verifyRes.isValid) {
1281
- session.send(`绑定失败,${verifyRes.reason}`);
1275
+ session.send(session.text(`.bind_failed`, verifyRes));
1282
1276
  return;
1283
1277
  }
1284
1278
  if (!/^(?:.{1,20})?$/.test(nick_name ?? "")) {
1285
- session.send("别名过长,请限制在20个字符以内。(也可以留空)");
1279
+ session.send(session.text(".nick_name_too_long"));
1286
1280
  return;
1287
1281
  }
1288
- session.send(
1289
- `
1290
- 绑定成功,
1291
- ID:${session.event.user.id}
1292
- 别名:${nick_name || ""}
1293
- SteamID:${steam_id}`.replace(/\n\s+/g, " ")
1294
- );
1282
+ session.send(session.text(".bind_success", { userId: session.event.user.id, nickName: nick_name || "", steamId: steam_id }));
1295
1283
  ctx.database.create("dt_subscribed_players", {
1296
1284
  userId: session.event.user.id,
1297
1285
  guildId: session.event.channel.id,
1298
1286
  platform: session.event.platform,
1299
1287
  steamId: parseInt(steam_id),
1300
- nickName: nick_name || null
1288
+ nickName: nick_name || ""
1301
1289
  });
1302
1290
  }
1303
1291
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjtdev/koishi-plugin-dota2tracker",
3
3
  "description": "koishi插件-追踪群友的DOTA2对局",
4
- "version": "1.3.0-pre.2",
4
+ "version": "1.3.0-pre.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [