koishi-plugin-cocoyyy-console 1.0.16-beta.10 → 1.0.16-beta.11
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 +34 -31
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -300,6 +300,11 @@ var menuList = [
|
|
|
300
300
|
description: "*人功能,用于*人",
|
|
301
301
|
command: "无"
|
|
302
302
|
},
|
|
303
|
+
{
|
|
304
|
+
name: "son",
|
|
305
|
+
description: "shit_or_not功能,用于鉴别史消息",
|
|
306
|
+
command: "无"
|
|
307
|
+
},
|
|
303
308
|
{
|
|
304
309
|
name: "kuro",
|
|
305
310
|
description: "库洛相关功能,用于鸣潮相关功能",
|
|
@@ -1527,27 +1532,6 @@ __name(checkShitOrNot, "checkShitOrNot");
|
|
|
1527
1532
|
|
|
1528
1533
|
// src/services/son_func/shit_or_not_command.ts
|
|
1529
1534
|
var local_config = null;
|
|
1530
|
-
function loadYamlConfig(configPath) {
|
|
1531
|
-
if (!configPath) {
|
|
1532
|
-
logger.error("[loadYamlConfig Error]: SON 配置文件路径未配置");
|
|
1533
|
-
return null;
|
|
1534
|
-
}
|
|
1535
|
-
try {
|
|
1536
|
-
const trimmedPath = configPath.trim();
|
|
1537
|
-
const fullPath = import_path3.default.isAbsolute(trimmedPath) ? trimmedPath : import_path3.default.resolve(process.cwd(), trimmedPath);
|
|
1538
|
-
if (!(0, import_fs3.existsSync)(fullPath)) {
|
|
1539
|
-
logger.error(`[loadYamlConfig Error]: SON 配置文件不存在: ${fullPath}`);
|
|
1540
|
-
return null;
|
|
1541
|
-
}
|
|
1542
|
-
const fileContent = (0, import_fs3.readFileSync)(fullPath, "utf-8");
|
|
1543
|
-
const config = yaml.load(fileContent);
|
|
1544
|
-
return config;
|
|
1545
|
-
} catch (error) {
|
|
1546
|
-
logger.error(`[loadYamlConfig Error]: SON 读取配置文件失败: ${configPath}`, error);
|
|
1547
|
-
return null;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
__name(loadYamlConfig, "loadYamlConfig");
|
|
1551
1535
|
function registerShitOrNotCommands(ctx, config) {
|
|
1552
1536
|
if (config?.config_path) {
|
|
1553
1537
|
local_config = loadYamlConfig(config.config_path);
|
|
@@ -1586,6 +1570,32 @@ son判断模式列表:
|
|
|
1586
1570
|
});
|
|
1587
1571
|
}
|
|
1588
1572
|
__name(registerShitOrNotCommands, "registerShitOrNotCommands");
|
|
1573
|
+
function loadYamlConfig(configPath) {
|
|
1574
|
+
if (!configPath) {
|
|
1575
|
+
logger.error("[loadYamlConfig Error]: SON 配置文件路径未配置");
|
|
1576
|
+
return null;
|
|
1577
|
+
}
|
|
1578
|
+
try {
|
|
1579
|
+
const trimmedPath = configPath.trim();
|
|
1580
|
+
const fullPath = import_path3.default.isAbsolute(trimmedPath) ? trimmedPath : import_path3.default.resolve(process.cwd(), trimmedPath);
|
|
1581
|
+
if (!(0, import_fs3.existsSync)(fullPath)) {
|
|
1582
|
+
logger.error(`[loadYamlConfig Error]: SON 配置文件不存在: ${fullPath}`);
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
const fileContent = (0, import_fs3.readFileSync)(fullPath, "utf-8");
|
|
1586
|
+
const config = yaml.load(fileContent);
|
|
1587
|
+
return config;
|
|
1588
|
+
} catch (error) {
|
|
1589
|
+
logger.error(`[loadYamlConfig Error]: SON 读取配置文件失败: ${configPath}`, error);
|
|
1590
|
+
return null;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
__name(loadYamlConfig, "loadYamlConfig");
|
|
1594
|
+
function extractAtId(content) {
|
|
1595
|
+
const match = content.match(/<at\b[^>]*id=["']?(\d+)["']?[^>]*>/i);
|
|
1596
|
+
return match ? match[1] : null;
|
|
1597
|
+
}
|
|
1598
|
+
__name(extractAtId, "extractAtId");
|
|
1589
1599
|
function is_at_bot_quote(session) {
|
|
1590
1600
|
if (!session.quote)
|
|
1591
1601
|
return false;
|
|
@@ -1594,17 +1604,10 @@ function is_at_bot_quote(session) {
|
|
|
1594
1604
|
const quoteUserId = quote.user.id;
|
|
1595
1605
|
const quoteContent = quote.content;
|
|
1596
1606
|
const botId = session?.bot?.selfId ?? session?.selfId;
|
|
1597
|
-
logger.info(`command: quoteContent: ${quoteContent}, quoteUserId: ${quoteUserId},content: ${content} userId: ${userId}`);
|
|
1598
1607
|
const elements = quote.elements || [];
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
const atId = elem.attrs.id;
|
|
1603
|
-
if (String(atId) === String(botId)) {
|
|
1604
|
-
return true;
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
+
const atId = extractAtId(session.content);
|
|
1609
|
+
if (atId === botId)
|
|
1610
|
+
return true;
|
|
1608
1611
|
return false;
|
|
1609
1612
|
}
|
|
1610
1613
|
__name(is_at_bot_quote, "is_at_bot_quote");
|