koishi-plugin-starfx-bot 0.17.0 → 0.18.0
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 +26 -13
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/index.js
CHANGED
|
@@ -73,11 +73,11 @@ async function addRecord(ctx, gid, avatarUrl) {
|
|
|
73
73
|
}
|
|
74
74
|
__name(addRecord, "addRecord");
|
|
75
75
|
async function getRecord(cfg, gid, tag) {
|
|
76
|
-
const
|
|
77
|
-
const links = cfg.recordLink;
|
|
76
|
+
const links = structuredClone(cfg.recordLink);
|
|
78
77
|
links[gid] = { linkGroup: gid, linkWeight: 100 };
|
|
79
78
|
const selectGid = getRandomLinkGroup(links).replaceAll(":", "_");
|
|
80
79
|
const recordDir = import_node_path.default.join(assetsDir, "record", selectGid);
|
|
80
|
+
const tagConfigPath = import_node_path.default.join(assetsDir, "tagConfig", `${selectGid}.json`);
|
|
81
81
|
if (!import_fs.default.existsSync(recordDir)) return null;
|
|
82
82
|
const files = import_fs.default.readdirSync(recordDir).filter((file) => /\.(png|jpe?g|webp|gif)$/i.test(file));
|
|
83
83
|
if (!files.length) return null;
|
|
@@ -717,20 +717,33 @@ function apply(ctx, cfg) {
|
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
if (cfg.echo) {
|
|
720
|
-
ctx.command("echo <params>").action(async ({ session }, params) => {
|
|
720
|
+
ctx.command("echo <params>").option("time", "-t <time: number> 指定时间(min)").action(async ({ session, options }, params) => {
|
|
721
721
|
if (detectControl(controlJson, session.guildId, "echo")) {
|
|
722
722
|
const elements = session.elements;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
723
|
+
const getEchoMessage = /* @__PURE__ */ __name(() => {
|
|
724
|
+
try {
|
|
725
|
+
while (elements[0].type === "at" || elements[0].type === "text" && !elements[0].attrs?.content.trim()) elements.shift();
|
|
726
|
+
elements[0].attrs.content = elements[0].attrs?.content.trim().split(/\s/).slice(1).join(" ");
|
|
727
|
+
elements.forEach((ele) => {
|
|
728
|
+
ele.attrs.content = ele.attrs?.content.trim().split(/\s/).filter((v, i, a) => v !== "-t" && a[i - 1] !== "-t").join(" ");
|
|
729
|
+
});
|
|
730
|
+
if (elements.length == 1 && !elements[0].attrs.content?.length) {
|
|
731
|
+
if (cfg.echoBanner?.some((banText) => session.quote?.content?.includes(banText))) return "包含屏蔽词,打断echo";
|
|
732
|
+
return session.quote?.elements;
|
|
733
|
+
}
|
|
734
|
+
if (cfg.echoBanner?.some((banText) => session.content?.includes(banText))) return "包含屏蔽词,打断echo";
|
|
735
|
+
return elements;
|
|
736
|
+
} catch (e) {
|
|
737
|
+
return params;
|
|
729
738
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return
|
|
739
|
+
}, "getEchoMessage");
|
|
740
|
+
const echoMessages = getEchoMessage();
|
|
741
|
+
if (!options?.time && options.time > 0) {
|
|
742
|
+
return echoMessages;
|
|
743
|
+
} else {
|
|
744
|
+
setTimeout(async () => {
|
|
745
|
+
await ctx.broadcast([session.gid], echoMessages);
|
|
746
|
+
}, options.time * 60 * 1e3);
|
|
734
747
|
}
|
|
735
748
|
}
|
|
736
749
|
});
|
package/package.json
CHANGED