@sjtdev/koishi-plugin-dota2tracker 1.1.2-beta.2 → 1.1.2-beta.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 +31 -23
- package/package.json +1 -1
- package/template/guild_member/guild_member.ejs +8 -5
package/lib/index.js
CHANGED
|
@@ -209,6 +209,11 @@ function PLAYERS_LASTMATCH(steamAccountIds) {
|
|
|
209
209
|
id
|
|
210
210
|
parsedDateTime
|
|
211
211
|
startDateTime
|
|
212
|
+
players{
|
|
213
|
+
steamAccount{
|
|
214
|
+
id
|
|
215
|
+
}
|
|
216
|
+
}
|
|
212
217
|
}
|
|
213
218
|
}
|
|
214
219
|
}
|
|
@@ -1201,7 +1206,7 @@ async function apply(ctx, config) {
|
|
|
1201
1206
|
session.send(await ctx.puppeteer.render(genImageHTML(match, config.template_match, "match" /* Match */)));
|
|
1202
1207
|
ctx.database.upsert("dt_previous_query_results", (row) => [{ matchId: match.id, data: match, queryTime: /* @__PURE__ */ new Date() }]);
|
|
1203
1208
|
} else {
|
|
1204
|
-
pendingMatches.push({ matchId, platform: session.event.platform, guildId: session.event.guild.id });
|
|
1209
|
+
pendingMatches.push({ matchId, guilds: [{ platform: session.event.platform, guildId: session.event.guild.id, players: [] }] });
|
|
1205
1210
|
session.send("比赛尚未解析,将在解析完成后发布。");
|
|
1206
1211
|
}
|
|
1207
1212
|
} catch (error) {
|
|
@@ -1441,7 +1446,6 @@ async function apply(ctx, config) {
|
|
|
1441
1446
|
ctx.database.remove("dt_previous_query_results", { queryTime: { $lt: oneMonthAgo } });
|
|
1442
1447
|
});
|
|
1443
1448
|
ctx.cron("* * * * *", async function() {
|
|
1444
|
-
const scanningMatches = [...pendingMatches];
|
|
1445
1449
|
const subscribedGuilds = await ctx.database.get("dt_subscribed_guilds", void 0);
|
|
1446
1450
|
const subscribedPlayersInGuild = (await ctx.database.get("dt_subscribed_players", void 0)).filter((player) => subscribedGuilds.some((guild) => guild.guildId == player.guildId));
|
|
1447
1451
|
if (subscribedPlayersInGuild.length > 0) {
|
|
@@ -1452,22 +1456,28 @@ async function apply(ctx, config) {
|
|
|
1452
1456
|
})
|
|
1453
1457
|
)
|
|
1454
1458
|
);
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1459
|
+
const lastMatches = queryRes.data.data.players.map((player) => player.matches[0]).filter((item, index, self) => index === self.findIndex((t) => t.id === item.id)).filter((match) => !pendingMatches.some((pendingMatch) => pendingMatch.matchId == match.id));
|
|
1460
|
+
const sendedMatchesIds = (await ctx.database.get("dt_sended_match_id", { matchId: lastMatches.map((match) => match.id) }, ["matchId"])).map((match) => match.matchId);
|
|
1461
|
+
lastMatches.filter((match) => !sendedMatchesIds.includes(match.id)).forEach((match) => {
|
|
1462
|
+
const tempGuilds = [];
|
|
1463
|
+
match.players.forEach((player) => {
|
|
1464
|
+
const subscribedPlayer = subscribedPlayersInGuild.find((subscribedPlayer2) => subscribedPlayer2.steamId === player.steamAccount.id);
|
|
1465
|
+
if (subscribedPlayer) {
|
|
1466
|
+
const tempGuild = tempGuilds.find((guild) => guild.guildId == subscribedPlayer.guildId && guild.platform == subscribedPlayer.platform);
|
|
1467
|
+
if (tempGuild)
|
|
1468
|
+
tempGuild.players.push(subscribedPlayer);
|
|
1469
|
+
else
|
|
1470
|
+
tempGuilds.push({ guildId: subscribedPlayer.guildId, platform: subscribedPlayer.platform, players: [subscribedPlayer] });
|
|
1465
1471
|
}
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1472
|
+
});
|
|
1473
|
+
pendingMatches.push({ matchId: match.id, guilds: tempGuilds });
|
|
1474
|
+
ctx.logger.info(
|
|
1475
|
+
tempGuilds.map((guild) => `追踪到来自群组${guild.platform}:${guild.guildId}的用户${guild.players.map((player) => `[${player.nickName ?? ""}(${player.steamId})]`).join("、")}的尚未播报过的最新比赛 ${match.id}。`).join("")
|
|
1476
|
+
);
|
|
1477
|
+
});
|
|
1468
1478
|
}
|
|
1469
|
-
if (
|
|
1470
|
-
const pendingMatch =
|
|
1479
|
+
if (pendingMatches.length > 0) {
|
|
1480
|
+
const pendingMatch = pendingMatches[0];
|
|
1471
1481
|
try {
|
|
1472
1482
|
let match;
|
|
1473
1483
|
let queryLocal = await ctx.database.get("dt_previous_query_results", pendingMatch.matchId, ["data"]);
|
|
@@ -1481,13 +1491,11 @@ async function apply(ctx, config) {
|
|
|
1481
1491
|
}
|
|
1482
1492
|
}
|
|
1483
1493
|
if (match.parsedDateTime || import_moment.default.unix(match.startDateTime).isBefore((0, import_moment.default)().subtract(1, "years"))) {
|
|
1484
|
-
|
|
1485
|
-
const realCommingMatches = commingMatches.filter((commingMatch, index, self) => index === self.findIndex((t) => t.guildId === commingMatch.guildId && t.platform === commingMatch.platform));
|
|
1486
|
-
let broadMatchMessage = "";
|
|
1494
|
+
pendingMatches = pendingMatches.filter((item) => item.matchId != match.id);
|
|
1487
1495
|
const img = await ctx.puppeteer.render(genImageHTML(match, config.template_match, "match" /* Match */));
|
|
1488
|
-
for (let
|
|
1489
|
-
let
|
|
1490
|
-
let idsToFind =
|
|
1496
|
+
for (let commingGuild of pendingMatch.guilds) {
|
|
1497
|
+
let broadMatchMessage = "";
|
|
1498
|
+
let idsToFind = commingGuild.players.map((player) => player.steamId);
|
|
1491
1499
|
let broadPlayers = match.players.filter((item) => idsToFind.includes(item.steamAccountId));
|
|
1492
1500
|
for (let player of broadPlayers) {
|
|
1493
1501
|
let broadPlayerMessage = `${player.steamAccount.name}的${random.pick(HEROES_CHINESE[player.hero.id])}`;
|
|
@@ -1506,7 +1514,7 @@ async function apply(ctx, config) {
|
|
|
1506
1514
|
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)}%`;
|
|
1507
1515
|
broadMatchMessage += broadPlayerMessage + "\n";
|
|
1508
1516
|
}
|
|
1509
|
-
await ctx.broadcast([`${
|
|
1517
|
+
await ctx.broadcast([`${commingGuild.platform}:${commingGuild.guildId}`], broadMatchMessage + img);
|
|
1510
1518
|
}
|
|
1511
1519
|
ctx.database.upsert("dt_previous_query_results", (row) => [{ matchId: match.id, data: match, queryTime: /* @__PURE__ */ new Date() }]);
|
|
1512
1520
|
ctx.database.create("dt_sended_match_id", { matchId: match.id, sendTime: /* @__PURE__ */ new Date() });
|
package/package.json
CHANGED
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
.player.full .info > .name > .nick_name {
|
|
44
44
|
font-size: 18px;
|
|
45
45
|
line-height: 24px;
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
|
+
.player.full .info > .name >p{
|
|
48
|
+
display: flex;justify-content: space-around;
|
|
49
|
+
}
|
|
47
50
|
.player.full .last_match_date {
|
|
48
51
|
position: relative;
|
|
49
52
|
padding-top: 1px;
|
|
@@ -73,12 +76,12 @@
|
|
|
73
76
|
width: 150px;
|
|
74
77
|
height: 36px;
|
|
75
78
|
border-radius: 36px;
|
|
76
|
-
padding:
|
|
79
|
+
padding: 0 6px;
|
|
77
80
|
display: flex;
|
|
78
81
|
box-sizing: border-box;
|
|
79
82
|
align-items: center;
|
|
80
83
|
flex-direction: row;
|
|
81
|
-
justify-content: space-
|
|
84
|
+
justify-content: space-between;
|
|
82
85
|
}
|
|
83
86
|
.player.full .last10match .match.win {
|
|
84
87
|
background-color: #006400;
|
|
@@ -119,12 +122,12 @@
|
|
|
119
122
|
let playerInMatch = match.players.find(player=>player.steamAccount.id==user.steamId)
|
|
120
123
|
return `
|
|
121
124
|
<div class="match ${match.didRadiantWin==playerInMatch.isRadiant?"win":"lose"}">
|
|
122
|
-
<img src="${utils.getImageUrl(playerInMatch.hero.shortName
|
|
125
|
+
<img src="${utils.getImageUrl(playerInMatch.hero.shortName,ImageType.HeroIcons)}" alt="" />
|
|
123
126
|
<span>${playerInMatch.kills}/${playerInMatch.deaths}/${playerInMatch.assists}</span>
|
|
124
127
|
<span>${(playerInMatch.imp > 0 ? "+" : "") + playerInMatch.imp}</span>
|
|
125
128
|
</div>`}).join("")}
|
|
126
129
|
</div>`:0}
|
|
127
|
-
<div class="last_match_date">最近游戏: ${user.matches[0].startDateTime}</div>
|
|
130
|
+
<div class="last_match_date">最近游戏: ${moment(new Date(user.matches[0].startDateTime * 1000)).format("YYYY-MM-DD HH:mm:ss")}</div>
|
|
128
131
|
</div>`).join("")
|
|
129
132
|
%>
|
|
130
133
|
</body>
|