koishi-plugin-cocoyyy-console 1.0.14-beta.6 → 1.0.14-beta.7
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 +43 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1143,6 +1143,32 @@ 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
|
+
uidList = uidList.replaceAll(source_uid, target_uid);
|
|
1162
|
+
existed.set("uid_list", uidList);
|
|
1163
|
+
await existed.save();
|
|
1164
|
+
personMap.set(guild_id, uidList.split(";"));
|
|
1165
|
+
return { result: true, error: null };
|
|
1166
|
+
} catch (e) {
|
|
1167
|
+
logger.error("[instead_person Error]: " + e?.message || String(e));
|
|
1168
|
+
return { result: false, error: e?.message || String(e) };
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
__name(instead_person, "instead_person");
|
|
1146
1172
|
function get_person_map() {
|
|
1147
1173
|
return personMap;
|
|
1148
1174
|
}
|
|
@@ -1237,11 +1263,16 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1237
1263
|
return `${target_uid}不在当前群聊中`;
|
|
1238
1264
|
}
|
|
1239
1265
|
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
|
-
|
|
1266
|
+
if (target_uid == session.selfId || target_uid == "2440587103") {
|
|
1267
|
+
let new_target = session.uid.replace("onebot:", "").toString();
|
|
1268
|
+
exec = await instead_person(session.guildId, source_uid, new_target);
|
|
1269
|
+
if (!exec.result)
|
|
1270
|
+
return `替换rbq失败:${exec.error}`;
|
|
1271
|
+
return "倒反天罡!进去吧你,已替换rbq:\n" + (0, import_koishi8.h)("at", { id: source_uid }) + " -> " + (0, import_koishi8.h)("at", { id: new_target });
|
|
1244
1272
|
}
|
|
1273
|
+
exec = await instead_person(session.guildId, source_uid, target_uid);
|
|
1274
|
+
if (!exec.result)
|
|
1275
|
+
return `替换rbq失败:${exec.error}`;
|
|
1245
1276
|
return (0, import_koishi8.h)("p", "已替换rbq:", (0, import_koishi8.h)("at", { id: source_uid }), " -> ", (0, import_koishi8.h)("at", { id: target_uid }));
|
|
1246
1277
|
});
|
|
1247
1278
|
ctx.command("rbqadd_txt <参数>", "添加自定义文本").action(async ({ session }, ...args) => {
|
|
@@ -1266,7 +1297,9 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1266
1297
|
});
|
|
1267
1298
|
ctx.middleware(async (session, next) => {
|
|
1268
1299
|
const { guildId, elements } = session;
|
|
1300
|
+
let user_id = session.uid.replace("onebot:", "").toString();
|
|
1269
1301
|
if (ctx.bots[session.uid]) return next();
|
|
1302
|
+
if (ctx.bots[user_id]) return next();
|
|
1270
1303
|
const personMap2 = get_person_map();
|
|
1271
1304
|
const rbqList = personMap2.get(guildId);
|
|
1272
1305
|
if (!rbqList || rbqList.length === 0) return next();
|
|
@@ -1504,7 +1537,8 @@ async function checkUserToken(qq_uid) {
|
|
|
1504
1537
|
}
|
|
1505
1538
|
__name(checkUserToken, "checkUserToken");
|
|
1506
1539
|
async function getToken(session, mobile, code) {
|
|
1507
|
-
|
|
1540
|
+
let user_id = session.uid.replace("onebot:", "").toString();
|
|
1541
|
+
const existed = await checkUserToken(user_id);
|
|
1508
1542
|
if (existed) {
|
|
1509
1543
|
return { status: true, data: existed };
|
|
1510
1544
|
}
|
|
@@ -1531,7 +1565,7 @@ async function getToken(session, mobile, code) {
|
|
|
1531
1565
|
return { status: false, msg: available_response.msg };
|
|
1532
1566
|
}
|
|
1533
1567
|
const userInfo = {
|
|
1534
|
-
qq_uid:
|
|
1568
|
+
qq_uid: user_id,
|
|
1535
1569
|
user_id: user_response.data.data.userId,
|
|
1536
1570
|
user_name: user_response.data.data.userName,
|
|
1537
1571
|
role_id: game_response.data.roleId,
|
|
@@ -1540,7 +1574,7 @@ async function getToken(session, mobile, code) {
|
|
|
1540
1574
|
bat: available_response.data
|
|
1541
1575
|
};
|
|
1542
1576
|
createUpdateUser(userInfo);
|
|
1543
|
-
userTokenMap.set(
|
|
1577
|
+
userTokenMap.set(user_id, userInfo);
|
|
1544
1578
|
logger.info(`[getToken Info]: 验证码登录成功,库街区用户: ${user_response.data.data.userName}`);
|
|
1545
1579
|
return { status: true, data: userInfo };
|
|
1546
1580
|
} catch (error) {
|
|
@@ -1697,7 +1731,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
1697
1731
|
if (!is_at_bot(session)) return;
|
|
1698
1732
|
}
|
|
1699
1733
|
try {
|
|
1700
|
-
const result = await signIn(session.uid);
|
|
1734
|
+
const result = await signIn(session.uid.replace("onebot:", "").toString());
|
|
1701
1735
|
if (result.status) {
|
|
1702
1736
|
return "库街区签到成功";
|
|
1703
1737
|
} else {
|
|
@@ -1715,7 +1749,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
1715
1749
|
}
|
|
1716
1750
|
if (!roleName) {
|
|
1717
1751
|
try {
|
|
1718
|
-
const result = await getRoleData(session.uid);
|
|
1752
|
+
const result = await getRoleData(session.uid.replace("onebot:", "").toString());
|
|
1719
1753
|
if (result.status) {
|
|
1720
1754
|
return result.data;
|
|
1721
1755
|
} else {
|