koishi-plugin-cocoyyy-console 1.0.14-beta.7 → 1.0.15

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 +25 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1158,6 +1158,9 @@ async function instead_person(guild_id, source_uid, target_uid) {
1158
1158
  if (!list.includes(source_uid)) {
1159
1159
  throw new Error("not found source_uid in " + guild_id);
1160
1160
  }
1161
+ if (list.includes(target_uid)) {
1162
+ throw new Error("target_uid already in rbqlist");
1163
+ }
1161
1164
  uidList = uidList.replaceAll(source_uid, target_uid);
1162
1165
  existed.set("uid_list", uidList);
1163
1166
  await existed.save();
@@ -1265,6 +1268,9 @@ function registerRbqCommands(ctx, connected) {
1265
1268
  logger.info(`[rbqinstead] info: input_uid: ${session.uid}, sourceId: ${source_uid}, targetId: ${target_uid}, botId: ${session.selfId}`);
1266
1269
  if (target_uid == session.selfId || target_uid == "2440587103") {
1267
1270
  let new_target = session.uid.replace("onebot:", "").toString();
1271
+ if (new_target == source_uid) {
1272
+ return "自救不了一点,乖乖挨草!";
1273
+ }
1268
1274
  exec = await instead_person(session.guildId, source_uid, new_target);
1269
1275
  if (!exec.result)
1270
1276
  return `替换rbq失败:${exec.error}`;
@@ -1290,6 +1296,25 @@ function registerRbqCommands(ctx, connected) {
1290
1296
  return `${target_uid}不在当前群聊中`;
1291
1297
  }
1292
1298
  }
1299
+ let user_id = session.uid.replace("onebot:", "").toString();
1300
+ if (user_id == target_uid) {
1301
+ const personMap2 = get_person_map();
1302
+ const rbqList = personMap2.get(session.guildId);
1303
+ if (!rbqList || rbqList.length === 0) return "不能给自己设置文本,请输入其他qq号";
1304
+ if (!rbqList.includes(user_id)) return "不能给自己设置文本,请输入其他qq号";
1305
+ try {
1306
+ const contents = await get_content_list(session.guildId, target_uid);
1307
+ let content2 = "*死你";
1308
+ if (contents && contents.length > 0) {
1309
+ const random = new import_koishi8.Random(() => Math.random());
1310
+ content2 = contents[random.int(0, contents.length)];
1311
+ }
1312
+ return (0, import_koishi8.h)("at", { id: target_uid }) + "还想自己加文本?!\n" + content2;
1313
+ } catch (error) {
1314
+ logger.error("[rbq rbqadd_txt] Error:", error);
1315
+ return "不能给自己设置文本,请输入其他qq号";
1316
+ }
1317
+ }
1293
1318
  let exec = await create_content(session.guildId, content, target_uid);
1294
1319
  if (!exec.result)
1295
1320
  return `添加自定义文本失败:${exec.error}`;
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.14-beta.7",
4
+ "version": "1.0.15",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [