mioki 0.3.0 → 0.4.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/index.cjs CHANGED
@@ -871,12 +871,30 @@ function getLogFilePath$1(uin, platformName) {
871
871
  //#endregion
872
872
  //#region src/logger.ts
873
873
  const LEVEL_MAP = {
874
- 0: "FATAL",
875
- 1: "ERROR",
876
- 2: "WARN",
877
- 3: "INFO",
878
- 4: "DEBUG",
879
- 5: "TRACE"
874
+ 0: {
875
+ name: "ERROR",
876
+ color: "red"
877
+ },
878
+ 1: {
879
+ name: "WARN",
880
+ color: "yellow"
881
+ },
882
+ 2: {
883
+ name: "LOG",
884
+ color: "white"
885
+ },
886
+ 3: {
887
+ name: "INFO",
888
+ color: "green"
889
+ },
890
+ 4: {
891
+ name: "DEBUG",
892
+ color: "blue"
893
+ },
894
+ 5: {
895
+ name: "TRACE",
896
+ color: "gray"
897
+ }
880
898
  };
881
899
  /**
882
900
  * 获取日志文件名
@@ -894,11 +912,11 @@ const getMiokiLogger = (level) => {
894
912
  defaults: { tag: "mioki" },
895
913
  reporters: [{ log: (logObj) => {
896
914
  const message = (0, consola_utils.stripAnsi)(logObj.message || logObj.args?.join(" ") || "");
897
- const line = `${`[${logObj.date.toISOString()}] [${LEVEL_MAP[logObj.level]}] ${logObj.tag ? `[${logObj.tag}] ` : ""}`}${message}`;
915
+ const line = `${`[${logObj.date.toISOString()}] [${LEVEL_MAP[logObj.level].name}] ${logObj.tag ? `[${logObj.tag}] ` : ""}`}${message}`;
898
916
  node_fs.default.appendFileSync(logFile, line + "\n");
899
917
  } }, { log: (logObj) => {
900
918
  const message = logObj.message || logObj.args?.join(" ") || "";
901
- const line = `${consola_utils.colors.gray(`[${logObj.date.toLocaleTimeString("zh-CN")}]`) + " " + consola_utils.colors.bold(consola_utils.colors.blue(LEVEL_MAP[logObj.level])) + " " + (logObj.tag ? consola_utils.colors.bold(consola_utils.colors.green(`[${logObj.tag}] `)) : "")}${message}`;
919
+ const line = `${consola_utils.colors.gray(`[${logObj.date.toLocaleTimeString("zh-CN")}]`) + " " + consola_utils.colors.bold(consola_utils.colors[LEVEL_MAP[logObj.level].color](LEVEL_MAP[logObj.level].name)) + " " + (logObj.tag ? consola_utils.colors.bold(consola_utils.colors.dim(`[${logObj.tag}] `)) : "")}${message}`;
902
920
  if (logObj.level <= consola_core.LogLevels["info"]) console.log(line);
903
921
  else if (logObj.level === consola_core.LogLevels["warn"]) console.warn(line);
904
922
  else console.debug(line);
@@ -913,7 +931,7 @@ const getMiokiLogger = (level) => {
913
931
 
914
932
  //#endregion
915
933
  //#region package.json
916
- var version = "0.3.0";
934
+ var version = "0.4.0";
917
935
 
918
936
  //#endregion
919
937
  //#region src/actions.ts
@@ -1721,15 +1739,19 @@ async function start(options = {}) {
1721
1739
  process.title = `mioki v${version}`;
1722
1740
  const logger = getMiokiLogger(botConfig.log_level || "info");
1723
1741
  const plugin_dir = getAbsPluginDir();
1724
- logger.info(`>>> mioki v${version} 启动中`);
1725
- logger.info(`>>> 工作目录: ${BOT_CWD.value}`);
1726
- logger.info(`>>> 插件目录: ${plugin_dir}`);
1742
+ logger.info(`>>> 〓 ${consola_utils.colors.bold(consola_utils.colors.cyan("mioki"))} ${consola_utils.colors.bold(consola_utils.colors.green(`v${version}`))} 〓`);
1743
+ logger.info(`>>> ${consola_utils.colors.yellow(consola_utils.colors.underline(`基于 NapCat 的 TypeScript 🤖️ 机器人框架。`))}`);
1744
+ logger.info(`>>> ${consola_utils.colors.yellow(consola_utils.colors.underline(`作者: Viki <hi@viki.moe> (https://github.com/vikiboss)`))}`);
1745
+ logger.info(`>>> ${consola_utils.colors.yellow(consola_utils.colors.underline(`协议: Licensed under MIT License.`))}`);
1746
+ logger.info(`>>> ${consola_utils.colors.cyan(consola_utils.colors.underline(`GitHub: http://github.com/vikiboss/mioki`))}`);
1747
+ logger.info(`>>> 工作目录: ${consola_utils.colors.bold(consola_utils.colors.blue(BOT_CWD.value))}`);
1748
+ logger.info(`>>> 插件目录: ${consola_utils.colors.bold(consola_utils.colors.blue(plugin_dir))}`);
1727
1749
  const napcat = new napcat_sdk.NapCat({
1728
1750
  ...botConfig.napcat,
1729
1751
  logger
1730
1752
  });
1731
1753
  napcat.on("napcat.connected", async ({ user_id, nickname }) => {
1732
- logger.info(`>>> 已连接到 NapCat: ${nickname} (${user_id})`);
1754
+ logger.info(`>>> 已连接到 NapCat: ${consola_utils.colors.bold(consola_utils.colors.green(nickname))} (${consola_utils.colors.bold(consola_utils.colors.green(user_id))})`);
1733
1755
  let lastNoticeTime = 0;
1734
1756
  process.on("uncaughtException", async (err) => {
1735
1757
  const msg = stringifyError(err);
@@ -1813,6 +1835,7 @@ async function start(options = {}) {
1813
1835
  const failedCount = failedImportPlugins.length + failedEnablePlugins.length;
1814
1836
  const failedInfo = failedCount > 0 ? `${failedCount} 个失败 (导入 ${failedImportPlugins.length},启用 ${failedImportPlugins.length})。` : "";
1815
1837
  napcat.logger.info(`>>> 成功加载了 ${runtimePlugins.size} 个插件。${failedInfo ? failedInfo : ""}总耗时 ${costTime} ms`);
1838
+ napcat.logger.info(`>>> mioki 启动完成!祝您使用愉快!🎉️`);
1816
1839
  if (botConfig.online_push) await noticeMainOwner(napcat, `✅ mioki v${version} 已就绪`).catch((err) => {
1817
1840
  napcat.logger.error(`>>> 发送就绪通知失败: ${stringifyError(err)}`);
1818
1841
  });