@sjtdev/koishi-plugin-dota2tracker 1.1.3 → 1.1.5-beta.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/lib/index.js +48 -2
- package/package.json +1 -1
- package/readme.md +2 -2
- package/template/player/player_1.ejs +15 -21
package/lib/index.js
CHANGED
|
@@ -52,6 +52,7 @@ __export(utils_exports, {
|
|
|
52
52
|
readDirectoryFilesSync: () => readDirectoryFilesSync,
|
|
53
53
|
roundToDecimalPlaces: () => roundToDecimalPlaces,
|
|
54
54
|
sec2time: () => sec2time,
|
|
55
|
+
testGetHtml: () => testGetHtml,
|
|
55
56
|
winRateColor: () => winRateColor
|
|
56
57
|
});
|
|
57
58
|
var import_axios = __toESM(require("axios"));
|
|
@@ -493,6 +494,10 @@ async function query(query_str) {
|
|
|
493
494
|
});
|
|
494
495
|
}
|
|
495
496
|
__name(query, "query");
|
|
497
|
+
async function testGetHtml(URL) {
|
|
498
|
+
return await import_axios.default.get(URL);
|
|
499
|
+
}
|
|
500
|
+
__name(testGetHtml, "testGetHtml");
|
|
496
501
|
var ImageType = /* @__PURE__ */ ((ImageType2) => {
|
|
497
502
|
ImageType2["Icons"] = "icons";
|
|
498
503
|
ImageType2["Heroes"] = "heroes";
|
|
@@ -1342,6 +1347,12 @@ async function apply(ctx, config) {
|
|
|
1342
1347
|
filteredDotaPlus[hero2.hero.id].matchCount = hero2.matchCount;
|
|
1343
1348
|
}
|
|
1344
1349
|
});
|
|
1350
|
+
player.rank = {
|
|
1351
|
+
medal: parseInt(player.steamAccount.seasonRank?.toString().split("")[0] ?? 0),
|
|
1352
|
+
star: parseInt(player.steamAccount.seasonRank?.toString().split("")[1] ?? 0),
|
|
1353
|
+
leaderboard: player.steamAccount.seasonLeaderboardRank,
|
|
1354
|
+
inTop100: player.steamAccount.seasonLeaderboardRank ? player.steamAccount.seasonLeaderboardRank <= 10 ? "8c" : player.steamAccount.seasonLeaderboardRank <= 100 ? "8b" : void 0 : void 0
|
|
1355
|
+
};
|
|
1345
1356
|
player.dotaPlus = Object.values(filteredDotaPlus);
|
|
1346
1357
|
player.dotaPlus.sort((a, b) => {
|
|
1347
1358
|
if (b.level !== a.level) {
|
|
@@ -1352,7 +1363,14 @@ async function apply(ctx, config) {
|
|
|
1352
1363
|
player.heroesPerformanceTop10 = playerExtra.heroesPerformance.slice(0, 10);
|
|
1353
1364
|
} else
|
|
1354
1365
|
throw 0;
|
|
1355
|
-
|
|
1366
|
+
if (hero) {
|
|
1367
|
+
const { matchCount, winCount, imp } = player.heroesPerformanceTop10[0];
|
|
1368
|
+
player.matchCount = matchCount;
|
|
1369
|
+
player.winCount = winCount;
|
|
1370
|
+
player.performance.imp = imp;
|
|
1371
|
+
player.dotaPlus = player.dotaPlus.filter((dpHero) => dpHero.heroId == hero.id);
|
|
1372
|
+
}
|
|
1373
|
+
player.genHero = hero;
|
|
1356
1374
|
session.send(await ctx.puppeteer.render(genImageHTML(player, config.template_player, "player" /* Player */)));
|
|
1357
1375
|
} catch (error) {
|
|
1358
1376
|
ctx.logger.error(error);
|
|
@@ -1457,6 +1475,34 @@ async function apply(ctx, config) {
|
|
|
1457
1475
|
return heroes3.find((hero) => hero.names_cn.includes(input) || hero.shortName === input.toLowerCase() || hero.id == input);
|
|
1458
1476
|
}
|
|
1459
1477
|
__name(findingHero, "findingHero");
|
|
1478
|
+
ctx.command("7.36 <input_data>", "查询7.36改动").usage("可查询英雄改动并生成图片返回").example("7.36 小松许").action(async ({ session }, input_data) => {
|
|
1479
|
+
if (input_data) {
|
|
1480
|
+
const page = await ctx.puppeteer.page();
|
|
1481
|
+
await page.goto("https://www.dota2.com/patches/7.36");
|
|
1482
|
+
await page.waitForSelector("body > div:nth-of-type(3) > div:first-of-type > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(5) > div:nth-of-type(2) > div:nth-of-type(1)");
|
|
1483
|
+
const hero = findingHero(input_data);
|
|
1484
|
+
await page.evaluate((hero2) => {
|
|
1485
|
+
const divs = document.querySelectorAll("body > div:nth-of-type(3) > div:first-of-type > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(5) > div:nth-of-type(2) > div");
|
|
1486
|
+
for (const div of divs) {
|
|
1487
|
+
const firstChild = div.firstElementChild;
|
|
1488
|
+
if (firstChild && firstChild.tagName === "A" && firstChild.getAttribute("href") === "/hero/" + hero2.shortName) {
|
|
1489
|
+
div.classList.add("selector");
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
return null;
|
|
1493
|
+
}, hero);
|
|
1494
|
+
const testE = await page.$("body > div:nth-of-type(2) > div:first-of-type > div:nth-of-type(2) > div:nth-of-type(3) > div:nth-of-type(5) > div:nth-of-type(2) > div.selector");
|
|
1495
|
+
const res = await testE.screenshot();
|
|
1496
|
+
const base64String = Buffer.from(res).toString("base64");
|
|
1497
|
+
const imgTag = `<img src="data:image/png;base64,${base64String}" alt="Image" />`;
|
|
1498
|
+
if (process.env.NODE_ENV === "development")
|
|
1499
|
+
import_fs2.default.writeFileSync("./node_modules/@sjtdev/koishi-plugin-dota2tracker/temp.png", res);
|
|
1500
|
+
session.send(imgTag);
|
|
1501
|
+
} else
|
|
1502
|
+
session.send("https://www.dota2.com/patches/7.36");
|
|
1503
|
+
});
|
|
1504
|
+
ctx.command("test <input_data>").action(async ({ session }, input_data) => {
|
|
1505
|
+
});
|
|
1460
1506
|
ctx.on("ready", async () => {
|
|
1461
1507
|
const tables = await ctx.database.tables;
|
|
1462
1508
|
if (!("dt_subscribed_guilds" in tables)) {
|
|
@@ -1562,7 +1608,7 @@ async function apply(ctx, config) {
|
|
|
1562
1608
|
})
|
|
1563
1609
|
)
|
|
1564
1610
|
);
|
|
1565
|
-
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));
|
|
1611
|
+
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) => import_moment.default.unix(match.startDateTime).isAfter((0, import_moment.default)().subtract(1, "days"))).filter((match) => !pendingMatches.some((pendingMatch) => pendingMatch.matchId == match.id));
|
|
1566
1612
|
const sendedMatchesIds = (await ctx.database.get("dt_sended_match_id", { matchId: lastMatches.map((match) => match.id) }, ["matchId"])).map((match) => match.matchId);
|
|
1567
1613
|
lastMatches.filter((match) => !sendedMatchesIds.includes(match.id)).forEach((match) => {
|
|
1568
1614
|
const tempGuilds = [];
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -25,8 +25,8 @@ DOTA2Bot插件-提供自动追踪群友的最新对局的功能(需群友绑
|
|
|
25
25
|
* <input type="checkbox" checked>`取消绑定`
|
|
26
26
|
* <input type="checkbox" checked>`改名 <新玩家别名>`
|
|
27
27
|
##### 查询
|
|
28
|
-
* <input type="checkbox" checked>`查询玩家 [SteamID|别名]`
|
|
29
|
-
|
|
28
|
+
* <input type="checkbox" checked>`查询玩家 [SteamID|别名] [<--hero|-o> <英雄ID|英雄名|英雄常用别名>]`
|
|
29
|
+
返回一张图片,包含玩家各类信息。(缺省参数时并且调用者已绑定将自查)(输入--hero或-o并跟上查询英雄的参数时,将查询玩家指定英雄)
|
|
30
30
|
* <input type="checkbox" checked>`查询比赛 <比赛ID>`
|
|
31
31
|
返回一张图片,包含比赛对战信息。
|
|
32
32
|
* <input type="checkbox" checked>`查询最近比赛 [SteamID|别名]`
|
|
@@ -410,12 +410,10 @@
|
|
|
410
410
|
<%- `
|
|
411
411
|
<div class="avatar"><img src="${player.steamAccount?.avatar}" alt="" /></div>
|
|
412
412
|
<div class="info">
|
|
413
|
-
<p class="name">${player.steamAccount.name}${player.guildMember ? ` <span class="guild ${guildLevel(player.guildMember.guild.currentPercentile)}">[${player.guildMember.guild.tag}]</span
|
|
414
|
-
<p class="matches"><span>场次:${player.matchCount}(<span class="win">${player.winCount}</span>/<span class="lose">${player.matchCount - player.winCount}</span>)</span>胜率:<span style="color:${utils.winRateColor(
|
|
415
|
-
player.winCount / player.matchCount
|
|
416
|
-
)};">${((player.winCount / player.matchCount) * 100).toFixed(2)}%</span></p>
|
|
413
|
+
<p class="name">${player.steamAccount.name}${player.guildMember ? ` <span class="guild ${guildLevel(player.guildMember.guild.currentPercentile)}">[${player.guildMember.guild.tag}]</span>${player.genHero?` >${player.genHero.names_cn[0]}<`:""}</p>` : ""}
|
|
414
|
+
<p class="matches"><span>场次:${player.matchCount}(<span class="win">${player.winCount}</span>/<span class="lose">${player.matchCount - player.winCount}</span>)</span>胜率:<span style="color:${utils.winRateColor(player.winCount / player.matchCount)};">${((player.winCount / player.matchCount) * 100).toFixed(2)}%</span></p>
|
|
417
415
|
<p class="matches"><span>最近25场:<span class="win">${nearWinCount}</span>/<span class="lose">${nearMatchCount - nearWinCount}</span></span><span>胜率:<span style="color:${utils.winRateColor(nearWinCount / nearMatchCount)};">${(
|
|
418
|
-
(nearWinCount / nearMatchCount) * 100).toFixed(2)}%</span></span><span>评分:${player.performance.imp}</span></span></p>
|
|
416
|
+
(nearWinCount / nearMatchCount) * 100).toFixed(2)}%</span></span><span>评分:${(player.performance.imp > 0 ? "+" : "") + player.performance.imp}</span></span></p>
|
|
419
417
|
<p class="matches"><span>对线:<span class="victory">${outcomeCounts.victory + outcomeCounts.stomp}(<span class="stomp">${outcomeCounts.stomp}</span>)</span>-<span class="tie">${outcomeCounts.tie}</span>-<span class="fail">${
|
|
420
418
|
outcomeCounts.fail + outcomeCounts.stomped
|
|
421
419
|
}(<span class="stomped">${outcomeCounts.stomped}</span>)</span></span><span>线优:<span style="color:${utils.winRateColor(
|
|
@@ -423,23 +421,17 @@
|
|
|
423
421
|
)};">${(((outcomeCounts.victory + outcomeCounts.stomp) / (outcomeCounts.victory + outcomeCounts.stomp + outcomeCounts.fail + outcomeCounts.stomped)) * 100).toFixed(2)}%</span></span></p>
|
|
424
422
|
</div>
|
|
425
423
|
<div class="rank">
|
|
426
|
-
<img class="medal" src="${utils.getImageUrl(
|
|
427
|
-
|
|
428
|
-
((player.steamAccount.seasonLeaderboardRank
|
|
429
|
-
? player.steamAccount.seasonLeaderboardRank <= 100
|
|
430
|
-
? player.steamAccount.seasonLeaderboardRank <= 10
|
|
431
|
-
? "8c"
|
|
432
|
-
: "8b"
|
|
433
|
-
: player.steamAccount.seasonRank?.toString().split("")[0]
|
|
434
|
-
: player.steamAccount.seasonRank?.toString().split("")[0]) ?? "0")
|
|
435
|
-
)}" alt="" />
|
|
436
|
-
<img class="star" src="${utils.getImageUrl("star_" + (player.steamAccount.seasonRank?.toString().split("")[1] ?? "0"))}" alt="" />
|
|
424
|
+
<img class="medal" src="${utils.getImageUrl('medal_' +(player.inTop100??player.rank.medal))}" alt="" />
|
|
425
|
+
<img class="star" src="${utils.getImageUrl('star_' + player.rank.star)}" alt="" />
|
|
437
426
|
<p>${player.steamAccount.seasonLeaderboardRank ?? ""}</p>
|
|
438
427
|
</div>` %>
|
|
439
428
|
</div>
|
|
440
429
|
<div class="hero_winrate">
|
|
441
430
|
<div class="heroes">
|
|
442
|
-
|
|
431
|
+
<%- !player.genHero ?
|
|
432
|
+
`<p class="tip row total">全期场次前十的英雄:</p>`:
|
|
433
|
+
`<p class="tip row total">全期场次:</p>`
|
|
434
|
+
%>
|
|
443
435
|
<span class="tip">英雄</span>
|
|
444
436
|
<span class="tip" style="margin: 0 4px">场次</span>
|
|
445
437
|
<span class="tip" style="margin: 0 4px">胜率</span>
|
|
@@ -454,7 +446,10 @@
|
|
|
454
446
|
<span class="imp">${(hero.imp > 0 ? "+" : "") + hero.imp}</span>
|
|
455
447
|
<span class="win" style="${hero.winCount == 0 ? "visibility:hidden;" : ""}width: ${hero.winCount * pixelOfPerMatchInTotal}px">${hero.winCount}</span>
|
|
456
448
|
<span class="lose" style="${hero.matchCount - hero.winCount == 0 ? "visibility:hidden;" : ""}width: ${(hero.matchCount - hero.winCount) * pixelOfPerMatchInTotal}px">${hero.matchCount - hero.winCount}</span>`).join("") %>
|
|
457
|
-
|
|
449
|
+
<%- !player.genHero ?
|
|
450
|
+
`<p class="tip row near">近期使用场次大于1的英雄:</p>`:
|
|
451
|
+
`<p class="tip row total">近25场:</p>`
|
|
452
|
+
%>
|
|
458
453
|
<%- player.heroesPerformance
|
|
459
454
|
.filter((hero) => hero.matchCount > 1)
|
|
460
455
|
.map((hero, index) => `
|
|
@@ -530,14 +525,13 @@
|
|
|
530
525
|
</tbody>
|
|
531
526
|
</table>
|
|
532
527
|
<div class="plus">
|
|
533
|
-
<%-
|
|
534
|
-
player.dotaPlus.map((hero) => `
|
|
528
|
+
<%- player.dotaPlus.map((hero) => `
|
|
535
529
|
<div class="hero">
|
|
536
530
|
<img src="${utils.getImageUrl(hero.shortName, ImageType.Heroes)}" alt="" />
|
|
537
531
|
<div class="level"><img src="${utils.getImageUrl("hero_badge_" + Math.ceil((hero.level + 1) / 6))}" alt="" /><span>${hero.level}</span></div>
|
|
538
532
|
<span>${((hero.winCount / hero.matchCount) * 100).toFixed(2)}%</span>
|
|
539
533
|
<span>${hero.matchCount}</span>
|
|
540
|
-
</div>`).join("")
|
|
534
|
+
</div>`).join("") %>
|
|
541
535
|
</div>
|
|
542
536
|
</div>
|
|
543
537
|
</body>
|