koishi-plugin-eat-what-next 0.0.1

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/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Context, Schema } from "koishi";
2
+ export declare const name = "eat-what-next";
3
+ export interface Config {
4
+ }
5
+ export declare const Config: Schema<Config>;
6
+ export declare function apply(ctx: Context): void;
package/lib/index.js ADDED
@@ -0,0 +1,78 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name2 in all)
10
+ __defProp(target, name2, { get: all[name2], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Config: () => Config,
34
+ apply: () => apply,
35
+ name: () => name
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+ var import_koishi = require("koishi");
39
+ var import_path = __toESM(require("path"));
40
+ var import_fs = __toESM(require("fs"));
41
+ var import_jsx_runtime = require("@satorijs/element/jsx-runtime");
42
+ var name = "eat-what-next";
43
+ var Config = import_koishi.Schema.object({});
44
+ function getMimeType(fileName) {
45
+ const ext = import_path.default.extname(fileName).toLowerCase();
46
+ if (ext === ".png") return "image/png";
47
+ if (ext === ".jpg" || ext === ".jpeg") return "image/jpeg";
48
+ if (ext === ".webp") return "image/webp";
49
+ if (ext === ".gif") return "image/gif";
50
+ return "image/jpeg";
51
+ }
52
+ __name(getMimeType, "getMimeType");
53
+ function apply(ctx) {
54
+ ctx.guild().command("吃什么", "吃什么呢?").action(async () => {
55
+ const dir = import_path.default.resolve(__dirname, "../assets/foods");
56
+ const fileList = import_fs.default.readdirSync(dir).filter((file) => /\.(png|jpe?g|webp|gif)$/i.test(file));
57
+ if (!fileList.length) {
58
+ return "暂无可用菜品图片。";
59
+ }
60
+ const randomFood = fileList[import_koishi.Random.int(fileList.length - 1)];
61
+ const imagePath = import_path.default.join(dir, randomFood);
62
+ const imageBuffer = import_fs.default.readFileSync(imagePath);
63
+ const foodName = import_path.default.parse(randomFood).name;
64
+ const mime = getMimeType(randomFood);
65
+ const base64 = imageBuffer.toString("base64");
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
67
+ `今天吃:${foodName}`,
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: `data:${mime};base64,${base64}`, alt: foodName })
69
+ ] });
70
+ });
71
+ }
72
+ __name(apply, "apply");
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ Config,
76
+ apply,
77
+ name
78
+ });
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "koishi-plugin-eat-what-next",
3
+ "description": "吃什么呢pro",
4
+ "version": "0.0.1",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "dist"
10
+ ],
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "chatbot",
14
+ "koishi",
15
+ "plugin"
16
+ ],
17
+ "dependencies": {
18
+ "@satorijs/element": "^3.1.8"
19
+ },
20
+ "peerDependencies": {
21
+ "koishi": "4.18.11"
22
+ }
23
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # koishi-plugin-eat-what-next
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-eat-what-next?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-eat-what-next)
4
+
5
+ 吃什么呢