@sjtdev/koishi-plugin-dota2tracker 1.3.0-pre.2 → 1.3.0-pre.4

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.js CHANGED
@@ -564,7 +564,7 @@ var require_zh_CN_constants = __commonJS({
564
564
  // src/locales/en-US.command.yml
565
565
  var require_en_US_command = __commonJS({
566
566
  "src/locales/en-US.command.yml"(exports2, module2) {
567
- module2.exports = { commands: { subscribe: { description: "After subscribing, players need to bind their Steam ID to this group.", usage: "After subscribing, players need to bind their Steam ID to this group. BOT will subscribe to the new game data of bound players in this group. After the STRATZ game analysis is completed, the game data will be generated into a picture battle report and published to this group.", messages: { subscribe_success: "Subscription successful.", subscribed: "This Channel has been subscribed, no need to subscribe again." } }, unsubscribe: { description: "Unsubscribe from this group.", messages: { unsubscribe_success: "Unsubscription successful.", not_subscribed: "This Channel has not been subscribed yet, so there is no need to unsubscribe." } } } };
567
+ module2.exports = { commands: { dota2tracker: { subscribe: { description: "After subscribing, players need to bind their Steam ID to this group.", usage: "After subscribing, players need to bind their Steam ID to this group. BOT will subscribe to the new game data of bound players in this group. After the STRATZ game analysis is completed, the game data will be generated into a picture battle report and published to this group.", messages: { subscribe_success: "Subscription successful.", subscribed: "This Channel has been subscribed, no need to subscribe again." } }, unsubscribe: { description: "Unsubscribe from this group.", messages: { unsubscribe_success: "Unsubscription successful.", not_subscribed: "This Channel has not been subscribed yet, so there is no need to unsubscribe." } }, bind: { description: "Bind your SteamID and optionally set a nickname.", usage: "Bind your SteamID to your account. If the group is subscribed, your new match data will be posted in the group in real-time.", examples: 'bind 123456789\nbind 123456789 John\nbind 123456789 "John Doe"', messages: { steam_id_invalid: "Invalid SteamID.", bind_success: "Binding successful,\nID: {userId}\nNickname: {nickName}\nSteamID: {steamId}", bind_failed: "Binding failed, {0}", reason_without_match: "Invalid SteamID or no matches found.", reason_fetch_failed: "Poor network conditions or other reasons prevented the verification of the SteamID. Please try again later.", already_binded: "You are already bound, no need to bind again.\nHere is your personal information:\nID: {userId}\nNickname: {nickName}\nSteamID: {steamId}", nick_name_too_long: "Nickname is too long, please limit it to 20 characters or less. (It can also be left blank)" } }, unbind: { description: "Unbind your personal information.", messages: { unbind_success: "Unbinding successful.", not_binded: "Not bound, no need to unbind." } }, rename: { description: "Change the nickname set during binding.", examples: 'rename John\nrename "John Doe"', messages: { rename_success: "Rename successful, now you are called {nick_name}.", empty_input: "Please enter your nickname.", not_binded: "Please bind first, you can set a nickname during binding.", nick_name_too_long: "Nickname is too long, please limit it to 20 characters." } }, "query-members": { description: "Query the players bound in this group.", messages: { no_members: "No players bound in this group.", query_failed: "Failed to query group members." } }, "query-match": { description: "Query the match data of the specified match ID and generate a picture.", examples: "query-match 1234567890", messages: { empty_input: "Please enter the match ID.", match_id_invalid: "Invalid match ID.", querying_match: "Searching for match details, please wait...", query_failed: "Failed to get match data." } }, "query-recent-match": { description: "Query the most recent match data and generate a picture.", usage: "Query the most recent match data of the specified player and generate a picture.\nThe parameter can be the player's SteamID or the nickname of a player bound in this group. If no parameter is provided, it will try to query the SteamID of the command caller.", examples: "query-recent-match\nquery-recent-match 123456789\nquery-recent-match John", messages: { not_binded: "By default, it tries to find your information from the bound SteamID players, but it seems you are not bound.\nPlease bind your SteamID in this group. (You can enter [-bind -h] for help)\nOr follow the command with the SteamID or nickname of the player you want to query.", steam_id_invalid: "Invalid SteamID and the player was not found in this group.", querying_match: "Searching for match details, please wait...", query_failed: "Failed to get the player's recent match.", not_in_group: "Command failed.\nCurrently not in a group chat, you must provide the specified player's SteamID." } }, "query-player": { description: "Query the player's personal information, optionally specify a hero.", options: { hero: "Query the player's usage of the specified hero (same as querying a hero, can use nickname or ID)" }, usage: "Query the personal information of the specified player and generate a picture, optionally specify a hero.\nThe parameter can be the player's SteamID or the nickname of a player bound in this group. If no parameter is provided, it will try to query the SteamID of the command caller.", examples: "query-player 123456789\nquery-player John\nquery-player John --hero Anti-Mage\nquery-player John -o Anti-Mage", messages: { not_binded: "By default, it tries to find your information from the bound SteamID players, but it seems you are not bound.\nPlease bind your SteamID in this group. (You can enter [-bind -h] for help)\nOr follow the command with the SteamID or nickname of the player you want to query.", steam_id_invalid: "Invalid SteamID and the player was not found in this group.", querying_player: "Retrieving player data, please wait...", query_failed: "Failed to get player information.", not_in_group: "Command failed.\nCurrently not in a group chat, you must provide the specified player's SteamID." } }, "query-hero": { description: "Query hero skills/stats information.", options: { random: "Randomly select a hero." }, usage: "Query the hero's skill descriptions and various stats, generate a picture.\nThe parameter can be the hero's ID, name, or common nickname.", examples: "query-hero 15\nquery-hero Razor\nquery-hero -r", messages: { not_found: "Hero not found, please confirm and re-enter.", querying_hero: "Retrieving hero data, please wait...", query_failed: "Failed to get hero data.", empty_input: "Please enter a parameter." } } } } };
568
568
  }
569
569
  });
570
570
 
@@ -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: { dota2tracker: { 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 张三\n绑定 123456789 "张 三"', messages: { steam_id_invalid: "SteamID无效。", bind_success: "绑定成功,\nID:{userId}\n别名:{nickName}\nSteamID:{steamId}", bind_failed: "绑定失败,{0}", reason_without_match: "SteamID无效或无任何场次。", reason_fetch_failed: "网络状况不佳或其他原因无法验证SteamID,请稍后重试。", already_binded: "你已绑定,无需重复绑定。\n以下是你的个人信息:\nID:{userId}\n别名:{nickName}\nSteamID:{steamId}", nick_name_too_long: "别名过长,请限制在20个字符以内。(也可以留空)" } }, unbind: { description: "取消绑定你的个人信息", messages: { unbind_success: "取消绑定成功。", not_binded: "尚未绑定,无需取消绑定。" } }, rename: { description: "修改绑定时设定的别名", examples: '改名 李四\n改名 "李 四"', messages: { rename_success: "改名成功,现在你叫{nick_name}了。", empty_input: "请输入你的别名。", not_binded: "请先绑定,绑定时即可设定别名。", nick_name_too_long: "别名过长,请限制在20个字符以内。" } }, "query-members": { description: "查询本群已绑定的玩家", messages: { no_members: "本群尚无绑定玩家。", query_failed: "查询群友失败。" } }, "query-match": { description: "查询指定比赛ID的比赛数据,生成图片发布", examples: "查询比赛 1234567890", messages: { empty_input: "请输入比赛ID。", match_id_invalid: "比赛ID无效。", querying_match: "正在搜索对局详情,请稍后……", query_failed: "获取比赛数据失败。" } }, "query-recent-match": { description: "查询最近的比赛数据,生成图片发布", usage: "查询指定玩家的最近一场比赛的比赛数据,生成图片发布。\n参数可输入该玩家的SteamID或已在本群绑定玩家的别名,无参数时尝试查询调用指令玩家的SteamID", examples: "查询最近比赛\n查询最近比赛 123456789\n查询最近比赛 张三", messages: { not_binded: "无参数时默认从已绑定SteamID玩家中寻找你的信息,但你似乎并没有绑定。\n请在本群绑定SteamID。(可输入【-绑定 -h】获取帮助)\n或在指令后跟上希望查询的SteamID或已绑定玩家的别名。", steam_id_invalid: "SteamID无效并且未在本群找到此玩家。", querying_match: "正在搜索对局详情,请稍后……", query_failed: "获取玩家最近比赛失败。", not_in_group: "指令调用失败。\n当前不属于群聊状态,必须提供指定玩家的SteamID。" } }, "query-player": { description: "查询玩家的个人信息,可指定英雄", options: { hero: "查询玩家指定英雄使用情况(同查询英雄,可用别名或ID)" }, usage: "查询指定玩家的个人信息,生成图片发布,可指定英雄。\n参数可输入该玩家的SteamID或已在本群绑定玩家的别名,无参数时尝试查询调用指令玩家的SteamID", examples: "查询玩家 123456789\n查询玩家 张三\n查询玩家 张三 hero 敌法师", messages: { not_binded: "无参数时默认从已绑定SteamID玩家中寻找你的信息,但你似乎并没有绑定。\n请在本群绑定SteamID。(可输入【-绑定 -h】获取帮助)\n或在指令后跟上希望查询的SteamID或已绑定玩家的别名。", steam_id_invalid: "SteamID无效并且未在本群找到此玩家。", querying_player: "正在获取玩家数据,请稍后……", query_failed: "获取玩家信息失败。", not_in_group: "指令调用失败。\n当前不属于群聊状态,必须提供指定玩家的SteamID。" } }, "query-hero": { description: "查询英雄技能/面板信息", options: { random: "随机选择英雄" }, usage: "查询英雄的技能说明与各项数据,生成图片发布。\n参数可输入英雄ID、英雄名、英雄常用别名。", examples: "查询英雄 15\n查询英雄 雷泽\n查询英雄 电魂", messages: { not_found: "未找到输入的英雄,请确认后重新输入。", querying_hero: "正在获取英雄数据,请稍后……", query_failed: "获取英雄数据失败。", empty_input: "请输入参数。" } } } } };
589
589
  }
590
590
  });
591
591
 
@@ -1051,14 +1051,15 @@ 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
- else return { isValid: false, reason: "SteamID无效或无任何场次。" };
1058
+ if (queryRes.player.matchCount != null) return { isValid: true };
1059
+ else return { isValid: false, reason: ".reason_without_match" };
1059
1060
  } catch (error) {
1060
1061
  console.error(error);
1061
- return { isValid: false, reason: "网络状况不佳SteamID验证失败,请稍后重试。" };
1062
+ return { isValid: false, reason: ".reason_fetch_failed" };
1062
1063
  }
1063
1064
  }
1064
1065
  __name(playerisValid, "playerisValid");
@@ -1222,7 +1223,7 @@ async function apply(ctx, config) {
1222
1223
  const resolvedChannel = channel ?? (await ctx.database.get("channel", { id: session?.event.channel.id ?? channelId }))?.at(0);
1223
1224
  return ctx.i18n.fallback((resolvedChannel?.locales ?? []).concat(Object.values(ctx.i18n.locales).map((locale) => Object.keys(locale).at(0)))).find((locale) => Object.keys(GraphqlLanguageEnum).some((language) => locale == language));
1224
1225
  }, "getLanguageTag");
1225
- ctx.command("subscribe").alias("订阅本群").action(async ({ session }) => {
1226
+ ctx.command("dota2tracker.subscribe").alias("订阅本群").action(async ({ session }) => {
1226
1227
  if (session.guild) {
1227
1228
  let currentGuild = (await ctx.database.get("dt_subscribed_guilds", {
1228
1229
  guildId: session.event.channel.id,
@@ -1238,7 +1239,7 @@ async function apply(ctx, config) {
1238
1239
  }
1239
1240
  }
1240
1241
  });
1241
- ctx.command("unsubscribe").alias("取消订阅").action(async ({ session }) => {
1242
+ ctx.command("dota2tracker.unsubscribe").alias("取消订阅").action(async ({ session }) => {
1242
1243
  if (session.guild) {
1243
1244
  let cancelingGuild = (await ctx.database.get("dt_subscribed_guilds", {
1244
1245
  guildId: session.event.channel.id,
@@ -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("dota2tracker.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,42 +1267,29 @@ 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`, [session.text(verifyRes.reason)]));
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
  });
1304
- ctx.command("取消绑定", "取消绑定你的个人信息").action(async ({ session }) => {
1292
+ ctx.command("dota2tracker.unbind").alias("取消绑定").action(async ({ session }) => {
1305
1293
  if (session.guild) {
1306
1294
  let sessionPlayer = (await ctx.database.get("dt_subscribed_players", {
1307
1295
  guildId: session.event.channel.id,
@@ -1310,11 +1298,11 @@ async function apply(ctx, config) {
1310
1298
  }))[0];
1311
1299
  if (sessionPlayer) {
1312
1300
  await ctx.database.remove("dt_subscribed_players", sessionPlayer.id);
1313
- session.send("取消绑定成功。");
1314
- } else session.send("尚未绑定,无需取消绑定。");
1301
+ session.send(session.text(".unbind_success"));
1302
+ } else session.send(session.text(".not_binded"));
1315
1303
  }
1316
1304
  });
1317
- ctx.command("改名 <nick_name>", "修改绑定时设定的别名").example("改名 李四").action(async ({ session }, nick_name) => {
1305
+ ctx.command("dota2tracker.rename <nick_name>").alias("改名").action(async ({ session }, nick_name) => {
1318
1306
  if (session.guild) {
1319
1307
  let sessionPlayer = (await ctx.database.get("dt_subscribed_players", {
1320
1308
  guildId: session.event.channel.id,
@@ -1323,22 +1311,22 @@ async function apply(ctx, config) {
1323
1311
  }))[0];
1324
1312
  if (sessionPlayer) {
1325
1313
  if (!nick_name) {
1326
- session.send("请输入你的别名。");
1314
+ session.send(session.text(".emtpy_input"));
1327
1315
  return;
1328
1316
  }
1329
1317
  if (!/^.{1,20}$/.test(nick_name ?? "")) {
1330
- session.send("别名过长,请限制在20个字符以内。");
1318
+ session.send(session.text(".nick_name_too_long"));
1331
1319
  return;
1332
1320
  }
1333
1321
  sessionPlayer.nickName = nick_name;
1334
1322
  await ctx.database.set("dt_subscribed_players", sessionPlayer.id, { nickName: sessionPlayer.nickName });
1335
- session.send(`改名成功,现在你叫${nick_name}了。`);
1323
+ session.send(session.text(".rename_success", { nick_name }));
1336
1324
  } else {
1337
- session.send("请先绑定,绑定时即可设定别名。");
1325
+ session.send(session.text(".not_binded"));
1338
1326
  }
1339
1327
  }
1340
1328
  });
1341
- ctx.command("查询群友", "查询本群已绑定的玩家").action(async ({ session }) => {
1329
+ ctx.command("dota2tracker.query-members").alias("查询群友").action(async ({ session }) => {
1342
1330
  if (session.guild) {
1343
1331
  const languageTag = await getLanguageTag(session);
1344
1332
  const subscribedPlayers = await ctx.database.get("dt_subscribed_players", {
@@ -1346,7 +1334,7 @@ async function apply(ctx, config) {
1346
1334
  platform: session.platform
1347
1335
  });
1348
1336
  if (!subscribedPlayers.length) {
1349
- session.send("本群尚无绑定玩家。");
1337
+ session.send(session.text(".no_members"));
1350
1338
  return;
1351
1339
  }
1352
1340
  if (subscribedPlayers.length <= 20) {
@@ -1379,7 +1367,7 @@ async function apply(ctx, config) {
1379
1367
  session.send(await ctx.puppeteer.render(await genImageHTML(users, "guild_member" /* GuildMember */, "guild_member" /* GuildMember */, ctx, languageTag)));
1380
1368
  } catch (error) {
1381
1369
  ctx.logger.error(error);
1382
- session.send("查询群友失败。");
1370
+ session.send(session.text(".query_failed"));
1383
1371
  }
1384
1372
  }
1385
1373
  }
@@ -1456,16 +1444,16 @@ async function apply(ctx, config) {
1456
1444
  return await ctx.puppeteer.render(imageHTML);
1457
1445
  }
1458
1446
  __name(generateMatchImage, "generateMatchImage");
1459
- ctx.command("查询比赛 <match_id>", "查询比赛ID").alias("querymatch").usage("查询指定比赛ID的比赛数据,生成图片发布。").example("查询比赛 1234567890").action(async ({ session }, match_id) => {
1447
+ ctx.command("dota2tracker.query-match <match_id>").alias("查询比赛").action(async ({ session }, match_id) => {
1460
1448
  if (!match_id) {
1461
- session.send("请输入比赛ID。");
1449
+ session.send(session.text(".empty_input"));
1462
1450
  return;
1463
1451
  }
1464
1452
  if (!/^\d{1,11}$/.test(match_id)) {
1465
- session.send("比赛ID无效。");
1453
+ session.send(session.text(".match_id_invalid"));
1466
1454
  return;
1467
1455
  }
1468
- await session.send("正在搜索对局详情,请稍后...");
1456
+ await session.send(session.text(".querying_match"));
1469
1457
  try {
1470
1458
  const languageTag = await getLanguageTag(session);
1471
1459
  const matchQuery = await queryMatchData(Number(match_id));
@@ -1473,11 +1461,11 @@ async function apply(ctx, config) {
1473
1461
  const image = await generateMatchImage(match, languageTag);
1474
1462
  session.send((ctx.config.urlInMessageType.some((type) => type == "match") ? "https://stratz.com/matches/" + match.id : "") + image);
1475
1463
  } catch (error) {
1476
- session.send("获取比赛信息失败。");
1464
+ session.send(session.text(".query_failed"));
1477
1465
  ctx.logger.error(error);
1478
1466
  }
1479
1467
  });
1480
- ctx.command("查询最近比赛 [input_data]", "查询玩家的最近比赛").usage("查询指定玩家的最近一场比赛的比赛数据,生成图片发布。\n参数可输入该玩家的SteamID或已在本群绑定玩家的别名,无参数时尝试查询调用指令玩家的SteamID").example("查询最近比赛 123456789").example("查询最近比赛 张三").action(async ({ session }, input_data) => {
1468
+ ctx.command("dota2tracker.query-recent-match [input_data]").alias("查询最近比赛").action(async ({ session }, input_data) => {
1481
1469
  if (session.guild || !session.guild && input_data) {
1482
1470
  let sessionPlayer;
1483
1471
  if (!input_data) {
@@ -1487,7 +1475,7 @@ async function apply(ctx, config) {
1487
1475
  userId: session.event.user.id
1488
1476
  }))[0];
1489
1477
  if (!sessionPlayer) {
1490
- session.send("无参数时默认从已绑定SteamID玩家中寻找你的信息,但你似乎并没有绑定。\n请在本群绑定SteamID。(可输入【-绑定 -h】获取帮助)\n或在指令后跟上希望查询的SteamID或已绑定玩家的别名。");
1478
+ session.send(session.text(".not_binded"));
1491
1479
  return;
1492
1480
  }
1493
1481
  }
@@ -1497,17 +1485,17 @@ async function apply(ctx, config) {
1497
1485
  nickName: input_data
1498
1486
  }))[0];
1499
1487
  if (!(flagBindedPlayer || /^\d{1,11}$/.test(input_data))) {
1500
- session.send("SteamID不合法并且未在本群找到此玩家。");
1488
+ session.send(session.text(".steam_id_invalid"));
1501
1489
  return;
1502
1490
  }
1503
1491
  let lastMatchId = 0;
1504
1492
  try {
1505
- session.send("正在搜索对局详情,请稍后...");
1493
+ session.send(session.text(".querying_match"));
1506
1494
  lastMatchId = (await query("PlayersLastmatchRankinfo", {
1507
1495
  steamAccountIds: [parseInt(flagBindedPlayer?.steamId ?? input_data)]
1508
1496
  })).players[0].matches[0].id;
1509
1497
  } catch (error) {
1510
- session.send("获取玩家最近比赛失败。");
1498
+ session.send(session.text(".query_failed"));
1511
1499
  ctx.logger.error(error);
1512
1500
  return;
1513
1501
  }
@@ -1517,10 +1505,10 @@ async function apply(ctx, config) {
1517
1505
  const image = await generateMatchImage(match, languageTag);
1518
1506
  session.send((ctx.config.urlInMessageType.some((type) => type == "match") ? "https://stratz.com/matches/" + match.id : "") + image);
1519
1507
  } else {
1520
- session.send("<p>指令调用失败。</p><p>当前不属于群聊状态,必须提供指定玩家的SteamID。</p>");
1508
+ session.send(session.text(".not_in_group"));
1521
1509
  }
1522
1510
  });
1523
- ctx.command("查询玩家 <input_data>", "查询玩家信息,可指定英雄").usage("查询指定玩家的个人信息与最近战绩,生成图片发布。\n参数可输入该玩家的SteamID或已在本群绑定玩家的别名,无参数时尝试查询调用指令玩家的SteamID").option("hero", "-o <value:string> 查询玩家指定英雄使用情况(同其他英雄查询,可用简称与ID)").example("查询玩家 123456789").example("查询玩家 张三").example("查询玩家 张三 hero 敌法师").action(async ({ session, options }, input_data) => {
1511
+ ctx.command("dota2tracker.query-player <input_data>").option("hero", "-o <value:string>").alias("查询玩家").action(async ({ session, options }, input_data) => {
1524
1512
  if (session.guild || !session.guild && input_data) {
1525
1513
  let sessionPlayer;
1526
1514
  const languageTag = await getLanguageTag(session);
@@ -1531,7 +1519,7 @@ async function apply(ctx, config) {
1531
1519
  userId: session.event.user.id
1532
1520
  }))[0];
1533
1521
  if (!sessionPlayer) {
1534
- session.send("无参数时默认从已绑定SteamID玩家中寻找你的信息,但你似乎并没有绑定。\n请在本群绑定SteamID。(可输入【-绑定 -h】获取帮助)\n或在指令后跟上希望查询的SteamID或已绑定玩家的别名。");
1522
+ session.send(session.text(".not_binded"));
1535
1523
  return;
1536
1524
  }
1537
1525
  }
@@ -1541,10 +1529,10 @@ async function apply(ctx, config) {
1541
1529
  nickName: input_data
1542
1530
  }))[0];
1543
1531
  if (!(flagBindedPlayer || /^\d{1,11}$/.test(input_data))) {
1544
- session.send("SteamID不合法并且未在本群找到此玩家。");
1532
+ session.send(session.text(".steam_id_invalid"));
1545
1533
  return;
1546
1534
  }
1547
- session.send("正在获取玩家数据,请稍后...");
1535
+ session.send(session.text(".querying_player"));
1548
1536
  let heroId = findingHero(options.hero);
1549
1537
  let steamId = flagBindedPlayer?.steamId ?? input_data;
1550
1538
  let player;
@@ -1604,22 +1592,22 @@ async function apply(ctx, config) {
1604
1592
  );
1605
1593
  } catch (error) {
1606
1594
  ctx.logger.error(error);
1607
- session.send("获取玩家信息失败。");
1595
+ session.send(session.text(".query_failed"));
1608
1596
  }
1609
1597
  } else {
1610
- session.send("<p>指令调用失败。</p><p>当前不属于群聊状态,必须提供指定玩家的SteamID。</p>");
1598
+ session.send(session.text(".not_in_group"));
1611
1599
  }
1612
1600
  });
1613
- ctx.command("查询英雄 <input_data>", "查询英雄技能/面板信息").usage("查询英雄的技能说明与各项数据,生成图片发布。\n参数可输入英雄ID、英雄名、英雄常用别名").option("random", "-r 随机选择英雄").example("查询英雄 15").example("查询英雄 雷泽").example("查询英雄 电魂").action(async ({ session, options }, input_data) => {
1601
+ ctx.command("dota2tracker.query-hero <input_data>").option("random", "-r").alias("查询英雄").action(async ({ session, options }, input_data) => {
1614
1602
  const languageTag = await getLanguageTag(session);
1615
1603
  if (options.random) input_data = random.pick(Object.keys(dotaconstants2.heroes));
1616
1604
  if (input_data) {
1617
1605
  let heroId = findingHero(input_data);
1618
1606
  if (!heroId) {
1619
- session.send("未找到输入的英雄,请确认后重新输入。");
1607
+ session.send(session.text(".hero_not_found"));
1620
1608
  return;
1621
1609
  }
1622
- await session.send("正在获取英雄数据,请稍后...");
1610
+ await session.send(session.text(".querying_hero"));
1623
1611
  try {
1624
1612
  let hero = await queryHeroFromValve(heroId, languageTag);
1625
1613
  hero.facet_abilities.forEach((fa, i) => {
@@ -1712,10 +1700,10 @@ async function apply(ctx, config) {
1712
1700
  );
1713
1701
  } catch (error) {
1714
1702
  ctx.logger.error(error);
1715
- session.send("获取数据失败");
1703
+ session.send(session.text(".query_failed"));
1716
1704
  }
1717
1705
  } else {
1718
- session.send("请输入参数。");
1706
+ session.send(session.text(".empty_input"));
1719
1707
  }
1720
1708
  });
1721
1709
  function findingHero(input) {
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.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -473,7 +473,7 @@
473
473
  <span class="lose" style="${hero.matchCount - hero.winCount == 0 ? "visibility:hidden;" : ""}width: ${(hero.matchCount - hero.winCount) * pixelOfPerMatchInTotal}px">${hero.matchCount - hero.winCount}</span>`).join("") %>
474
474
  <%- !player.genHero ?
475
475
  `<p class="tip row near">${$t("dota2tracker.template.recently_heroes")}</p>`:
476
- `<p class="tip row total">${$t("dota2tracker.template.last25match_")}</p>`
476
+ `<p class="tip row total">${$t("dota2tracker.template.last25matches_")}</p>`
477
477
  %>
478
478
  <%- player.heroesPerformance
479
479
  .filter((hero) => hero.matchCount > 1)