koishi-plugin-cocoyyy-console 1.0.9-beta.2 → 1.0.10
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
CHANGED
|
@@ -1233,9 +1233,12 @@ ${list.join(",")}`;
|
|
|
1233
1233
|
}
|
|
1234
1234
|
const uid = args?.[0];
|
|
1235
1235
|
if (!uid) return "请提供正确格式,如:@bot rbqadd [QQ号]";
|
|
1236
|
-
let exec =
|
|
1237
|
-
if (!
|
|
1238
|
-
|
|
1236
|
+
let exec = null;
|
|
1237
|
+
if (!dev_mode) {
|
|
1238
|
+
exec = await check_in_group(ctx, session, uid);
|
|
1239
|
+
if (!exec.result)
|
|
1240
|
+
return `${uid}不在当前群聊中`;
|
|
1241
|
+
}
|
|
1239
1242
|
exec = await create_person(session.guildId, uid);
|
|
1240
1243
|
if (!exec.result)
|
|
1241
1244
|
return `添加rbq失败:${exec.error}`;
|
|
@@ -1249,9 +1252,12 @@ ${list.join(",")}`;
|
|
|
1249
1252
|
const source_uid = args?.[0];
|
|
1250
1253
|
const target_uid = args?.[1];
|
|
1251
1254
|
if (!source_uid || !target_uid) return "请提供正确格式,如:@bot rbqinstead [已存在QQ号] [替换QQ号]";
|
|
1252
|
-
let exec =
|
|
1253
|
-
if (!
|
|
1254
|
-
|
|
1255
|
+
let exec = null;
|
|
1256
|
+
if (!dev_mode) {
|
|
1257
|
+
exec = await check_in_group(ctx, session, target_uid);
|
|
1258
|
+
if (!exec.result)
|
|
1259
|
+
return `${target_uid}不在当前群聊中`;
|
|
1260
|
+
}
|
|
1255
1261
|
exec = await instead_person(session.guildId, source_uid, target_uid);
|
|
1256
1262
|
if (!exec.result)
|
|
1257
1263
|
return `替换rbq失败:${exec.error}`;
|
|
@@ -1265,10 +1271,14 @@ ${list.join(",")}`;
|
|
|
1265
1271
|
const content = args?.[0];
|
|
1266
1272
|
const target_uid = args?.[1] ?? null;
|
|
1267
1273
|
if (!content) return "请提供正确格式,如:@bot rbqadd_txt [文本] [目标QQ号(可选)]";
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1274
|
+
if (!dev_mode) {
|
|
1275
|
+
if (target_uid) {
|
|
1276
|
+
let exec2 = await check_in_group(ctx, session, target_uid);
|
|
1277
|
+
if (!exec2.result)
|
|
1278
|
+
return `${target_uid}不在当前群聊中`;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
let exec = await create_content(session.guildId, content, target_uid);
|
|
1272
1282
|
if (!exec.result)
|
|
1273
1283
|
return `添加自定义文本失败:${exec.error}`;
|
|
1274
1284
|
return "已添加自定义文本";
|
|
@@ -1284,18 +1294,19 @@ ${list.join(",")}`;
|
|
|
1284
1294
|
const matchedUid = atElements.find((el) => {
|
|
1285
1295
|
const targetUid = el.attrs?.id;
|
|
1286
1296
|
return targetUid && rbqList.includes(targetUid);
|
|
1287
|
-
})?.attrs?.id;
|
|
1297
|
+
})?.attrs?.id?.trim();
|
|
1288
1298
|
if (!matchedUid) return next();
|
|
1289
1299
|
try {
|
|
1290
1300
|
const contents = await get_content_list(guildId, matchedUid);
|
|
1301
|
+
let content = "*死你";
|
|
1291
1302
|
if (contents && contents.length > 0) {
|
|
1292
1303
|
const random = new import_koishi8.Random(() => Math.random());
|
|
1293
|
-
|
|
1294
|
-
session.send((0, import_koishi8.h)("at", { id: matchedUid }) + " " + result);
|
|
1304
|
+
content = contents[random.int(0, contents.length - 1)];
|
|
1295
1305
|
}
|
|
1296
|
-
return
|
|
1306
|
+
return (0, import_koishi8.h)("at", { id: matchedUid }) + " " + content;
|
|
1297
1307
|
} catch (error) {
|
|
1298
1308
|
logger.error("[rbq middleware] Error:", error);
|
|
1309
|
+
return next();
|
|
1299
1310
|
}
|
|
1300
1311
|
});
|
|
1301
1312
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from "koishi";
|
|
2
|
+
declare function saveImg(ctx: Context, tag_name: string, imgurl: string, savePath: string): Promise<{
|
|
3
|
+
result: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
}>;
|
|
6
|
+
declare function randomImgByTag(tag_name: string): Promise<string | null>;
|
|
7
|
+
declare function getImgCountByTag(tag_id: number): Promise<number>;
|
|
8
|
+
export { saveImg, randomImgByTag, getImgCountByTag };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TagsModel } from '../models/tags';
|
|
2
|
+
declare function createorUpdateTag(tag_name: string, savePath?: string | null): Promise<{
|
|
3
|
+
result: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
}>;
|
|
6
|
+
declare function getTag(tag_name: string): Promise<TagsModel | null>;
|
|
7
|
+
declare function bindAlias(tag_name: string, alias: string): Promise<{
|
|
8
|
+
result: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
}>;
|
|
11
|
+
declare function unbindAlias(tag_name: string, alias: string): Promise<{
|
|
12
|
+
result: boolean;
|
|
13
|
+
error: string | null;
|
|
14
|
+
}>;
|
|
15
|
+
declare function getTagList(): Promise<{
|
|
16
|
+
tag: string;
|
|
17
|
+
alias: string;
|
|
18
|
+
count: number;
|
|
19
|
+
}[]>;
|
|
20
|
+
export { createorUpdateTag, getTag, bindAlias, unbindAlias, getTagList };
|