koishi-plugin-cocoyyy-console 1.0.14-beta.6 → 1.0.14
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 +49 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1143,6 +1143,35 @@ async function get_person_list(guild_id) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
1145
|
__name(get_person_list, "get_person_list");
|
|
1146
|
+
async function instead_person(guild_id, source_uid, target_uid) {
|
|
1147
|
+
try {
|
|
1148
|
+
const Rbq = getRbqPersonModel();
|
|
1149
|
+
const existed = await findGuildRecord(guild_id);
|
|
1150
|
+
if (!existed) {
|
|
1151
|
+
throw new Error("not found record in " + guild_id);
|
|
1152
|
+
}
|
|
1153
|
+
let uidList = existed.get("uid_list");
|
|
1154
|
+
if (uidList == null) {
|
|
1155
|
+
throw new Error("not found source_uid in " + guild_id);
|
|
1156
|
+
}
|
|
1157
|
+
let list = uidList.split(";");
|
|
1158
|
+
if (!list.includes(source_uid)) {
|
|
1159
|
+
throw new Error("not found source_uid in " + guild_id);
|
|
1160
|
+
}
|
|
1161
|
+
if (list.includes(target_uid)) {
|
|
1162
|
+
throw new Error("target_uid already in rbqlist");
|
|
1163
|
+
}
|
|
1164
|
+
uidList = uidList.replaceAll(source_uid, target_uid);
|
|
1165
|
+
existed.set("uid_list", uidList);
|
|
1166
|
+
await existed.save();
|
|
1167
|
+
personMap.set(guild_id, uidList.split(";"));
|
|
1168
|
+
return { result: true, error: null };
|
|
1169
|
+
} catch (e) {
|
|
1170
|
+
logger.error("[instead_person Error]: " + e?.message || String(e));
|
|
1171
|
+
return { result: false, error: e?.message || String(e) };
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
__name(instead_person, "instead_person");
|
|
1146
1175
|
function get_person_map() {
|
|
1147
1176
|
return personMap;
|
|
1148
1177
|
}
|
|
@@ -1237,11 +1266,19 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1237
1266
|
return `${target_uid}不在当前群聊中`;
|
|
1238
1267
|
}
|
|
1239
1268
|
logger.info(`[rbqinstead] info: input_uid: ${session.uid}, sourceId: ${source_uid}, targetId: ${target_uid}, botId: ${session.selfId}`);
|
|
1240
|
-
if (target_uid == session.selfId) {
|
|
1241
|
-
let new_target = session.uid;
|
|
1242
|
-
|
|
1243
|
-
|
|
1269
|
+
if (target_uid == session.selfId || target_uid == "2440587103") {
|
|
1270
|
+
let new_target = session.uid.replace("onebot:", "").toString();
|
|
1271
|
+
if (new_target == source_uid) {
|
|
1272
|
+
return "自救不了一点,乖乖挨草!";
|
|
1273
|
+
}
|
|
1274
|
+
exec = await instead_person(session.guildId, source_uid, new_target);
|
|
1275
|
+
if (!exec.result)
|
|
1276
|
+
return `替换rbq失败:${exec.error}`;
|
|
1277
|
+
return "倒反天罡!进去吧你,已替换rbq:\n" + (0, import_koishi8.h)("at", { id: source_uid }) + " -> " + (0, import_koishi8.h)("at", { id: new_target });
|
|
1244
1278
|
}
|
|
1279
|
+
exec = await instead_person(session.guildId, source_uid, target_uid);
|
|
1280
|
+
if (!exec.result)
|
|
1281
|
+
return `替换rbq失败:${exec.error}`;
|
|
1245
1282
|
return (0, import_koishi8.h)("p", "已替换rbq:", (0, import_koishi8.h)("at", { id: source_uid }), " -> ", (0, import_koishi8.h)("at", { id: target_uid }));
|
|
1246
1283
|
});
|
|
1247
1284
|
ctx.command("rbqadd_txt <参数>", "添加自定义文本").action(async ({ session }, ...args) => {
|
|
@@ -1266,7 +1303,9 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1266
1303
|
});
|
|
1267
1304
|
ctx.middleware(async (session, next) => {
|
|
1268
1305
|
const { guildId, elements } = session;
|
|
1306
|
+
let user_id = session.uid.replace("onebot:", "").toString();
|
|
1269
1307
|
if (ctx.bots[session.uid]) return next();
|
|
1308
|
+
if (ctx.bots[user_id]) return next();
|
|
1270
1309
|
const personMap2 = get_person_map();
|
|
1271
1310
|
const rbqList = personMap2.get(guildId);
|
|
1272
1311
|
if (!rbqList || rbqList.length === 0) return next();
|
|
@@ -1504,7 +1543,8 @@ async function checkUserToken(qq_uid) {
|
|
|
1504
1543
|
}
|
|
1505
1544
|
__name(checkUserToken, "checkUserToken");
|
|
1506
1545
|
async function getToken(session, mobile, code) {
|
|
1507
|
-
|
|
1546
|
+
let user_id = session.uid.replace("onebot:", "").toString();
|
|
1547
|
+
const existed = await checkUserToken(user_id);
|
|
1508
1548
|
if (existed) {
|
|
1509
1549
|
return { status: true, data: existed };
|
|
1510
1550
|
}
|
|
@@ -1531,7 +1571,7 @@ async function getToken(session, mobile, code) {
|
|
|
1531
1571
|
return { status: false, msg: available_response.msg };
|
|
1532
1572
|
}
|
|
1533
1573
|
const userInfo = {
|
|
1534
|
-
qq_uid:
|
|
1574
|
+
qq_uid: user_id,
|
|
1535
1575
|
user_id: user_response.data.data.userId,
|
|
1536
1576
|
user_name: user_response.data.data.userName,
|
|
1537
1577
|
role_id: game_response.data.roleId,
|
|
@@ -1540,7 +1580,7 @@ async function getToken(session, mobile, code) {
|
|
|
1540
1580
|
bat: available_response.data
|
|
1541
1581
|
};
|
|
1542
1582
|
createUpdateUser(userInfo);
|
|
1543
|
-
userTokenMap.set(
|
|
1583
|
+
userTokenMap.set(user_id, userInfo);
|
|
1544
1584
|
logger.info(`[getToken Info]: 验证码登录成功,库街区用户: ${user_response.data.data.userName}`);
|
|
1545
1585
|
return { status: true, data: userInfo };
|
|
1546
1586
|
} catch (error) {
|
|
@@ -1697,7 +1737,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
1697
1737
|
if (!is_at_bot(session)) return;
|
|
1698
1738
|
}
|
|
1699
1739
|
try {
|
|
1700
|
-
const result = await signIn(session.uid);
|
|
1740
|
+
const result = await signIn(session.uid.replace("onebot:", "").toString());
|
|
1701
1741
|
if (result.status) {
|
|
1702
1742
|
return "库街区签到成功";
|
|
1703
1743
|
} else {
|
|
@@ -1715,7 +1755,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
1715
1755
|
}
|
|
1716
1756
|
if (!roleName) {
|
|
1717
1757
|
try {
|
|
1718
|
-
const result = await getRoleData(session.uid);
|
|
1758
|
+
const result = await getRoleData(session.uid.replace("onebot:", "").toString());
|
|
1719
1759
|
if (result.status) {
|
|
1720
1760
|
return result.data;
|
|
1721
1761
|
} else {
|