koishi-plugin-cocoyyy-console 1.0.17 → 1.1.0-beta.0
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.d.ts +2 -1
- package/lib/index.js +101 -62
- package/lib/services/game_func/game_command.d.ts +6 -0
- package/lib/services/game_func/game_service.d.ts +6 -0
- package/lib/services/son_func/shit_or_not_command.d.ts +2 -1
- package/lib/services/son_func/shit_or_not_service.d.ts +2 -2
- package/lib/utils/common.d.ts +2 -1
- package/lib/utils/config.d.ts +2 -0
- package/lib/utils/configs/ai_config.d.ts +8 -0
- package/lib/utils/configs/function_config.d.ts +1 -0
- package/lib/utils/configs/game_config.d.ts +6 -0
- package/lib/utils/configs/son_config.d.ts +0 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export declare const name = "cocoyyy-console";
|
|
|
4
4
|
export declare let dev_mode: boolean;
|
|
5
5
|
export interface Config {
|
|
6
6
|
function_config?: my_config.FunctionConfig;
|
|
7
|
-
|
|
7
|
+
ai_config?: my_config.AiAPIConfig;
|
|
8
8
|
mysql_config?: my_config.MysqlConfig;
|
|
9
9
|
tag_config?: my_config.SaveConfig;
|
|
10
10
|
repeat_config?: my_config.RepeatConfig;
|
|
11
11
|
son_config?: my_config.ShitOrNotConfig;
|
|
12
|
+
game_config?: my_config.GameConfig;
|
|
12
13
|
test?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare const Config: Schema<Config>;
|
package/lib/index.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
savePath: () => savePath
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
|
-
var
|
|
41
|
+
var import_koishi12 = require("koishi");
|
|
42
42
|
|
|
43
43
|
// src/utils/configs/function_config.ts
|
|
44
44
|
var import_koishi = require("koishi");
|
|
@@ -48,6 +48,7 @@ var FunctionConfigSchema = import_koishi.Schema.object({
|
|
|
48
48
|
repeat_flag: import_koishi.Schema.boolean().default(true).description("复读功能是否启用"),
|
|
49
49
|
rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用"),
|
|
50
50
|
son_flag: import_koishi.Schema.boolean().default(true).description("鉴别史消息功能是否启用"),
|
|
51
|
+
game_flag: import_koishi.Schema.boolean().default(true).description("游戏功能是否启用"),
|
|
51
52
|
kuro_flag: import_koishi.Schema.boolean().default(true).description("鸣潮功能是否启用")
|
|
52
53
|
});
|
|
53
54
|
|
|
@@ -90,12 +91,23 @@ var RedisConfigSchema = import_koishi5.Schema.object({
|
|
|
90
91
|
// src/utils/configs/son_config.ts
|
|
91
92
|
var import_koishi6 = require("koishi");
|
|
92
93
|
var ShitOrNotConfigSchema = import_koishi6.Schema.object({
|
|
93
|
-
api_url: import_koishi6.Schema.string().default("").description("Api接口Url"),
|
|
94
|
-
api_model: import_koishi6.Schema.string().default("").description("AI模型"),
|
|
95
|
-
api_key: import_koishi6.Schema.string().default("").description("API Key"),
|
|
96
94
|
config_path: import_koishi6.Schema.string().default("").description("配置文件路径")
|
|
97
95
|
});
|
|
98
96
|
|
|
97
|
+
// src/utils/configs/game_config.ts
|
|
98
|
+
var import_koishi7 = require("koishi");
|
|
99
|
+
var GameConfigSchema = import_koishi7.Schema.object({
|
|
100
|
+
config_path: import_koishi7.Schema.string().default("").description("配置文件路径")
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// src/utils/configs/ai_config.ts
|
|
104
|
+
var import_koishi8 = require("koishi");
|
|
105
|
+
var AiAPIConfigSchema = import_koishi8.Schema.object({
|
|
106
|
+
api_url: import_koishi8.Schema.string().default("").description("Api接口Url"),
|
|
107
|
+
api_model: import_koishi8.Schema.string().default("").description("AI模型"),
|
|
108
|
+
api_key: import_koishi8.Schema.string().default("").description("API Key")
|
|
109
|
+
});
|
|
110
|
+
|
|
99
111
|
// src/infra/mysql_init.ts
|
|
100
112
|
var import_sequelize = require("sequelize");
|
|
101
113
|
var sequelize = null;
|
|
@@ -259,6 +271,9 @@ function getImgsModel() {
|
|
|
259
271
|
__name(getImgsModel, "getImgsModel");
|
|
260
272
|
|
|
261
273
|
// src/utils/common.ts
|
|
274
|
+
var import_fs = require("fs");
|
|
275
|
+
var yaml = __toESM(require("js-yaml"));
|
|
276
|
+
var import_path = __toESM(require("path"));
|
|
262
277
|
function is_at_bot(session) {
|
|
263
278
|
const elements = Array.isArray(session?.elements) ? session.elements : [];
|
|
264
279
|
const atElement = elements.find((element) => element?.type === "at");
|
|
@@ -282,6 +297,27 @@ function decodeHtmlEntities(text) {
|
|
|
282
297
|
});
|
|
283
298
|
}
|
|
284
299
|
__name(decodeHtmlEntities, "decodeHtmlEntities");
|
|
300
|
+
function loadYamlConfig(configPath) {
|
|
301
|
+
if (!configPath) {
|
|
302
|
+
logger.error("[loadYamlConfig Error]: SON 配置文件路径未配置");
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const trimmedPath = configPath.trim();
|
|
307
|
+
const fullPath = import_path.default.isAbsolute(trimmedPath) ? trimmedPath : import_path.default.resolve(process.cwd(), trimmedPath);
|
|
308
|
+
if (!(0, import_fs.existsSync)(fullPath)) {
|
|
309
|
+
logger.error(`[loadYamlConfig Error]: SON 配置文件不存在: ${fullPath}`);
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
const fileContent = (0, import_fs.readFileSync)(fullPath, "utf-8");
|
|
313
|
+
const config = yaml.load(fileContent);
|
|
314
|
+
return config;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
logger.error(`[loadYamlConfig Error]: SON 读取配置文件失败: ${configPath}`, error);
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
__name(loadYamlConfig, "loadYamlConfig");
|
|
285
321
|
|
|
286
322
|
// src/services/menu_service.ts
|
|
287
323
|
var menuList = [
|
|
@@ -305,6 +341,11 @@ var menuList = [
|
|
|
305
341
|
description: "shit_or_not功能,用于鉴别史消息",
|
|
306
342
|
command: "无"
|
|
307
343
|
},
|
|
344
|
+
{
|
|
345
|
+
name: "game",
|
|
346
|
+
description: "游戏功能,用于游玩游戏",
|
|
347
|
+
command: "无"
|
|
348
|
+
},
|
|
308
349
|
{
|
|
309
350
|
name: "kuro",
|
|
310
351
|
description: "库洛相关功能,用于鸣潮相关功能",
|
|
@@ -332,6 +373,10 @@ function getMenuList(command = null, functionConfig) {
|
|
|
332
373
|
if (!functionConfig.son_flag)
|
|
333
374
|
return "son功能已关闭";
|
|
334
375
|
return getSonFuncMenu(command);
|
|
376
|
+
case "game":
|
|
377
|
+
if (!functionConfig.game_flag)
|
|
378
|
+
return "游戏功能已关闭";
|
|
379
|
+
return getGameFuncMenu(command);
|
|
335
380
|
case "kuro":
|
|
336
381
|
if (!functionConfig.kuro_flag)
|
|
337
382
|
return "库洛相关功能已关闭";
|
|
@@ -441,6 +486,25 @@ son功能菜单:
|
|
|
441
486
|
输入对应指令使用son功能,如果遇到问题请联系开发人员。`;
|
|
442
487
|
}
|
|
443
488
|
__name(getSonFuncMenu, "getSonFuncMenu");
|
|
489
|
+
var gameFuncMenuList = [
|
|
490
|
+
{
|
|
491
|
+
name: "gamelist",
|
|
492
|
+
description: "查看son判断模式列表",
|
|
493
|
+
command: "sonlist"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: "game",
|
|
497
|
+
description: "开始游戏",
|
|
498
|
+
command: "game [游戏]"
|
|
499
|
+
}
|
|
500
|
+
];
|
|
501
|
+
function getGameFuncMenu(command = null) {
|
|
502
|
+
return `[所有命令都需要@bot]
|
|
503
|
+
游戏功能菜单:
|
|
504
|
+
${gameFuncMenuList.map((item) => item.command + ": " + item.description).join("\n ")}
|
|
505
|
+
输入对应指令使用游戏功能,如果遇到问题请联系开发人员。`;
|
|
506
|
+
}
|
|
507
|
+
__name(getGameFuncMenu, "getGameFuncMenu");
|
|
444
508
|
var kuroFuncMenuList = [
|
|
445
509
|
{
|
|
446
510
|
name: "login",
|
|
@@ -473,17 +537,17 @@ function registerMenuCommands(ctx, connected, functionConfig) {
|
|
|
473
537
|
__name(registerMenuCommands, "registerMenuCommands");
|
|
474
538
|
|
|
475
539
|
// src/services/tag_func/tag_commands.ts
|
|
476
|
-
var
|
|
540
|
+
var import_koishi10 = require("koishi");
|
|
477
541
|
|
|
478
542
|
// src/services/tag_func/tag_service.ts
|
|
479
543
|
var import_sequelize4 = require("sequelize");
|
|
480
|
-
var
|
|
481
|
-
var
|
|
544
|
+
var import_fs3 = require("fs");
|
|
545
|
+
var import_path3 = require("path");
|
|
482
546
|
|
|
483
547
|
// src/services/tag_func/img_service.ts
|
|
484
|
-
var
|
|
485
|
-
var
|
|
486
|
-
var
|
|
548
|
+
var import_koishi9 = require("koishi");
|
|
549
|
+
var import_path2 = require("path");
|
|
550
|
+
var import_fs2 = require("fs");
|
|
487
551
|
async function loadImageFromUrl(ctx, url) {
|
|
488
552
|
try {
|
|
489
553
|
const responseArrayBuffer = await ctx.http.get(url, {
|
|
@@ -512,7 +576,7 @@ async function saveImg(ctx, tag_name, guild_id, imgurl, savePath2) {
|
|
|
512
576
|
if (savePath2 == null) {
|
|
513
577
|
throw new Error("saving path config wrong!");
|
|
514
578
|
}
|
|
515
|
-
let dir = (0,
|
|
579
|
+
let dir = (0, import_path2.join)(savePath2, String(tag.get("id")));
|
|
516
580
|
const now = new Date(Date.now() + 8 * 60 * 60 * 1e3);
|
|
517
581
|
const srcMatch = imgurl.match(/src="([^"]+)"/);
|
|
518
582
|
if (!srcMatch) throw new Error("invalid img tag, no src found!");
|
|
@@ -526,8 +590,8 @@ async function saveImg(ctx, tag_name, guild_id, imgurl, savePath2) {
|
|
|
526
590
|
const fileNameMatch = imgurl.match(/file="([^"]+)"/);
|
|
527
591
|
if (!fileNameMatch) throw new Error("invalid img tag, no file name found!");
|
|
528
592
|
const fileName = fileNameMatch[1];
|
|
529
|
-
const filePath = (0,
|
|
530
|
-
await
|
|
593
|
+
const filePath = (0, import_path2.join)(dir, fileName);
|
|
594
|
+
await import_fs2.promises.writeFile(filePath, imageBuffer);
|
|
531
595
|
const saveImg2 = await Img.create({ tag_id: tag.get("id"), img_url: filePath, createtime: now });
|
|
532
596
|
logger.info("[saveImg Info]: save image to '" + tag_name + "' success");
|
|
533
597
|
return { result: true, error: null };
|
|
@@ -556,7 +620,7 @@ async function randomImgByTag(tag_name, guild_id) {
|
|
|
556
620
|
if (ImgList.length <= 0) {
|
|
557
621
|
throw new Error("Don't have image!");
|
|
558
622
|
}
|
|
559
|
-
const random = new
|
|
623
|
+
const random = new import_koishi9.Random(() => Math.random());
|
|
560
624
|
let result = ImgList[random.int(0, ImgList.length)];
|
|
561
625
|
const filePath = result.get("img_url");
|
|
562
626
|
return filePath;
|
|
@@ -665,8 +729,8 @@ async function createorUpdateTag(tag_name, guild_id, savePath2) {
|
|
|
665
729
|
}
|
|
666
730
|
const now = new Date(Date.now() + 8 * 60 * 60 * 1e3);
|
|
667
731
|
const tag = await Tag.create({ tags: tag_name, alias: null, guild_id, createtime: now });
|
|
668
|
-
const dir = (0,
|
|
669
|
-
(0,
|
|
732
|
+
const dir = (0, import_path3.join)(savePath2, String(tag.id));
|
|
733
|
+
(0, import_fs3.mkdirSync)(dir, { recursive: true });
|
|
670
734
|
return { result: true, error: null };
|
|
671
735
|
} catch (e) {
|
|
672
736
|
logger.error("[createorUpdateTag Error]: " + e?.message || String(e));
|
|
@@ -801,7 +865,7 @@ function registerTagCommands(ctx, connected, savePath2) {
|
|
|
801
865
|
if (!exec)
|
|
802
866
|
return `获取图片失败`;
|
|
803
867
|
let path2 = (0, import_url.pathToFileURL)(exec).href;
|
|
804
|
-
return
|
|
868
|
+
return import_koishi10.h.image(path2);
|
|
805
869
|
});
|
|
806
870
|
ctx.command("bind <参数>", "标签绑定别名").action(async ({ session }, ...args) => {
|
|
807
871
|
if (!dev_mode) {
|
|
@@ -944,7 +1008,7 @@ function registerRepeatMiddleware(ctx, config) {
|
|
|
944
1008
|
__name(registerRepeatMiddleware, "registerRepeatMiddleware");
|
|
945
1009
|
|
|
946
1010
|
// src/services/rbq_func/rbq_command.ts
|
|
947
|
-
var
|
|
1011
|
+
var import_koishi11 = require("koishi");
|
|
948
1012
|
|
|
949
1013
|
// src/models/rbq_persons.ts
|
|
950
1014
|
var import_sequelize5 = require("sequelize");
|
|
@@ -1269,7 +1333,7 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1269
1333
|
if (!list || list.length === 0) {
|
|
1270
1334
|
return "当前群聊还没有设置任何rbq";
|
|
1271
1335
|
}
|
|
1272
|
-
return "当前群聊rbq列表:\n" + list.map((item) => (0,
|
|
1336
|
+
return "当前群聊rbq列表:\n" + list.map((item) => (0, import_koishi11.h)("at", { id: item })).join(",");
|
|
1273
1337
|
});
|
|
1274
1338
|
ctx.command("rbqadd <参数>", "添加rbq").action(async ({ session }, ...args) => {
|
|
1275
1339
|
if (!dev_mode) {
|
|
@@ -1287,7 +1351,7 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1287
1351
|
exec = await create_person(session.guildId, uid);
|
|
1288
1352
|
if (!exec.result)
|
|
1289
1353
|
return `添加rbq失败: ${exec.error}`;
|
|
1290
|
-
return "已添加rbq:" + (0,
|
|
1354
|
+
return "已添加rbq:" + (0, import_koishi11.h)("at", { id: uid });
|
|
1291
1355
|
});
|
|
1292
1356
|
ctx.command("rbqinstead <参数>", "替换rbq").action(async ({ session }, ...args) => {
|
|
1293
1357
|
if (!dev_mode) {
|
|
@@ -1312,12 +1376,12 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1312
1376
|
exec = await instead_person(session.guildId, source_uid, new_target);
|
|
1313
1377
|
if (!exec.result)
|
|
1314
1378
|
return `替换rbq失败:${exec.error}`;
|
|
1315
|
-
return "倒反天罡!进去吧你,已替换rbq:\n" + (0,
|
|
1379
|
+
return "倒反天罡!进去吧你,已替换rbq:\n" + (0, import_koishi11.h)("at", { id: source_uid }) + " -> " + (0, import_koishi11.h)("at", { id: new_target });
|
|
1316
1380
|
}
|
|
1317
1381
|
exec = await instead_person(session.guildId, source_uid, target_uid);
|
|
1318
1382
|
if (!exec.result)
|
|
1319
1383
|
return `替换rbq失败:${exec.error}`;
|
|
1320
|
-
return (0,
|
|
1384
|
+
return (0, import_koishi11.h)("p", "已替换rbq:", (0, import_koishi11.h)("at", { id: source_uid }), " -> ", (0, import_koishi11.h)("at", { id: target_uid }));
|
|
1321
1385
|
});
|
|
1322
1386
|
ctx.command("rbqadd_txt <参数>", "添加自定义文本").action(async ({ session }, ...args) => {
|
|
1323
1387
|
if (!dev_mode) {
|
|
@@ -1344,10 +1408,10 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1344
1408
|
const contents = await get_content_list(session.guildId, target_uid);
|
|
1345
1409
|
let content2 = "*死你";
|
|
1346
1410
|
if (contents && contents.length > 0) {
|
|
1347
|
-
const random = new
|
|
1411
|
+
const random = new import_koishi11.Random(() => Math.random());
|
|
1348
1412
|
content2 = contents[random.int(0, contents.length)];
|
|
1349
1413
|
}
|
|
1350
|
-
return (0,
|
|
1414
|
+
return (0, import_koishi11.h)("at", { id: target_uid }) + "还想自己加文本?!\n" + content2;
|
|
1351
1415
|
} catch (error) {
|
|
1352
1416
|
logger.error("[rbq rbqadd_txt] Error:", error);
|
|
1353
1417
|
return "不能给自己设置文本,请输入其他qq号";
|
|
@@ -1377,10 +1441,10 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1377
1441
|
const contents = await get_content_list(guildId, matchedUid);
|
|
1378
1442
|
let content = "*死你";
|
|
1379
1443
|
if (contents && contents.length > 0) {
|
|
1380
|
-
const random = new
|
|
1444
|
+
const random = new import_koishi11.Random(() => Math.random());
|
|
1381
1445
|
content = contents[random.int(0, contents.length)];
|
|
1382
1446
|
}
|
|
1383
|
-
return (0,
|
|
1447
|
+
return (0, import_koishi11.h)("at", { id: matchedUid }) + " " + content;
|
|
1384
1448
|
} catch (error) {
|
|
1385
1449
|
logger.error("[rbq middleware] Error:", error);
|
|
1386
1450
|
return next();
|
|
@@ -1424,11 +1488,6 @@ function registerTestCommands(ctx, config) {
|
|
|
1424
1488
|
}
|
|
1425
1489
|
__name(registerTestCommands, "registerTestCommands");
|
|
1426
1490
|
|
|
1427
|
-
// src/services/son_func/shit_or_not_command.ts
|
|
1428
|
-
var import_fs3 = require("fs");
|
|
1429
|
-
var yaml = __toESM(require("js-yaml"));
|
|
1430
|
-
var import_path3 = __toESM(require("path"));
|
|
1431
|
-
|
|
1432
1491
|
// src/services/son_func/shit_or_not_service.ts
|
|
1433
1492
|
var import_tesseract2 = require("tesseract.js");
|
|
1434
1493
|
|
|
@@ -1503,7 +1562,7 @@ function extractImageAndText(content) {
|
|
|
1503
1562
|
__name(extractImageAndText, "extractImageAndText");
|
|
1504
1563
|
async function checkShitOrNot(session, parttern_msg, config) {
|
|
1505
1564
|
chatHistory = [];
|
|
1506
|
-
chatHistory.push({ role: "
|
|
1565
|
+
chatHistory.push({ role: "system", content: [{ type: "text", text: parttern_msg }] });
|
|
1507
1566
|
const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1508
1567
|
if (err != null) {
|
|
1509
1568
|
logger.error("[callOpenRouter Error 1]: " + err);
|
|
@@ -1533,9 +1592,9 @@ __name(checkShitOrNot, "checkShitOrNot");
|
|
|
1533
1592
|
// src/services/son_func/shit_or_not_command.ts
|
|
1534
1593
|
var local_config = null;
|
|
1535
1594
|
var think_flag = false;
|
|
1536
|
-
function registerShitOrNotCommands(ctx,
|
|
1537
|
-
if (
|
|
1538
|
-
local_config = loadYamlConfig(
|
|
1595
|
+
function registerShitOrNotCommands(ctx, ai_config, son_config) {
|
|
1596
|
+
if (son_config?.config_path) {
|
|
1597
|
+
local_config = loadYamlConfig(son_config.config_path);
|
|
1539
1598
|
if (local_config) {
|
|
1540
1599
|
logger.info("[loadYamlConfig Info]: SON 成功加载配置文件");
|
|
1541
1600
|
} else {
|
|
@@ -1570,7 +1629,7 @@ son判断模式列表:
|
|
|
1570
1629
|
await session.send("已收到,正在品鉴中...");
|
|
1571
1630
|
think_flag = true;
|
|
1572
1631
|
try {
|
|
1573
|
-
let exec = await checkShitOrNot(session, parttern_msg,
|
|
1632
|
+
let exec = await checkShitOrNot(session, parttern_msg, ai_config);
|
|
1574
1633
|
if (exec == null) return "品鉴失败,请查看日志";
|
|
1575
1634
|
return exec;
|
|
1576
1635
|
} finally {
|
|
@@ -1579,27 +1638,6 @@ son判断模式列表:
|
|
|
1579
1638
|
});
|
|
1580
1639
|
}
|
|
1581
1640
|
__name(registerShitOrNotCommands, "registerShitOrNotCommands");
|
|
1582
|
-
function loadYamlConfig(configPath) {
|
|
1583
|
-
if (!configPath) {
|
|
1584
|
-
logger.error("[loadYamlConfig Error]: SON 配置文件路径未配置");
|
|
1585
|
-
return null;
|
|
1586
|
-
}
|
|
1587
|
-
try {
|
|
1588
|
-
const trimmedPath = configPath.trim();
|
|
1589
|
-
const fullPath = import_path3.default.isAbsolute(trimmedPath) ? trimmedPath : import_path3.default.resolve(process.cwd(), trimmedPath);
|
|
1590
|
-
if (!(0, import_fs3.existsSync)(fullPath)) {
|
|
1591
|
-
logger.error(`[loadYamlConfig Error]: SON 配置文件不存在: ${fullPath}`);
|
|
1592
|
-
return null;
|
|
1593
|
-
}
|
|
1594
|
-
const fileContent = (0, import_fs3.readFileSync)(fullPath, "utf-8");
|
|
1595
|
-
const config = yaml.load(fileContent);
|
|
1596
|
-
return config;
|
|
1597
|
-
} catch (error) {
|
|
1598
|
-
logger.error(`[loadYamlConfig Error]: SON 读取配置文件失败: ${configPath}`, error);
|
|
1599
|
-
return null;
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
__name(loadYamlConfig, "loadYamlConfig");
|
|
1603
1641
|
function extractAtId(content) {
|
|
1604
1642
|
const match = content.match(/<at\b[^>]*id=["']?(\d+)["']?[^>]*>/i);
|
|
1605
1643
|
return match ? match[1] : null;
|
|
@@ -2032,16 +2070,17 @@ __name(registerKuroCommands, "registerKuroCommands");
|
|
|
2032
2070
|
// src/index.ts
|
|
2033
2071
|
var name = "cocoyyy-console";
|
|
2034
2072
|
var dev_mode;
|
|
2035
|
-
var Config =
|
|
2073
|
+
var Config = import_koishi12.Schema.object({
|
|
2036
2074
|
function_config: FunctionConfigSchema.description("功能开关配置"),
|
|
2037
|
-
|
|
2075
|
+
ai_config: AiAPIConfigSchema.description("AI API配置"),
|
|
2038
2076
|
mysql_config: MysqlConfigSchema.description("MySQL 数据库配置"),
|
|
2039
2077
|
tag_config: SaveConfigSchema.description("tag图片保存配置"),
|
|
2040
2078
|
repeat_config: RepeatConfigSchema.description("复读配置"),
|
|
2041
2079
|
son_config: ShitOrNotConfigSchema.description("SON配置"),
|
|
2042
|
-
|
|
2080
|
+
game_config: GameConfigSchema.description("游戏配置"),
|
|
2081
|
+
test: import_koishi12.Schema.string().description("测试")
|
|
2043
2082
|
});
|
|
2044
|
-
var logger = new
|
|
2083
|
+
var logger = new import_koishi12.Logger(name);
|
|
2045
2084
|
var savePath = null;
|
|
2046
2085
|
async function apply(ctx, config) {
|
|
2047
2086
|
ctx = ctx.guild();
|
|
@@ -2062,7 +2101,7 @@ async function apply(ctx, config) {
|
|
|
2062
2101
|
if (config.function_config.repeat_flag)
|
|
2063
2102
|
registerRepeatMiddleware(ctx, config?.repeat_config);
|
|
2064
2103
|
if (config.function_config.son_flag)
|
|
2065
|
-
registerShitOrNotCommands(ctx, config?.son_config);
|
|
2104
|
+
registerShitOrNotCommands(ctx, config?.ai_config, config?.son_config);
|
|
2066
2105
|
if (config.function_config.rbq_flag)
|
|
2067
2106
|
registerRbqCommands(ctx, connected);
|
|
2068
2107
|
if (config.function_config)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { GameConfig } from '../../utils/configs/game_config';
|
|
3
|
+
import { AiAPIConfig } from '../../utils/config';
|
|
4
|
+
declare function registerGameCommands(ctx: Context, game_config: GameConfig, ai_config: AiAPIConfig): void;
|
|
5
|
+
declare function registerGameMiddleware(ctx: Context, ai_config: AiAPIConfig): void;
|
|
6
|
+
export { registerGameCommands, registerGameMiddleware, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AiAPIConfig } from "../../utils/config";
|
|
2
|
+
declare let is_gaming: boolean;
|
|
3
|
+
declare function startSituationPuzzle(config: AiAPIConfig): Promise<string>;
|
|
4
|
+
declare function questSituationPuzzle(content: string, config: AiAPIConfig): Promise<any>;
|
|
5
|
+
declare function endSituationPuzzle(config: AiAPIConfig): Promise<string>;
|
|
6
|
+
export { is_gaming, startSituationPuzzle, questSituationPuzzle, endSituationPuzzle };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
2
|
import { ShitOrNotConfig } from '../../utils/config';
|
|
3
|
-
|
|
3
|
+
import { AiAPIConfig } from '../../utils/configs/ai_config';
|
|
4
|
+
declare function registerShitOrNotCommands(ctx: Context, ai_config: AiAPIConfig, son_config: ShitOrNotConfig): void;
|
|
4
5
|
export { registerShitOrNotCommands };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Session } from 'koishi';
|
|
2
|
-
import {
|
|
2
|
+
import { AiAPIConfig } from '../../utils/configs/ai_config';
|
|
3
3
|
declare function ocrImage(buffer: Buffer): Promise<string>;
|
|
4
|
-
declare function checkShitOrNot(session: Session, parttern_msg: string, config:
|
|
4
|
+
declare function checkShitOrNot(session: Session, parttern_msg: string, config: AiAPIConfig): Promise<string>;
|
|
5
5
|
export { checkShitOrNot, ocrImage };
|
package/lib/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
declare function is_at_bot(session: any): boolean;
|
|
2
2
|
declare function decodeHtmlEntities(text: string): string;
|
|
3
|
-
|
|
3
|
+
declare function loadYamlConfig(configPath: string): any;
|
|
4
|
+
export { is_at_bot, decodeHtmlEntities, loadYamlConfig };
|
package/lib/utils/config.d.ts
CHANGED