mioki 0.16.0 → 0.16.2
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 +18 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +18 -22
- package/dist/index.mjs.map +1 -1
- package/dist/{package-Cs8cEndC.cjs → package-CYh8zbTm.cjs} +2 -2
- package/dist/package-CYh8zbTm.cjs.map +1 -0
- package/dist/package-CwoAh-rX.mjs +6 -0
- package/dist/package-CwoAh-rX.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/package-Cs8cEndC.cjs.map +0 -1
- package/dist/package-UYRX612w.mjs +0 -6
- package/dist/package-UYRX612w.mjs.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;
|
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;
|
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-CwoAh-rX.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";
|
|
@@ -1408,11 +1408,10 @@ async function enablePlugin(bots, plugin, type = "external") {
|
|
|
1408
1408
|
if (isPrivateMessageEvent(e)) {
|
|
1409
1409
|
if (e.self_id !== bot$1.bot_id) return;
|
|
1410
1410
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
if (isFromConnectedBot || isFromConnectedBotOperator) return;
|
|
1411
|
+
if (isMessageEvent(e)) {
|
|
1412
|
+
const senderUserId = e.user_id;
|
|
1413
|
+
if (senderUserId && bots.some((b) => b.bot_id === senderUserId)) return;
|
|
1414
|
+
}
|
|
1416
1415
|
if (deduplicate && isDeduplicableEvent(e)) {
|
|
1417
1416
|
if (deduplicator.isProcessed(e, dedupeScope)) return;
|
|
1418
1417
|
deduplicator.markProcessed(e, dedupeScope);
|
|
@@ -1526,7 +1525,6 @@ async function getMiokiStatus(bots) {
|
|
|
1526
1525
|
botStatuses.push({
|
|
1527
1526
|
uin: bot.bot_id,
|
|
1528
1527
|
nickname: bot.nickname,
|
|
1529
|
-
name: bot.name,
|
|
1530
1528
|
friends: friendList.length,
|
|
1531
1529
|
groups: groupList.length,
|
|
1532
1530
|
send: bot.stat.send.group + bot.stat.send.private,
|
|
@@ -1538,7 +1536,6 @@ async function getMiokiStatus(bots) {
|
|
|
1538
1536
|
botStatuses.push({
|
|
1539
1537
|
uin: bot.bot_id,
|
|
1540
1538
|
nickname: bot.nickname,
|
|
1541
|
-
name: bot.name,
|
|
1542
1539
|
friends: 0,
|
|
1543
1540
|
groups: 0,
|
|
1544
1541
|
send: 0,
|
|
@@ -1593,13 +1590,14 @@ async function formatMiokiStatus(status) {
|
|
|
1593
1590
|
const { bots, plugins, stats, system, disk, cpu, memory, versions } = status;
|
|
1594
1591
|
const diskValid = disk.total > 0 && disk.free >= 0;
|
|
1595
1592
|
const diskDesc = `${disk.percent}%-${filesize(disk.used, { round: 1 })}/${filesize(disk.total, { round: 1 })}`;
|
|
1593
|
+
const botLines = bots.map((bot) => {
|
|
1594
|
+
return `👤 ${bot.nickname} (${bot.uin})\n 📋 ${localNum(bot.friends)} 好友 / ${localNum(bot.groups)} 群 / 📮 收 ${localNum(bot.receive)} 发 ${localNum(bot.send)}`;
|
|
1595
|
+
}).join("\n");
|
|
1596
|
+
const statsLine = bots.length > 1 ? `\n📮 总计: 收 ${localNum(stats.receive)} 条,发 ${localNum(stats.send)} 条` : "";
|
|
1596
1597
|
return `
|
|
1597
1598
|
〓 🟢 mioki 状态 〓
|
|
1598
|
-
${
|
|
1599
|
-
|
|
1600
|
-
}).join("\n")}
|
|
1601
|
-
🧩 启用了 ${localNum(plugins.enabled)} 个插件,共 ${localNum(plugins.total)} 个
|
|
1602
|
-
📮 总计: 收 ${localNum(stats.receive)} 条,发 ${localNum(stats.send)} 条
|
|
1599
|
+
${botLines}
|
|
1600
|
+
🧩 启用了 ${localNum(plugins.enabled)} 个插件,共 ${localNum(plugins.total)} 个${statsLine}
|
|
1603
1601
|
🚀 ${filesize(memory.rss.used, { round: 1 })}/${memory.percent}%
|
|
1604
1602
|
⏳ 已运行 ${prettyMs(stats.uptime, {
|
|
1605
1603
|
hideYear: true,
|
|
@@ -1939,8 +1937,8 @@ const BUILTIN_PLUGINS = [core_default];
|
|
|
1939
1937
|
//#region src/start.ts
|
|
1940
1938
|
const connectedBots = /* @__PURE__ */ new Map();
|
|
1941
1939
|
async function connectBot(config, index) {
|
|
1942
|
-
const { protocol = "ws", port = 3001, host = "localhost", token = ""
|
|
1943
|
-
const botName =
|
|
1940
|
+
const { protocol = "ws", port = 3001, host = "localhost", token = "" } = config;
|
|
1941
|
+
const botName = `Bot${index + 1}`;
|
|
1944
1942
|
const wsUrl = colors$1.green(`${protocol}://${host}:${port}${token ? "?access_token=***" : ""}`);
|
|
1945
1943
|
logger.info(`>>> 正在连接 ${colors$1.cyan(botName)}: ${wsUrl}`);
|
|
1946
1944
|
const napcat = new NapCat({
|
|
@@ -1960,8 +1958,7 @@ async function connectBot(config, index) {
|
|
|
1960
1958
|
napcat.once("napcat.connected", ({ user_id, nickname, app_name, app_version }) => {
|
|
1961
1959
|
logger.info(`已连接到 ${colors$1.cyan(botName)}: ${colors$1.green(`${app_name}-v${app_version} ${nickname}(${user_id})`)}`);
|
|
1962
1960
|
if (connectedBots.has(user_id)) {
|
|
1963
|
-
|
|
1964
|
-
if (existingBot.name) logger.warn(`${colors$1.yellow(botName)} (${user_id}) 与 ${colors$1.yellow(existingBot.name)} (${user_id}) QQ 号重复,将跳过`);
|
|
1961
|
+
logger.warn(`${colors$1.yellow(botName)} (${user_id}) 与已存在的 bot (${user_id}) QQ 号重复,将跳过`);
|
|
1965
1962
|
napcat.close();
|
|
1966
1963
|
resolve(null);
|
|
1967
1964
|
return;
|
|
@@ -1970,7 +1967,6 @@ async function connectBot(config, index) {
|
|
|
1970
1967
|
extendedNapCat.bot_id = user_id;
|
|
1971
1968
|
extendedNapCat.app_name = app_name;
|
|
1972
1969
|
extendedNapCat.app_version = app_version;
|
|
1973
|
-
extendedNapCat.name = botName;
|
|
1974
1970
|
resolve(extendedNapCat);
|
|
1975
1971
|
});
|
|
1976
1972
|
napcat.run().catch((err) => {
|
|
@@ -2077,10 +2073,10 @@ async function start(options = {}) {
|
|
|
2077
2073
|
}
|
|
2078
2074
|
const seenEndpoints = /* @__PURE__ */ new Set();
|
|
2079
2075
|
const duplicateConfigs = [];
|
|
2080
|
-
for (
|
|
2081
|
-
const { protocol = "ws", host = "localhost", port = 3001 } =
|
|
2076
|
+
for (let i = 0; i < napcatConfigs.length; i++) {
|
|
2077
|
+
const { protocol = "ws", host = "localhost", port = 3001 } = napcatConfigs[i];
|
|
2082
2078
|
const endpoint = `${protocol}://${host}:${port}`;
|
|
2083
|
-
if (seenEndpoints.has(endpoint)) duplicateConfigs.push(
|
|
2079
|
+
if (seenEndpoints.has(endpoint)) duplicateConfigs.push(`Bot${i + 1} (${endpoint})`);
|
|
2084
2080
|
else seenEndpoints.add(endpoint);
|
|
2085
2081
|
}
|
|
2086
2082
|
if (duplicateConfigs.length > 0) {
|
|
@@ -2098,7 +2094,7 @@ async function start(options = {}) {
|
|
|
2098
2094
|
}
|
|
2099
2095
|
for (const bot of bots) connectedBots.set(bot.bot_id, bot);
|
|
2100
2096
|
if (bots.length < napcatConfigs.length) logger.warn(`${colors$1.yellow(napcatConfigs.length - bots.length)} 个 NapCat 实例连接失败`);
|
|
2101
|
-
const botNames = bots.map((b) => `${b.
|
|
2097
|
+
const botNames = bots.map((b) => `${b.bot_id}`).join(", ");
|
|
2102
2098
|
logger.info(colors$1.green(`成功连接 ${bots.length} 个实例: ${botNames}`));
|
|
2103
2099
|
logger.info(colors$1.dim("=".repeat(40)));
|
|
2104
2100
|
const mainBot = bots[0];
|