@sjtdev/koishi-plugin-dota2tracker 1.1.4 → 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.
Files changed (2) hide show
  1. package/lib/index.js +34 -1
  2. package/package.json +1 -1
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";
@@ -1470,6 +1475,34 @@ async function apply(ctx, config) {
1470
1475
  return heroes3.find((hero) => hero.names_cn.includes(input) || hero.shortName === input.toLowerCase() || hero.id == input);
1471
1476
  }
1472
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
+ });
1473
1506
  ctx.on("ready", async () => {
1474
1507
  const tables = await ctx.database.tables;
1475
1508
  if (!("dt_subscribed_guilds" in tables)) {
@@ -1575,7 +1608,7 @@ async function apply(ctx, config) {
1575
1608
  })
1576
1609
  )
1577
1610
  );
1578
- 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));
1579
1612
  const sendedMatchesIds = (await ctx.database.get("dt_sended_match_id", { matchId: lastMatches.map((match) => match.id) }, ["matchId"])).map((match) => match.matchId);
1580
1613
  lastMatches.filter((match) => !sendedMatchesIds.includes(match.id)).forEach((match) => {
1581
1614
  const tempGuilds = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjtdev/koishi-plugin-dota2tracker",
3
3
  "description": "",
4
- "version": "1.1.4",
4
+ "version": "1.1.5-beta.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [