koishi-plugin-cocoyyy-console 1.0.9-beta.2 → 1.0.9-beta.3

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 +11 -8
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1265,10 +1265,12 @@ ${list.join(",")}`;
1265
1265
  const content = args?.[0];
1266
1266
  const target_uid = args?.[1] ?? null;
1267
1267
  if (!content) return "请提供正确格式,如:@bot rbqadd_txt [文本] [目标QQ号(可选)]";
1268
- let exec = await check_in_group(ctx, session, target_uid);
1269
- if (!exec.result)
1270
- return `${target_uid}不在当前群聊中`;
1271
- exec = await create_content(session.guildId, content, target_uid);
1268
+ if (target_uid) {
1269
+ let exec2 = await check_in_group(ctx, session, target_uid);
1270
+ if (!exec2.result)
1271
+ return `${target_uid}不在当前群聊中`;
1272
+ }
1273
+ let exec = await create_content(session.guildId, content, target_uid);
1272
1274
  if (!exec.result)
1273
1275
  return `添加自定义文本失败:${exec.error}`;
1274
1276
  return "已添加自定义文本";
@@ -1284,18 +1286,19 @@ ${list.join(",")}`;
1284
1286
  const matchedUid = atElements.find((el) => {
1285
1287
  const targetUid = el.attrs?.id;
1286
1288
  return targetUid && rbqList.includes(targetUid);
1287
- })?.attrs?.id;
1289
+ })?.attrs?.id?.trim();
1288
1290
  if (!matchedUid) return next();
1289
1291
  try {
1290
1292
  const contents = await get_content_list(guildId, matchedUid);
1293
+ let content = "*死你";
1291
1294
  if (contents && contents.length > 0) {
1292
1295
  const random = new import_koishi8.Random(() => Math.random());
1293
- let result = contents[random.int(0, contents.length)];
1294
- session.send((0, import_koishi8.h)("at", { id: matchedUid }) + " " + result);
1296
+ content = contents[random.int(0, contents.length - 1)];
1295
1297
  }
1296
- return session.send((0, import_koishi8.h)("at", { id: matchedUid }) + " *死你");
1298
+ return session.send((0, import_koishi8.h)("at", { id: matchedUid }) + " " + content);
1297
1299
  } catch (error) {
1298
1300
  logger.error("[rbq middleware] Error:", error);
1301
+ return next();
1299
1302
  }
1300
1303
  });
1301
1304
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.0.9-beta.2",
4
+ "version": "1.0.9-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [