mioki 0.6.10 → 0.7.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/cli.cjs ADDED
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env node
2
+ const require_package = require('./package-CBPOLltF.cjs');
3
+ let node_fs = require("node:fs");
4
+ node_fs = require_package.__toESM(node_fs);
5
+ let node_path = require("node:path");
6
+ node_path = require_package.__toESM(node_path);
7
+ let mri = require("mri");
8
+ mri = require_package.__toESM(mri);
9
+ let dedent = require("dedent");
10
+ dedent = require_package.__toESM(dedent);
11
+ let consola = require("consola");
12
+ consola = require_package.__toESM(consola);
13
+
14
+ //#region src/cli.ts
15
+ const args = process.argv.slice(2);
16
+ (async () => {
17
+ const cli = (0, mri.default)(args, { alias: {
18
+ v: "version",
19
+ h: "help"
20
+ } });
21
+ const helpInfo = (0, dedent.default)(`
22
+ mioki 命令行工具 v${require_package.version}
23
+
24
+ 选项:
25
+ -h, --help 显示帮助信息
26
+ -v, --version 显示版本号
27
+
28
+ 用法: mioki <命令> [选项]
29
+
30
+ 命令:
31
+ init [选项] 创建一个新的 mioki 项目
32
+
33
+ 选项:
34
+ --name <name> 指定项目名称
35
+ --protocol <protocol> 指定 NapCat 协议,默认 ws
36
+ --host <host> 指定 NapCat 主机,默认 localhost
37
+ --port <port> 指定 NapCat 端口,默认 3333
38
+ --token <token> 指定 NapCat 连接令牌
39
+ --prefix <prefix> 指定命令前缀,默认 #
40
+ --owners <owners> 指定主人 QQ,英文逗号分隔
41
+ --admins <admins> 指定管理员 QQ,英文逗号分隔
42
+ --use-npm-mirror 使用 npm 镜像源加速依赖安装
43
+ `);
44
+ switch (true) {
45
+ case cli.version:
46
+ console.log(`v${require_package.version}`);
47
+ process.exit(0);
48
+ case cli.help:
49
+ console.log(helpInfo);
50
+ process.exit(0);
51
+ }
52
+ const { name = await input("请输入项目名称", {
53
+ default: "bot",
54
+ placeholder: "bot",
55
+ required: true
56
+ }), protocol = await input("请输入 NapCat WS 协议", {
57
+ default: "ws",
58
+ placeholder: "ws",
59
+ required: true
60
+ }), host = await input("请输入 NapCat WS 主机", {
61
+ default: "localhost",
62
+ placeholder: "localhost",
63
+ required: true
64
+ }), port = parseInt(await input("请输入 NapCat WS 端口", {
65
+ default: "3333",
66
+ placeholder: "3333",
67
+ required: true
68
+ })), token = await input("请输入 NapCat WS Token(必填)", {
69
+ default: "",
70
+ placeholder: "请输入",
71
+ required: true
72
+ }), prefix = await input("请输入消息命令前缀", {
73
+ default: "#",
74
+ placeholder: "#",
75
+ required: true
76
+ }), owners = await input("请输入主人 QQ (最高权限,英文逗号分隔,必填)", {
77
+ placeholder: "请输入",
78
+ required: true
79
+ }), admins = await input("请输入管理员 QQ (插件权限,英文逗号分隔,可空)", { placeholder: "可空" }) || "", "use-npm-mirror": useNpmMirror = await confirm("是否使用 npm 镜像源加速依赖安装?") } = cli;
80
+ const pkgJson = (0, dedent.default)(`
81
+ {
82
+ "name": "mioki-bot",
83
+ "private": true,
84
+ "dependencies": {
85
+ "mioki": "^${require_package.version}"
86
+ },
87
+ "mioki": {
88
+ "prefix": "${prefix}",
89
+ "owners": [${owners.split(",").map((o) => o.trim()).join(", ")}],
90
+ "admins": [${admins ? admins.split(",").map((o) => `"${o.trim()}"`).join(", ") : ""}],
91
+ "plugins": [],
92
+ "log_level": "info",
93
+ "online_push": true,
94
+ "error_push": true,
95
+ "napcat": {
96
+ "protocol": "${protocol}",
97
+ "port": ${port},
98
+ "host": "${host}",
99
+ "token": "${token}"
100
+ }
101
+ },
102
+ "scripts": {
103
+ "start": "node app.ts"
104
+ }
105
+ }
106
+ `);
107
+ const pluginCode = (0, dedent.default)(`
108
+ import { definePlugin } from 'mioki'
109
+
110
+ export default definePlugin({
111
+ name: 'demo',
112
+ version: '${require_package.version}',
113
+ async setup(ctx) {
114
+ ctx.logger.info('Demo 插件已加载')
115
+
116
+ // ctx.bot.nickname;
117
+ // ctx.bot.uin;
118
+ // ctx.bot.api('xxx', params);
119
+
120
+ // ctx.bot.sendGroupMsg(123456789, 'Hello Group!') // 发送群消息
121
+
122
+ // const group = await ctx.bot.pickGroup(123456789) // 使用群号选择一个群实例
123
+ // group?.sign() // 调用群实例方法
124
+
125
+ // const friend = await ctx.bot.pickFriend(987654321) // 使用好友号选择一个好友实例
126
+ // friend?.delete() // 调用好友实例方法
127
+
128
+ // 处理所有消息:群、好友
129
+ ctx.handle('message', async (e) => {
130
+ // 收到 hello 消息时回复 world
131
+ if (e.raw_message === 'hello') {
132
+ // 第二个参数表示是否回复原消息
133
+ e.reply('world', true)
134
+ }
135
+
136
+ // 收到 love 消息时回复"爱你哟"和一个爱心 QQ 表情
137
+ if (e.raw_message === 'love') {
138
+ // 复杂消息消息可以使用数组组合
139
+ e.reply(['爱你哟 ', ctx.segment.face(66)])
140
+ }
141
+
142
+ // 收到 壁纸 消息时回复今天的 bing 壁纸
143
+ if (e.raw_message === '壁纸') {
144
+ e.reply(ctx.segment.image('https://60s.viki.moe/v2/bing?encoding=image'))
145
+ }
146
+
147
+ // 收到 一言 消息时回复一言
148
+ if (e.raw_message === '一言') {
149
+ const data = await (await fetch('https://v1.hitokoto.cn/')).json()
150
+ e.reply(data.hitokoto, true)
151
+ }
152
+ })
153
+
154
+ ctx.handle('message.group', (e) => {
155
+ // 处理群消息
156
+ // 调用消息实例上挂载的快速方法
157
+ // e.reply('这是群消息的回复') // 回复消息
158
+ // e.recall() // 撤回消息
159
+ // e.getQuoteMessage() // 获取引用的消息
160
+ // e.group.getInfo(); // 也可以通过群消息事件获取群实例,并调用群实例方法获取群信息
161
+ })
162
+
163
+ ctx.handle('message.private', (e) => {
164
+ // 处理好友消息
165
+ })
166
+
167
+ // 处理所有请求:好友、群,添加好友、邀请入群等等
168
+ ctx.handle('request', (e) => {
169
+ e.approve() // 同意请求
170
+ // e.reject() // 拒绝请求
171
+ })
172
+
173
+ // 处理所有通知,好友、群的数量增加与减少、戳一戳、撤回等等
174
+ ctx.handle('notice', (e) => {
175
+ ctx.logger.info('Notice', e)
176
+ })
177
+
178
+ // 注册定时任务
179
+ ctx.cron('*/3 * * * * *', async (ctx, task) => {
180
+ ctx.logger.info('Cron', task)
181
+ })
182
+
183
+ return () => {
184
+ ctx.logger.info('Demo 插件已卸载')
185
+ }
186
+ },
187
+ })
188
+
189
+ `);
190
+ const npmrc = (0, dedent.default)(`
191
+ registry=https://registry.npmmirror.com
192
+ fund=false
193
+ `);
194
+ createNewProject(name, {
195
+ "app.ts": "require('mioki').start({ cwd: __dirname })",
196
+ "package.json": pkgJson,
197
+ plugins: { demo: { "index.ts": pluginCode } },
198
+ ...useNpmMirror ? { ".npmrc": npmrc } : {}
199
+ });
200
+ })();
201
+ async function createNewProject(name, fileTree) {
202
+ const projectName = name;
203
+ const projectPath = withRoot(`./${projectName}`);
204
+ if (node_fs.default.existsSync(projectPath)) {
205
+ if (!await confirm(`项目 ${projectName} 已存在,是否覆盖?`)) gracefullyExit();
206
+ if (projectPath === process.cwd()) {
207
+ if (node_fs.default.readdirSync(projectPath).length !== 0) {
208
+ if (!await confirm("项目路径与当前路径相同,将删除当前目录下所有内容再创建,是否继续?")) gracefullyExit();
209
+ }
210
+ }
211
+ node_fs.default.rmSync(projectPath, { recursive: true });
212
+ }
213
+ node_fs.default.mkdirSync(projectPath);
214
+ makeFileTree(fileTree, projectPath);
215
+ console.log(`项目 ${projectName} 创建成功!根据下面的引导启动 mioki。`);
216
+ console.log(`\ncd ${projectPath} && npm install && npm start\n`);
217
+ }
218
+ function gracefullyExit() {
219
+ console.log("Bye!");
220
+ process.exit(0);
221
+ }
222
+ function withRoot(_path) {
223
+ return node_path.default.resolve(process.cwd(), _path);
224
+ }
225
+ async function confirm(message, options) {
226
+ return consola.default.prompt(message, {
227
+ type: "confirm",
228
+ cancel: "reject",
229
+ ...options
230
+ });
231
+ }
232
+ async function input(message, options) {
233
+ const res = await consola.default.prompt(message, {
234
+ type: "text",
235
+ cancel: "reject",
236
+ ...options
237
+ });
238
+ if (options?.required) required(res);
239
+ return res;
240
+ }
241
+ function makeFileTree(fileTree, base) {
242
+ for (const [name, content] of Object.entries(fileTree)) if (typeof content === "object" && content !== null) {
243
+ const subPath = `${base}/${name}`;
244
+ if (!node_fs.default.existsSync(subPath)) node_fs.default.mkdirSync(subPath);
245
+ for (const [subName, subContent] of Object.entries(content)) if (typeof subContent === "object") makeFileTree(content, subPath);
246
+ else node_fs.default.writeFileSync(`${subPath}/${subName}`, subContent);
247
+ } else {
248
+ const filePath = `${base}/${name}`;
249
+ const dirname = node_path.default.dirname(filePath);
250
+ if (!node_fs.default.existsSync(dirname)) node_fs.default.mkdirSync(dirname);
251
+ node_fs.default.writeFileSync(filePath, content);
252
+ }
253
+ }
254
+ function required(value) {
255
+ if (Array.isArray(value) ? !value.length : !value) {
256
+ console.error("目标值不能为空");
257
+ process.exit(1);
258
+ }
259
+ return value;
260
+ }
261
+
262
+ //#endregion
263
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.cjs","names":["version","fs","path"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from 'node:fs'\nimport mri from 'mri'\nimport path from 'node:path'\nimport dedent from 'dedent'\nimport consola from 'consola'\nimport { version } from '../package.json'\n\nimport type { ConfirmPromptOptions, TextPromptOptions } from 'consola'\n\nconst args = process.argv.slice(2)\n\ninterface CliOptions {\n name?: string\n protocol?: string\n host?: string\n port?: number\n token?: string\n prefix?: string\n owners?: string\n admins?: string\n help?: boolean\n version?: boolean\n 'use-npm-mirror'?: boolean\n}\n\n;(async () => {\n const cli = mri<CliOptions>(args, {\n alias: {\n v: 'version',\n h: 'help',\n },\n })\n\n const helpInfo = dedent(\n `\n mioki 命令行工具 v${version}\n\n 选项:\n -h, --help 显示帮助信息\n -v, --version 显示版本号\n\n 用法: mioki <命令> [选项]\n\n 命令:\n init [选项] 创建一个新的 mioki 项目\n\n 选项:\n --name <name> 指定项目名称\n --protocol <protocol> 指定 NapCat 协议,默认 ws\n --host <host> 指定 NapCat 主机,默认 localhost\n --port <port> 指定 NapCat 端口,默认 3333\n --token <token> 指定 NapCat 连接令牌\n --prefix <prefix> 指定命令前缀,默认 #\n --owners <owners> 指定主人 QQ,英文逗号分隔\n --admins <admins> 指定管理员 QQ,英文逗号分隔\n --use-npm-mirror 使用 npm 镜像源加速依赖安装\n`,\n )\n\n switch (true) {\n case cli.version:\n console.log(`v${version}`)\n process.exit(0)\n\n case cli.help:\n console.log(helpInfo)\n process.exit(0)\n }\n\n const {\n name = await input('请输入项目名称', { default: 'bot', placeholder: 'bot', required: true }),\n protocol = await input('请输入 NapCat WS 协议', { default: 'ws', placeholder: 'ws', required: true }),\n host = await input('请输入 NapCat WS 主机', { default: 'localhost', placeholder: 'localhost', required: true }),\n port = parseInt(await input('请输入 NapCat WS 端口', { default: '3333', placeholder: '3333', required: true })),\n token = await input('请输入 NapCat WS Token(必填)', { default: '', placeholder: '请输入', required: true }),\n prefix = await input('请输入消息命令前缀', { default: '#', placeholder: '#', required: true }),\n owners = await input('请输入主人 QQ (最高权限,英文逗号分隔,必填)', { placeholder: '请输入', required: true }),\n admins = (await input('请输入管理员 QQ (插件权限,英文逗号分隔,可空)', { placeholder: '可空' })) || '',\n 'use-npm-mirror': useNpmMirror = await confirm('是否使用 npm 镜像源加速依赖安装?'),\n } = cli\n\n const pkgJson = dedent(`\n {\n \"name\": \"mioki-bot\",\n \"private\": true,\n \"dependencies\": {\n \"mioki\": \"^${version}\"\n },\n \"mioki\": {\n \"prefix\": \"${prefix}\",\n \"owners\": [${owners\n .split(',')\n .map((o) => o.trim())\n .join(', ')}],\n \"admins\": [${\n admins\n ? admins\n .split(',')\n .map((o) => `\"${o.trim()}\"`)\n .join(', ')\n : ''\n }],\n \"plugins\": [],\n \"log_level\": \"info\",\n \"online_push\": true,\n \"error_push\": true,\n \"napcat\": {\n \"protocol\": \"${protocol}\",\n \"port\": ${port},\n \"host\": \"${host}\",\n \"token\": \"${token}\"\n }\n },\n \"scripts\": {\n \"start\": \"node app.ts\"\n }\n }\n`)\n\n const pluginCode = dedent(`\n import { definePlugin } from 'mioki'\n\n export default definePlugin({\n name: 'demo',\n version: '${version}',\n async setup(ctx) {\n ctx.logger.info('Demo 插件已加载')\n\n // ctx.bot.nickname;\n // ctx.bot.uin;\n // ctx.bot.api('xxx', params);\n\n // ctx.bot.sendGroupMsg(123456789, 'Hello Group!') // 发送群消息\n\n // const group = await ctx.bot.pickGroup(123456789) // 使用群号选择一个群实例\n // group?.sign() // 调用群实例方法\n\n // const friend = await ctx.bot.pickFriend(987654321) // 使用好友号选择一个好友实例\n // friend?.delete() // 调用好友实例方法\n\n // 处理所有消息:群、好友\n ctx.handle('message', async (e) => {\n // 收到 hello 消息时回复 world\n if (e.raw_message === 'hello') {\n // 第二个参数表示是否回复原消息\n e.reply('world', true)\n }\n\n // 收到 love 消息时回复\"爱你哟\"和一个爱心 QQ 表情\n if (e.raw_message === 'love') {\n // 复杂消息消息可以使用数组组合\n e.reply(['爱你哟 ', ctx.segment.face(66)])\n }\n\n // 收到 壁纸 消息时回复今天的 bing 壁纸\n if (e.raw_message === '壁纸') {\n e.reply(ctx.segment.image('https://60s.viki.moe/v2/bing?encoding=image'))\n }\n\n // 收到 一言 消息时回复一言\n if (e.raw_message === '一言') {\n const data = await (await fetch('https://v1.hitokoto.cn/')).json()\n e.reply(data.hitokoto, true)\n }\n })\n\n ctx.handle('message.group', (e) => {\n // 处理群消息\n // 调用消息实例上挂载的快速方法\n // e.reply('这是群消息的回复') // 回复消息\n // e.recall() // 撤回消息\n // e.getQuoteMessage() // 获取引用的消息\n // e.group.getInfo(); // 也可以通过群消息事件获取群实例,并调用群实例方法获取群信息\n })\n\n ctx.handle('message.private', (e) => {\n // 处理好友消息\n })\n\n // 处理所有请求:好友、群,添加好友、邀请入群等等\n ctx.handle('request', (e) => {\n e.approve() // 同意请求\n // e.reject() // 拒绝请求\n })\n\n // 处理所有通知,好友、群的数量增加与减少、戳一戳、撤回等等\n ctx.handle('notice', (e) => {\n ctx.logger.info('Notice', e)\n })\n\n // 注册定时任务\n ctx.cron('*/3 * * * * *', async (ctx, task) => {\n ctx.logger.info('Cron', task)\n })\n\n return () => {\n ctx.logger.info('Demo 插件已卸载')\n }\n },\n })\n\n`)\n\n const npmrc = dedent(`\n registry=https://registry.npmmirror.com\n fund=false\n`)\n\n const fileTree = {\n 'app.ts': \"require('mioki').start({ cwd: __dirname })\",\n 'package.json': pkgJson,\n plugins: { demo: { 'index.ts': pluginCode } },\n ...(useNpmMirror ? { '.npmrc': npmrc } : {}),\n }\n\n createNewProject(name, fileTree)\n})()\n\nasync function createNewProject(name: string, fileTree: Record<string, any>) {\n const projectName = name\n const projectPath = withRoot(`./${projectName}`)\n\n if (fs.existsSync(projectPath)) {\n const overwrite = await confirm(`项目 ${projectName} 已存在,是否覆盖?`)\n\n if (!overwrite) {\n gracefullyExit()\n }\n\n if (projectPath === process.cwd()) {\n if (fs.readdirSync(projectPath).length !== 0) {\n const confirmOver = await confirm('项目路径与当前路径相同,将删除当前目录下所有内容再创建,是否继续?')\n if (!confirmOver) {\n gracefullyExit()\n }\n }\n }\n\n fs.rmSync(projectPath, { recursive: true })\n }\n\n fs.mkdirSync(projectPath)\n\n makeFileTree(fileTree, projectPath)\n\n console.log(`项目 ${projectName} 创建成功!根据下面的引导启动 mioki。`)\n console.log(`\\ncd ${projectPath} && npm install && npm start\\n`)\n}\n\nfunction gracefullyExit() {\n console.log('Bye!')\n process.exit(0)\n}\n\nfunction withRoot(_path: string) {\n return path.resolve(process.cwd(), _path)\n}\n\ntype OmitTypeWithRequired<T> = Omit<T, 'type' | 'required'> & { required?: boolean }\n\nasync function confirm(message: string, options?: OmitTypeWithRequired<ConfirmPromptOptions>) {\n return consola.prompt(message, { type: 'confirm', cancel: 'reject', ...options })\n}\n\nasync function input(message: string, options?: OmitTypeWithRequired<TextPromptOptions>) {\n const res = await consola.prompt(message, { type: 'text', cancel: 'reject', ...options })\n if (options?.required) required(res)\n return res\n}\n\nfunction makeFileTree(\n fileTree: Record<string, string | Record<string, string | Record<string, string>>>,\n base: string,\n) {\n for (const [name, content] of Object.entries(fileTree)) {\n if (typeof content === 'object' && content !== null) {\n const subPath = `${base}/${name}`\n if (!fs.existsSync(subPath)) {\n fs.mkdirSync(subPath)\n }\n for (const [subName, subContent] of Object.entries(content)) {\n if (typeof subContent === 'object') {\n makeFileTree(content, subPath)\n } else {\n fs.writeFileSync(`${subPath}/${subName}`, subContent)\n }\n }\n } else {\n const filePath = `${base}/${name}`\n const dirname = path.dirname(filePath)\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname)\n }\n fs.writeFileSync(filePath, content)\n }\n }\n}\n\nfunction required<T extends string | undefined | null | Array<string | undefined | null>>(value: T): T {\n if (Array.isArray(value) ? !value.length : !value) {\n console.error('目标值不能为空')\n process.exit(1)\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;CAgBhC,YAAY;CACZ,MAAM,uBAAsB,MAAM,EAChC,OAAO;EACL,GAAG;EACH,GAAG;EACJ,EACF,CAAC;CAEF,MAAM,+BACJ;iBACaA,wBAAQ;;;;;;;;;;;;;;;;;;;;;EAsBtB;AAED,SAAQ,MAAR;EACE,KAAK,IAAI;AACP,WAAQ,IAAI,IAAIA,0BAAU;AAC1B,WAAQ,KAAK,EAAE;EAEjB,KAAK,IAAI;AACP,WAAQ,IAAI,SAAS;AACrB,WAAQ,KAAK,EAAE;;CAGnB,MAAM,EACJ,OAAO,MAAM,MAAM,WAAW;EAAE,SAAS;EAAO,aAAa;EAAO,UAAU;EAAM,CAAC,EACrF,WAAW,MAAM,MAAM,oBAAoB;EAAE,SAAS;EAAM,aAAa;EAAM,UAAU;EAAM,CAAC,EAChG,OAAO,MAAM,MAAM,oBAAoB;EAAE,SAAS;EAAa,aAAa;EAAa,UAAU;EAAM,CAAC,EAC1G,OAAO,SAAS,MA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AAG;EAC5B,MAAM,UAAUC,kBAAK,QAAQ,SAAS;AACtC,MAAI,CAACD,gBAAG,WAAW,QAAQ,CACzB,iBAAG,UAAU,QAAQ;AAEvB,kBAAG,cAAc,UAAU,QAAQ;;;AAKzC,SAAS,SAAiF,OAAa;AACrG,KAAI,MAAM,QAAQ,MAAM,GAAG,CAAC,MAAM,SAAS,CAAC,OAAO;AACjD,UAAQ,MAAM,UAAU;AACxB,UAAQ,KAAK,EAAE;;AAGjB,QAAO"}
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs ADDED
@@ -0,0 +1,259 @@
1
+ #!/usr/bin/env node
2
+ import { t as version } from "./package-BcfUfnW0.mjs";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import mri from "mri";
6
+ import dedent from "dedent";
7
+ import consola from "consola";
8
+
9
+ //#region src/cli.ts
10
+ const args = process.argv.slice(2);
11
+ (async () => {
12
+ const cli = mri(args, { alias: {
13
+ v: "version",
14
+ h: "help"
15
+ } });
16
+ const helpInfo = dedent(`
17
+ mioki 命令行工具 v${version}
18
+
19
+ 选项:
20
+ -h, --help 显示帮助信息
21
+ -v, --version 显示版本号
22
+
23
+ 用法: mioki <命令> [选项]
24
+
25
+ 命令:
26
+ init [选项] 创建一个新的 mioki 项目
27
+
28
+ 选项:
29
+ --name <name> 指定项目名称
30
+ --protocol <protocol> 指定 NapCat 协议,默认 ws
31
+ --host <host> 指定 NapCat 主机,默认 localhost
32
+ --port <port> 指定 NapCat 端口,默认 3333
33
+ --token <token> 指定 NapCat 连接令牌
34
+ --prefix <prefix> 指定命令前缀,默认 #
35
+ --owners <owners> 指定主人 QQ,英文逗号分隔
36
+ --admins <admins> 指定管理员 QQ,英文逗号分隔
37
+ --use-npm-mirror 使用 npm 镜像源加速依赖安装
38
+ `);
39
+ switch (true) {
40
+ case cli.version:
41
+ console.log(`v${version}`);
42
+ process.exit(0);
43
+ case cli.help:
44
+ console.log(helpInfo);
45
+ process.exit(0);
46
+ }
47
+ const { name = await input("请输入项目名称", {
48
+ default: "bot",
49
+ placeholder: "bot",
50
+ required: true
51
+ }), protocol = await input("请输入 NapCat WS 协议", {
52
+ default: "ws",
53
+ placeholder: "ws",
54
+ required: true
55
+ }), host = await input("请输入 NapCat WS 主机", {
56
+ default: "localhost",
57
+ placeholder: "localhost",
58
+ required: true
59
+ }), port = parseInt(await input("请输入 NapCat WS 端口", {
60
+ default: "3333",
61
+ placeholder: "3333",
62
+ required: true
63
+ })), token = await input("请输入 NapCat WS Token(必填)", {
64
+ default: "",
65
+ placeholder: "请输入",
66
+ required: true
67
+ }), prefix = await input("请输入消息命令前缀", {
68
+ default: "#",
69
+ placeholder: "#",
70
+ required: true
71
+ }), owners = await input("请输入主人 QQ (最高权限,英文逗号分隔,必填)", {
72
+ placeholder: "请输入",
73
+ required: true
74
+ }), admins = await input("请输入管理员 QQ (插件权限,英文逗号分隔,可空)", { placeholder: "可空" }) || "", "use-npm-mirror": useNpmMirror = await confirm("是否使用 npm 镜像源加速依赖安装?") } = cli;
75
+ const pkgJson = dedent(`
76
+ {
77
+ "name": "mioki-bot",
78
+ "private": true,
79
+ "dependencies": {
80
+ "mioki": "^${version}"
81
+ },
82
+ "mioki": {
83
+ "prefix": "${prefix}",
84
+ "owners": [${owners.split(",").map((o) => o.trim()).join(", ")}],
85
+ "admins": [${admins ? admins.split(",").map((o) => `"${o.trim()}"`).join(", ") : ""}],
86
+ "plugins": [],
87
+ "log_level": "info",
88
+ "online_push": true,
89
+ "error_push": true,
90
+ "napcat": {
91
+ "protocol": "${protocol}",
92
+ "port": ${port},
93
+ "host": "${host}",
94
+ "token": "${token}"
95
+ }
96
+ },
97
+ "scripts": {
98
+ "start": "node app.ts"
99
+ }
100
+ }
101
+ `);
102
+ const pluginCode = dedent(`
103
+ import { definePlugin } from 'mioki'
104
+
105
+ export default definePlugin({
106
+ name: 'demo',
107
+ version: '${version}',
108
+ async setup(ctx) {
109
+ ctx.logger.info('Demo 插件已加载')
110
+
111
+ // ctx.bot.nickname;
112
+ // ctx.bot.uin;
113
+ // ctx.bot.api('xxx', params);
114
+
115
+ // ctx.bot.sendGroupMsg(123456789, 'Hello Group!') // 发送群消息
116
+
117
+ // const group = await ctx.bot.pickGroup(123456789) // 使用群号选择一个群实例
118
+ // group?.sign() // 调用群实例方法
119
+
120
+ // const friend = await ctx.bot.pickFriend(987654321) // 使用好友号选择一个好友实例
121
+ // friend?.delete() // 调用好友实例方法
122
+
123
+ // 处理所有消息:群、好友
124
+ ctx.handle('message', async (e) => {
125
+ // 收到 hello 消息时回复 world
126
+ if (e.raw_message === 'hello') {
127
+ // 第二个参数表示是否回复原消息
128
+ e.reply('world', true)
129
+ }
130
+
131
+ // 收到 love 消息时回复"爱你哟"和一个爱心 QQ 表情
132
+ if (e.raw_message === 'love') {
133
+ // 复杂消息消息可以使用数组组合
134
+ e.reply(['爱你哟 ', ctx.segment.face(66)])
135
+ }
136
+
137
+ // 收到 壁纸 消息时回复今天的 bing 壁纸
138
+ if (e.raw_message === '壁纸') {
139
+ e.reply(ctx.segment.image('https://60s.viki.moe/v2/bing?encoding=image'))
140
+ }
141
+
142
+ // 收到 一言 消息时回复一言
143
+ if (e.raw_message === '一言') {
144
+ const data = await (await fetch('https://v1.hitokoto.cn/')).json()
145
+ e.reply(data.hitokoto, true)
146
+ }
147
+ })
148
+
149
+ ctx.handle('message.group', (e) => {
150
+ // 处理群消息
151
+ // 调用消息实例上挂载的快速方法
152
+ // e.reply('这是群消息的回复') // 回复消息
153
+ // e.recall() // 撤回消息
154
+ // e.getQuoteMessage() // 获取引用的消息
155
+ // e.group.getInfo(); // 也可以通过群消息事件获取群实例,并调用群实例方法获取群信息
156
+ })
157
+
158
+ ctx.handle('message.private', (e) => {
159
+ // 处理好友消息
160
+ })
161
+
162
+ // 处理所有请求:好友、群,添加好友、邀请入群等等
163
+ ctx.handle('request', (e) => {
164
+ e.approve() // 同意请求
165
+ // e.reject() // 拒绝请求
166
+ })
167
+
168
+ // 处理所有通知,好友、群的数量增加与减少、戳一戳、撤回等等
169
+ ctx.handle('notice', (e) => {
170
+ ctx.logger.info('Notice', e)
171
+ })
172
+
173
+ // 注册定时任务
174
+ ctx.cron('*/3 * * * * *', async (ctx, task) => {
175
+ ctx.logger.info('Cron', task)
176
+ })
177
+
178
+ return () => {
179
+ ctx.logger.info('Demo 插件已卸载')
180
+ }
181
+ },
182
+ })
183
+
184
+ `);
185
+ const npmrc = dedent(`
186
+ registry=https://registry.npmmirror.com
187
+ fund=false
188
+ `);
189
+ createNewProject(name, {
190
+ "app.ts": "require('mioki').start({ cwd: __dirname })",
191
+ "package.json": pkgJson,
192
+ plugins: { demo: { "index.ts": pluginCode } },
193
+ ...useNpmMirror ? { ".npmrc": npmrc } : {}
194
+ });
195
+ })();
196
+ async function createNewProject(name, fileTree) {
197
+ const projectName = name;
198
+ const projectPath = withRoot(`./${projectName}`);
199
+ if (fs.existsSync(projectPath)) {
200
+ if (!await confirm(`项目 ${projectName} 已存在,是否覆盖?`)) gracefullyExit();
201
+ if (projectPath === process.cwd()) {
202
+ if (fs.readdirSync(projectPath).length !== 0) {
203
+ if (!await confirm("项目路径与当前路径相同,将删除当前目录下所有内容再创建,是否继续?")) gracefullyExit();
204
+ }
205
+ }
206
+ fs.rmSync(projectPath, { recursive: true });
207
+ }
208
+ fs.mkdirSync(projectPath);
209
+ makeFileTree(fileTree, projectPath);
210
+ console.log(`项目 ${projectName} 创建成功!根据下面的引导启动 mioki。`);
211
+ console.log(`\ncd ${projectPath} && npm install && npm start\n`);
212
+ }
213
+ function gracefullyExit() {
214
+ console.log("Bye!");
215
+ process.exit(0);
216
+ }
217
+ function withRoot(_path) {
218
+ return path.resolve(process.cwd(), _path);
219
+ }
220
+ async function confirm(message, options) {
221
+ return consola.prompt(message, {
222
+ type: "confirm",
223
+ cancel: "reject",
224
+ ...options
225
+ });
226
+ }
227
+ async function input(message, options) {
228
+ const res = await consola.prompt(message, {
229
+ type: "text",
230
+ cancel: "reject",
231
+ ...options
232
+ });
233
+ if (options?.required) required(res);
234
+ return res;
235
+ }
236
+ function makeFileTree(fileTree, base) {
237
+ for (const [name, content] of Object.entries(fileTree)) if (typeof content === "object" && content !== null) {
238
+ const subPath = `${base}/${name}`;
239
+ if (!fs.existsSync(subPath)) fs.mkdirSync(subPath);
240
+ for (const [subName, subContent] of Object.entries(content)) if (typeof subContent === "object") makeFileTree(content, subPath);
241
+ else fs.writeFileSync(`${subPath}/${subName}`, subContent);
242
+ } else {
243
+ const filePath = `${base}/${name}`;
244
+ const dirname = path.dirname(filePath);
245
+ if (!fs.existsSync(dirname)) fs.mkdirSync(dirname);
246
+ fs.writeFileSync(filePath, content);
247
+ }
248
+ }
249
+ function required(value) {
250
+ if (Array.isArray(value) ? !value.length : !value) {
251
+ console.error("目标值不能为空");
252
+ process.exit(1);
253
+ }
254
+ return value;
255
+ }
256
+
257
+ //#endregion
258
+ export { };
259
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from 'node:fs'\nimport mri from 'mri'\nimport path from 'node:path'\nimport dedent from 'dedent'\nimport consola from 'consola'\nimport { version } from '../package.json'\n\nimport type { ConfirmPromptOptions, TextPromptOptions } from 'consola'\n\nconst args = process.argv.slice(2)\n\ninterface CliOptions {\n name?: string\n protocol?: string\n host?: string\n port?: number\n token?: string\n prefix?: string\n owners?: string\n admins?: string\n help?: boolean\n version?: boolean\n 'use-npm-mirror'?: boolean\n}\n\n;(async () => {\n const cli = mri<CliOptions>(args, {\n alias: {\n v: 'version',\n h: 'help',\n },\n })\n\n const helpInfo = dedent(\n `\n mioki 命令行工具 v${version}\n\n 选项:\n -h, --help 显示帮助信息\n -v, --version 显示版本号\n\n 用法: mioki <命令> [选项]\n\n 命令:\n init [选项] 创建一个新的 mioki 项目\n\n 选项:\n --name <name> 指定项目名称\n --protocol <protocol> 指定 NapCat 协议,默认 ws\n --host <host> 指定 NapCat 主机,默认 localhost\n --port <port> 指定 NapCat 端口,默认 3333\n --token <token> 指定 NapCat 连接令牌\n --prefix <prefix> 指定命令前缀,默认 #\n --owners <owners> 指定主人 QQ,英文逗号分隔\n --admins <admins> 指定管理员 QQ,英文逗号分隔\n --use-npm-mirror 使用 npm 镜像源加速依赖安装\n`,\n )\n\n switch (true) {\n case cli.version:\n console.log(`v${version}`)\n process.exit(0)\n\n case cli.help:\n console.log(helpInfo)\n process.exit(0)\n }\n\n const {\n name = await input('请输入项目名称', { default: 'bot', placeholder: 'bot', required: true }),\n protocol = await input('请输入 NapCat WS 协议', { default: 'ws', placeholder: 'ws', required: true }),\n host = await input('请输入 NapCat WS 主机', { default: 'localhost', placeholder: 'localhost', required: true }),\n port = parseInt(await input('请输入 NapCat WS 端口', { default: '3333', placeholder: '3333', required: true })),\n token = await input('请输入 NapCat WS Token(必填)', { default: '', placeholder: '请输入', required: true }),\n prefix = await input('请输入消息命令前缀', { default: '#', placeholder: '#', required: true }),\n owners = await input('请输入主人 QQ (最高权限,英文逗号分隔,必填)', { placeholder: '请输入', required: true }),\n admins = (await input('请输入管理员 QQ (插件权限,英文逗号分隔,可空)', { placeholder: '可空' })) || '',\n 'use-npm-mirror': useNpmMirror = await confirm('是否使用 npm 镜像源加速依赖安装?'),\n } = cli\n\n const pkgJson = dedent(`\n {\n \"name\": \"mioki-bot\",\n \"private\": true,\n \"dependencies\": {\n \"mioki\": \"^${version}\"\n },\n \"mioki\": {\n \"prefix\": \"${prefix}\",\n \"owners\": [${owners\n .split(',')\n .map((o) => o.trim())\n .join(', ')}],\n \"admins\": [${\n admins\n ? admins\n .split(',')\n .map((o) => `\"${o.trim()}\"`)\n .join(', ')\n : ''\n }],\n \"plugins\": [],\n \"log_level\": \"info\",\n \"online_push\": true,\n \"error_push\": true,\n \"napcat\": {\n \"protocol\": \"${protocol}\",\n \"port\": ${port},\n \"host\": \"${host}\",\n \"token\": \"${token}\"\n }\n },\n \"scripts\": {\n \"start\": \"node app.ts\"\n }\n }\n`)\n\n const pluginCode = dedent(`\n import { definePlugin } from 'mioki'\n\n export default definePlugin({\n name: 'demo',\n version: '${version}',\n async setup(ctx) {\n ctx.logger.info('Demo 插件已加载')\n\n // ctx.bot.nickname;\n // ctx.bot.uin;\n // ctx.bot.api('xxx', params);\n\n // ctx.bot.sendGroupMsg(123456789, 'Hello Group!') // 发送群消息\n\n // const group = await ctx.bot.pickGroup(123456789) // 使用群号选择一个群实例\n // group?.sign() // 调用群实例方法\n\n // const friend = await ctx.bot.pickFriend(987654321) // 使用好友号选择一个好友实例\n // friend?.delete() // 调用好友实例方法\n\n // 处理所有消息:群、好友\n ctx.handle('message', async (e) => {\n // 收到 hello 消息时回复 world\n if (e.raw_message === 'hello') {\n // 第二个参数表示是否回复原消息\n e.reply('world', true)\n }\n\n // 收到 love 消息时回复\"爱你哟\"和一个爱心 QQ 表情\n if (e.raw_message === 'love') {\n // 复杂消息消息可以使用数组组合\n e.reply(['爱你哟 ', ctx.segment.face(66)])\n }\n\n // 收到 壁纸 消息时回复今天的 bing 壁纸\n if (e.raw_message === '壁纸') {\n e.reply(ctx.segment.image('https://60s.viki.moe/v2/bing?encoding=image'))\n }\n\n // 收到 一言 消息时回复一言\n if (e.raw_message === '一言') {\n const data = await (await fetch('https://v1.hitokoto.cn/')).json()\n e.reply(data.hitokoto, true)\n }\n })\n\n ctx.handle('message.group', (e) => {\n // 处理群消息\n // 调用消息实例上挂载的快速方法\n // e.reply('这是群消息的回复') // 回复消息\n // e.recall() // 撤回消息\n // e.getQuoteMessage() // 获取引用的消息\n // e.group.getInfo(); // 也可以通过群消息事件获取群实例,并调用群实例方法获取群信息\n })\n\n ctx.handle('message.private', (e) => {\n // 处理好友消息\n })\n\n // 处理所有请求:好友、群,添加好友、邀请入群等等\n ctx.handle('request', (e) => {\n e.approve() // 同意请求\n // e.reject() // 拒绝请求\n })\n\n // 处理所有通知,好友、群的数量增加与减少、戳一戳、撤回等等\n ctx.handle('notice', (e) => {\n ctx.logger.info('Notice', e)\n })\n\n // 注册定时任务\n ctx.cron('*/3 * * * * *', async (ctx, task) => {\n ctx.logger.info('Cron', task)\n })\n\n return () => {\n ctx.logger.info('Demo 插件已卸载')\n }\n },\n })\n\n`)\n\n const npmrc = dedent(`\n registry=https://registry.npmmirror.com\n fund=false\n`)\n\n const fileTree = {\n 'app.ts': \"require('mioki').start({ cwd: __dirname })\",\n 'package.json': pkgJson,\n plugins: { demo: { 'index.ts': pluginCode } },\n ...(useNpmMirror ? { '.npmrc': npmrc } : {}),\n }\n\n createNewProject(name, fileTree)\n})()\n\nasync function createNewProject(name: string, fileTree: Record<string, any>) {\n const projectName = name\n const projectPath = withRoot(`./${projectName}`)\n\n if (fs.existsSync(projectPath)) {\n const overwrite = await confirm(`项目 ${projectName} 已存在,是否覆盖?`)\n\n if (!overwrite) {\n gracefullyExit()\n }\n\n if (projectPath === process.cwd()) {\n if (fs.readdirSync(projectPath).length !== 0) {\n const confirmOver = await confirm('项目路径与当前路径相同,将删除当前目录下所有内容再创建,是否继续?')\n if (!confirmOver) {\n gracefullyExit()\n }\n }\n }\n\n fs.rmSync(projectPath, { recursive: true })\n }\n\n fs.mkdirSync(projectPath)\n\n makeFileTree(fileTree, projectPath)\n\n console.log(`项目 ${projectName} 创建成功!根据下面的引导启动 mioki。`)\n console.log(`\\ncd ${projectPath} && npm install && npm start\\n`)\n}\n\nfunction gracefullyExit() {\n console.log('Bye!')\n process.exit(0)\n}\n\nfunction withRoot(_path: string) {\n return path.resolve(process.cwd(), _path)\n}\n\ntype OmitTypeWithRequired<T> = Omit<T, 'type' | 'required'> & { required?: boolean }\n\nasync function confirm(message: string, options?: OmitTypeWithRequired<ConfirmPromptOptions>) {\n return consola.prompt(message, { type: 'confirm', cancel: 'reject', ...options })\n}\n\nasync function input(message: string, options?: OmitTypeWithRequired<TextPromptOptions>) {\n const res = await consola.prompt(message, { type: 'text', cancel: 'reject', ...options })\n if (options?.required) required(res)\n return res\n}\n\nfunction makeFileTree(\n fileTree: Record<string, string | Record<string, string | Record<string, string>>>,\n base: string,\n) {\n for (const [name, content] of Object.entries(fileTree)) {\n if (typeof content === 'object' && content !== null) {\n const subPath = `${base}/${name}`\n if (!fs.existsSync(subPath)) {\n fs.mkdirSync(subPath)\n }\n for (const [subName, subContent] of Object.entries(content)) {\n if (typeof subContent === 'object') {\n makeFileTree(content, subPath)\n } else {\n fs.writeFileSync(`${subPath}/${subName}`, subContent)\n }\n }\n } else {\n const filePath = `${base}/${name}`\n const dirname = path.dirname(filePath)\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname)\n }\n fs.writeFileSync(filePath, content)\n }\n }\n}\n\nfunction required<T extends string | undefined | null | Array<string | undefined | null>>(value: T): T {\n if (Array.isArray(value) ? !value.length : !value) {\n console.error('目标值不能为空')\n process.exit(1)\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;CAgBhC,YAAY;CACZ,MAAM,MAAM,IAAgB,MAAM,EAChC,OAAO;EACL,GAAG;EACH,GAAG;EACJ,EACF,CAAC;CAEF,MAAM,WAAW,OACf;iBACa,QAAQ;;;;;;;;;;;;;;;;;;;;;EAsBtB;AAED,SAAQ,MAAR;EACE,KAAK,IAAI;AACP,WAAQ,IAAI,IAAI,UAAU;AAC1B,WAAQ,KAAK,EAAE;EAEjB,KAAK,IAAI;AACP,WAAQ,IAAI,SAAS;AACrB,WAAQ,KAAK,EAAE;;CAGnB,MAAM,EACJ,OAAO,MAAM,MAAM,WAAW;EAAE,SAAS;EAAO,aAAa;EAAO,UAAU;EAAM,CAAC,EACrF,WAAW,MAAM,MAAM,oBAAoB;EAAE,SAAS;EAAM,aAAa;EAAM,UAAU;EAAM,CAAC,EAChG,OAAO,MAAM,MAAM,oBAAoB;EAAE,SAAS;EAAa,aAAa;EAAa,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