@azimiao/koishi-plugin-cafe-bot-exp 0.0.21 → 0.0.23

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/lib/config.d.ts CHANGED
@@ -2,5 +2,10 @@ import { Schema } from "koishi";
2
2
  import { CafeBotDrawConfig } from "./draw/config";
3
3
  import { CafeBotQuizConfig } from "./quiz/config";
4
4
  import { CafeBotCatConfig } from "./cat/config";
5
- export type Config = CafeBotDrawConfig & CafeBotQuizConfig & CafeBotCatConfig;
5
+ export interface CafeBotConfig {
6
+ logoUrl: string;
7
+ refreshLogoWhenLoad: boolean;
8
+ useLocalLogoFile: boolean;
9
+ }
10
+ export type Config = CafeBotConfig & CafeBotDrawConfig & CafeBotQuizConfig & CafeBotCatConfig;
6
11
  export declare const Config: Schema<Config>;
package/lib/index.js CHANGED
@@ -37,10 +37,13 @@ __export(src_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(src_exports);
39
39
  var import_url = require("url");
40
- var import_path = require("path");
41
40
 
42
41
  // package.json
43
- var version = "0.0.21";
42
+ var version = "0.0.23";
43
+
44
+ // src/index.ts
45
+ var fs4 = __toESM(require("fs/promises"));
46
+ var path3 = __toESM(require("path"));
44
47
 
45
48
  // src/draw/index.ts
46
49
  var draw_exports = {};
@@ -802,6 +805,11 @@ __name(apply3, "apply");
802
805
  // src/config.ts
803
806
  var import_koishi7 = require("koishi");
804
807
  var Config4 = import_koishi7.Schema.intersect([
808
+ import_koishi7.Schema.object({
809
+ logoUrl: import_koishi7.Schema.string().description("LOGO图片").default("https://www.azimiao.com/wp-content/uploads/2025/05/cafe-wide.jpg"),
810
+ refreshLogoWhenLoad: import_koishi7.Schema.boolean().description("每次加载插件强制刷新logo").default(false),
811
+ useLocalLogoFile: import_koishi7.Schema.boolean().description("使用本地存储的logo文件").default(false)
812
+ }),
805
813
  CafeBotDrawConfig.collapse(),
806
814
  CafeBotQuizConfig.collapse(),
807
815
  CafeBotCatConfig.collapse()
@@ -813,13 +821,22 @@ var inject3 = {
813
821
  required: ["http", "cache", "database"],
814
822
  optional: ["logger"]
815
823
  };
824
+ var logger3 = null;
825
+ var logoFilePath = null;
816
826
  async function apply4(ctx, config) {
827
+ logger3 = ctx.logger(name4);
817
828
  ctx.plugin(draw_exports, config);
818
829
  ctx.plugin(quiz_exports, config);
819
830
  ctx.plugin(cat_exports, config);
831
+ const root = path3.join(ctx.baseDir, "data", `${name4}-data`);
832
+ await fs4.mkdir(root, { recursive: true });
833
+ logoFilePath = path3.join(root, "logo.jpg");
834
+ logger3?.info(`Try check logoFile ${logoFilePath} or download it, forceUpdate:${config.refreshLogoWhenLoad}`);
835
+ var result = await downloadTool_default(ctx.http, config.logoUrl, logoFilePath, config.refreshLogoWhenLoad);
836
+ logger3?.info(`download file ${result ? "ok" : "failed"}`);
820
837
  ctx.command("关于", "关于本机器人的信息").action(async (argv, _) => {
821
838
  argv.session?.send(
822
- `<img src="${(0, import_url.pathToFileURL)((0, import_path.resolve)(__dirname, "logo.jpg")).href}"/>
839
+ `<img src="${config.useLocalLogoFile ? (0, import_url.pathToFileURL)(logoFilePath).href : config.logoUrl}"/>
823
840
  Hi~我是轨迹CafeBot概念版v${version}🎉~
824
841
  我运行在🖥️超级计算机『卡佩尔』上🛜
825
842
  🔹 我提供轨迹抽卡🎴和轨迹问答🙋‍功能
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azimiao/koishi-plugin-cafe-bot-exp",
3
3
  "description": "cafe bot experiment",
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "repository": {