mioki 0.2.1 → 0.2.3
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/index.cjs +41 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +41 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,7 @@ interface StartOptions {
|
|
|
25
25
|
}
|
|
26
26
|
declare function start(options?: StartOptions): Promise<void>;
|
|
27
27
|
declare namespace utils_d_exports {
|
|
28
|
-
export { AnyFunc, Arrayable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop,
|
|
28
|
+
export { AnyFunc, Arrayable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop, PureObject, START_TIME, base64Decode, base64Encode, clamp, createCmd, createDB, createStore, dayjs, dedent, ensureBuffer, filesize, filter, find, formatDuration, formatQQLevel, fs, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, isBoolean, isDefined, isFunction, isGroupMsg, isNumber, isObject, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, requestLoginViaDevTools, runWithReaction, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, uuid, wait };
|
|
29
29
|
}
|
|
30
30
|
declare const ChromeUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0";
|
|
31
31
|
type Noop = () => void;
|
|
@@ -351,8 +351,6 @@ declare function getMinicoTokenViaAuthCode(authCode: string, appid: number): Pro
|
|
|
351
351
|
* 获取终端输入,返回 Promise,支持提示信息
|
|
352
352
|
*/
|
|
353
353
|
declare function getTerminalInput(inputTip?: string): Promise<string>;
|
|
354
|
-
type OmitBotParamFromFunc$1<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
|
|
355
|
-
declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc$1<(bot: NapCat, ...args: Params) => Return$1>;
|
|
356
354
|
/**
|
|
357
355
|
* 当前 Node.js 进程的启动时间,常量,Date 类型
|
|
358
356
|
*/
|
|
@@ -370,7 +368,7 @@ interface MiokiConfig {
|
|
|
370
368
|
plugins: string[];
|
|
371
369
|
online_push?: boolean;
|
|
372
370
|
log_level?: string;
|
|
373
|
-
|
|
371
|
+
plugins_dir?: string;
|
|
374
372
|
napcat: {
|
|
375
373
|
protocol?: "ws" | "wss";
|
|
376
374
|
port?: number;
|
|
@@ -519,7 +517,7 @@ declare function getViolationRecords(bot: NapCat, authCode: string, appid: numbe
|
|
|
519
517
|
reason: number;
|
|
520
518
|
}[]>;
|
|
521
519
|
//#endregion
|
|
522
|
-
//#region src/builtins/
|
|
520
|
+
//#region src/builtins/core/status.d.ts
|
|
523
521
|
interface MiokiStatus {
|
|
524
522
|
bot: {
|
|
525
523
|
uin: number;
|
|
@@ -565,15 +563,15 @@ interface MiokiStatus {
|
|
|
565
563
|
};
|
|
566
564
|
}
|
|
567
565
|
//#endregion
|
|
568
|
-
//#region src/builtins/
|
|
569
|
-
interface
|
|
566
|
+
//#region src/builtins/core/index.d.ts
|
|
567
|
+
interface MiokiCoreServiceContrib {
|
|
570
568
|
/** 获取框架和系统的实时状态 */
|
|
571
569
|
getMiokiStatus(): Promise<MiokiStatus>;
|
|
572
570
|
}
|
|
573
571
|
declare namespace services_d_exports {
|
|
574
572
|
export { MiokiServices, addService, services };
|
|
575
573
|
}
|
|
576
|
-
interface MiokiServices extends Record<string, unknown>,
|
|
574
|
+
interface MiokiServices extends Record<string, unknown>, MiokiCoreServiceContrib {}
|
|
577
575
|
/**
|
|
578
576
|
* 服务,由其他插件贡献的方法、数据等
|
|
579
577
|
*/
|
|
@@ -596,6 +594,7 @@ type Services = typeof services_d_exports;
|
|
|
596
594
|
type StrictEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends (<G>() => G extends U ? 1 : 2) ? true : false;
|
|
597
595
|
type RemoveBotParam<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? StrictEqual<Parameters<T[K]>[0], NapCat> extends true ? OmitBotParamFromFunc<T[K]> : never : never };
|
|
598
596
|
type OmitBotParamFromFunc<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
|
|
597
|
+
declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc<(bot: NapCat, ...args: Params) => Return$1>;
|
|
599
598
|
/**
|
|
600
599
|
* Mioki 上下文对象,包含 Mioki 运行时的信息和方法
|
|
601
600
|
*/
|
|
@@ -604,6 +603,8 @@ interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions>
|
|
|
604
603
|
bot: NapCat;
|
|
605
604
|
/** 消息构造器 */
|
|
606
605
|
segment: NapCat["segment"];
|
|
606
|
+
/** 通过域名获取 Cookies */
|
|
607
|
+
getCookie: NapCat["getCookie"];
|
|
607
608
|
/** 注册事件处理器 */
|
|
608
609
|
handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any) => void;
|
|
609
610
|
/** 注册定时任务 */
|
|
@@ -653,5 +654,5 @@ declare function findLocalPlugins(): Promise<{
|
|
|
653
654
|
absPath: string;
|
|
654
655
|
}[]>;
|
|
655
656
|
//#endregion
|
|
656
|
-
export { AnyFunc, Arrayable, BOT_CWD, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiPlugin, MiokiServices, Noop, PureObject, START_TIME, StartOptions, addService, base64Decode, base64Encode, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
657
|
+
export { AnyFunc, Arrayable, BOT_CWD, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiPlugin, MiokiServices, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, addService, base64Decode, base64Encode, bindBot, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
657
658
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -23,7 +23,7 @@ interface StartOptions {
|
|
|
23
23
|
}
|
|
24
24
|
declare function start(options?: StartOptions): Promise<void>;
|
|
25
25
|
declare namespace utils_d_exports {
|
|
26
|
-
export { AnyFunc, Arrayable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop,
|
|
26
|
+
export { AnyFunc, Arrayable, ChromeUA, CreateCmdOptions, Gettable, HasMessage, Noop, PureObject, START_TIME, base64Decode, base64Encode, clamp, createCmd, createDB, createStore, dayjs, dedent, ensureBuffer, filesize, filter, find, formatDuration, formatQQLevel, fs, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, isBoolean, isDefined, isFunction, isGroupMsg, isNumber, isObject, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, requestLoginViaDevTools, runWithReaction, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, uuid, wait };
|
|
27
27
|
}
|
|
28
28
|
declare const ChromeUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0";
|
|
29
29
|
type Noop = () => void;
|
|
@@ -349,8 +349,6 @@ declare function getMinicoTokenViaAuthCode(authCode: string, appid: number): Pro
|
|
|
349
349
|
* 获取终端输入,返回 Promise,支持提示信息
|
|
350
350
|
*/
|
|
351
351
|
declare function getTerminalInput(inputTip?: string): Promise<string>;
|
|
352
|
-
type OmitBotParamFromFunc$1<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
|
|
353
|
-
declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc$1<(bot: NapCat, ...args: Params) => Return$1>;
|
|
354
352
|
/**
|
|
355
353
|
* 当前 Node.js 进程的启动时间,常量,Date 类型
|
|
356
354
|
*/
|
|
@@ -368,7 +366,7 @@ interface MiokiConfig {
|
|
|
368
366
|
plugins: string[];
|
|
369
367
|
online_push?: boolean;
|
|
370
368
|
log_level?: string;
|
|
371
|
-
|
|
369
|
+
plugins_dir?: string;
|
|
372
370
|
napcat: {
|
|
373
371
|
protocol?: "ws" | "wss";
|
|
374
372
|
port?: number;
|
|
@@ -517,7 +515,7 @@ declare function getViolationRecords(bot: NapCat, authCode: string, appid: numbe
|
|
|
517
515
|
reason: number;
|
|
518
516
|
}[]>;
|
|
519
517
|
//#endregion
|
|
520
|
-
//#region src/builtins/
|
|
518
|
+
//#region src/builtins/core/status.d.ts
|
|
521
519
|
interface MiokiStatus {
|
|
522
520
|
bot: {
|
|
523
521
|
uin: number;
|
|
@@ -563,15 +561,15 @@ interface MiokiStatus {
|
|
|
563
561
|
};
|
|
564
562
|
}
|
|
565
563
|
//#endregion
|
|
566
|
-
//#region src/builtins/
|
|
567
|
-
interface
|
|
564
|
+
//#region src/builtins/core/index.d.ts
|
|
565
|
+
interface MiokiCoreServiceContrib {
|
|
568
566
|
/** 获取框架和系统的实时状态 */
|
|
569
567
|
getMiokiStatus(): Promise<MiokiStatus>;
|
|
570
568
|
}
|
|
571
569
|
declare namespace services_d_exports {
|
|
572
570
|
export { MiokiServices, addService, services };
|
|
573
571
|
}
|
|
574
|
-
interface MiokiServices extends Record<string, unknown>,
|
|
572
|
+
interface MiokiServices extends Record<string, unknown>, MiokiCoreServiceContrib {}
|
|
575
573
|
/**
|
|
576
574
|
* 服务,由其他插件贡献的方法、数据等
|
|
577
575
|
*/
|
|
@@ -594,6 +592,7 @@ type Services = typeof services_d_exports;
|
|
|
594
592
|
type StrictEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends (<G>() => G extends U ? 1 : 2) ? true : false;
|
|
595
593
|
type RemoveBotParam<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? StrictEqual<Parameters<T[K]>[0], NapCat> extends true ? OmitBotParamFromFunc<T[K]> : never : never };
|
|
596
594
|
type OmitBotParamFromFunc<Func extends (bot: NapCat, ...args: any[]) => any> = Func extends ((bot: NapCat, ...args: infer A) => infer Return) ? (...args: A) => Return : never;
|
|
595
|
+
declare function bindBot<Params extends Array<any> = any[], Return$1 = any>(bot: NapCat, func: (bot: NapCat, ...args: Params) => Return$1): OmitBotParamFromFunc<(bot: NapCat, ...args: Params) => Return$1>;
|
|
597
596
|
/**
|
|
598
597
|
* Mioki 上下文对象,包含 Mioki 运行时的信息和方法
|
|
599
598
|
*/
|
|
@@ -602,6 +601,8 @@ interface MiokiContext extends Services, Configs, Utils, RemoveBotParam<Actions>
|
|
|
602
601
|
bot: NapCat;
|
|
603
602
|
/** 消息构造器 */
|
|
604
603
|
segment: NapCat["segment"];
|
|
604
|
+
/** 通过域名获取 Cookies */
|
|
605
|
+
getCookie: NapCat["getCookie"];
|
|
605
606
|
/** 注册事件处理器 */
|
|
606
607
|
handle: <EventName extends keyof EventMap>(eventName: EventName, handler: (event: EventMap[EventName]) => any) => void;
|
|
607
608
|
/** 注册定时任务 */
|
|
@@ -651,5 +652,5 @@ declare function findLocalPlugins(): Promise<{
|
|
|
651
652
|
absPath: string;
|
|
652
653
|
}[]>;
|
|
653
654
|
//#endregion
|
|
654
|
-
export { AnyFunc, Arrayable, BOT_CWD, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiPlugin, MiokiServices, Noop, PureObject, START_TIME, StartOptions, addService, base64Decode, base64Encode, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
655
|
+
export { AnyFunc, Arrayable, BOT_CWD, ChromeUA, CreateCmdOptions, Gettable, HasMessage, MiokiConfig, MiokiContext, MiokiPlugin, MiokiServices, Noop, OmitBotParamFromFunc, PureObject, START_TIME, StartOptions, addService, base64Decode, base64Encode, bindBot, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
655
656
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -39,7 +39,6 @@ var utils_exports = /* @__PURE__ */ __export({
|
|
|
39
39
|
START_TIME: () => START_TIME,
|
|
40
40
|
base64Decode: () => base64Decode,
|
|
41
41
|
base64Encode: () => base64Encode,
|
|
42
|
-
bindBot: () => bindBot,
|
|
43
42
|
clamp: () => clamp,
|
|
44
43
|
createCmd: () => createCmd,
|
|
45
44
|
createDB: () => createDB,
|
|
@@ -137,9 +136,9 @@ const jiti = createJiti(__dirname, {
|
|
|
137
136
|
function createCmd(cmdStr, options = {}) {
|
|
138
137
|
const { prefix = "", onPrefix = () => {} } = options;
|
|
139
138
|
const { _, ...cmdOptions } = mri$1(string2argv$1(cmdStr));
|
|
140
|
-
const [cmd
|
|
139
|
+
const [cmd, ...params] = _;
|
|
141
140
|
if (prefix) {
|
|
142
|
-
if (cmd
|
|
141
|
+
if (cmd !== prefix) return {
|
|
143
142
|
cmd: void 0,
|
|
144
143
|
params: [],
|
|
145
144
|
options: cmdOptions
|
|
@@ -152,7 +151,7 @@ function createCmd(cmdStr, options = {}) {
|
|
|
152
151
|
};
|
|
153
152
|
}
|
|
154
153
|
return {
|
|
155
|
-
cmd
|
|
154
|
+
cmd,
|
|
156
155
|
params,
|
|
157
156
|
options: cmdOptions
|
|
158
157
|
};
|
|
@@ -731,9 +730,6 @@ async function getTerminalInput(inputTip = "请输入") {
|
|
|
731
730
|
getInput();
|
|
732
731
|
});
|
|
733
732
|
}
|
|
734
|
-
function bindBot(bot, func) {
|
|
735
|
-
return (...args) => func(bot, ...args);
|
|
736
|
-
}
|
|
737
733
|
/**
|
|
738
734
|
* 当前 Node.js 进程的启动时间,常量,Date 类型
|
|
739
735
|
*/
|
|
@@ -836,7 +832,7 @@ function getLogFilePath(uin, platformName) {
|
|
|
836
832
|
|
|
837
833
|
//#endregion
|
|
838
834
|
//#region package.json
|
|
839
|
-
var version = "0.2.
|
|
835
|
+
var version = "0.2.3";
|
|
840
836
|
|
|
841
837
|
//#endregion
|
|
842
838
|
//#region src/actions.ts
|
|
@@ -1109,6 +1105,9 @@ function addService(name, service, cover = true) {
|
|
|
1109
1105
|
|
|
1110
1106
|
//#endregion
|
|
1111
1107
|
//#region src/plugin.ts
|
|
1108
|
+
function bindBot(bot, func) {
|
|
1109
|
+
return (...args) => func(bot, ...args);
|
|
1110
|
+
}
|
|
1112
1111
|
const runtimePlugins = /* @__PURE__ */ new Map();
|
|
1113
1112
|
const buildRemovedActions = (bot) => Object.fromEntries(Object.entries(actions_exports).map(([k, v]) => [k, bindBot(bot, v)]));
|
|
1114
1113
|
/**
|
|
@@ -1129,9 +1128,9 @@ function ensurePluginDir() {
|
|
|
1129
1128
|
/**
|
|
1130
1129
|
* 获取插件目录的绝对路径
|
|
1131
1130
|
*/
|
|
1132
|
-
function getAbsPluginDir(defaultDir = "
|
|
1131
|
+
function getAbsPluginDir(defaultDir = "plugins") {
|
|
1133
1132
|
const cwd = BOT_CWD.value;
|
|
1134
|
-
return path$1.
|
|
1133
|
+
return path$1.join(cwd, botConfig.plugins_dir || defaultDir);
|
|
1135
1134
|
}
|
|
1136
1135
|
async function enablePlugin(bot, plugin, type = "external") {
|
|
1137
1136
|
const typeDesc = type === "builtin" ? "内置" : "用户";
|
|
@@ -1144,6 +1143,7 @@ async function enablePlugin(bot, plugin, type = "external") {
|
|
|
1144
1143
|
const context = {
|
|
1145
1144
|
bot,
|
|
1146
1145
|
segment: bot.segment,
|
|
1146
|
+
getCookie: bot.getCookie,
|
|
1147
1147
|
...utils_exports,
|
|
1148
1148
|
...config_exports,
|
|
1149
1149
|
...buildRemovedActions(bot),
|
|
@@ -1179,15 +1179,15 @@ async function enablePlugin(bot, plugin, type = "external") {
|
|
|
1179
1179
|
await Promise.all([...clears, ...userClears].map((fn) => fn?.()));
|
|
1180
1180
|
runtimePlugins.delete(name);
|
|
1181
1181
|
} catch (err) {
|
|
1182
|
-
throw new Error(
|
|
1182
|
+
throw new Error(`>>> 禁用插件 [${typeDesc}]${name}@${version$1} 失败: ${err?.message}`);
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
});
|
|
1186
1186
|
const end = hrtime.bigint();
|
|
1187
1187
|
const time = Math.round(Number(end - start$1)) / 1e6;
|
|
1188
|
-
bot.logger.info(
|
|
1188
|
+
bot.logger.info(`>>> 启用插件 [${typeDesc}]${name}@${version$1} => 耗时 ${time} ms`);
|
|
1189
1189
|
} catch (e) {
|
|
1190
|
-
throw new Error(
|
|
1190
|
+
throw new Error(`>>> 启用插件 [${typeDesc}]${name}@${version$1} 失败: ${e?.message}`);
|
|
1191
1191
|
}
|
|
1192
1192
|
return plugin;
|
|
1193
1193
|
}
|
|
@@ -1199,7 +1199,7 @@ async function findLocalPlugins() {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
|
|
1201
1201
|
//#endregion
|
|
1202
|
-
//#region src/builtins/
|
|
1202
|
+
//#region src/builtins/core/status.ts
|
|
1203
1203
|
const SystemMap = {
|
|
1204
1204
|
Linux: "Linux",
|
|
1205
1205
|
Darwin: "macOS",
|
|
@@ -1251,8 +1251,8 @@ async function getMiokiStatus(bot) {
|
|
|
1251
1251
|
protocol: versionInfo.protocol_version
|
|
1252
1252
|
},
|
|
1253
1253
|
system: {
|
|
1254
|
-
name: system.name,
|
|
1255
|
-
version: system.version,
|
|
1254
|
+
name: system.name || "N/A",
|
|
1255
|
+
version: system.version || "N/A",
|
|
1256
1256
|
arch
|
|
1257
1257
|
},
|
|
1258
1258
|
memory: {
|
|
@@ -1271,7 +1271,7 @@ async function getMiokiStatus(bot) {
|
|
|
1271
1271
|
percent: 0
|
|
1272
1272
|
},
|
|
1273
1273
|
cpu: {
|
|
1274
|
-
name: cpu.name,
|
|
1274
|
+
name: cpu.name.trim(),
|
|
1275
1275
|
count: cpu.count,
|
|
1276
1276
|
percent: Number((await measureCpuUsage()).toFixed(1))
|
|
1277
1277
|
}
|
|
@@ -1290,7 +1290,7 @@ async function getMiokiStatusStr(client) {
|
|
|
1290
1290
|
hideYear: true,
|
|
1291
1291
|
secondsDecimalDigits: 0
|
|
1292
1292
|
})}
|
|
1293
|
-
🤖
|
|
1293
|
+
🤖 mioki/${versions.mioki}-NapCat/${versions.napcat}
|
|
1294
1294
|
🖥️ ${system.name.split(" ")[0]}/${system.version.split(".")[0]}-${system.name}-node/${versions.node.split(".")[0]}
|
|
1295
1295
|
📊 ${memory.percent}%-${filesize(memory.used, {
|
|
1296
1296
|
base: 2,
|
|
@@ -1300,7 +1300,7 @@ async function getMiokiStatusStr(client) {
|
|
|
1300
1300
|
round: 1
|
|
1301
1301
|
})}
|
|
1302
1302
|
🧮 ${cpu.percent}%-${cpu.name}-${cpu.count}核
|
|
1303
|
-
|
|
1303
|
+
${diskValid ? `💾 ${diskDesc}` : ""}
|
|
1304
1304
|
`.trim();
|
|
1305
1305
|
}
|
|
1306
1306
|
async function getDiskUsageInUnix(path$2 = "/") {
|
|
@@ -1356,10 +1356,10 @@ function getCpuInfo() {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
|
|
1358
1358
|
//#endregion
|
|
1359
|
-
//#region src/builtins/
|
|
1360
|
-
const corePlugins = ["mioki-
|
|
1361
|
-
const
|
|
1362
|
-
name: "
|
|
1359
|
+
//#region src/builtins/core/index.ts
|
|
1360
|
+
const corePlugins = ["mioki-core"];
|
|
1361
|
+
const core = definePlugin({
|
|
1362
|
+
name: "mioki-core",
|
|
1363
1363
|
version,
|
|
1364
1364
|
priority: 1,
|
|
1365
1365
|
setup(ctx) {
|
|
@@ -1377,9 +1377,9 @@ const cmd = definePlugin({
|
|
|
1377
1377
|
}
|
|
1378
1378
|
if (!ctx.isOwner(e)) return;
|
|
1379
1379
|
const { _: params, ..._options } = mri$1(string2argv$1(text$1));
|
|
1380
|
-
const cmd
|
|
1380
|
+
const cmd = params.shift()?.replace(cmdPrefix, "") ?? "";
|
|
1381
1381
|
const [subCmd, target, ..._subParams] = params;
|
|
1382
|
-
switch (cmd
|
|
1382
|
+
switch (cmd) {
|
|
1383
1383
|
case "帮助":
|
|
1384
1384
|
await e.reply(dedent$1(`
|
|
1385
1385
|
〓 💡 mioki 帮助 〓
|
|
@@ -1608,11 +1608,11 @@ const cmd = definePlugin({
|
|
|
1608
1608
|
}, e));
|
|
1609
1609
|
}
|
|
1610
1610
|
});
|
|
1611
|
-
var
|
|
1611
|
+
var core_default = core;
|
|
1612
1612
|
|
|
1613
1613
|
//#endregion
|
|
1614
1614
|
//#region src/builtins/index.ts
|
|
1615
|
-
const BUILTIN_PLUGINS = [
|
|
1615
|
+
const BUILTIN_PLUGINS = [core_default];
|
|
1616
1616
|
|
|
1617
1617
|
//#endregion
|
|
1618
1618
|
//#region src/start.ts
|
|
@@ -1622,13 +1622,16 @@ async function start(options = {}) {
|
|
|
1622
1622
|
process.title = `mioki v${version}`;
|
|
1623
1623
|
const logger = getMiokiLogger(botConfig.log_level || "info");
|
|
1624
1624
|
const plugin_dir = getAbsPluginDir();
|
|
1625
|
-
logger.info(`>>> mioki v${version}
|
|
1625
|
+
logger.info(`>>> mioki v${version} 启动中`);
|
|
1626
|
+
logger.info(`>>> 工作目录: ${BOT_CWD.value}`);
|
|
1627
|
+
logger.info(`>>> 插件目录: ${plugin_dir}`);
|
|
1626
1628
|
const napcat = new NapCat({
|
|
1627
1629
|
...botConfig.napcat,
|
|
1628
1630
|
logger
|
|
1629
1631
|
});
|
|
1630
1632
|
napcat.on("napcat.connected", async ({ uin }) => {
|
|
1631
|
-
logger.info(`>>> 已连接到 NapCat
|
|
1633
|
+
logger.info(`>>> 已连接到 NapCat 服务器`);
|
|
1634
|
+
logger.info(`>>> 当前登录 QQ 账号: ${uin}`);
|
|
1632
1635
|
let lastNoticeTime = 0;
|
|
1633
1636
|
process.on("uncaughtException", async (err) => {
|
|
1634
1637
|
napcat.logger.error(">>> uncaughtException, 出错了", err);
|
|
@@ -1688,17 +1691,14 @@ async function start(options = {}) {
|
|
|
1688
1691
|
try {
|
|
1689
1692
|
napcat.logger.info(`>>> 加载内置插件: ${BUILTIN_PLUGINS.map((p) => p.name).join(", ")}`);
|
|
1690
1693
|
await Promise.all(BUILTIN_PLUGINS.map((p) => enablePlugin(napcat, p, "builtin")));
|
|
1691
|
-
for (const [
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
}));
|
|
1701
|
-
}
|
|
1694
|
+
for (const [_, plugins$1] of sortedGroups) await Promise.all(plugins$1.map(async (p) => {
|
|
1695
|
+
try {
|
|
1696
|
+
await enablePlugin(napcat, p, "external");
|
|
1697
|
+
} catch (e) {
|
|
1698
|
+
const err = stringifyError(e);
|
|
1699
|
+
failedEnablePlugins.push([p.name, err]);
|
|
1700
|
+
}
|
|
1701
|
+
}));
|
|
1702
1702
|
} catch (e) {
|
|
1703
1703
|
napcat.logger.error(e?.message);
|
|
1704
1704
|
noticeMainOwner(napcat, e?.message);
|
|
@@ -1714,5 +1714,5 @@ async function start(options = {}) {
|
|
|
1714
1714
|
}
|
|
1715
1715
|
|
|
1716
1716
|
//#endregion
|
|
1717
|
-
export { BOT_CWD, ChromeUA, START_TIME, addService, base64Decode, base64Encode, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
1717
|
+
export { BOT_CWD, ChromeUA, START_TIME, addService, base64Decode, base64Encode, bindBot, botConfig, clamp, createCmd, createDB, createForwardMsg, createStore, dayjs, dedent, definePlugin, enablePlugin, ensureBuffer, ensurePluginDir, filesize, filter, find, findLocalPlugins, formatDuration, formatQQLevel, fs, getAbsPluginDir, getAuthCodeViaTicket, getBfaceUrl, getGroupAvatarLink, getImage, getImageUrl, getLogFilePath, getMentionedImage, getMentionedImageUrl, getMentionedUserId, getMinicoTokenViaAuthCode, getMiokiLogger, getQQAvatarLink, getQuoteImage, getQuoteImageUrl, getQuoteMessage, getQuoteText, getTerminalInput, getViolationRecords, hasRight, isAdmin, isBoolean, isDefined, isFunction, isGroupMsg, isInPm2, isNumber, isObject, isOwner, isOwnerOrAdmin, isPrivateMsg, isString, jiti, localNum, localeDate, localeTime, match, md5, mri, noNullish, noticeAdmins, noticeFriends, noticeGroups, noticeMainOwner, noticeOwners, path, prettyMs, qs, queryDevToolsLoginStatus, randomId, randomInt, randomItem, randomItems, readMiokiConfig, readPackageJson, requestLoginViaDevTools, runWithErrorHandler, runWithReaction, runtimePlugins, services, signArk, start, string2argv, stringifyError, systemInfo, text, toArray, toMsgId, unique, updateBotCWD, updateBotConfig, uploadImageToCollection, uploadImageToGroupHomework, uploadImageToGroupNotice, uuid, wait, writePackageJson };
|
|
1718
1718
|
//# sourceMappingURL=index.mjs.map
|