koishi-plugin-starfx-bot 0.18.0 → 0.18.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.
package/lib/index.js CHANGED
@@ -308,8 +308,9 @@ async function getImageFromUrl(ctx, url) {
308
308
  }
309
309
  __name(getImageFromUrl, "getImageFromUrl");
310
310
  async function atNotSayReply(cfg, session, elements) {
311
- if ((cfg.atNotSay || cfg.atNotSayOther) && elements.length === 1 && elements[0].type === "at") {
312
- const isAtSelf = elements[0].attrs.id === session.selfId;
311
+ const trimElements = elements.filter((e) => !(e.type === "text" && /^\s*$/.test(e.attrs.content)));
312
+ if ((cfg.atNotSay || cfg.atNotSayOther) && trimElements.length === 1 && trimElements[0].type === "at") {
313
+ const isAtSelf = trimElements[0].attrs.id === session.selfId;
313
314
  if (isAtSelf && cfg.atNotSay && import_koishi.Random.bool(cfg.atNotSayProperty)) {
314
315
  await session.send(session.text("middleware.messages.atNotReply"));
315
316
  } else if (!isAtSelf && cfg.atNotSayOther && import_koishi.Random.bool(cfg.atNotSayOtherProperty)) {
@@ -621,6 +622,58 @@ __name(ready, "ready");
621
622
  // src/index.ts
622
623
  var import_node_path2 = __toESM(require("node:path"));
623
624
  var import_mime_types = __toESM(require("mime-types"));
625
+
626
+ // package.json
627
+ var package_default = {
628
+ name: "koishi-plugin-starfx-bot",
629
+ description: "StarFreedomX机器人的小功能,自用",
630
+ contributors: [
631
+ "StarFreedomX <starfreedomx@outlook.com>"
632
+ ],
633
+ version: "0.18.2",
634
+ main: "lib/index.js",
635
+ typings: "lib/index.d.ts",
636
+ files: [
637
+ "lib",
638
+ "dist",
639
+ "assets"
640
+ ],
641
+ license: "MIT",
642
+ homepage: "https://github.com/StarFreedomX/starfx-bot",
643
+ repository: {
644
+ type: "git",
645
+ url: "git+https://github.com/StarFreedomX/starfx-bot.git"
646
+ },
647
+ scripts: {},
648
+ keywords: [
649
+ "chatbot",
650
+ "koishi",
651
+ "plugin"
652
+ ],
653
+ koishi: {
654
+ description: {
655
+ zh: "starfx的机器人小插件,自用"
656
+ },
657
+ service: {},
658
+ preview: true,
659
+ hidden: false
660
+ },
661
+ peerDependencies: {
662
+ koishi: "^4.18.7"
663
+ },
664
+ dependencies: {
665
+ axios: "^1.9.0",
666
+ cheerio: "^1.0.0",
667
+ "http-proxy-agent": "^7.0.2",
668
+ "https-proxy-agent": "^7.0.6",
669
+ jimp: "^1.6.0",
670
+ "mime-types": "^3.0.1",
671
+ "rss-parser": "^3.13.0",
672
+ sharp: "^0.34.1"
673
+ }
674
+ };
675
+
676
+ // src/index.ts
624
677
  var name = "starfx-bot";
625
678
  var baseDir;
626
679
  var assetsDir;
@@ -937,19 +990,34 @@ function apply(ctx, cfg) {
937
990
  });
938
991
  if (process.env.NODE_ENV === "development") {
939
992
  ctx.command("test").action(async ({ session }) => {
993
+ await session.send(" d d ");
994
+ });
995
+ ctx.middleware(async (session, next) => {
996
+ return next();
940
997
  });
941
998
  }
942
999
  function initAssets() {
943
- const fromUrl = `${__dirname}/../assets`;
944
- assetsDir = `${ctx.baseDir}/data/starfx-bot/assets`;
945
- if (!fs2.existsSync(fromUrl)) return;
946
- if (!fs2.readdirSync(fromUrl)?.length) return;
947
- if (!fs2.existsSync(assetsDir)) {
948
- fs2.mkdirSync(assetsDir, { recursive: true });
1000
+ const defaultAssetsDir = import_node_path2.default.join(__dirname, "../assets");
1001
+ assetsDir = import_node_path2.default.join(ctx.baseDir, "data/starfx-bot/assets");
1002
+ if (!fs2.existsSync(assetsDir)) fs2.mkdirSync(assetsDir, { recursive: true });
1003
+ const versionFile = import_node_path2.default.join(assetsDir, "plugin_version.json");
1004
+ let localVersion = "0";
1005
+ if (fs2.existsSync(versionFile)) {
1006
+ try {
1007
+ localVersion = JSON.parse(fs2.readFileSync(versionFile, "utf-8")).version || "0";
1008
+ } catch {
1009
+ }
949
1010
  }
950
- fs2.cpSync(fromUrl, assetsDir, { recursive: true, force: true });
951
- if (process.env.NODE_ENV !== "development") {
952
- fs2.rmSync(fromUrl, { recursive: true });
1011
+ const pluginVersion = package_default.version;
1012
+ if (pluginVersion > localVersion) {
1013
+ try {
1014
+ if (fs2.existsSync(defaultAssetsDir)) {
1015
+ fs2.cpSync(defaultAssetsDir, assetsDir, { recursive: true, force: true });
1016
+ }
1017
+ fs2.writeFileSync(versionFile, JSON.stringify({ version: pluginVersion }));
1018
+ } catch (err) {
1019
+ console.error("initAssets copy failed:", err);
1020
+ }
953
1021
  }
954
1022
  }
955
1023
  __name(initAssets, "initAssets");
package/lib/utils.d.ts CHANGED
@@ -80,14 +80,14 @@ export declare function handleBanGDreamConfig(options: any): Promise<{
80
80
  * @param baseImage 被封印的图片url
81
81
  * @return 画完的图片 h对象
82
82
  */
83
- export declare function drawLock(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
83
+ export declare function drawLock(ctx: Context, baseImage: string): Promise<h | "输入无效" | "发生错误">;
84
84
  /**
85
85
  * "卖掉了"绘图函数
86
86
  * @param ctx
87
87
  * @param baseImage
88
88
  * @return 画完的图片 h对象
89
89
  */
90
- export declare function drawSold(ctx: Context, baseImage: string): Promise<"发生错误" | "输入无效" | h>;
90
+ export declare function drawSold(ctx: Context, baseImage: string): Promise<h | "输入无效" | "发生错误">;
91
91
  /**
92
92
  * 从url下载图片并返回sharp对象
93
93
  * @param ctx Context
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.18.0",
7
+ "version": "0.18.2",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
package/readme.md CHANGED
@@ -20,7 +20,7 @@ StarFreedomX机器人的小功能,自用
20
20
 
21
21
  ## List to Do
22
22
 
23
- * 修改BanG Dream!边框的绘制为使用sharp,加快速度
23
+ * 修改BanG Dream!边框的绘制为使用sharp等库,加快速度
24
24
 
25
25
  ## 语录tag可视化控制
26
26
 
@@ -107,3 +107,5 @@ StarFreedomX机器人的小功能,自用
107
107
  | `0.17.0` | 语录功能新增链接,可以配置权重 |
108
108
  | `0.17.1` | 修复语录链接跨群bug |
109
109
  | `0.18.0` | 新增定时echo |
110
+ | `0.18.1` | 修复艾特不说话功能 |
111
+ | `0.18.2` | 不直接操作插件目录,防止更新问题 |