koishi-plugin-echo-cave 1.16.10 → 1.16.12
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/cqcode-helper.d.ts +1 -1
- package/lib/index.cjs +13 -29
- package/package.json +1 -1
package/lib/cqcode-helper.d.ts
CHANGED
package/lib/index.cjs
CHANGED
|
@@ -154,10 +154,9 @@ __export(index_exports, {
|
|
|
154
154
|
name: () => name
|
|
155
155
|
});
|
|
156
156
|
module.exports = __toCommonJS(index_exports);
|
|
157
|
-
var
|
|
157
|
+
var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
|
|
158
158
|
|
|
159
159
|
// src/cqcode-helper.ts
|
|
160
|
-
var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
|
|
161
160
|
function createTextMsg(content) {
|
|
162
161
|
return {
|
|
163
162
|
type: "text",
|
|
@@ -168,28 +167,8 @@ function createTextMsg(content) {
|
|
|
168
167
|
}
|
|
169
168
|
function parseUserIds(userIds) {
|
|
170
169
|
const parsedUserIds = [];
|
|
171
|
-
for (const
|
|
172
|
-
|
|
173
|
-
const cqCode = import_koishi_plugin_adapter_onebot.CQCode.from(userIdStr);
|
|
174
|
-
if (cqCode.type === "at") {
|
|
175
|
-
const qq = cqCode.data.qq;
|
|
176
|
-
if (qq === "all") {
|
|
177
|
-
return {
|
|
178
|
-
parsedUserIds: [],
|
|
179
|
-
error: "invalid_all_mention"
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (qq) {
|
|
183
|
-
parsedUserIds.push(qq);
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
const num = Number(userIdStr);
|
|
187
|
-
if (!Number.isNaN(num)) {
|
|
188
|
-
parsedUserIds.push(String(num));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
} catch (e) {
|
|
192
|
-
parsedUserIds.push(userIdStr.split(":")[1]);
|
|
170
|
+
for (const userId of userIds) {
|
|
171
|
+
if (userId) {
|
|
193
172
|
}
|
|
194
173
|
}
|
|
195
174
|
return {
|
|
@@ -543,7 +522,7 @@ async function processMessageContent(ctx, msg, cfg) {
|
|
|
543
522
|
}
|
|
544
523
|
|
|
545
524
|
// src/index.ts
|
|
546
|
-
var
|
|
525
|
+
var import_koishi_plugin_adapter_onebot2 = require("@pynickle/koishi-plugin-adapter-onebot");
|
|
547
526
|
var import_koishi = require("koishi");
|
|
548
527
|
var name = "echo-cave";
|
|
549
528
|
var inject = ["database"];
|
|
@@ -594,7 +573,14 @@ function apply(ctx, cfg) {
|
|
|
594
573
|
async ({ session }) => await getCaveListByOriginUser(ctx, session)
|
|
595
574
|
);
|
|
596
575
|
ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
|
|
597
|
-
async ({ session }, id, ...userIds) =>
|
|
576
|
+
async ({ session }, id, ...userIds) => {
|
|
577
|
+
ctx.logger.info(`Binding users ${JSON.stringify(userIds)} to cave ID ${id}`);
|
|
578
|
+
for (const uid of userIds) {
|
|
579
|
+
ctx.logger.info(`User ID to bind: ${uid}`);
|
|
580
|
+
ctx.logger.info(`userid type: ${typeof uid}`);
|
|
581
|
+
}
|
|
582
|
+
await bindUsersToCave(ctx, session, id, userIds);
|
|
583
|
+
}
|
|
598
584
|
);
|
|
599
585
|
}
|
|
600
586
|
async function getCaveListByUser(ctx, session) {
|
|
@@ -718,7 +704,6 @@ async function addCave(ctx, session, cfg, userIds) {
|
|
|
718
704
|
return session.text(".invalidAllMention");
|
|
719
705
|
}
|
|
720
706
|
parsedUserIds = result.parsedUserIds;
|
|
721
|
-
ctx.logger.info(`Parsed userIds in addCave: ${JSON.stringify(parsedUserIds)}`);
|
|
722
707
|
const isAllUsersInGroup = await checkUsersInGroup(ctx, session, parsedUserIds);
|
|
723
708
|
if (!isAllUsersInGroup) {
|
|
724
709
|
return session.text(".userNotInGroup");
|
|
@@ -740,7 +725,7 @@ async function addCave(ctx, session, cfg, userIds) {
|
|
|
740
725
|
const message = (await session.onebot.getMsg(messageId)).message;
|
|
741
726
|
let msgJson;
|
|
742
727
|
if (typeof message === "string") {
|
|
743
|
-
msgJson =
|
|
728
|
+
msgJson = import_koishi_plugin_adapter_onebot2.CQCode.parse(message);
|
|
744
729
|
} else {
|
|
745
730
|
if (message[0].type === "video" || message[0].type === "file") {
|
|
746
731
|
type = "forward";
|
|
@@ -785,7 +770,6 @@ async function bindUsersToCave(ctx, session, id, userIds) {
|
|
|
785
770
|
return session.text(".invalidAllMention");
|
|
786
771
|
}
|
|
787
772
|
parsedUserIds = result.parsedUserIds;
|
|
788
|
-
ctx.logger.info(`Parsed userIds: ${JSON.stringify(parsedUserIds)}`);
|
|
789
773
|
const caves = await ctx.database.get("echo_cave", id);
|
|
790
774
|
if (caves.length === 0) {
|
|
791
775
|
return session.text("echo-cave.general.noMsgWithId");
|