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.mjs CHANGED
@@ -821,12 +821,30 @@ function getLogFilePath$1(uin, platformName) {
821
821
  //#endregion
822
822
  //#region src/logger.ts
823
823
  const LEVEL_MAP = {
824
- 0: "FATAL",
825
- 1: "ERROR",
826
- 2: "WARN",
827
- 3: "INFO",
828
- 4: "DEBUG",
829
- 5: "TRACE"
824
+ 0: {
825
+ name: "ERROR",
826
+ color: "red"
827
+ },
828
+ 1: {
829
+ name: "WARN",
830
+ color: "yellow"
831
+ },
832
+ 2: {
833
+ name: "LOG",
834
+ color: "white"
835
+ },
836
+ 3: {
837
+ name: "INFO",
838
+ color: "green"
839
+ },
840
+ 4: {
841
+ name: "DEBUG",
842
+ color: "blue"
843
+ },
844
+ 5: {
845
+ name: "TRACE",
846
+ color: "gray"
847
+ }
830
848
  };
831
849
  /**
832
850
  * 获取日志文件名
@@ -844,11 +862,11 @@ const getMiokiLogger = (level) => {
844
862
  defaults: { tag: "mioki" },
845
863
  reporters: [{ log: (logObj) => {
846
864
  const message = stripAnsi(logObj.message || logObj.args?.join(" ") || "");
847
- const line = `${`[${logObj.date.toISOString()}] [${LEVEL_MAP[logObj.level]}] ${logObj.tag ? `[${logObj.tag}] ` : ""}`}${message}`;
865
+ const line = `${`[${logObj.date.toISOString()}] [${LEVEL_MAP[logObj.level].name}] ${logObj.tag ? `[${logObj.tag}] ` : ""}`}${message}`;
848
866
  fs$1.appendFileSync(logFile, line + "\n");
849
867
  } }, { log: (logObj) => {
850
868
  const message = logObj.message || logObj.args?.join(" ") || "";
851
- const line = `${colors.gray(`[${logObj.date.toLocaleTimeString("zh-CN")}]`) + " " + colors.bold(colors.blue(LEVEL_MAP[logObj.level])) + " " + (logObj.tag ? colors.bold(colors.green(`[${logObj.tag}] `)) : "")}${message}`;
869
+ const line = `${colors.gray(`[${logObj.date.toLocaleTimeString("zh-CN")}]`) + " " + colors.bold(colors[LEVEL_MAP[logObj.level].color](LEVEL_MAP[logObj.level].name)) + " " + (logObj.tag ? colors.bold(colors.dim(`[${logObj.tag}] `)) : "")}${message}`;
852
870
  if (logObj.level <= LogLevels["info"]) console.log(line);
853
871
  else if (logObj.level === LogLevels["warn"]) console.warn(line);
854
872
  else console.debug(line);
@@ -863,7 +881,7 @@ const getMiokiLogger = (level) => {
863
881
 
864
882
  //#endregion
865
883
  //#region package.json
866
- var version = "0.3.0";
884
+ var version = "0.4.0";
867
885
 
868
886
  //#endregion
869
887
  //#region src/actions.ts
@@ -1671,15 +1689,19 @@ async function start(options = {}) {
1671
1689
  process.title = `mioki v${version}`;
1672
1690
  const logger = getMiokiLogger(botConfig.log_level || "info");
1673
1691
  const plugin_dir = getAbsPluginDir();
1674
- logger.info(`>>> mioki v${version} 启动中`);
1675
- logger.info(`>>> 工作目录: ${BOT_CWD.value}`);
1676
- logger.info(`>>> 插件目录: ${plugin_dir}`);
1692
+ logger.info(`>>> 〓 ${colors.bold(colors.cyan("mioki"))} ${colors.bold(colors.green(`v${version}`))} 〓`);
1693
+ logger.info(`>>> ${colors.yellow(colors.underline(`基于 NapCat 的 TypeScript 🤖️ 机器人框架。`))}`);
1694
+ logger.info(`>>> ${colors.yellow(colors.underline(`作者: Viki <hi@viki.moe> (https://github.com/vikiboss)`))}`);
1695
+ logger.info(`>>> ${colors.yellow(colors.underline(`协议: Licensed under MIT License.`))}`);
1696
+ logger.info(`>>> ${colors.cyan(colors.underline(`GitHub: http://github.com/vikiboss/mioki`))}`);
1697
+ logger.info(`>>> 工作目录: ${colors.bold(colors.blue(BOT_CWD.value))}`);
1698
+ logger.info(`>>> 插件目录: ${colors.bold(colors.blue(plugin_dir))}`);
1677
1699
  const napcat = new NapCat({
1678
1700
  ...botConfig.napcat,
1679
1701
  logger
1680
1702
  });
1681
1703
  napcat.on("napcat.connected", async ({ user_id, nickname }) => {
1682
- logger.info(`>>> 已连接到 NapCat: ${nickname} (${user_id})`);
1704
+ logger.info(`>>> 已连接到 NapCat: ${colors.bold(colors.green(nickname))} (${colors.bold(colors.green(user_id))})`);
1683
1705
  let lastNoticeTime = 0;
1684
1706
  process.on("uncaughtException", async (err) => {
1685
1707
  const msg = stringifyError(err);
@@ -1763,6 +1785,7 @@ async function start(options = {}) {
1763
1785
  const failedCount = failedImportPlugins.length + failedEnablePlugins.length;
1764
1786
  const failedInfo = failedCount > 0 ? `${failedCount} 个失败 (导入 ${failedImportPlugins.length},启用 ${failedImportPlugins.length})。` : "";
1765
1787
  napcat.logger.info(`>>> 成功加载了 ${runtimePlugins.size} 个插件。${failedInfo ? failedInfo : ""}总耗时 ${costTime} ms`);
1788
+ napcat.logger.info(`>>> mioki 启动完成!祝您使用愉快!🎉️`);
1766
1789
  if (botConfig.online_push) await noticeMainOwner(napcat, `✅ mioki v${version} 已就绪`).catch((err) => {
1767
1790
  napcat.logger.error(`>>> 发送就绪通知失败: ${stringifyError(err)}`);
1768
1791
  });