koishi-plugin-cocoyyy-console 1.0.14-beta.4 → 1.0.14-beta.6
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 +5 -37
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1143,32 +1143,6 @@ 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");
|
|
1172
1146
|
function get_person_map() {
|
|
1173
1147
|
return personMap;
|
|
1174
1148
|
}
|
|
@@ -1228,8 +1202,7 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1228
1202
|
if (!list || list.length === 0) {
|
|
1229
1203
|
return "当前群聊还没有设置任何rbq";
|
|
1230
1204
|
}
|
|
1231
|
-
return
|
|
1232
|
-
${list.map((item) => (0, import_koishi8.h)("at", { id: item })).join(",")}`;
|
|
1205
|
+
return "当前群聊rbq列表:\n" + list.map((item) => (0, import_koishi8.h)("at", { id: item })).join(",");
|
|
1233
1206
|
});
|
|
1234
1207
|
ctx.command("rbqadd <参数>", "添加rbq").action(async ({ session }, ...args) => {
|
|
1235
1208
|
if (!dev_mode) {
|
|
@@ -1247,7 +1220,7 @@ ${list.map((item) => (0, import_koishi8.h)("at", { id: item })).join(",")}`;
|
|
|
1247
1220
|
exec = await create_person(session.guildId, uid);
|
|
1248
1221
|
if (!exec.result)
|
|
1249
1222
|
return `添加rbq失败: ${exec.error}`;
|
|
1250
|
-
return
|
|
1223
|
+
return "已添加rbq:" + (0, import_koishi8.h)("at", { id: uid });
|
|
1251
1224
|
});
|
|
1252
1225
|
ctx.command("rbqinstead <参数>", "替换rbq").action(async ({ session }, ...args) => {
|
|
1253
1226
|
if (!dev_mode) {
|
|
@@ -1266,15 +1239,10 @@ ${list.map((item) => (0, import_koishi8.h)("at", { id: item })).join(",")}`;
|
|
|
1266
1239
|
logger.info(`[rbqinstead] info: input_uid: ${session.uid}, sourceId: ${source_uid}, targetId: ${target_uid}, botId: ${session.selfId}`);
|
|
1267
1240
|
if (target_uid == session.selfId) {
|
|
1268
1241
|
let new_target = session.uid;
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
return `替换rbq失败:${exec.error}`;
|
|
1272
|
-
return `还想让我变rbq?进去吧你,已替换rbq:${(0, import_koishi8.h)("at", { id: source_uid })} -> ${(0, import_koishi8.h)("at", { id: new_target })}`;
|
|
1242
|
+
logger.info(`[rbqinstead] info: new_target: ${new_target}`);
|
|
1243
|
+
return "还想让我变rbq?进去吧你,已替换rbq:\n" + (0, import_koishi8.h)("at", { id: source_uid }) + " -> " + (0, import_koishi8.h)("at", { id: new_target });
|
|
1273
1244
|
}
|
|
1274
|
-
|
|
1275
|
-
if (!exec.result)
|
|
1276
|
-
return `替换rbq失败:${exec.error}`;
|
|
1277
|
-
return `已替换rbq:${(0, import_koishi8.h)("at", { id: source_uid })} -> ${(0, import_koishi8.h)("at", { id: target_uid })}`;
|
|
1245
|
+
return (0, import_koishi8.h)("p", "已替换rbq:", (0, import_koishi8.h)("at", { id: source_uid }), " -> ", (0, import_koishi8.h)("at", { id: target_uid }));
|
|
1278
1246
|
});
|
|
1279
1247
|
ctx.command("rbqadd_txt <参数>", "添加自定义文本").action(async ({ session }, ...args) => {
|
|
1280
1248
|
if (!dev_mode) {
|