mioki 0.15.1 → 0.16.1
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/cli.cjs +1 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +17 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -5
- package/dist/index.d.mts +12 -5
- package/dist/index.mjs +17 -18
- package/dist/index.mjs.map +1 -1
- package/dist/{package-DrAKGYns.cjs → package-Bryo1nSK.cjs} +2 -2
- package/dist/package-Bryo1nSK.cjs.map +1 -0
- package/dist/package-Bvcr71Zp.mjs +6 -0
- package/dist/package-Bvcr71Zp.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/package-75_Caljc.mjs +0 -6
- package/dist/package-75_Caljc.mjs.map +0 -1
- package/dist/package-DrAKGYns.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -32,7 +32,6 @@ interface ExtendedNapCat extends NapCat {
|
|
|
32
32
|
bot_id: number;
|
|
33
33
|
app_name: string;
|
|
34
34
|
app_version: string;
|
|
35
|
-
name?: string;
|
|
36
35
|
}
|
|
37
36
|
declare const connectedBots: Map<number, ExtendedNapCat>;
|
|
38
37
|
declare function start(options?: StartOptions): Promise<void>;
|
|
@@ -551,7 +550,6 @@ declare const ArchMap: Record<string, string>;
|
|
|
551
550
|
interface BotStatus {
|
|
552
551
|
uin: number;
|
|
553
552
|
nickname: string;
|
|
554
|
-
name?: string;
|
|
555
553
|
friends: number;
|
|
556
554
|
groups: number;
|
|
557
555
|
send: number;
|
|
@@ -690,12 +688,21 @@ declare const deduplicator: Deduplicator;
|
|
|
690
688
|
* Mioki 上下文对象,包含 Mioki 运行时的信息和方法
|
|
691
689
|
*/
|
|
692
690
|
interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
|
|
693
|
-
/**
|
|
691
|
+
/**
|
|
692
|
+
* 单实例模式下:机器人实例
|
|
693
|
+
* 多实例模式下:第一个机器人实例
|
|
694
|
+
*
|
|
695
|
+
* 如果要获取指定机器人实例,请使用 ctx.getBot(id) 方法,id 通常可以从 event.self_id 获取
|
|
696
|
+
*/
|
|
694
697
|
bot: NapCat;
|
|
695
|
-
/** 所有已连接的机器人实例列表 */
|
|
696
|
-
bots: ExtendedNapCat[];
|
|
697
698
|
/** 当前机器人 QQ 号 */
|
|
698
699
|
self_id: number;
|
|
700
|
+
/** 多实例模式下:所有已连接的机器人实例列表 */
|
|
701
|
+
bots: ExtendedNapCat[];
|
|
702
|
+
/** 多实例模式下:通过 QQ 号获取机器人实例 */
|
|
703
|
+
pickBot: (id: number) => ExtendedNapCat;
|
|
704
|
+
/** 多实例模式下:需要手动传入 bot 实例的操作方法集合*/
|
|
705
|
+
actions: Actions;
|
|
699
706
|
/** 消息构造器 */
|
|
700
707
|
segment: NapCat['segment'];
|
|
701
708
|
/** 通过域名获取 Cookies */
|
package/dist/index.d.mts
CHANGED
|
@@ -30,7 +30,6 @@ interface ExtendedNapCat extends NapCat {
|
|
|
30
30
|
bot_id: number;
|
|
31
31
|
app_name: string;
|
|
32
32
|
app_version: string;
|
|
33
|
-
name?: string;
|
|
34
33
|
}
|
|
35
34
|
declare const connectedBots: Map<number, ExtendedNapCat>;
|
|
36
35
|
declare function start(options?: StartOptions): Promise<void>;
|
|
@@ -549,7 +548,6 @@ declare const ArchMap: Record<string, string>;
|
|
|
549
548
|
interface BotStatus {
|
|
550
549
|
uin: number;
|
|
551
550
|
nickname: string;
|
|
552
|
-
name?: string;
|
|
553
551
|
friends: number;
|
|
554
552
|
groups: number;
|
|
555
553
|
send: number;
|
|
@@ -688,12 +686,21 @@ declare const deduplicator: Deduplicator;
|
|
|
688
686
|
* Mioki 上下文对象,包含 Mioki 运行时的信息和方法
|
|
689
687
|
*/
|
|
690
688
|
interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions> {
|
|
691
|
-
/**
|
|
689
|
+
/**
|
|
690
|
+
* 单实例模式下:机器人实例
|
|
691
|
+
* 多实例模式下:第一个机器人实例
|
|
692
|
+
*
|
|
693
|
+
* 如果要获取指定机器人实例,请使用 ctx.getBot(id) 方法,id 通常可以从 event.self_id 获取
|
|
694
|
+
*/
|
|
692
695
|
bot: NapCat;
|
|
693
|
-
/** 所有已连接的机器人实例列表 */
|
|
694
|
-
bots: ExtendedNapCat[];
|
|
695
696
|
/** 当前机器人 QQ 号 */
|
|
696
697
|
self_id: number;
|
|
698
|
+
/** 多实例模式下:所有已连接的机器人实例列表 */
|
|
699
|
+
bots: ExtendedNapCat[];
|
|
700
|
+
/** 多实例模式下:通过 QQ 号获取机器人实例 */
|
|
701
|
+
pickBot: (id: number) => ExtendedNapCat;
|
|
702
|
+
/** 多实例模式下:需要手动传入 bot 实例的操作方法集合*/
|
|
703
|
+
actions: Actions;
|
|
697
704
|
/** 消息构造器 */
|
|
698
705
|
segment: NapCat['segment'];
|
|
699
706
|
/** 通过域名获取 Cookies */
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-BiucMVzj.mjs";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-Bvcr71Zp.mjs";
|
|
3
3
|
import fs, { default as fs$1 } from "node:fs";
|
|
4
4
|
import util from "node:util";
|
|
5
5
|
import path, { default as path$1 } from "node:path";
|
|
@@ -1380,13 +1380,15 @@ async function enablePlugin(bots, plugin, type = "external") {
|
|
|
1380
1380
|
const createContext = (bot) => {
|
|
1381
1381
|
return {
|
|
1382
1382
|
bot,
|
|
1383
|
-
bots,
|
|
1384
1383
|
self_id: bot.bot_id,
|
|
1384
|
+
bots,
|
|
1385
|
+
pickBot: (id) => bots.find((b) => b.bot_id === id),
|
|
1385
1386
|
segment: bot.segment,
|
|
1386
1387
|
getCookie: bot.getCookie.bind(bot),
|
|
1387
1388
|
...utils_exports,
|
|
1388
1389
|
...config_exports,
|
|
1389
1390
|
...buildRemovedActions(bot),
|
|
1391
|
+
actions: actions_exports,
|
|
1390
1392
|
logger: logger$1,
|
|
1391
1393
|
services,
|
|
1392
1394
|
clears: userClears,
|
|
@@ -1524,7 +1526,6 @@ async function getMiokiStatus(bots) {
|
|
|
1524
1526
|
botStatuses.push({
|
|
1525
1527
|
uin: bot.bot_id,
|
|
1526
1528
|
nickname: bot.nickname,
|
|
1527
|
-
name: bot.name,
|
|
1528
1529
|
friends: friendList.length,
|
|
1529
1530
|
groups: groupList.length,
|
|
1530
1531
|
send: bot.stat.send.group + bot.stat.send.private,
|
|
@@ -1536,7 +1537,6 @@ async function getMiokiStatus(bots) {
|
|
|
1536
1537
|
botStatuses.push({
|
|
1537
1538
|
uin: bot.bot_id,
|
|
1538
1539
|
nickname: bot.nickname,
|
|
1539
|
-
name: bot.name,
|
|
1540
1540
|
friends: 0,
|
|
1541
1541
|
groups: 0,
|
|
1542
1542
|
send: 0,
|
|
@@ -1591,13 +1591,14 @@ async function formatMiokiStatus(status) {
|
|
|
1591
1591
|
const { bots, plugins, stats, system, disk, cpu, memory, versions } = status;
|
|
1592
1592
|
const diskValid = disk.total > 0 && disk.free >= 0;
|
|
1593
1593
|
const diskDesc = `${disk.percent}%-${filesize(disk.used, { round: 1 })}/${filesize(disk.total, { round: 1 })}`;
|
|
1594
|
+
const botLines = bots.map((bot) => {
|
|
1595
|
+
return `👤 ${bot.nickname} (${bot.uin})\n 📋 ${localNum(bot.friends)} 好友 / ${localNum(bot.groups)} 群 / 📮 收 ${localNum(bot.receive)} 发 ${localNum(bot.send)}`;
|
|
1596
|
+
}).join("\n");
|
|
1597
|
+
const statsLine = bots.length > 1 ? `\n📮 总计: 收 ${localNum(stats.receive)} 条,发 ${localNum(stats.send)} 条` : "";
|
|
1594
1598
|
return `
|
|
1595
1599
|
〓 🟢 mioki 状态 〓
|
|
1596
|
-
${
|
|
1597
|
-
|
|
1598
|
-
}).join("\n")}
|
|
1599
|
-
🧩 启用了 ${localNum(plugins.enabled)} 个插件,共 ${localNum(plugins.total)} 个
|
|
1600
|
-
📮 总计: 收 ${localNum(stats.receive)} 条,发 ${localNum(stats.send)} 条
|
|
1600
|
+
${botLines}
|
|
1601
|
+
🧩 启用了 ${localNum(plugins.enabled)} 个插件,共 ${localNum(plugins.total)} 个${statsLine}
|
|
1601
1602
|
🚀 ${filesize(memory.rss.used, { round: 1 })}/${memory.percent}%
|
|
1602
1603
|
⏳ 已运行 ${prettyMs(stats.uptime, {
|
|
1603
1604
|
hideYear: true,
|
|
@@ -1937,8 +1938,8 @@ const BUILTIN_PLUGINS = [core_default];
|
|
|
1937
1938
|
//#region src/start.ts
|
|
1938
1939
|
const connectedBots = /* @__PURE__ */ new Map();
|
|
1939
1940
|
async function connectBot(config, index) {
|
|
1940
|
-
const { protocol = "ws", port = 3001, host = "localhost", token = ""
|
|
1941
|
-
const botName =
|
|
1941
|
+
const { protocol = "ws", port = 3001, host = "localhost", token = "" } = config;
|
|
1942
|
+
const botName = `Bot${index + 1}`;
|
|
1942
1943
|
const wsUrl = colors$1.green(`${protocol}://${host}:${port}${token ? "?access_token=***" : ""}`);
|
|
1943
1944
|
logger.info(`>>> 正在连接 ${colors$1.cyan(botName)}: ${wsUrl}`);
|
|
1944
1945
|
const napcat = new NapCat({
|
|
@@ -1958,8 +1959,7 @@ async function connectBot(config, index) {
|
|
|
1958
1959
|
napcat.once("napcat.connected", ({ user_id, nickname, app_name, app_version }) => {
|
|
1959
1960
|
logger.info(`已连接到 ${colors$1.cyan(botName)}: ${colors$1.green(`${app_name}-v${app_version} ${nickname}(${user_id})`)}`);
|
|
1960
1961
|
if (connectedBots.has(user_id)) {
|
|
1961
|
-
|
|
1962
|
-
if (existingBot.name) logger.warn(`${colors$1.yellow(botName)} (${user_id}) 与 ${colors$1.yellow(existingBot.name)} (${user_id}) QQ 号重复,将跳过`);
|
|
1962
|
+
logger.warn(`${colors$1.yellow(botName)} (${user_id}) 与已存在的 bot (${user_id}) QQ 号重复,将跳过`);
|
|
1963
1963
|
napcat.close();
|
|
1964
1964
|
resolve(null);
|
|
1965
1965
|
return;
|
|
@@ -1968,7 +1968,6 @@ async function connectBot(config, index) {
|
|
|
1968
1968
|
extendedNapCat.bot_id = user_id;
|
|
1969
1969
|
extendedNapCat.app_name = app_name;
|
|
1970
1970
|
extendedNapCat.app_version = app_version;
|
|
1971
|
-
extendedNapCat.name = botName;
|
|
1972
1971
|
resolve(extendedNapCat);
|
|
1973
1972
|
});
|
|
1974
1973
|
napcat.run().catch((err) => {
|
|
@@ -2075,10 +2074,10 @@ async function start(options = {}) {
|
|
|
2075
2074
|
}
|
|
2076
2075
|
const seenEndpoints = /* @__PURE__ */ new Set();
|
|
2077
2076
|
const duplicateConfigs = [];
|
|
2078
|
-
for (
|
|
2079
|
-
const { protocol = "ws", host = "localhost", port = 3001 } =
|
|
2077
|
+
for (let i = 0; i < napcatConfigs.length; i++) {
|
|
2078
|
+
const { protocol = "ws", host = "localhost", port = 3001 } = napcatConfigs[i];
|
|
2080
2079
|
const endpoint = `${protocol}://${host}:${port}`;
|
|
2081
|
-
if (seenEndpoints.has(endpoint)) duplicateConfigs.push(
|
|
2080
|
+
if (seenEndpoints.has(endpoint)) duplicateConfigs.push(`Bot${i + 1} (${endpoint})`);
|
|
2082
2081
|
else seenEndpoints.add(endpoint);
|
|
2083
2082
|
}
|
|
2084
2083
|
if (duplicateConfigs.length > 0) {
|
|
@@ -2096,7 +2095,7 @@ async function start(options = {}) {
|
|
|
2096
2095
|
}
|
|
2097
2096
|
for (const bot of bots) connectedBots.set(bot.bot_id, bot);
|
|
2098
2097
|
if (bots.length < napcatConfigs.length) logger.warn(`${colors$1.yellow(napcatConfigs.length - bots.length)} 个 NapCat 实例连接失败`);
|
|
2099
|
-
const botNames = bots.map((b) => `${b.
|
|
2098
|
+
const botNames = bots.map((b) => `${b.bot_id}`).join(", ");
|
|
2100
2099
|
logger.info(colors$1.green(`成功连接 ${bots.length} 个实例: ${botNames}`));
|
|
2101
2100
|
logger.info(colors$1.dim("=".repeat(40)));
|
|
2102
2101
|
const mainBot = bots[0];
|