@sjtdev/koishi-plugin-dota2tracker 1.1.4 → 1.1.5-beta.2

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 +35 -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,35 @@ 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
+ await session.send("正在查询,请耐心等待……");
1481
+ const page = await ctx.puppeteer.page();
1482
+ await page.goto("https://www.dota2.com.cn/patches/7.36");
1483
+ 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)");
1484
+ const hero = findingHero(input_data);
1485
+ await page.evaluate((hero2) => {
1486
+ 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");
1487
+ for (const div of divs) {
1488
+ const firstChild = div.firstElementChild;
1489
+ if (firstChild && firstChild.tagName === "A" && firstChild.getAttribute("href") === "/hero/" + hero2.shortName) {
1490
+ div.classList.add("selector");
1491
+ }
1492
+ }
1493
+ return null;
1494
+ }, hero);
1495
+ const testE = await page.$("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.selector");
1496
+ const res = await testE.screenshot();
1497
+ const base64String = Buffer.from(res).toString("base64");
1498
+ const imgTag = `<img src="data:image/png;base64,${base64String}" alt="Image" />`;
1499
+ if (process.env.NODE_ENV === "development")
1500
+ import_fs2.default.writeFileSync("./node_modules/@sjtdev/koishi-plugin-dota2tracker/temp.png", res);
1501
+ session.send(imgTag);
1502
+ } else
1503
+ session.send("https://www.dota2.com.cn/patches/7.36");
1504
+ });
1505
+ ctx.command("test <input_data>").action(async ({ session }, input_data) => {
1506
+ });
1473
1507
  ctx.on("ready", async () => {
1474
1508
  const tables = await ctx.database.tables;
1475
1509
  if (!("dt_subscribed_guilds" in tables)) {
@@ -1575,7 +1609,7 @@ async function apply(ctx, config) {
1575
1609
  })
1576
1610
  )
1577
1611
  );
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));
1612
+ 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
1613
  const sendedMatchesIds = (await ctx.database.get("dt_sended_match_id", { matchId: lastMatches.map((match) => match.id) }, ["matchId"])).map((match) => match.matchId);
1580
1614
  lastMatches.filter((match) => !sendedMatchesIds.includes(match.id)).forEach((match) => {
1581
1615
  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.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [