@sjtdev/koishi-plugin-dota2tracker 2.3.0 → 2.3.1

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/changelog.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # 更新日志
2
2
 
3
+ ### [2.3.1](https://github.com/sjtdev/koishi-plugin-dota2tracker/compare/v2.3.0...v2.3.1) (2025-12-17)
4
+
5
+ ### 🐛 Bug 修复
6
+
7
+ * 修复依赖`dotaconstants`的新版本在部分环境中无法引用导致插件启用失败的问题。 ([045cd0c](https://github.com/sjtdev/koishi-plugin-dota2tracker/commit/045cd0c8a66dda2bf084a3b5d6470250a372a366))
8
+
3
9
  ## [2.3.0](https://github.com/sjtdev/koishi-plugin-dota2tracker/compare/v2.2.3...v2.3.0) (2025-12-17)
4
10
 
5
11
  ### ✨ 新增功能
package/lib/index.js CHANGED
@@ -835,7 +835,6 @@ var import_path5 = __toESM(require("path"));
835
835
 
836
836
  // src/app/common/i18n.ts
837
837
  var import_koishi = require("koishi");
838
- var dotaconstants = __toESM(require("dotaconstants"));
839
838
 
840
839
  // src/app/common/utils.ts
841
840
  var import_luxon = require("luxon");
@@ -927,14 +926,9 @@ var LanguageTags = {
927
926
  "zh-CN": { graphqlTag: "S_CHINESE", valveTag: "schinese" }
928
927
  };
929
928
  var I18NService = class extends import_koishi.Service {
930
- static {
931
- __name(this, "I18NService");
932
- }
933
- constantLocales = {};
934
- i18n;
935
- globalLanguageTag;
936
- constructor(ctx) {
929
+ constructor(ctx, dotaconstants) {
937
930
  super(ctx, "dota2tracker.i18n", true);
931
+ this.dotaconstants = dotaconstants;
938
932
  this.config = ctx.config;
939
933
  this.i18n = this.ctx.i18n;
940
934
  for (const supportLanguageTag of Object.keys(LanguageTags)) {
@@ -945,6 +939,12 @@ var I18NService = class extends import_koishi.Service {
945
939
  }
946
940
  this.globalLanguageTag = this.i18n.fallback(Object.values(this.i18n.locales).map((locale) => Object.keys(locale).at(0))).find((locale) => Object.keys(LanguageTags).includes(locale));
947
941
  }
942
+ static {
943
+ __name(this, "I18NService");
944
+ }
945
+ constantLocales = {};
946
+ i18n;
947
+ globalLanguageTag;
948
948
  getGraphqlLanguageTag(languageTag) {
949
949
  return LanguageTags[languageTag].graphqlTag;
950
950
  }
@@ -1050,7 +1050,7 @@ var I18NService = class extends import_koishi.Service {
1050
1050
  */
1051
1051
  _buildNicknameMap(languageTag) {
1052
1052
  this.logger.debug(`Building nickname map for ${languageTag}...`);
1053
- const heroIds = Object.keys(dotaconstants.heroes).map(Number);
1053
+ const heroIds = Object.keys(this.dotaconstants.heroes).map(Number);
1054
1054
  const nicknameMap = /* @__PURE__ */ new Map();
1055
1055
  for (const heroId of heroIds) {
1056
1056
  const allNames = this._getAllHeroNames(heroId, languageTag);
@@ -1065,7 +1065,7 @@ var I18NService = class extends import_koishi.Service {
1065
1065
  const inputStr = String(input).toLowerCase();
1066
1066
  if (/^\d+$/.test(inputStr)) {
1067
1067
  const heroId = Number(inputStr);
1068
- if (dotaconstants.heroes[heroId]) {
1068
+ if (this.dotaconstants.heroes[heroId]) {
1069
1069
  return heroId;
1070
1070
  }
1071
1071
  }
@@ -1091,7 +1091,6 @@ var I18NService = class extends import_koishi.Service {
1091
1091
 
1092
1092
  // src/app/core/hero.service.ts
1093
1093
  var import_koishi2 = require("koishi");
1094
- var dotaconstants2 = __toESM(require("dotaconstants"));
1095
1094
  var import_luxon2 = require("luxon");
1096
1095
 
1097
1096
  // src/app/common/constants.ts
@@ -1100,12 +1099,13 @@ var RANK_BRACKETS = ["UNCALIBRATED", "HERALD", "GUARDIAN", "CRUSADER", "ARCHON",
1100
1099
 
1101
1100
  // src/app/core/hero.service.ts
1102
1101
  var HeroService = class _HeroService extends import_koishi2.Service {
1102
+ constructor(ctx, dotaconstants) {
1103
+ super(ctx, "dota2tracker.hero", true);
1104
+ this.dotaconstants = dotaconstants;
1105
+ }
1103
1106
  static {
1104
1107
  __name(this, "HeroService");
1105
1108
  }
1106
- constructor(ctx) {
1107
- super(ctx, "dota2tracker.hero", true);
1108
- }
1109
1109
  async getWeeklyHeroMeta(rank) {
1110
1110
  const MINIMUM_PICK_RATE = 0.02;
1111
1111
  const RECOMMENDATION_COUNT = 3;
@@ -1140,7 +1140,7 @@ var HeroService = class _HeroService extends import_koishi2.Service {
1140
1140
  return weeklyHeroMeta;
1141
1141
  }
1142
1142
  async getHeroDetails(input, languageTag, isRandom = false) {
1143
- const heroId = this.ctx.dota2tracker.i18n.findHeroIdInLocale(isRandom ? import_koishi2.Random.pick(Object.keys(dotaconstants2.heroes)) : input);
1143
+ const heroId = this.ctx.dota2tracker.i18n.findHeroIdInLocale(isRandom ? import_koishi2.Random.pick(Object.keys(this.dotaconstants.heroes)) : input);
1144
1144
  if (!heroId) return;
1145
1145
  return _HeroService.formatHeroDetails(await this.ctx.dota2tracker.valveAPI.queryHeroDetailsFromValve(heroId, languageTag));
1146
1146
  }
@@ -1300,7 +1300,7 @@ var ItemService = class _ItemService extends import_koishi3.Service {
1300
1300
  }
1301
1301
  static getFormattedItemListData(rawItems) {
1302
1302
  const processItemName = /* @__PURE__ */ __name((name2) => name2.replace(/^item_/i, "").replace(/^recipe_/i, "recipe_"), "processItemName");
1303
- const [recipes, items3] = rawItems.reduce(
1303
+ const [recipes, items] = rawItems.reduce(
1304
1304
  (acc, item) => {
1305
1305
  const processed = {
1306
1306
  ...item,
@@ -1314,14 +1314,14 @@ var ItemService = class _ItemService extends import_koishi3.Service {
1314
1314
  [[], []]
1315
1315
  );
1316
1316
  const itemMap = /* @__PURE__ */ new Map();
1317
- items3.concat(recipes).forEach(
1317
+ items.concat(recipes).forEach(
1318
1318
  (item) => itemMap.set(item.id, {
1319
1319
  id: item.id,
1320
1320
  name: item.name,
1321
1321
  name_loc: item.name_loc
1322
1322
  })
1323
1323
  );
1324
- const processedItems = items3.map((baseItem) => {
1324
+ const processedItems = items.map((baseItem) => {
1325
1325
  const recipe = recipes.find((r) => r.name === `recipe_${baseItem.name.replace("item_", "")}`);
1326
1326
  return {
1327
1327
  ...baseItem,
@@ -1354,19 +1354,19 @@ var ItemService = class _ItemService extends import_koishi3.Service {
1354
1354
  }))
1355
1355
  }));
1356
1356
  }
1357
- searchItems(items3, keyword, languageTag, config) {
1357
+ searchItems(items, keyword, languageTag, config) {
1358
1358
  if (!keyword) return [];
1359
1359
  const alias = this.ctx.dota2tracker.i18n.getConstantLocale(languageTag).dota2tracker.items_alias?.[keyword] ?? config.customItemAlias.filter((cia) => cia.alias == keyword).map((cia) => cia.keyword);
1360
- const exactMatch = items3.filter(
1360
+ const exactMatch = items.filter(
1361
1361
  (item) => alias?.some((a) => item.name_loc.trim().toLowerCase() == a.toLowerCase()) || item.name_loc.trim().toLowerCase() === keyword.trim().toLowerCase() || Number.isInteger(Number(keyword)) && item.id === Number(keyword)
1362
1362
  );
1363
1363
  if (exactMatch.length) return exactMatch;
1364
- return this.fuzzySearchItems(alias.length ? alias : [keyword], items3);
1364
+ return this.fuzzySearchItems(alias.length ? alias : [keyword], items);
1365
1365
  }
1366
- fuzzySearchItems(keywords, items3) {
1366
+ fuzzySearchItems(keywords, items) {
1367
1367
  const resultMap = /* @__PURE__ */ new Map();
1368
1368
  if (!keywords.length) return [];
1369
- for (const item of items3) {
1369
+ for (const item of items) {
1370
1370
  const cleanName = item.name_loc.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "").trim();
1371
1371
  let matchAllKeywords = true;
1372
1372
  for (const keyword of keywords) {
@@ -1393,7 +1393,6 @@ var ItemService = class _ItemService extends import_koishi3.Service {
1393
1393
 
1394
1394
  // src/app/core/match.service.ts
1395
1395
  var import_koishi4 = require("koishi");
1396
- var dotaconstants3 = __toESM(require("dotaconstants"));
1397
1396
 
1398
1397
  // src/app/common/error.ts
1399
1398
  var import_util = require("util");
@@ -1522,9 +1521,10 @@ __name(handleError, "handleError");
1522
1521
 
1523
1522
  // src/app/core/match.service.ts
1524
1523
  var MatchService = class _MatchService extends import_koishi4.Service {
1525
- constructor(ctx, pluginVersion) {
1524
+ constructor(ctx, pluginVersion, dotaconstants) {
1526
1525
  super(ctx, "dota2tracker.match", true);
1527
1526
  this.pluginVersion = pluginVersion;
1527
+ this.dotaconstants = dotaconstants;
1528
1528
  }
1529
1529
  static {
1530
1530
  __name(this, "MatchService");
@@ -1629,7 +1629,7 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1629
1629
  }
1630
1630
  const facetData = await _MatchService.constantsInjectFacetData(constantsQuery, matchQuery, languageTag, this.ctx.dota2tracker.hero);
1631
1631
  this.ctx.dota2tracker.cache.setFacetConstantsCache(languageTag, constantsQuery);
1632
- const match = _MatchService.extendMatchData(matchQuery, facetData);
1632
+ const match = _MatchService.extendMatchData(matchQuery, facetData, this.dotaconstants);
1633
1633
  return match;
1634
1634
  } catch (error) {
1635
1635
  this.ctx.dota2tracker.cache.deleteFacetConstantsCache(languageTag);
@@ -1654,7 +1654,7 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1654
1654
  return facetData;
1655
1655
  }
1656
1656
  // 对比赛数据进行补充以供生成模板函数使用
1657
- static extendMatchData(matchQuery, facetData) {
1657
+ static extendMatchData(matchQuery, facetData, dotaconstants) {
1658
1658
  const match = matchQuery.match;
1659
1659
  const matchParsed = _MatchService.isMatchParsed(matchQuery);
1660
1660
  ["radiant", "dire"].forEach((team) => {
@@ -1774,9 +1774,9 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1774
1774
  }
1775
1775
  purchaseTimesMap[item.itemId].push(item.time);
1776
1776
  } else {
1777
- const itemName = dotaconstants3.item_ids[item.itemId];
1777
+ const itemName = dotaconstants.item_ids[item.itemId];
1778
1778
  if (itemName) {
1779
- const itemDetails = dotaconstants3.items[itemName];
1779
+ const itemDetails = dotaconstants.items[itemName];
1780
1780
  if (itemDetails && itemDetails.cost) {
1781
1781
  player.utilityScore += itemDetails.cost;
1782
1782
  }
@@ -1789,7 +1789,7 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1789
1789
  for (let itemId in supportItemsCount) {
1790
1790
  if (supportItemsCount[itemId] === 0) continue;
1791
1791
  player.supportItemsCount.push({
1792
- name: dotaconstants3.item_ids[itemId],
1792
+ name: dotaconstants.item_ids[itemId],
1793
1793
  count: supportItemsCount[itemId]
1794
1794
  });
1795
1795
  }
@@ -1797,13 +1797,13 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1797
1797
  player.items = [];
1798
1798
  for (let i = 0; i <= 5; i++) {
1799
1799
  const itemId = player[`item${i}Id`];
1800
- const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices);
1800
+ const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices, dotaconstants);
1801
1801
  player.items.push(itemObject);
1802
1802
  }
1803
1803
  player.backpacks = [];
1804
1804
  for (let i = 0; i <= 2; i++) {
1805
1805
  const itemId = player[`backpack${i}Id`];
1806
- const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices);
1806
+ const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices, dotaconstants);
1807
1807
  player.backpacks.push(itemObject);
1808
1808
  }
1809
1809
  if (player.additionalUnit) {
@@ -1811,12 +1811,12 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1811
1811
  player.unitBackpacks = [];
1812
1812
  for (let i = 0; i <= 5; i++) {
1813
1813
  const itemId = player.additionalUnit[`item${i}Id`];
1814
- const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices);
1814
+ const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices, dotaconstants);
1815
1815
  player.unitItems.push(itemObject);
1816
1816
  }
1817
1817
  for (let i = 0; i <= 2; i++) {
1818
1818
  const itemId = player.additionalUnit[`backpack${i}Id`];
1819
- const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices);
1819
+ const itemObject = createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices, dotaconstants);
1820
1820
  player.unitBackpacks.push(itemObject);
1821
1821
  }
1822
1822
  }
@@ -1895,15 +1895,15 @@ var MatchService = class _MatchService extends import_koishi4.Service {
1895
1895
  return matchQuery?.match?.parsedDateTime && matchQuery?.match?.players.filter((player) => player?.stats?.heroDamageReport?.dealtTotal).length > 0;
1896
1896
  }
1897
1897
  };
1898
- function createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices) {
1898
+ function createItemObject(itemId, purchaseTimesMap, purchaseTimeIndices, dotaconstants) {
1899
1899
  if (itemId === void 0 || itemId === null) {
1900
1900
  return null;
1901
1901
  }
1902
- if (dotaconstants3.item_ids[itemId]) {
1902
+ if (dotaconstants.item_ids[itemId]) {
1903
1903
  const currentIndex = purchaseTimeIndices.get(itemId) || 0;
1904
1904
  const seconds = purchaseTimesMap[itemId]?.[currentIndex];
1905
1905
  purchaseTimeIndices.set(itemId, currentIndex + 1);
1906
- const name2 = dotaconstants3.item_ids[itemId];
1906
+ const name2 = dotaconstants.item_ids[itemId];
1907
1907
  const prefix = "recipe_";
1908
1908
  const isRecipe = name2.startsWith(prefix);
1909
1909
  const cleanName = isRecipe ? name2.substring(prefix.length) : name2;
@@ -1921,16 +1921,16 @@ __name(createItemObject, "createItemObject");
1921
1921
 
1922
1922
  // src/app/core/player.service.ts
1923
1923
  var import_koishi5 = require("koishi");
1924
- var dotaconstants4 = __toESM(require("dotaconstants"));
1925
1924
  var import_luxon3 = require("luxon");
1926
1925
  var PlayerService = class _PlayerService extends import_koishi5.Service {
1927
- static {
1928
- __name(this, "PlayerService");
1929
- }
1930
- constructor(ctx) {
1926
+ constructor(ctx, dotaconstants) {
1931
1927
  super(ctx, "dota2tracker.player", true);
1928
+ this.dotaconstants = dotaconstants;
1932
1929
  this.config = ctx.config;
1933
1930
  }
1931
+ static {
1932
+ __name(this, "PlayerService");
1933
+ }
1934
1934
  async getHeroRecommendation(steamId, player) {
1935
1935
  const RECENT_IMP_WEIGHT = 0.1;
1936
1936
  const LIFETIME_WIN_LOG_WEIGHT = 5;
@@ -2051,12 +2051,15 @@ var PlayerService = class _PlayerService extends import_koishi5.Service {
2051
2051
  dotaPlus: null
2052
2052
  }
2053
2053
  };
2054
- const player = _PlayerService.extendPlayerData({
2055
- playerQuery,
2056
- playerExtraQuery,
2057
- genHero: heroId ? { heroId, name: this.ctx.dota2tracker.i18n.getConstantLocale(languageTag).dota2tracker.template.hero_names[heroId] } : null,
2058
- estimateRank: this.config.playerRankEstimate
2059
- });
2054
+ const player = _PlayerService.extendPlayerData(
2055
+ {
2056
+ playerQuery,
2057
+ playerExtraQuery,
2058
+ genHero: heroId ? { heroId, name: this.ctx.dota2tracker.i18n.getConstantLocale(languageTag).dota2tracker.template.hero_names[heroId] } : null,
2059
+ estimateRank: this.config.playerRankEstimate
2060
+ },
2061
+ this.dotaconstants
2062
+ );
2060
2063
  return player;
2061
2064
  }
2062
2065
  async validateSteamId(steamId) {
@@ -2078,14 +2081,14 @@ var PlayerService = class _PlayerService extends import_koishi5.Service {
2078
2081
  };
2079
2082
  }
2080
2083
  }
2081
- static extendPlayerData(param) {
2084
+ static extendPlayerData(param, dotaconstants) {
2082
2085
  const { playerQuery, playerExtraQuery, genHero, estimateRank } = param;
2083
2086
  const player = playerQuery.player;
2084
2087
  const playerExtra = playerExtraQuery?.player;
2085
2088
  if (player.steamAccount.isAnonymous) {
2086
2089
  for (let index = 0; index < 25; index++) {
2087
2090
  const random = new import_koishi5.Random(() => enhancedSimpleHashToSeed(`${player.steamAccount.id}-${index}`));
2088
- const heroId = random.pick(Object.keys(dotaconstants4.heroes));
2091
+ const heroId = random.pick(Object.keys(dotaconstants.heroes));
2089
2092
  player.matches.push({
2090
2093
  id: 1e9 + index,
2091
2094
  gameMode: "UNKNOWN",
@@ -2102,7 +2105,7 @@ var PlayerService = class _PlayerService extends import_koishi5.Service {
2102
2105
  kills: random.int(0, 20),
2103
2106
  deaths: random.int(0, 20),
2104
2107
  assists: random.int(0, 20),
2105
- hero: { id: heroId, shortName: dotaconstants4.heroes[heroId].name.match(/^npc_dota_hero_(.+)$/)[1] }
2108
+ hero: { id: heroId, shortName: dotaconstants.heroes[heroId].name.match(/^npc_dota_hero_(.+)$/)[1] }
2106
2109
  }
2107
2110
  ]
2108
2111
  });
@@ -2646,7 +2649,6 @@ var import_koishi10 = require("koishi");
2646
2649
  var import_ejs = __toESM(require("ejs"));
2647
2650
  var import_fs2 = __toESM(require("fs"));
2648
2651
  var import_path2 = __toESM(require("path"));
2649
- var dotaconstants5 = __toESM(require("dotaconstants"));
2650
2652
 
2651
2653
  // src/app/common/types.ts
2652
2654
  var ImageType = /* @__PURE__ */ ((ImageType2) => {
@@ -2669,15 +2671,16 @@ var ImageFormat = /* @__PURE__ */ ((ImageFormat2) => {
2669
2671
  // src/app/presentation/image.renderer.ts
2670
2672
  var import_luxon5 = require("luxon");
2671
2673
  var ImageRenderer = class extends import_koishi10.Service {
2672
- static {
2673
- __name(this, "ImageRenderer");
2674
- }
2675
- templateDir;
2676
- constructor(ctx, currentDir) {
2674
+ constructor(ctx, currentDir, dotaconstants) {
2677
2675
  super(ctx, "dota2tracker.image", true);
2676
+ this.dotaconstants = dotaconstants;
2678
2677
  this.config = ctx.config;
2679
2678
  this.templateDir = import_path2.default.join(currentDir, "templates");
2680
2679
  }
2680
+ static {
2681
+ __name(this, "ImageRenderer");
2682
+ }
2683
+ templateDir;
2681
2684
  async renderToImageByFile(data, templateName, type, languageTag) {
2682
2685
  const html = await this.generateHTML(data, { source: "FILE", templateName, type }, languageTag);
2683
2686
  return this.ctx.puppeteer.render(html);
@@ -2694,7 +2697,7 @@ var ImageRenderer = class extends import_koishi10.Service {
2694
2697
  data,
2695
2698
  ImageType,
2696
2699
  ImageFormat,
2697
- dotaconstants: dotaconstants5,
2700
+ dotaconstants: this.dotaconstants,
2698
2701
  DateTime: import_luxon5.DateTime,
2699
2702
  $t: /* @__PURE__ */ __name((key, params) => this.ctx.dota2tracker.i18n.$t(languageTag, key, params), "$t"),
2700
2703
  languageTag,
@@ -3769,14 +3772,14 @@ var OpenDotaAPI = class extends import_koishi15.Service {
3769
3772
 
3770
3773
  // src/app/core/opendota.adapter.ts
3771
3774
  var import_koishi16 = require("koishi");
3772
- var dotaconstants6 = __toESM(require("dotaconstants"));
3773
3775
  var OpenDotaAdapter = class extends import_koishi16.Service {
3776
+ constructor(ctx, dotaconstants) {
3777
+ super(ctx, "dota2tracker.opendota-adapter", true);
3778
+ this.dotaconstants = dotaconstants;
3779
+ }
3774
3780
  static {
3775
3781
  __name(this, "OpenDotaAdapter");
3776
3782
  }
3777
- constructor(ctx) {
3778
- super(ctx, "dota2tracker.opendota-adapter", true);
3779
- }
3780
3783
  transform(_match) {
3781
3784
  determinePlayerPositions(_match);
3782
3785
  const players = [];
@@ -3824,9 +3827,9 @@ var OpenDotaAdapter = class extends import_koishi16.Service {
3824
3827
  steamAccount: { name: _player.personaname, seasonRank: _player.rank_tier, seasonLeaderboardRank: null },
3825
3828
  hero: {
3826
3829
  id: _player.hero_id,
3827
- name: dotaconstants6.heroes[_player.hero_id].name,
3828
- shortName: dotaconstants6.heroes[_player.hero_id].name.match(/^npc_dota_hero_(.+)$/)[1],
3829
- facets: [...dotaconstants6.hero_abilities[dotaconstants6.heroes[_player.hero_id].name].facets.map((f) => ({ id: -1, name: f.name }))]
3830
+ name: this.dotaconstants.heroes[_player.hero_id].name,
3831
+ shortName: this.dotaconstants.heroes[_player.hero_id].name.match(/^npc_dota_hero_(.+)$/)[1],
3832
+ facets: [...this.dotaconstants.hero_abilities[this.dotaconstants.heroes[_player.hero_id].name].facets.map((f) => ({ id: -1, name: f.name }))]
3830
3833
  },
3831
3834
  dotaPlus: null,
3832
3835
  stats: {
@@ -3857,7 +3860,7 @@ var OpenDotaAdapter = class extends import_koishi16.Service {
3857
3860
  disableCount: 0
3858
3861
  }
3859
3862
  },
3860
- itemPurchases: _player.purchase_log.map((p) => ({ time: p.time, itemId: dotaconstants6.items[p.key].id }))
3863
+ itemPurchases: _player.purchase_log.map((p) => ({ time: p.time, itemId: this.dotaconstants.items[p.key].id }))
3861
3864
  },
3862
3865
  additionalUnit: null
3863
3866
  };
@@ -3886,8 +3889,8 @@ var OpenDotaAdapter = class extends import_koishi16.Service {
3886
3889
  const match = {
3887
3890
  id: _match.match_id,
3888
3891
  didRadiantWin: _match.radiant_win,
3889
- lobbyType: convertLobbyType(_match.lobby_type),
3890
- gameMode: convertGameMode(_match.game_mode),
3892
+ lobbyType: convertLobbyType(_match.lobby_type, this.dotaconstants),
3893
+ gameMode: convertGameMode(_match.game_mode, this.dotaconstants),
3891
3894
  regionId: _match.region,
3892
3895
  parsedDateTime: _match.start_time + _match.duration,
3893
3896
  startDateTime: _match.start_time,
@@ -3972,7 +3975,7 @@ function convertPosition(openDotaPosition) {
3972
3975
  }
3973
3976
  }
3974
3977
  __name(convertPosition, "convertPosition");
3975
- function convertLobbyType(openDotaLobbyType) {
3978
+ function convertLobbyType(openDotaLobbyType, dotaconstants) {
3976
3979
  const map = {
3977
3980
  lobby_type_normal: "UNRANKED" /* Unranked */,
3978
3981
  lobby_type_practice: "PRACTICE" /* Practice */,
@@ -3989,11 +3992,11 @@ function convertLobbyType(openDotaLobbyType) {
3989
3992
  lobby_type_new_player: "COOP_VS_BOTS" /* CoopVsBots */,
3990
3993
  lobby_type_featured: "EVENT" /* Event */
3991
3994
  };
3992
- return map[dotaconstants6.lobby_type[openDotaLobbyType].name] || "EVENT" /* Event */;
3995
+ return map[dotaconstants.lobby_type[openDotaLobbyType].name] || "EVENT" /* Event */;
3993
3996
  }
3994
3997
  __name(convertLobbyType, "convertLobbyType");
3995
- function convertGameMode(openDotaGameModeId) {
3996
- const gameModeName = dotaconstants6.game_mode[openDotaGameModeId]?.name;
3998
+ function convertGameMode(openDotaGameModeId, dotaconstants) {
3999
+ const gameModeName = dotaconstants.game_mode[openDotaGameModeId]?.name;
3997
4000
  switch (gameModeName) {
3998
4001
  case "game_mode_all_pick":
3999
4002
  return "ALL_PICK" /* AllPick */;
@@ -4319,15 +4322,17 @@ var inject = {
4319
4322
  optional: ["cron", "console"]
4320
4323
  };
4321
4324
  async function apply(ctx, config) {
4325
+ const lib = await import("dotaconstants");
4326
+ const dotaconstants = lib.default || lib;
4322
4327
  const logger = ctx.logger("dota2tracker");
4323
4328
  const currentDir = import_path5.default.resolve(__dirname);
4324
4329
  const pluginVersion = require(import_path5.default.join(currentDir, "..", "package.json")).version;
4325
4330
  ctx.dota2tracker = {};
4326
- ctx.dota2tracker.i18n = new I18NService(ctx);
4327
- ctx.dota2tracker.image = new ImageRenderer(ctx, currentDir);
4331
+ ctx.dota2tracker.i18n = new I18NService(ctx, dotaconstants);
4332
+ ctx.dota2tracker.image = new ImageRenderer(ctx, currentDir, dotaconstants);
4328
4333
  ctx.dota2tracker.messageBuilder = new MessageBuilder(ctx);
4329
- ctx.dota2tracker.match = new MatchService(ctx, pluginVersion);
4330
- ctx.dota2tracker.player = new PlayerService(ctx);
4334
+ ctx.dota2tracker.match = new MatchService(ctx, pluginVersion, dotaconstants);
4335
+ ctx.dota2tracker.player = new PlayerService(ctx, dotaconstants);
4331
4336
  if (ctx.cron) {
4332
4337
  ctx.dota2tracker.matchWatcher = new MatchWatcherTask(ctx);
4333
4338
  ctx.dota2tracker.parsePolling = new ParsePollingTask(ctx);
@@ -4339,7 +4344,7 @@ async function apply(ctx, config) {
4339
4344
  } else {
4340
4345
  logger.info(ctx.dota2tracker.i18n.gt("dota2tracker.logger.cron_not_enabled"));
4341
4346
  }
4342
- ctx.dota2tracker.hero = new HeroService(ctx);
4347
+ ctx.dota2tracker.hero = new HeroService(ctx, dotaconstants);
4343
4348
  ctx.dota2tracker.item = new ItemService(ctx);
4344
4349
  ctx.dota2tracker.cache = new CacheService(ctx);
4345
4350
  ctx.dota2tracker.database = new DatabaseService(ctx);
@@ -4347,7 +4352,7 @@ async function apply(ctx, config) {
4347
4352
  ctx.dota2tracker.stratzAPI = new StratzAPI(ctx, currentDir);
4348
4353
  if (config.enableOpenDotaFallback) {
4349
4354
  ctx.dota2tracker.opendotaAPI = new OpenDotaAPI(ctx);
4350
- ctx.dota2tracker.opendotaAdapter = new OpenDotaAdapter(ctx);
4355
+ ctx.dota2tracker.opendotaAdapter = new OpenDotaAdapter(ctx, dotaconstants);
4351
4356
  }
4352
4357
  ctx.dota2tracker = ctx.dota2tracker;
4353
4358
  usage = await ctx.dota2tracker.i18n.generateUsage();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjtdev/koishi-plugin-dota2tracker",
3
3
  "description": "koishi插件-追踪群友的DOTA2对局",
4
- "version": "2.3.0",
4
+ "version": "2.3.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [