@sjtdev/koishi-plugin-dota2tracker 1.2.5-fix3 → 1.2.5

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 CHANGED
@@ -1,6 +1,3 @@
1
- ### 1.2.5-fix
2
- **修复**:使用临时替代方案修复由koishi-4.17.9的bug引起的无法主动发送消息(播报战报等),待koishi更新修复后回滚此改动。
3
-
4
1
  ### 1.2.5
5
2
  **改进**:优化`查询玩家`图片中近期战绩列表内未解析比赛的显示效果
6
3
  **修复**:修复`查询英雄`图片技能属性名多显示了一个冒号的问题
package/lib/index.js CHANGED
@@ -1690,23 +1690,17 @@ async function apply(ctx, config) {
1690
1690
  }
1691
1691
  });
1692
1692
  const combinations = Array.from(combinationsMap.values());
1693
- try {
1694
- await sendMessageToChannel(
1695
- ctx,
1696
- guild,
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
- }
1693
+ await ctx.broadcast(
1694
+ [`${guild.platform}:${guild.guildId}`],
1695
+ `昨日总结:
1696
+ ${currentsubscribedPlayers.map(
1697
+ (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}`
1698
+ ).join("\n")}
1699
+ ${combinations.map((combi) => `组合[${combi.name}]: ${combi.winCount}胜${combi.matches.length - combi.winCount}负 胜率${Math.round(combi.winCount / combi.matches.length * 100)}%`).join("\n")}`.replace(
1700
+ /\s*\n\s*/g,
1701
+ "\n"
1702
+ )
1703
+ );
1710
1704
  }
1711
1705
  }
1712
1706
  });
@@ -1772,7 +1766,7 @@ async function apply(ctx, config) {
1772
1766
  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)}%`;
1773
1767
  broadMatchMessage += broadPlayerMessage + "\n";
1774
1768
  }
1775
- await sendMessageToChannel(ctx, commingGuild, broadMatchMessage + img);
1769
+ await ctx.broadcast([`${commingGuild.platform}:${commingGuild.guildId}`], broadMatchMessage + img);
1776
1770
  ctx.logger.info(`${match.id}${match.parsedDateTime ? "已解析," : "已结束超过1小时仍未被解析,放弃解析直接"}生成图片并发布于${commingGuild.platform}:${commingGuild.guildId}。`);
1777
1771
  }
1778
1772
  if (match.parsedDateTime)
@@ -1813,26 +1807,6 @@ function genImageHTML(data, template, type) {
1813
1807
  return result;
1814
1808
  }
1815
1809
  __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");
1836
1810
  // Annotate the CommonJS export names for ESM import in node:
1837
1811
  0 && (module.exports = {
1838
1812
  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.5-fix3",
4
+ "version": "1.2.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [