@sjtdev/koishi-plugin-dota2tracker 1.2.4 → 1.2.5-fix2
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 +8 -1
- package/lib/index.js +39 -12
- package/package.json +2 -1
- package/template/hero/hero_1.ejs +0 -4
- package/template/player/player_1.ejs +11 -9
package/changelog.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### 1.2.5-fix
|
|
2
|
+
**修复**:使用临时替代方案修复由koishi-4.17.9的bug引起的无法主动发送消息(播报战报等),待koishi更新修复后回滚此改动。
|
|
3
|
+
|
|
4
|
+
### 1.2.5
|
|
5
|
+
**改进**:优化`查询玩家`图片中近期战绩列表内未解析比赛的显示效果
|
|
6
|
+
**修复**:修复`查询英雄`图片技能属性名多显示了一个冒号的问题
|
|
7
|
+
|
|
1
8
|
### 1.2.4
|
|
2
9
|
**修复**:修正调用help指令时本插件某些指令的说明错误
|
|
3
10
|
**修复**:修复`取消订阅`指令失效的问题
|
|
@@ -86,4 +93,4 @@
|
|
|
86
93
|
|
|
87
94
|
### 1.1.0
|
|
88
95
|
**改进**:使用ejs重写模板相关代码使其模块化,使新增模板更方便
|
|
89
|
-
**新增**:为比赛信息添加了仿MAX+模板,效果可见[match_2](
|
|
96
|
+
**新增**:为比赛信息添加了仿MAX+模板,效果可见[match_2](https://github.com/sjtdev/koishi-plugin-dota2tracker/wiki/match_2),可在插件配置中切换
|
package/lib/index.js
CHANGED
|
@@ -302,6 +302,7 @@ function PLAYER_INFO_WITH_25_MATCHES(steamAccountId, heroId) {
|
|
|
302
302
|
lobbyType
|
|
303
303
|
gameMode
|
|
304
304
|
startDateTime
|
|
305
|
+
parsedDateTime
|
|
305
306
|
durationSeconds
|
|
306
307
|
didRadiantWin
|
|
307
308
|
topLaneOutcome
|
|
@@ -1689,17 +1690,23 @@ async function apply(ctx, config) {
|
|
|
1689
1690
|
}
|
|
1690
1691
|
});
|
|
1691
1692
|
const combinations = Array.from(combinationsMap.values());
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
"\n"
|
|
1701
|
-
|
|
1702
|
-
|
|
1693
|
+
try {
|
|
1694
|
+
await sendMessageToChannel(
|
|
1695
|
+
ctx,
|
|
1696
|
+
guild.guildId,
|
|
1697
|
+
// [`${guild.platform}:${guild.guildId}`],
|
|
1698
|
+
`昨日总结:
|
|
1699
|
+
${currentsubscribedPlayers.map(
|
|
1700
|
+
(player) => `${player.name}: ${player.winCount}胜${player.loseCount}负 胜率${Math.round(player.winCount / player.matches.length * 100)}%,平均KDA: [${player.avgKills}/${player.avgDeaths}/${player.avgAssists}](${player.avgKDA}),平均表现: ${player.avgImp > 0 ? "+" : ""}${player.avgImp}`
|
|
1701
|
+
).join("\n")}
|
|
1702
|
+
${combinations.map((combi) => `组合[${combi.name}]: ${combi.winCount}胜${combi.matches.length - combi.winCount}负 胜率${Math.round(combi.winCount / combi.matches.length * 100)}%`).join("\n")}`.replace(
|
|
1703
|
+
/\s*\n\s*/g,
|
|
1704
|
+
"\n"
|
|
1705
|
+
)
|
|
1706
|
+
);
|
|
1707
|
+
} catch (error) {
|
|
1708
|
+
ctx.logger.error(error);
|
|
1709
|
+
}
|
|
1703
1710
|
}
|
|
1704
1711
|
}
|
|
1705
1712
|
});
|
|
@@ -1765,7 +1772,7 @@ async function apply(ctx, config) {
|
|
|
1765
1772
|
KDA:${((player.kills + player.assists) / (player.deaths || 1)).toFixed(2)} [${player.kills}/${player.deaths}/${player.assists}],GPM/XPM:${player.goldPerMinute}/${player.experiencePerMinute},补刀数:${player.numLastHits}/${player.numDenies},伤害/塔伤:${player.heroDamage}/${player.towerDamage},参战/参葬率:${(player.killContribution * 100).toFixed(2)}%/${(player.deathContribution * 100).toFixed(2)}%`;
|
|
1766
1773
|
broadMatchMessage += broadPlayerMessage + "\n";
|
|
1767
1774
|
}
|
|
1768
|
-
await ctx
|
|
1775
|
+
await sendMessageToChannel(ctx, commingGuild, broadMatchMessage + img);
|
|
1769
1776
|
ctx.logger.info(`${match.id}${match.parsedDateTime ? "已解析," : "已结束超过1小时仍未被解析,放弃解析直接"}生成图片并发布于${commingGuild.platform}:${commingGuild.guildId}。`);
|
|
1770
1777
|
}
|
|
1771
1778
|
if (match.parsedDateTime)
|
|
@@ -1806,6 +1813,26 @@ function genImageHTML(data, template, type) {
|
|
|
1806
1813
|
return result;
|
|
1807
1814
|
}
|
|
1808
1815
|
__name(genImageHTML, "genImageHTML");
|
|
1816
|
+
async function sendMessageToChannel(ctx, commingGuild, broadMatchMessage) {
|
|
1817
|
+
try {
|
|
1818
|
+
const targetChannels = await ctx.database.get("channel", { id: commingGuild.guildId, platform: commingGuild.platform });
|
|
1819
|
+
if (targetChannels.length === 1) {
|
|
1820
|
+
const bot = ctx.bots.find((bot2) => bot2.userId === targetChannels[0].assignee);
|
|
1821
|
+
if (bot) {
|
|
1822
|
+
await bot.sendMessage(commingGuild.guildId, broadMatchMessage);
|
|
1823
|
+
} else {
|
|
1824
|
+
throw new Error("指定的bot未找到。");
|
|
1825
|
+
}
|
|
1826
|
+
} else if (targetChannels.length > 1) {
|
|
1827
|
+
throw new Error("有复数个bot存在于该群组/频道,请移除多余bot。");
|
|
1828
|
+
} else {
|
|
1829
|
+
throw new Error("未找到目标群组/频道。");
|
|
1830
|
+
}
|
|
1831
|
+
} catch (error) {
|
|
1832
|
+
throw error;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
__name(sendMessageToChannel, "sendMessageToChannel");
|
|
1809
1836
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1810
1837
|
0 && (module.exports = {
|
|
1811
1838
|
Config,
|
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.2.
|
|
4
|
+
"version": "1.2.5-fix2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"zh": "追踪群友的DOTA2对局"
|
|
40
40
|
},
|
|
41
41
|
"required": [
|
|
42
|
+
"http",
|
|
42
43
|
"database",
|
|
43
44
|
"puppeteer",
|
|
44
45
|
"cron"
|
package/template/hero/hero_1.ejs
CHANGED
|
@@ -503,25 +503,27 @@
|
|
|
503
503
|
</tr>
|
|
504
504
|
</thead>
|
|
505
505
|
<tbody>
|
|
506
|
-
<%- player.matches.map((match) =>
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
<%- player.matches.map((match) => {
|
|
507
|
+
const innerPlayer = match.players[0];
|
|
508
|
+
return `
|
|
509
|
+
<tr class="match ${match.didRadiantWin == innerPlayer.isRadiant ? "win" : "lose"}">
|
|
510
|
+
<td>${match.parsedDateTime ? match.id : `<p>${match.id}</p><p>(未解析)</p>`}</td>
|
|
509
511
|
<td>
|
|
510
512
|
<p>${d2a.lobbyTypes[match.lobbyType] || match.lobbyType}</p>
|
|
511
513
|
<p>${d2a.gameMode[match.gameMode] || match.gameMode}</p>
|
|
512
514
|
</td>
|
|
513
|
-
<td><img alt="" src="${utils.getImageUrl(
|
|
515
|
+
<td><img alt="" src="${utils.getImageUrl(innerPlayer.hero.shortName, ImageType.HeroIcons)}" /></td>
|
|
514
516
|
<td style="line-height: 20px">
|
|
515
|
-
<p>${((
|
|
516
|
-
(match
|
|
517
|
-
<p>${
|
|
517
|
+
<p>${((innerPlayer.kills + innerPlayer.assists) / Math.max(1, innerPlayer.deaths)).toFixed(2)} (${match.parsedDateTime?((((innerPlayer.kills + innerPlayer.assists) /
|
|
518
|
+
(match[(innerPlayer.isRadiant ? "radiant" : "dire")+"Kills"]?.reduce((acc, cva) => acc + cva, 0))) * 100)?.toFixed(0)):"?"}%)</p>
|
|
519
|
+
<p>${innerPlayer.kills}/${innerPlayer.deaths}/${innerPlayer.assists}</p>
|
|
518
520
|
</td>
|
|
519
521
|
<td><div class="player_lane ${match.laneResult}">${laneSVG[match.laneResult]}</div></td>
|
|
520
522
|
<td style="line-height: 20px">${moment(new Date(match.startDateTime * 1000)).format("YYYY-MM-DD HH:mm:ss").slice(2)}</td>
|
|
521
523
|
<td>${utils.sec2time(match.durationSeconds)}</td>
|
|
522
|
-
<td>${(
|
|
524
|
+
<td>${innerPlayer.imp ? ((innerPlayer.imp > 0 ? "+" : "") + innerPlayer.imp) : "?"}</td>
|
|
523
525
|
<td><img class="medal" src="${utils.getImageUrl("medal_" + match.rank?.toString().split("")[0])}" style="width: 100%" /></td>
|
|
524
|
-
</tr>`).join("")%>
|
|
526
|
+
</tr>`}).join("")%>
|
|
525
527
|
</tbody>
|
|
526
528
|
</table>
|
|
527
529
|
<div class="plus">
|