@sjtdev/koishi-plugin-dota2tracker 1.3.0-pre.6 → 1.3.0
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 +208 -175
- package/package.json +1 -1
- package/readme.md +4 -1
- package/template/report/daily.ejs +7 -7
package/lib/index.js
CHANGED
|
@@ -35,11 +35,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
35
|
));
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
|
|
38
|
+
// src/locales/en-US.schema.yml
|
|
39
|
+
var require_en_US_schema = __commonJS({
|
|
40
|
+
"src/locales/en-US.schema.yml"(exports2, module2) {
|
|
41
|
+
module2.exports = { _config: { base: { $desc: "Basic Settings", STRATZ_API_TOKEN: "Required. API TOKEN from stratz.com, available at https://stratz.com/api.", dataParsingTimeoutMinutes: "Time to wait for match data parsing (in minutes). If the data parsing time exceeds the waiting time, the report will be generated directly without waiting for the parsing to complete.", urlInMessageType: { $desc: "Include links in messages, <br/>please select the message type:", $inner: ["Include stratz match page link in match query and report messages", "Include stratz player page link in player information query messages", "Include Dota Encyclopedia hero page link in hero data query messages"] } }, rank: { rankBroadSwitch: "Rank change broadcast", rankBroadStar: "Star change broadcast", rankBroadLeader: "Leaderboard rank change broadcast", rankBroadFun: "Fun broadcast template" }, report: { $desc: "Summary Settings", dailyReportSwitch: "Daily Report Function", dailyReportHours: "Daily report time in hours", dailyReportShowCombi: "Show combinations in daily report", weeklyReportSwitch: "Weekly Report Function", weeklyReportDayHours: "Weekly report published on (day) at (hour)", weeklyReportShowCombi: "Show combinations in weekly report" }, template: { $desc: "Template Settings", template_match: "Template used to generate match information images, see https://github.com/sjtdev/koishi-plugin-dota2tracker/wiki for template display.", template_player: "Template used to generate player information images. (Currently only one template available)", template_hero: "Template used to generate hero information images. (Currently only one template available)" } } };
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// src/locales/zh-CN.schema.yml
|
|
46
|
+
var require_zh_CN_schema = __commonJS({
|
|
47
|
+
"src/locales/zh-CN.schema.yml"(exports2, module2) {
|
|
48
|
+
module2.exports = { _config: { base: { $desc: "基础设置", STRATZ_API_TOKEN: "※必须。stratz.com的API TOKEN,可在 https://stratz.com/api 获取。", dataParsingTimeoutMinutes: "等待比赛数据解析的时间(单位:分钟)。如果数据解析时间超过等待时间,将直接生成战报而不再等待解析完成。", urlInMessageType: { $desc: "在消息中附带链接,<br/>请选择消息类型:", $inner: ["在查询比赛与战报消息中附带stratz比赛页面链接", "在查询玩家信息消息中附带stratz玩家页面链接", "在查询英雄数据消息中附带刀塔百科对应英雄页面链接"] } }, rank: { rankBroadSwitch: "段位变动播报", rankBroadStar: "星级变动播报", rankBroadLeader: "冠绝名次变动播报", rankBroadFun: "整活播报模板" }, report: { $desc: "总结设置", dailyReportSwitch: "日报功能", dailyReportHours: "日报时间小时", dailyReportShowCombi: "日报是否显示组合", weeklyReportSwitch: "周报功能", weeklyReportDayHours: "周报发布于周(几)的(几)点", weeklyReportShowCombi: "周报是否显示组合" }, template: { $desc: "模板设置", template_match: "生成比赛信息图片使用的模板,见 https://github.com/sjtdev/koishi-plugin-dota2tracker/wiki 有模板展示。", template_player: "生成玩家信息图片使用的模板。(目前仅有一张模板)", template_hero: "生成英雄信息图片使用的模板。(目前仅有一张模板)" } } };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
38
52
|
// src/locales/en-US.constants.json
|
|
39
53
|
var require_en_US_constants = __commonJS({
|
|
40
54
|
"src/locales/en-US.constants.json"(exports2, module2) {
|
|
41
55
|
module2.exports = {
|
|
42
56
|
dota2tracker: {
|
|
57
|
+
usage: "DOTA2Bot plugin - provides the functionality to automatically track the latest matches of group members (requires group members to bind), as well as a series of query functions. \n[Localization/dota2tracker](../../locales/dota2tracker) allows customization of hero aliases and position nicknames, etc. \n**For more information, please visit the [plugin homepage](https://sjtdev.github.io/koishi-plugin-dota2tracker/) and [changelog](https://github.com/sjtdev/koishi-plugin-dota2tracker/blob/master/changelog.md).**",
|
|
43
58
|
template: {
|
|
44
59
|
game_modes: {
|
|
45
60
|
NONE: "None",
|
|
@@ -85,6 +100,7 @@ var require_en_US_constants = __commonJS({
|
|
|
85
100
|
NEW_PLAYER_POOL: "New Player Pool"
|
|
86
101
|
},
|
|
87
102
|
regions: {
|
|
103
|
+
"0": "Unknown",
|
|
88
104
|
"1": "US West",
|
|
89
105
|
"2": "US East",
|
|
90
106
|
"3": "Europe West",
|
|
@@ -303,9 +319,10 @@ var require_zh_CN_constants = __commonJS({
|
|
|
303
319
|
"src/locales/zh-CN.constants.json"(exports2, module2) {
|
|
304
320
|
module2.exports = {
|
|
305
321
|
dota2tracker: {
|
|
322
|
+
usage: "DOTA2Bot插件-提供自动追踪群友的最新对局的功能(需群友绑定),以及一系列查询功能。 \n[本地化/dota2tracker](../../locales/dota2tracker)可以自定义英雄别名和位置代称等文本内容 \n**更多信息请进入[插件主页](https://sjtdev.github.io/koishi-plugin-dota2tracker/)与[更新日志](https://github.com/sjtdev/koishi-plugin-dota2tracker/blob/master/changelog.md)查看。**",
|
|
306
323
|
template: {
|
|
307
324
|
game_modes: {
|
|
308
|
-
NONE: "",
|
|
325
|
+
NONE: "未知",
|
|
309
326
|
ALL_PICK: "全英雄选择",
|
|
310
327
|
CAPTAINS_MODE: "队长模式",
|
|
311
328
|
RANDOM_DRAFT: "随机征召",
|
|
@@ -348,6 +365,7 @@ var require_zh_CN_constants = __commonJS({
|
|
|
348
365
|
NEW_PLAYER_POOL: ""
|
|
349
366
|
},
|
|
350
367
|
regions: {
|
|
368
|
+
"0": "未知",
|
|
351
369
|
"1": "US WEST",
|
|
352
370
|
"2": "US EAST",
|
|
353
371
|
"3": "EUROPE",
|
|
@@ -571,7 +589,7 @@ var require_en_US_command = __commonJS({
|
|
|
571
589
|
// src/locales/en-US.template.yml
|
|
572
590
|
var require_en_US_template = __commonJS({
|
|
573
591
|
"src/locales/en-US.template.yml"(exports2, module2) {
|
|
574
|
-
module2.exports = { dota2tracker: { template: { radiant: "Radiant", dire: "Dire", won: "Won", lost: "Lost", match_id_: "Match ID: {0}", game_mode_: "Mode: {0}", start_time_: "Start Time: {0}", end_time_: "End Time: {0}", pick_order: "#{0}", random: "R", hero_damage_: "Damage: {0}", building_damage_: "Building: {0}", damage_received_: "Received: {0}", lasthit_: "LastHit: {0}", deny_: "Deny: {0}", "lh/dn_": "LH/DN: {0}", GPM: "GPM", XPM: "XPM", heal_: "Heal: {0}", crowd_control_duration_: "CCD: {0}", "GPM/XPM_": "GPM/XPM: {0}", lane: "Lane", lane_: "Lane: ", lane_advantage: "Lane +", lane_disadvantage: "Lane -", lane_jungle: "Jungle", lane_stomp: "Lane+++", lane_stomped: "Lane---", lane_tie: "Lane ==", analysis_successful: "Analysis successful", analysis_incomplete: "Analysis incomplete", kill: "Kill", kill_contribution_: "KC: {0}", position: "Position", position_: "Position: ", position_1: "Carry", position_2: "Mid", position_3: "OffLane", position_4: "Softsup", position_5: "Hardsup", dire_won: "Dire Won", radiant_won: "Radiant Won", total_damage: "Damage", total_experience: "Exp.", total_gold: "Gold", region_: "Region: {0}", duration_: "Duration: {0}", position_undefined: "?", top10_: "Top 10 Heroes by Matches: ", match_count_: "Matches: ", last25matches_: "Last 25 Matches: ", winrate_: "Winrate: ", imp_: "IMP: ", lane_advantage_rate_: "Lane Advantage Rate: ", hero: "Hero", all_matches_: "All Matches: ", match_count: "Matches", winrate: "Winrate", imp: "IMP", win_count: "Wins", lose_count: "Losses", recently_heroes: "Heroes used more than once recently: ", recently_positions: "Performance in the last 25 matches across all positions: ", winning_streak: "Winning Streak", losing_streak: "Losing Streak", id: "ID", mode: "Mode", kda_kc: "KDA(KC)", time: "Time", duration: "Duration", rank: "Rank", un_parsed: "(Unparsed)" } } };
|
|
592
|
+
module2.exports = { dota2tracker: { template: { radiant: "Radiant", dire: "Dire", won: "Won", lost: "Lost", match_id_: "Match ID: {0}", game_mode_: "Mode: {0}", start_time_: "Start Time: {0}", end_time_: "End Time: {0}", pick_order: "#{0}", random: "R", hero_damage_: "Damage: {0}", building_damage_: "Building: {0}", damage_received_: "Received: {0}", lasthit_: "LastHit: {0}", deny_: "Deny: {0}", "lh/dn_": "LH/DN: {0}", GPM: "GPM", XPM: "XPM", heal_: "Heal: {0}", crowd_control_duration_: "CCD: {0}", "GPM/XPM_": "GPM/XPM: {0}", lane: "Lane", lane_: "Lane: ", lane_advantage: "Lane +", lane_disadvantage: "Lane -", lane_jungle: "Jungle", lane_stomp: "Lane+++", lane_stomped: "Lane---", lane_tie: "Lane ==", analysis_successful: "Analysis successful", analysis_incomplete: "Analysis incomplete", kill: "Kill", kill_contribution_: "KC: {0}", position: "Position", position_: "Position: ", position_1: "Carry", position_2: "Mid", position_3: "OffLane", position_4: "Softsup", position_5: "Hardsup", dire_won: "Dire Won", radiant_won: "Radiant Won", total_damage: "Damage", total_experience: "Exp.", total_gold: "Gold", region_: "Region: {0}", duration_: "Duration: {0}", position_undefined: "?", top10_: "Top 10 Heroes by Matches: ", match_count_: "Matches: ", last25matches_: "Last 25 Matches: ", winrate_: "Winrate: ", imp_: "IMP: ", lane_advantage_rate_: "Lane Advantage Rate: ", hero: "Hero", all_matches_: "All Matches: ", match_count: "Matches", winrate: "Winrate", imp: "IMP", win_count: "Wins", lose_count: "Losses", recently_heroes: "Heroes used more than once recently: ", recently_positions: "Performance in the last 25 matches across all positions: ", winning_streak: "Winning Streak", losing_streak: "Losing Streak", id: "ID", mode: "Mode", kda_kc: "KDA(KC)", time: "Time", duration: "Duration", rank: "Rank", un_parsed: "(Unparsed)", combined_win_loss_summary: "Combined Win/Loss Summary: ", yesterdays_summary: "Yesterday's Summary", last_weeks_summary: "Last Week's Summary", report_won: "W", report_lost: "L", report_winrate: "WR" } } };
|
|
575
593
|
}
|
|
576
594
|
});
|
|
577
595
|
|
|
@@ -592,7 +610,7 @@ var require_zh_CN_command = __commonJS({
|
|
|
592
610
|
// src/locales/zh-CN.template.yml
|
|
593
611
|
var require_zh_CN_template = __commonJS({
|
|
594
612
|
"src/locales/zh-CN.template.yml"(exports2, module2) {
|
|
595
|
-
module2.exports = { dota2tracker: { template: { radiant: "天辉", dire: "夜魇", won: "获胜", lost: "失败", match_id_: "比赛编号:{0}", game_mode_: "模式:{0}", start_time_: "起始时间:{0}", end_time_: "结束时间:{0}", pick_order: "第{0}手", random: "随机", hero_damage_: "英雄伤害:{0}", building_damage_: "建筑伤害:{0}", damage_received_: "受到伤害:{0}", lasthit_: "补刀:{0}", deny_: "反补:{0}", "lh/dn_": "补刀:{0}/{1}", GPM: "GPM", XPM: "XPM", heal_: "治疗量:{0}", crowd_control_duration_: "控制时间:{0}", "GPM/XPM_": "GPM/XPM:{0}", lane: "对线", lane_: "对线:", lane_advantage: "对线优势", lane_disadvantage: "对线劣势", lane_stomp: "对线碾压", lane_stomped: "对线被碾", lane_tie: "对线平手", lane_jungle: "野区霸主", analysis_successful: "录像分析成功", analysis_incomplete: "分析结果不完整", kill: "击杀", kill_contribution_: "参战率:{0}", position: "位置", position_: "位置:", position_1: "优势路", position_2: "中路", position_3: "烈士路", position_4: "采灵芝", position_5: "工具人", position_undefined: "?", total_damage: "总伤害", total_gold: "总经济", total_experience: "总经验", radiant_won: "天辉获胜", dire_won: "夜魇获胜", duration_: "持续时间:{0}", region_: "地区:{0}", match_count_: "场次:", last25matches_: "最近25场:", winrate_: "胜率:", imp_: "表现:", lane_advantage_rate_: "线优率:", top10_: "全期场次前十的英雄:", hero: "英雄", all_matches_: "全期场次:", match_count: "场次", winrate: "胜率", imp: "表现", win_count: "胜场", lose_count: "败场", recently_heroes: "近期使用场次大于1的英雄:", recently_positions: "近25场各个位置的表现:", winning_streak: "连胜", losing_streak: "连败", id: "ID", mode: "模式", kda_kc: "KDA(参战率)", time: "时间", duration: "时长", rank: "段位", un_parsed: "(未解析)" } } };
|
|
613
|
+
module2.exports = { dota2tracker: { template: { radiant: "天辉", dire: "夜魇", won: "获胜", lost: "失败", match_id_: "比赛编号:{0}", game_mode_: "模式:{0}", start_time_: "起始时间:{0}", end_time_: "结束时间:{0}", pick_order: "第{0}手", random: "随机", hero_damage_: "英雄伤害:{0}", building_damage_: "建筑伤害:{0}", damage_received_: "受到伤害:{0}", lasthit_: "补刀:{0}", deny_: "反补:{0}", "lh/dn_": "补刀:{0}/{1}", GPM: "GPM", XPM: "XPM", heal_: "治疗量:{0}", crowd_control_duration_: "控制时间:{0}", "GPM/XPM_": "GPM/XPM:{0}", lane: "对线", lane_: "对线:", lane_advantage: "对线优势", lane_disadvantage: "对线劣势", lane_stomp: "对线碾压", lane_stomped: "对线被碾", lane_tie: "对线平手", lane_jungle: "野区霸主", analysis_successful: "录像分析成功", analysis_incomplete: "分析结果不完整", kill: "击杀", kill_contribution_: "参战率:{0}", position: "位置", position_: "位置:", position_1: "优势路", position_2: "中路", position_3: "烈士路", position_4: "采灵芝", position_5: "工具人", position_undefined: "?", total_damage: "总伤害", total_gold: "总经济", total_experience: "总经验", radiant_won: "天辉获胜", dire_won: "夜魇获胜", duration_: "持续时间:{0}", region_: "地区:{0}", match_count_: "场次:", last25matches_: "最近25场:", winrate_: "胜率:", imp_: "表现:", lane_advantage_rate_: "线优率:", top10_: "全期场次前十的英雄:", hero: "英雄", all_matches_: "全期场次:", match_count: "场次", winrate: "胜率", imp: "表现", win_count: "胜场", lose_count: "败场", recently_heroes: "近期使用场次大于1的英雄:", recently_positions: "近25场各个位置的表现:", winning_streak: "连胜", losing_streak: "连败", id: "ID", mode: "模式", kda_kc: "KDA(参战率)", time: "时间", duration: "时长", rank: "段位", un_parsed: "(未解析)", combined_win_loss_summary: "组合胜负情况:", yesterdays_summary: "昨日总结", last_weeks_summary: "上周总结", report_won: "胜", report_lost: "负", report_winrate: "胜率" } } };
|
|
596
614
|
}
|
|
597
615
|
});
|
|
598
616
|
|
|
@@ -607,6 +625,7 @@ var require_zh_CN = __commonJS({
|
|
|
607
625
|
var src_exports = {};
|
|
608
626
|
__export(src_exports, {
|
|
609
627
|
Config: () => Config,
|
|
628
|
+
GraphqlLanguageEnum: () => GraphqlLanguageEnum,
|
|
610
629
|
apply: () => apply,
|
|
611
630
|
inject: () => inject,
|
|
612
631
|
name: () => name,
|
|
@@ -624,7 +643,9 @@ __export(utils_exports, {
|
|
|
624
643
|
ImageType: () => ImageType,
|
|
625
644
|
formatHeroDesc: () => formatHeroDesc,
|
|
626
645
|
formatNumber: () => formatNumber,
|
|
646
|
+
getFormattedHeroData: () => getFormattedHeroData,
|
|
627
647
|
getFormattedMatchData: () => getFormattedMatchData,
|
|
648
|
+
getFormattedPlayerData: () => getFormattedPlayerData,
|
|
628
649
|
getImageUrl: () => getImageUrl,
|
|
629
650
|
init: () => init,
|
|
630
651
|
playerisValid: () => playerisValid,
|
|
@@ -696,12 +717,12 @@ async function queryHeroFromValve(heroId, languageTag = "zh-CN") {
|
|
|
696
717
|
return (await http.get(`https://www.dota2.com/datafeed/herodata?language=${language[languageTag]}&hero_id=${heroId}`)).result.data.heroes[0];
|
|
697
718
|
}
|
|
698
719
|
__name(queryHeroFromValve, "queryHeroFromValve");
|
|
699
|
-
var HeroDescType = /* @__PURE__ */ ((
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return
|
|
720
|
+
var HeroDescType = /* @__PURE__ */ ((HeroDescType3) => {
|
|
721
|
+
HeroDescType3["Normal"] = "normal";
|
|
722
|
+
HeroDescType3["Facet"] = "facet";
|
|
723
|
+
HeroDescType3["Scepter"] = "scepter";
|
|
724
|
+
HeroDescType3["Shard"] = "shard";
|
|
725
|
+
return HeroDescType3;
|
|
705
726
|
})(HeroDescType || {});
|
|
706
727
|
var ImageType = /* @__PURE__ */ ((ImageType2) => {
|
|
707
728
|
ImageType2["Icons"] = "icons";
|
|
@@ -1013,6 +1034,140 @@ function getFormattedMatchData(matchQuery, constantsQuery) {
|
|
|
1013
1034
|
return match;
|
|
1014
1035
|
}
|
|
1015
1036
|
__name(getFormattedMatchData, "getFormattedMatchData");
|
|
1037
|
+
function getFormattedPlayerData(playerQuery, playerExtraQuery, genHero) {
|
|
1038
|
+
const player = playerQuery.player;
|
|
1039
|
+
const playerExtra = playerExtraQuery.player;
|
|
1040
|
+
let filteredDotaPlus = {};
|
|
1041
|
+
playerExtra.dotaPlus.forEach((item) => {
|
|
1042
|
+
if (!filteredDotaPlus[item.heroId] || filteredDotaPlus[item.heroId].level < item.level) {
|
|
1043
|
+
filteredDotaPlus[item.heroId] = {
|
|
1044
|
+
heroId: item.heroId,
|
|
1045
|
+
level: item.level
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
playerExtra.heroesPerformance.forEach((hero) => {
|
|
1050
|
+
if (filteredDotaPlus[hero.hero.id]) {
|
|
1051
|
+
filteredDotaPlus[hero.hero.id].shortName = hero.hero.shortName;
|
|
1052
|
+
filteredDotaPlus[hero.hero.id].winCount = hero.winCount;
|
|
1053
|
+
filteredDotaPlus[hero.hero.id].matchCount = hero.matchCount;
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
player.rank = {
|
|
1057
|
+
medal: parseInt(player.steamAccount.seasonRank?.toString().split("")[0] ?? 0),
|
|
1058
|
+
star: parseInt(player.steamAccount.seasonRank?.toString().split("")[1] ?? 0),
|
|
1059
|
+
leaderboard: player.steamAccount.seasonLeaderboardRank,
|
|
1060
|
+
inTop100: player.steamAccount.seasonLeaderboardRank ? player.steamAccount.seasonLeaderboardRank <= 10 ? "8c" : player.steamAccount.seasonLeaderboardRank <= 100 ? "8b" : void 0 : void 0
|
|
1061
|
+
};
|
|
1062
|
+
player.dotaPlus = Object.values(filteredDotaPlus);
|
|
1063
|
+
player.dotaPlus.sort((a, b) => {
|
|
1064
|
+
if (b.level !== a.level) {
|
|
1065
|
+
return b.level - a.level;
|
|
1066
|
+
}
|
|
1067
|
+
return a.heroId - b.heroId;
|
|
1068
|
+
});
|
|
1069
|
+
player.heroesPerformanceTop10 = playerExtra.heroesPerformance.slice(0, 10);
|
|
1070
|
+
if (genHero) {
|
|
1071
|
+
const { matchCount, winCount, imp } = player.heroesPerformanceTop10[0];
|
|
1072
|
+
player.matchCount = matchCount;
|
|
1073
|
+
player.winCount = winCount;
|
|
1074
|
+
player.performance.imp = imp;
|
|
1075
|
+
player.dotaPlus = player.dotaPlus.filter((dpHero) => dpHero.heroId == genHero.heroId);
|
|
1076
|
+
player.genHero = genHero;
|
|
1077
|
+
}
|
|
1078
|
+
return player;
|
|
1079
|
+
}
|
|
1080
|
+
__name(getFormattedPlayerData, "getFormattedPlayerData");
|
|
1081
|
+
function getFormattedHeroData(rawHero) {
|
|
1082
|
+
let hero = Object.assign({}, rawHero);
|
|
1083
|
+
hero.facet_abilities.forEach((fa, i) => {
|
|
1084
|
+
if (fa.abilities.length) {
|
|
1085
|
+
fa.abilities.forEach((ab) => {
|
|
1086
|
+
if (!hero.facets[i].abilities) hero.facets[i].abilities = [];
|
|
1087
|
+
if (hero.facets[i].description_loc !== ab.desc_loc)
|
|
1088
|
+
hero.facets[i].abilities.push({
|
|
1089
|
+
id: ab.id,
|
|
1090
|
+
name: ab.name,
|
|
1091
|
+
name_loc: ab.name_loc,
|
|
1092
|
+
description_ability_loc: formatHeroDesc(ab.desc_loc, ab.special_values, "facet" /* Facet */)
|
|
1093
|
+
});
|
|
1094
|
+
else hero.facets[i].description_loc = formatHeroDesc(hero.facets[i].description_loc, ab.special_values, "facet" /* Facet */);
|
|
1095
|
+
ab.ability_is_facet = true;
|
|
1096
|
+
ab.facet = hero.facets[i];
|
|
1097
|
+
hero.abilities.push(ab);
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
const all_special_values = [...hero.abilities.flatMap((ab) => ab.special_values), ...hero.facet_abilities.flatMap((fas) => fas.abilities.flatMap((fa) => fa.special_values))];
|
|
1102
|
+
hero.abilities.forEach((ab) => {
|
|
1103
|
+
ab.facets_loc.forEach((facet, i) => {
|
|
1104
|
+
i = i + (hero.facets.length - ab.facets_loc.length);
|
|
1105
|
+
if (i < 0) return;
|
|
1106
|
+
if (facet) {
|
|
1107
|
+
if (!hero.facets[i].abilities) hero.facets[i].abilities = [];
|
|
1108
|
+
hero.facets[i].abilities.push({
|
|
1109
|
+
id: ab.id,
|
|
1110
|
+
name: ab.name,
|
|
1111
|
+
name_loc: ab.name_loc,
|
|
1112
|
+
description_ability_loc: formatHeroDesc(facet, ab.special_values, "facet" /* Facet */),
|
|
1113
|
+
attributes: []
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
hero.facets.forEach((facet) => {
|
|
1118
|
+
const svs = ab.special_values.filter((sv) => sv.facet_bonus.name === facet.name);
|
|
1119
|
+
svs.forEach((sv) => {
|
|
1120
|
+
if (sv.heading_loc) {
|
|
1121
|
+
if (!facet.abilities) facet.abilities = [];
|
|
1122
|
+
facet.abilities.find((ability) => ab.id == ability.id)?.attributes.push({
|
|
1123
|
+
heading_loc: sv.heading_loc,
|
|
1124
|
+
values: [...sv.facet_bonus.values],
|
|
1125
|
+
is_percentage: sv.is_percentage
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
facet.description_loc = formatHeroDesc(facet.description_loc, svs, "facet" /* Facet */);
|
|
1130
|
+
});
|
|
1131
|
+
ab.desc_loc = formatHeroDesc(ab.desc_loc, ab.special_values, ab.ability_is_facet ? "facet" /* Facet */ : void 0);
|
|
1132
|
+
ab.notes_loc = ab.notes_loc.map((note) => formatHeroDesc(note, ab.special_values));
|
|
1133
|
+
if (ab.ability_has_scepter) ab.scepter_loc = formatHeroDesc(ab.scepter_loc, ab.special_values, "scepter" /* Scepter */);
|
|
1134
|
+
if (ab.ability_has_shard) ab.shard_loc = formatHeroDesc(ab.shard_loc, ab.special_values, "shard" /* Shard */);
|
|
1135
|
+
});
|
|
1136
|
+
hero.talents.forEach((talent) => {
|
|
1137
|
+
const regex = /\{s:(.*?)\}/g;
|
|
1138
|
+
let match;
|
|
1139
|
+
while ((match = regex.exec(talent.name_loc)) !== null) {
|
|
1140
|
+
const specialValueName = match[1];
|
|
1141
|
+
const target = talent.special_values?.find((sv) => sv.name === specialValueName);
|
|
1142
|
+
if (target) {
|
|
1143
|
+
talent.name_loc = talent.name_loc.replace(match[0], target.values_float.join("/"));
|
|
1144
|
+
} else {
|
|
1145
|
+
const abilities = hero.abilities.filter((ability) => ability.special_values.some((specialValue) => specialValue.bonuses.some((bonus) => bonus.name === talent.name)));
|
|
1146
|
+
for (const ability of abilities) {
|
|
1147
|
+
const specialValues = ability.special_values.filter((specialValue) => specialValue.bonuses.some((bonus) => bonus.name === talent.name));
|
|
1148
|
+
const regex2 = /{s:bonus_(.*?)}/g;
|
|
1149
|
+
let match2;
|
|
1150
|
+
const replacements = [];
|
|
1151
|
+
while ((match2 = regex2.exec(talent.name_loc)) !== null) {
|
|
1152
|
+
const specialValue = specialValues.find((sv) => sv.name === String(match2[1]));
|
|
1153
|
+
const replacement = specialValue?.bonuses.find((bonus) => bonus.name === talent.name)?.value;
|
|
1154
|
+
if (replacement !== void 0) {
|
|
1155
|
+
replacements.push({
|
|
1156
|
+
original: match2[0],
|
|
1157
|
+
replacement
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
replacements.forEach(({ original, replacement }) => {
|
|
1162
|
+
talent.name_loc = talent.name_loc.replace(original, replacement);
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
return hero;
|
|
1169
|
+
}
|
|
1170
|
+
__name(getFormattedHeroData, "getFormattedHeroData");
|
|
1016
1171
|
function sec2time(sec) {
|
|
1017
1172
|
return sec ? (sec < 0 ? "-" : "") + Math.floor(Math.abs(sec) / 60) + ":" + ("00" + Math.abs(sec) % 60).slice(-2) : "--:--";
|
|
1018
1173
|
}
|
|
@@ -1111,6 +1266,12 @@ var dotaconstants2 = __toESM(require("dotaconstants"));
|
|
|
1111
1266
|
var import_koishi2 = require("koishi");
|
|
1112
1267
|
var ejs = __toESM(require("ejs"));
|
|
1113
1268
|
|
|
1269
|
+
// require("./locales/**/*.schema.yml") in src/index.ts
|
|
1270
|
+
var globRequire_locales_schema_yml = __glob({
|
|
1271
|
+
"./locales/en-US.schema.yml": () => require_en_US_schema(),
|
|
1272
|
+
"./locales/zh-CN.schema.yml": () => require_zh_CN_schema()
|
|
1273
|
+
});
|
|
1274
|
+
|
|
1114
1275
|
// require("./locales/**/*.constants.json") in src/index.ts
|
|
1115
1276
|
var globRequire_locales_constants_json = __glob({
|
|
1116
1277
|
"./locales/en-US.constants.json": () => require_en_US_constants(),
|
|
@@ -1120,9 +1281,11 @@ var globRequire_locales_constants_json = __glob({
|
|
|
1120
1281
|
// require("./locales/**/*.yml") in src/index.ts
|
|
1121
1282
|
var globRequire_locales_yml = __glob({
|
|
1122
1283
|
"./locales/en-US.command.yml": () => require_en_US_command(),
|
|
1284
|
+
"./locales/en-US.schema.yml": () => require_en_US_schema(),
|
|
1123
1285
|
"./locales/en-US.template.yml": () => require_en_US_template(),
|
|
1124
1286
|
"./locales/en-US.yml": () => require_en_US(),
|
|
1125
1287
|
"./locales/zh-CN.command.yml": () => require_zh_CN_command(),
|
|
1288
|
+
"./locales/zh-CN.schema.yml": () => require_zh_CN_schema(),
|
|
1126
1289
|
"./locales/zh-CN.template.yml": () => require_zh_CN_template(),
|
|
1127
1290
|
"./locales/zh-CN.yml": () => require_zh_CN()
|
|
1128
1291
|
});
|
|
@@ -1141,66 +1304,57 @@ var globRequire_locales_template_yml = __glob({
|
|
|
1141
1304
|
|
|
1142
1305
|
// src/index.ts
|
|
1143
1306
|
var name = "dota2tracker";
|
|
1144
|
-
var usage =
|
|
1145
|
-
DOTA2Bot插件-提供自动追踪群友的最新对局的功能(需群友绑定),以及一系列查询功能。
|
|
1146
|
-
[本地化/dota2tracker](../../locales/dota2tracker)可以自定义英雄别名和位置代称等文本内容
|
|
1147
|
-
**更多信息请进入[插件主页](https://sjtdev.github.io/koishi-plugin-dota2tracker/)与[更新日志](https://github.com/sjtdev/koishi-plugin-dota2tracker/blob/master/changelog.md)查看。**`;
|
|
1307
|
+
var usage = "";
|
|
1148
1308
|
var inject = ["http", "database", "cron", "puppeteer", "cache"];
|
|
1149
1309
|
var Config = import_koishi.Schema.intersect([
|
|
1150
1310
|
import_koishi.Schema.object({
|
|
1151
|
-
STRATZ_API_TOKEN: import_koishi.Schema.string().required().role("secret")
|
|
1152
|
-
dataParsingTimeoutMinutes: import_koishi.Schema.number().default(60).min(0).max(1440)
|
|
1153
|
-
urlInMessageType: import_koishi.Schema.array(
|
|
1154
|
-
|
|
1155
|
-
import_koishi.Schema.const("match").description("在查询比赛与战报消息中附带stratz比赛页面链接"),
|
|
1156
|
-
import_koishi.Schema.const("player").description("在查询玩家信息消息中附带stratz玩家页面链接"),
|
|
1157
|
-
import_koishi.Schema.const("hero").description("在查询英雄数据消息中附带刀塔百科对应英雄页面链接")
|
|
1158
|
-
])
|
|
1159
|
-
).role("checkbox").description("在消息中附带链接,<br/>请选择消息类型:")
|
|
1160
|
-
}).description("基础设置"),
|
|
1311
|
+
STRATZ_API_TOKEN: import_koishi.Schema.string().required().role("secret"),
|
|
1312
|
+
dataParsingTimeoutMinutes: import_koishi.Schema.number().default(60).min(0).max(1440),
|
|
1313
|
+
urlInMessageType: import_koishi.Schema.array(import_koishi.Schema.union([import_koishi.Schema.const("match"), import_koishi.Schema.const("player"), import_koishi.Schema.const("hero")])).role("checkbox")
|
|
1314
|
+
}).i18n(["zh-CN", "en-US"].reduce((acc, cur) => (acc[cur] = globRequire_locales_schema_yml(`./locales/${cur}.schema.yml`)._config.base, acc), {})),
|
|
1161
1315
|
import_koishi.Schema.intersect([
|
|
1162
1316
|
import_koishi.Schema.object({
|
|
1163
|
-
rankBroadSwitch: import_koishi.Schema.boolean().default(false)
|
|
1317
|
+
rankBroadSwitch: import_koishi.Schema.boolean().default(false)
|
|
1164
1318
|
}),
|
|
1165
1319
|
import_koishi.Schema.union([
|
|
1166
1320
|
import_koishi.Schema.object({
|
|
1167
1321
|
rankBroadSwitch: import_koishi.Schema.const(true).required(),
|
|
1168
|
-
rankBroadStar: import_koishi.Schema.boolean().default(true)
|
|
1169
|
-
rankBroadLeader: import_koishi.Schema.boolean().default(true)
|
|
1170
|
-
rankBroadFun: import_koishi.Schema.boolean().default(false)
|
|
1322
|
+
rankBroadStar: import_koishi.Schema.boolean().default(true),
|
|
1323
|
+
rankBroadLeader: import_koishi.Schema.boolean().default(true),
|
|
1324
|
+
rankBroadFun: import_koishi.Schema.boolean().default(false)
|
|
1171
1325
|
}),
|
|
1172
1326
|
import_koishi.Schema.object({})
|
|
1173
1327
|
])
|
|
1174
|
-
]),
|
|
1328
|
+
]).i18n(["zh-CN", "en-US"].reduce((acc, cur) => (acc[cur] = globRequire_locales_schema_yml(`./locales/${cur}.schema.yml`)._config.rank, acc), {})),
|
|
1175
1329
|
import_koishi.Schema.intersect([
|
|
1176
1330
|
import_koishi.Schema.object({
|
|
1177
|
-
dailyReportSwitch: import_koishi.Schema.boolean().default(false)
|
|
1178
|
-
})
|
|
1331
|
+
dailyReportSwitch: import_koishi.Schema.boolean().default(false)
|
|
1332
|
+
}),
|
|
1179
1333
|
import_koishi.Schema.union([
|
|
1180
1334
|
import_koishi.Schema.object({
|
|
1181
1335
|
dailyReportSwitch: import_koishi.Schema.const(true).required(),
|
|
1182
|
-
dailyReportHours: import_koishi.Schema.number().min(0).max(23).default(6)
|
|
1183
|
-
dailyReportShowCombi: import_koishi.Schema.boolean().default(true)
|
|
1336
|
+
dailyReportHours: import_koishi.Schema.number().min(0).max(23).default(6),
|
|
1337
|
+
dailyReportShowCombi: import_koishi.Schema.boolean().default(true)
|
|
1184
1338
|
}),
|
|
1185
1339
|
import_koishi.Schema.object({})
|
|
1186
1340
|
]),
|
|
1187
1341
|
import_koishi.Schema.object({
|
|
1188
|
-
weeklyReportSwitch: import_koishi.Schema.boolean().default(false)
|
|
1342
|
+
weeklyReportSwitch: import_koishi.Schema.boolean().default(false)
|
|
1189
1343
|
}),
|
|
1190
1344
|
import_koishi.Schema.union([
|
|
1191
1345
|
import_koishi.Schema.object({
|
|
1192
1346
|
weeklyReportSwitch: import_koishi.Schema.const(true).required(),
|
|
1193
|
-
weeklyReportDayHours: import_koishi.Schema.tuple([import_koishi.Schema.number().min(1).max(7), import_koishi.Schema.number().min(0).max(23)]).default([1, 10])
|
|
1194
|
-
weeklyReportShowCombi: import_koishi.Schema.boolean().default(true)
|
|
1347
|
+
weeklyReportDayHours: import_koishi.Schema.tuple([import_koishi.Schema.number().min(1).max(7), import_koishi.Schema.number().min(0).max(23)]).default([1, 10]),
|
|
1348
|
+
weeklyReportShowCombi: import_koishi.Schema.boolean().default(true)
|
|
1195
1349
|
}),
|
|
1196
1350
|
import_koishi.Schema.object({})
|
|
1197
1351
|
])
|
|
1198
|
-
]),
|
|
1352
|
+
]).i18n(["zh-CN", "en-US"].reduce((acc, cur) => (acc[cur] = globRequire_locales_schema_yml(`./locales/${cur}.schema.yml`)._config.report, acc), {})),
|
|
1199
1353
|
import_koishi.Schema.object({
|
|
1200
|
-
template_match: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/match`)]).default("match_1")
|
|
1201
|
-
template_player: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/player`)]).default("player_1")
|
|
1202
|
-
template_hero: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/hero`)]).default("hero_1")
|
|
1203
|
-
}).
|
|
1354
|
+
template_match: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/match`)]).default("match_1"),
|
|
1355
|
+
template_player: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/player`)]).default("player_1"),
|
|
1356
|
+
template_hero: import_koishi.Schema.union([...readDirectoryFilesSync(`./node_modules/@sjtdev/koishi-plugin-${name}/template/hero`)]).default("hero_1")
|
|
1357
|
+
}).i18n(["zh-CN", "en-US"].reduce((acc, cur) => (acc[cur] = globRequire_locales_schema_yml(`./locales/${cur}.schema.yml`)._config.template, acc), {}))
|
|
1204
1358
|
]);
|
|
1205
1359
|
var pendingMatches = [];
|
|
1206
1360
|
var random = new import_koishi2.Random(() => Math.random());
|
|
@@ -1225,6 +1379,7 @@ async function apply(ctx, config) {
|
|
|
1225
1379
|
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));
|
|
1226
1380
|
}, "getLanguageTag");
|
|
1227
1381
|
const GlobalLanguageTag = await getLanguageTag();
|
|
1382
|
+
usage = $t(GlobalLanguageTag, "dota2tracker.usage");
|
|
1228
1383
|
ctx.command("dota2tracker.subscribe").alias("订阅本群").action(async ({ session }) => {
|
|
1229
1384
|
if (session.guild) {
|
|
1230
1385
|
let currentGuild = (await ctx.database.get("dt_subscribed_guilds", {
|
|
@@ -1546,58 +1701,18 @@ async function apply(ctx, config) {
|
|
|
1546
1701
|
session.send(session.text(".querying_player"));
|
|
1547
1702
|
let heroId = findingHero(options.hero);
|
|
1548
1703
|
let steamId = flagBindedPlayer?.steamId ?? input_data;
|
|
1549
|
-
let player;
|
|
1550
1704
|
try {
|
|
1551
|
-
|
|
1705
|
+
const playerQuery = await query("PlayerInfoWith25Matches", {
|
|
1552
1706
|
steamAccountId: steamId,
|
|
1553
1707
|
heroIds: heroId
|
|
1554
|
-
})
|
|
1555
|
-
|
|
1708
|
+
});
|
|
1709
|
+
const playerExtraQuery = await query("PlayerExtraInfo", {
|
|
1556
1710
|
steamAccountId: steamId,
|
|
1557
|
-
matchCount: player.matchCount,
|
|
1711
|
+
matchCount: playerQuery.player.matchCount,
|
|
1558
1712
|
totalHeroCount: Object.keys(dotaconstants2.heroes).length,
|
|
1559
1713
|
heroIds: heroId
|
|
1560
|
-
})).player;
|
|
1561
|
-
let filteredDotaPlus = {};
|
|
1562
|
-
playerExtra.dotaPlus.forEach((item) => {
|
|
1563
|
-
if (!filteredDotaPlus[item.heroId] || filteredDotaPlus[item.heroId].level < item.level) {
|
|
1564
|
-
filteredDotaPlus[item.heroId] = {
|
|
1565
|
-
heroId: item.heroId,
|
|
1566
|
-
level: item.level
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
1714
|
});
|
|
1570
|
-
|
|
1571
|
-
if (filteredDotaPlus[hero.hero.id]) {
|
|
1572
|
-
filteredDotaPlus[hero.hero.id].shortName = hero.hero.shortName;
|
|
1573
|
-
filteredDotaPlus[hero.hero.id].winCount = hero.winCount;
|
|
1574
|
-
filteredDotaPlus[hero.hero.id].matchCount = hero.matchCount;
|
|
1575
|
-
}
|
|
1576
|
-
});
|
|
1577
|
-
player.rank = {
|
|
1578
|
-
medal: parseInt(player.steamAccount.seasonRank?.toString().split("")[0] ?? 0),
|
|
1579
|
-
star: parseInt(player.steamAccount.seasonRank?.toString().split("")[1] ?? 0),
|
|
1580
|
-
leaderboard: player.steamAccount.seasonLeaderboardRank,
|
|
1581
|
-
inTop100: player.steamAccount.seasonLeaderboardRank ? player.steamAccount.seasonLeaderboardRank <= 10 ? "8c" : player.steamAccount.seasonLeaderboardRank <= 100 ? "8b" : void 0 : void 0
|
|
1582
|
-
};
|
|
1583
|
-
player.dotaPlus = Object.values(filteredDotaPlus);
|
|
1584
|
-
player.dotaPlus.sort((a, b) => {
|
|
1585
|
-
if (b.level !== a.level) {
|
|
1586
|
-
return b.level - a.level;
|
|
1587
|
-
}
|
|
1588
|
-
return a.heroId - b.heroId;
|
|
1589
|
-
});
|
|
1590
|
-
player.heroesPerformanceTop10 = playerExtra.heroesPerformance.slice(0, 10);
|
|
1591
|
-
if (heroId) {
|
|
1592
|
-
const { matchCount, winCount, imp } = player.heroesPerformanceTop10[0];
|
|
1593
|
-
player.matchCount = matchCount;
|
|
1594
|
-
player.winCount = winCount;
|
|
1595
|
-
player.performance.imp = imp;
|
|
1596
|
-
player.dotaPlus = player.dotaPlus.filter((dpHero) => dpHero.heroId == heroId);
|
|
1597
|
-
player.genHero = {
|
|
1598
|
-
name: constantLocales[languageTag].dota2tracker.template.hero_names[heroId]
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1715
|
+
const player = getFormattedPlayerData(playerQuery, playerExtraQuery, heroId ? { heroId, name: constantLocales[languageTag].dota2tracker.template.hero_names[heroId] } : null);
|
|
1601
1716
|
session.send(
|
|
1602
1717
|
(ctx.config.urlInMessageType.some((type) => type == "player") ? "https://stratz.com/players/" + player.steamAccount.id : "") + await ctx.puppeteer.render(await genImageHTML(player, config.template_player, "player" /* Player */, ctx, languageTag))
|
|
1603
1718
|
);
|
|
@@ -1621,91 +1736,7 @@ async function apply(ctx, config) {
|
|
|
1621
1736
|
await session.send(session.text(".querying_hero"));
|
|
1622
1737
|
try {
|
|
1623
1738
|
let hero = await queryHeroFromValve(heroId, languageTag);
|
|
1624
|
-
hero
|
|
1625
|
-
if (fa.abilities.length) {
|
|
1626
|
-
fa.abilities.forEach((ab) => {
|
|
1627
|
-
if (!hero.facets[i].abilities) hero.facets[i].abilities = [];
|
|
1628
|
-
if (hero.facets[i].description_loc !== ab.desc_loc)
|
|
1629
|
-
hero.facets[i].abilities.push({
|
|
1630
|
-
id: ab.id,
|
|
1631
|
-
name: ab.name,
|
|
1632
|
-
name_loc: ab.name_loc,
|
|
1633
|
-
description_ability_loc: formatHeroDesc(ab.desc_loc, ab.special_values, "facet" /* Facet */)
|
|
1634
|
-
});
|
|
1635
|
-
else hero.facets[i].description_loc = formatHeroDesc(hero.facets[i].description_loc, ab.special_values, "facet" /* Facet */);
|
|
1636
|
-
ab.ability_is_facet = true;
|
|
1637
|
-
ab.facet = hero.facets[i];
|
|
1638
|
-
hero.abilities.push(ab);
|
|
1639
|
-
});
|
|
1640
|
-
}
|
|
1641
|
-
});
|
|
1642
|
-
const all_special_values = [...hero.abilities.flatMap((ab) => ab.special_values), ...hero.facet_abilities.flatMap((fas) => fas.abilities.flatMap((fa) => fa.special_values))];
|
|
1643
|
-
hero.abilities.forEach((ab) => {
|
|
1644
|
-
ab.facets_loc.forEach((facet, i) => {
|
|
1645
|
-
i = i + (hero.facets.length - ab.facets_loc.length);
|
|
1646
|
-
if (i < 0) return;
|
|
1647
|
-
if (facet) {
|
|
1648
|
-
if (!hero.facets[i].abilities) hero.facets[i].abilities = [];
|
|
1649
|
-
hero.facets[i].abilities.push({
|
|
1650
|
-
id: ab.id,
|
|
1651
|
-
name: ab.name,
|
|
1652
|
-
name_loc: ab.name_loc,
|
|
1653
|
-
description_ability_loc: formatHeroDesc(facet, ab.special_values, "facet" /* Facet */),
|
|
1654
|
-
attributes: []
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
});
|
|
1658
|
-
hero.facets.forEach((facet) => {
|
|
1659
|
-
const svs = ab.special_values.filter((sv) => sv.facet_bonus.name === facet.name);
|
|
1660
|
-
svs.forEach((sv) => {
|
|
1661
|
-
if (sv.heading_loc) {
|
|
1662
|
-
if (!facet.abilities) facet.abilities = [];
|
|
1663
|
-
facet.abilities.find((ability) => ab.id == ability.id)?.attributes.push({
|
|
1664
|
-
heading_loc: sv.heading_loc,
|
|
1665
|
-
values: [...sv.facet_bonus.values],
|
|
1666
|
-
is_percentage: sv.is_percentage
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
});
|
|
1670
|
-
facet.description_loc = formatHeroDesc(facet.description_loc, svs, "facet" /* Facet */);
|
|
1671
|
-
});
|
|
1672
|
-
ab.desc_loc = formatHeroDesc(ab.desc_loc, ab.special_values, ab.ability_is_facet ? "facet" /* Facet */ : void 0);
|
|
1673
|
-
ab.notes_loc = ab.notes_loc.map((note) => formatHeroDesc(note, ab.special_values));
|
|
1674
|
-
if (ab.ability_has_scepter) ab.scepter_loc = formatHeroDesc(ab.scepter_loc, ab.special_values, "scepter" /* Scepter */);
|
|
1675
|
-
if (ab.ability_has_shard) ab.shard_loc = formatHeroDesc(ab.shard_loc, ab.special_values, "shard" /* Shard */);
|
|
1676
|
-
});
|
|
1677
|
-
hero.talents.forEach((talent) => {
|
|
1678
|
-
const regex = /\{s:(.*?)\}/g;
|
|
1679
|
-
let match;
|
|
1680
|
-
while ((match = regex.exec(talent.name_loc)) !== null) {
|
|
1681
|
-
const specialValueName = match[1];
|
|
1682
|
-
const target = talent.special_values?.find((sv) => sv.name === specialValueName);
|
|
1683
|
-
if (target) {
|
|
1684
|
-
talent.name_loc = talent.name_loc.replace(match[0], target.values_float.join("/"));
|
|
1685
|
-
} else {
|
|
1686
|
-
const abilities = hero.abilities.filter((ability) => ability.special_values.some((specialValue) => specialValue.bonuses.some((bonus) => bonus.name === talent.name)));
|
|
1687
|
-
for (const ability of abilities) {
|
|
1688
|
-
const specialValues = ability.special_values.filter((specialValue) => specialValue.bonuses.some((bonus) => bonus.name === talent.name));
|
|
1689
|
-
const regex2 = /{s:bonus_(.*?)}/g;
|
|
1690
|
-
let match2;
|
|
1691
|
-
const replacements = [];
|
|
1692
|
-
while ((match2 = regex2.exec(talent.name_loc)) !== null) {
|
|
1693
|
-
const specialValue = specialValues.find((sv) => sv.name === String(match2[1]));
|
|
1694
|
-
const replacement = specialValue?.bonuses.find((bonus) => bonus.name === talent.name)?.value;
|
|
1695
|
-
if (replacement !== void 0) {
|
|
1696
|
-
replacements.push({
|
|
1697
|
-
original: match2[0],
|
|
1698
|
-
replacement
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
replacements.forEach(({ original, replacement }) => {
|
|
1703
|
-
talent.name_loc = talent.name_loc.replace(original, replacement);
|
|
1704
|
-
});
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
});
|
|
1739
|
+
hero = getFormattedHeroData(hero);
|
|
1709
1740
|
await session.send(
|
|
1710
1741
|
(ctx.config.urlInMessageType.some((type) => type == "hero") ? `https://wiki.dota2.com.cn/hero/${hero["name"].match(/^npc_dota_hero_(.+)$/)[1]}.html` : "") + await ctx.puppeteer.render(await genImageHTML(hero, config.template_hero, "hero" /* Hero */, ctx, languageTag))
|
|
1711
1742
|
);
|
|
@@ -1774,13 +1805,13 @@ async function apply(ctx, config) {
|
|
|
1774
1805
|
if (config.dailyReportSwitch) {
|
|
1775
1806
|
ctx.cron(`0 ${config.dailyReportHours} * * *`, async function() {
|
|
1776
1807
|
const oneDayAgo = (0, import_moment.default)().subtract(1, "days").unix();
|
|
1777
|
-
await report(oneDayAgo, "
|
|
1808
|
+
await report(oneDayAgo, "dota2tracker.template.yesterdays_summary", config.dailyReportShowCombi);
|
|
1778
1809
|
});
|
|
1779
1810
|
}
|
|
1780
1811
|
if (config.weeklyReportSwitch) {
|
|
1781
1812
|
ctx.cron(`0 ${config.weeklyReportDayHours[1]} * * ${config.weeklyReportDayHours[0]}`, async function() {
|
|
1782
1813
|
const oneWeekAgo = (0, import_moment.default)().subtract(1, "weeks").unix();
|
|
1783
|
-
await report(oneWeekAgo, "
|
|
1814
|
+
await report(oneWeekAgo, "dota2tracker.template.last_weeks_summary", config.weeklyReportShowCombi);
|
|
1784
1815
|
});
|
|
1785
1816
|
}
|
|
1786
1817
|
ctx.cron("* * * * *", async function() {
|
|
@@ -1943,7 +1974,7 @@ async function apply(ctx, config) {
|
|
|
1943
1974
|
}
|
|
1944
1975
|
});
|
|
1945
1976
|
});
|
|
1946
|
-
async function report(timeAgo,
|
|
1977
|
+
async function report(timeAgo, titleKey, showCombi) {
|
|
1947
1978
|
const subscribedGuilds = await ctx.database.get("dt_subscribed_guilds", void 0);
|
|
1948
1979
|
const subscribedPlayersInGuild = (await ctx.database.get("dt_subscribed_players", void 0)).filter((player) => subscribedGuilds.some((guild) => guild.guildId == player.guildId));
|
|
1949
1980
|
const players = (await query("PlayersMatchesForDaily", {
|
|
@@ -1997,12 +2028,13 @@ async function apply(ctx, config) {
|
|
|
1997
2028
|
});
|
|
1998
2029
|
const combinations = Array.from(combinationsMap.values());
|
|
1999
2030
|
try {
|
|
2031
|
+
const languageTag = await getLanguageTag({ channelId: guild.guildId });
|
|
2000
2032
|
await ctx.broadcast(
|
|
2001
2033
|
[`${guild.platform}:${guild.guildId}`],
|
|
2002
2034
|
await ctx.puppeteer.render(
|
|
2003
2035
|
await genImageHTML(
|
|
2004
2036
|
{
|
|
2005
|
-
title,
|
|
2037
|
+
title: $t(languageTag, titleKey),
|
|
2006
2038
|
players: currentsubscribedPlayers.sort((a, b) => {
|
|
2007
2039
|
if (a.matches.length > b.matches.length) return -1;
|
|
2008
2040
|
else if (a.matches.length < b.matches.length) return 1;
|
|
@@ -2018,7 +2050,7 @@ async function apply(ctx, config) {
|
|
|
2018
2050
|
)
|
|
2019
2051
|
)
|
|
2020
2052
|
);
|
|
2021
|
-
ctx.logger.info($t(GlobalLanguageTag, "dota2tracker.logger.report_sent", { title, guildId: guild.guildId, platform: guild.platform }));
|
|
2053
|
+
ctx.logger.info($t(GlobalLanguageTag, "dota2tracker.logger.report_sent", { title: $t(languageTag, titleKey), guildId: guild.guildId, platform: guild.platform }));
|
|
2022
2054
|
} catch (error) {
|
|
2023
2055
|
ctx.logger.error(error);
|
|
2024
2056
|
}
|
|
@@ -2118,6 +2150,7 @@ __name(customConvertArrayOfString, "customConvertArrayOfString");
|
|
|
2118
2150
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2119
2151
|
0 && (module.exports = {
|
|
2120
2152
|
Config,
|
|
2153
|
+
GraphqlLanguageEnum,
|
|
2121
2154
|
apply,
|
|
2122
2155
|
inject,
|
|
2123
2156
|
name,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# [@sjtdev/koishi-plugin-dota2tracker](https://sjtdev.github.io/koishi-plugin-dota2tracker/)
|
|
2
2
|
|
|
3
|
+
[新文档](https://sjtdev.github.io/koishi-plugin-dota2tracker/)正在缓慢构建中……
|
|
4
|
+
|
|
3
5
|
[](https://www.npmjs.com/package/@sjtdev/koishi-plugin-dota2tracker)
|
|
4
6
|
[](https://www.npmjs.com/package/@sjtdev/koishi-plugin-dota2tracker)
|
|
5
7
|
[](https://www.npmjs.com/package/@sjtdev/koishi-plugin-dota2tracker)
|
|
6
|
-
> [!TIP]
|
|
8
|
+
> [!TIP]
|
|
9
|
+
> 两个标签取版本号最高的版为最新版本
|
|
7
10
|
|
|
8
11
|
DOTA2Bot插件-提供自动追踪群友的最新对局的功能(需群友绑定),以及一系列查询功能。
|
|
9
12
|
### 安装
|
|
@@ -144,9 +144,9 @@
|
|
|
144
144
|
<img src="<%= player.steamAccount.avatar %>" class="avatar" />
|
|
145
145
|
<span class="name"><%= player.name %></span>
|
|
146
146
|
<span class="count">
|
|
147
|
-
<span class="win"
|
|
148
|
-
<span class="lose"
|
|
149
|
-
<span
|
|
147
|
+
<span class="win"><%- $t("dota2tracker.template.report_won") %><%= player.winCount %></span>
|
|
148
|
+
<span class="lose"><%- $t("dota2tracker.template.report_lost") %><%= player.loseCount %></span>
|
|
149
|
+
<span><%- $t("dota2tracker.template.report_winrate") %> <%= Math.round((player.winCount / player.matches.length) * 100) %>%</span>
|
|
150
150
|
</span>
|
|
151
151
|
<div class="performance">
|
|
152
152
|
<% const imp = {sign : "", left : 0, right : 0, absValue : Math.abs(player.avgImp)} %>
|
|
@@ -169,16 +169,16 @@
|
|
|
169
169
|
<% } %>
|
|
170
170
|
</div>
|
|
171
171
|
<div class="combinations"<%= !showCombi ? ` style="display:none;"` : "" %>>
|
|
172
|
-
<span style="grid-column: 1/-1"
|
|
172
|
+
<span style="grid-column: 1/-1"><%- $t("dota2tracker.template.combined_win_loss_summary") %></span>
|
|
173
173
|
<% combinations.forEach((combi) => {%>
|
|
174
174
|
<div class="players">
|
|
175
175
|
<% combi.players.forEach(player => {%>
|
|
176
176
|
<img src="<%= player.steamAccount.avatar %>" class="avatar" />
|
|
177
177
|
<% }); %>
|
|
178
178
|
</div>
|
|
179
|
-
<span class="win"
|
|
180
|
-
<span class="lose"
|
|
181
|
-
<span
|
|
179
|
+
<span class="win"><%- $t("dota2tracker.template.report_won") %><%= combi.winCount %></span>
|
|
180
|
+
<span class="lose"><%- $t("dota2tracker.template.report_lost") %><%= combi.matches.length - combi.winCount %></span>
|
|
181
|
+
<span><%- $t("dota2tracker.template.report_winrate") %> <%= Math.round((combi.winCount / combi.matches.length) * 100) %>%</span>
|
|
182
182
|
<% }); %>
|
|
183
183
|
</div>
|
|
184
184
|
</body>
|