@napuketto/loader 0.2.0 → 0.3.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/dist/host/self-host.cjs +37 -4
- package/package.json +1 -1
package/dist/host/self-host.cjs
CHANGED
|
@@ -1358,7 +1358,7 @@ function handleControl(payload, onExit, onLogin) {
|
|
|
1358
1358
|
* ProtocolConfig 来源标注;seed 模式本就不读盘,协议段热更新在内联形态不可用)。
|
|
1359
1359
|
*
|
|
1360
1360
|
* 全局配置:**协议配置嵌在账号内**——accounts 数组每项含 [onebot11] / [satori] /
|
|
1361
|
-
* [kurobot] 段,登录成功后按账号 uin 找到对应项,取其段作 seed(zod 校验)。
|
|
1361
|
+
* [kurobot] / [milky] 段,登录成功后按账号 uin 找到对应项,取其段作 seed(zod 校验)。
|
|
1362
1362
|
* (ConfigBase seed 模式:load() 直接用内存值,不再读写独立协议文件)
|
|
1363
1363
|
*
|
|
1364
1364
|
* 内联分支宽松(解析失败回退文件形态并记日志,不阻塞引导):cli 主路径已在
|
|
@@ -1393,18 +1393,21 @@ function extractSections(accounts, uin) {
|
|
|
1393
1393
|
let ob11Section = {};
|
|
1394
1394
|
let satoriSection = {};
|
|
1395
1395
|
let kurobotSection = {};
|
|
1396
|
+
let milkySection = {};
|
|
1396
1397
|
if (Array.isArray(accounts)) {
|
|
1397
1398
|
const mine = accounts.find((item) => typeof item === "object" && item !== null && String(item["qq"]) === uin);
|
|
1398
1399
|
if (mine !== void 0) {
|
|
1399
1400
|
ob11Section = sectionOf(mine, "onebot11") ?? {};
|
|
1400
1401
|
satoriSection = sectionOf(mine, "satori") ?? {};
|
|
1401
1402
|
kurobotSection = sectionOf(mine, "kurobot") ?? {};
|
|
1403
|
+
milkySection = sectionOf(mine, "milky") ?? {};
|
|
1402
1404
|
}
|
|
1403
1405
|
}
|
|
1404
1406
|
return {
|
|
1405
1407
|
ob11Section,
|
|
1406
1408
|
satoriSection,
|
|
1407
|
-
kurobotSection
|
|
1409
|
+
kurobotSection,
|
|
1410
|
+
milkySection
|
|
1408
1411
|
};
|
|
1409
1412
|
}
|
|
1410
1413
|
/**
|
|
@@ -1424,7 +1427,8 @@ function loadProtocolSections(kernel, uin) {
|
|
|
1424
1427
|
let sections = {
|
|
1425
1428
|
ob11Section: {},
|
|
1426
1429
|
satoriSection: {},
|
|
1427
|
-
kurobotSection: {}
|
|
1430
|
+
kurobotSection: {},
|
|
1431
|
+
milkySection: {}
|
|
1428
1432
|
};
|
|
1429
1433
|
try {
|
|
1430
1434
|
const raw = (0, node_fs.readFileSync)(cfgFile, "utf8");
|
|
@@ -1570,18 +1574,21 @@ async function assembleOb11AndSatori(kernel, services, loginResult) {
|
|
|
1570
1574
|
return async () => {};
|
|
1571
1575
|
}
|
|
1572
1576
|
try {
|
|
1577
|
+
const milkyAdapters = [];
|
|
1573
1578
|
const network = await import(`file://${networkEntry.replace(BACKSLASH_RE, "/")}`);
|
|
1574
1579
|
const onebot11Entry = adapterEntry.replace(INDEX_MJS_RE, "onebot11/index.mjs");
|
|
1575
1580
|
const satoriEntry = adapterEntry.replace(INDEX_MJS_RE, "satori/index.mjs");
|
|
1576
1581
|
const kurobotEntry = adapterEntry.replace(INDEX_MJS_RE, "kurobot/index.mjs");
|
|
1582
|
+
const milkyEntry = adapterEntry.replace(INDEX_MJS_RE, "milky/index.mjs");
|
|
1577
1583
|
const coreEntry = adapterEntry.replace(INDEX_MJS_RE, "core/index.mjs");
|
|
1578
1584
|
const adapter = await import(`file://${onebot11Entry.replace(BACKSLASH_RE, "/")}`);
|
|
1579
1585
|
const satoriAdapter = await import(`file://${satoriEntry.replace(BACKSLASH_RE, "/")}`);
|
|
1580
1586
|
const kurobotAdapter = await import(`file://${kurobotEntry.replace(BACKSLASH_RE, "/")}`);
|
|
1587
|
+
const milkyAdapter = await import(`file://${milkyEntry.replace(BACKSLASH_RE, "/")}`);
|
|
1581
1588
|
const adapterCore = await import(`file://${coreEntry.replace(BACKSLASH_RE, "/")}`);
|
|
1582
1589
|
const { channel, groupCache } = services;
|
|
1583
1590
|
const broadcaster = new network.EventBroadcaster();
|
|
1584
|
-
const { cfgFile, ob11Section, satoriSection, kurobotSection } = loadProtocolSections(kernel, loginResult.uin);
|
|
1591
|
+
const { cfgFile, ob11Section, satoriSection, kurobotSection, milkySection } = loadProtocolSections(kernel, loginResult.uin);
|
|
1585
1592
|
const ob11Config = new adapterCore.ProtocolConfig({
|
|
1586
1593
|
path: cfgFile,
|
|
1587
1594
|
schema: adapter.ob11ConfigSchema,
|
|
@@ -1673,10 +1680,36 @@ async function assembleOb11AndSatori(kernel, services, loginResult) {
|
|
|
1673
1680
|
await kurobot.start();
|
|
1674
1681
|
log("bootstrap: kurobot adapter started");
|
|
1675
1682
|
}
|
|
1683
|
+
if (Object.keys(milkySection).length > 0) {
|
|
1684
|
+
const milkyConfig = new adapterCore.ProtocolConfig({
|
|
1685
|
+
path: cfgFile,
|
|
1686
|
+
schema: milkyAdapter.milkyConfigSchema,
|
|
1687
|
+
defaults: milkyAdapter.milkyConfigSchema.parse({}),
|
|
1688
|
+
seed: parseSeed("milky", milkyAdapter.milkyConfigSchema, milkySection)
|
|
1689
|
+
});
|
|
1690
|
+
const milky = new milkyAdapter.NapukettoMilkyAdapter({
|
|
1691
|
+
config: milkyConfig,
|
|
1692
|
+
broadcaster,
|
|
1693
|
+
msgChannel: channel,
|
|
1694
|
+
msgApi: services.msgApi,
|
|
1695
|
+
groupApi: services.groupApi,
|
|
1696
|
+
friendApi: services.friendApi,
|
|
1697
|
+
profileApi: services.profileApi,
|
|
1698
|
+
self: services.self,
|
|
1699
|
+
groupCache,
|
|
1700
|
+
qqVersion: env.NAPUTO_QQ_VERSION || "unknown",
|
|
1701
|
+
mediaDir: (0, node_path.join)(env.NAPUTO_CFG_DIR || ".", "cache"),
|
|
1702
|
+
logger: services.calibLogger
|
|
1703
|
+
});
|
|
1704
|
+
await milky.start();
|
|
1705
|
+
log("bootstrap: milky adapter started");
|
|
1706
|
+
milkyAdapters.push(milky);
|
|
1707
|
+
}
|
|
1676
1708
|
return async () => {
|
|
1677
1709
|
await ob11.stop();
|
|
1678
1710
|
await satori.stop();
|
|
1679
1711
|
if (kurobot !== null) await kurobot.stop();
|
|
1712
|
+
for (const milky of milkyAdapters) await milky.stop();
|
|
1680
1713
|
};
|
|
1681
1714
|
} catch (e) {
|
|
1682
1715
|
log(`bootstrap: 协议装配失败: ${errMsg(e)}`);
|