node-karin 0.6.3 → 0.6.5

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.
@@ -1,100 +1,102 @@
1
1
  name: 通用配置
2
2
  view:
3
- -
4
- key: 日志等级
3
+ - key: 日志等级
5
4
  comment: 日志等级:trace,debug,info,warn,fatal,mark,error,off
6
- path: 'log_level'
7
- type: 'select'
5
+ path: "log_level"
6
+ type: "select"
8
7
  multiple: false
9
8
  item:
10
- -
11
- name: Trace
9
+ - name: Trace
12
10
  value: trace
13
- -
14
- name: Debug
11
+ - name: Debug
15
12
  value: ebug
16
- -
17
- name: Info
13
+ - name: Info
18
14
  value: info
19
- -
20
- name: Warn
15
+ - name: Warn
21
16
  value: warn
22
- -
23
- name: Fatal
17
+ - name: Fatal
24
18
  value: fatal
25
- -
26
- name: Mark
19
+ - name: Mark
27
20
  value: mark
28
- -
29
- name: Error
21
+ - name: Error
30
22
  value: error
31
- -
32
- name: Off
23
+ - name: Off
33
24
  value: off
34
- -
35
- key: 日志保留天数
36
- path: 'log_days_Keep'
37
- type: 'number'
38
- -
39
- key: ffmpeg路径
25
+ - key: 日志保留天数
26
+ path: "log_days_Keep"
27
+ type: "number"
28
+ - key: ffmpeg路径
40
29
  comment: ffmpeg配置 用于音视频处理
41
- path: 'ffmpeg_path'
42
- type: 'text'
43
- -
44
- key: ffprobe路径
30
+ path: "ffmpeg_path"
31
+ type: "text"
32
+ - key: ffprobe路径
45
33
  comment: ffmpeg配置 用于音视频处理
46
- path: 'ffprobe_path'
47
- type: 'text'
48
- -
49
- key: 主人列表
34
+ path: "ffprobe_path"
35
+ type: "text"
36
+ - key: 主人列表
50
37
  comment: 主人列表 主权限
51
- path: 'master'
52
- type: 'array'
53
- arrayType: 'number'
54
- -
55
- key: 管理员列表
38
+ path: "master"
39
+ type: "array"
40
+ arrayType: "number"
41
+ - key: 管理员列表
56
42
  comment: 管理员列表 子权限
57
- path: 'admin'
58
- type: 'array'
59
- arrayType: 'number'
60
- -
61
- key: 黑名单
43
+ path: "admin"
44
+ type: "array"
45
+ arrayType: "number"
46
+ - key: 黑名单
62
47
  comment: 黑名单相关
63
- path: 'BlackList'
64
- type: 'group'
48
+ path: "BlackList"
49
+ type: "group"
65
50
  part:
66
- -
67
- key: 黑名单用户
68
- path: 'BlackList.users'
69
- type: 'array'
70
- arrayType: 'number'
71
- -
72
- key: 黑名单群聊
73
- path: 'BlackList.groups'
74
- type: 'array'
75
- arrayType: 'number'
76
- -
77
- key: 消息日志黑名单群聊
78
- comment: 设置后不会打印该群的消息日志
79
- path: 'BlackList.GroupMsgLog'
80
- type: 'array'
81
- arrayType: 'number'
82
- -
83
- key: 白名单
51
+ - key: 黑名单用户
52
+ path: "BlackList.users"
53
+ type: "array"
54
+ arrayType: "number"
55
+ associated:
56
+ - file: App
57
+ path: "BlackList.users"
58
+ requirement: true
59
+ - key: 黑名单群聊
60
+ path: "BlackList.groups"
61
+ type: "array"
62
+ arrayType: "number"
63
+ associated:
64
+ - file: App
65
+ path: "BlackList.groups"
66
+ requirement: true
67
+ - key: 消息日志黑名单群聊
68
+ comment: 设置后不会打印该群的消息日志
69
+ path: "BlackList.GroupMsgLog"
70
+ type: "array"
71
+ arrayType: "number"
72
+ associated:
73
+ - file: App
74
+ path: "BlackList.GroupMsgLog"
75
+ requirement: true
76
+ - key: 白名单
84
77
  comment: 白名单相关
85
- path: 'WhiteList'
86
- type: 'group'
78
+ path: "WhiteList"
79
+ type: "group"
87
80
  part:
88
- -
89
- key: 白名单用户
90
- path: 'WhiteList.users'
91
- type: 'boolean'
92
- -
93
- key: 白名单群聊
94
- path: 'WhiteList.groups'
95
- type: 'boolean'
96
- -
97
- key: 消息日志白名单群聊
98
- comment: 消息日志白名单群聊 设置后只会打印该群的消息日志
99
- path: 'WhiteList.GroupMsgLog'
100
- type: 'boolean'
81
+ - key: 白名单用户
82
+ path: "WhiteList.users"
83
+ type: "boolean"
84
+ associated:
85
+ - file: App
86
+ path: "WhiteList.users"
87
+ requirement: true
88
+ - key: 白名单群聊
89
+ path: "WhiteList.groups"
90
+ type: "boolean"
91
+ associated:
92
+ - file: App
93
+ path: "WhiteList.groups"
94
+ requirement: true
95
+ - key: 消息日志白名单群聊
96
+ comment: 消息日志白名单群聊 设置后只会打印该群的消息日志
97
+ path: "WhiteList.GroupMsgLog"
98
+ type: "boolean"
99
+ associated:
100
+ - file: App
101
+ path: "WhiteList.GroupMsgLog"
102
+ requirement: true
@@ -11,17 +11,32 @@ view:
11
11
  path: 'default.global_cd'
12
12
  type: 'number'
13
13
  suffix: 秒
14
+ associated:
15
+ -
16
+ file: App
17
+ path: 'GroupConfig.GroupCD'
18
+ requirement: true
14
19
  -
15
20
  key: 个人消息冷却时间
16
21
  comment: 群聊中 每个人的消息冷却时间,0则无限制。注意,开启后所有消息,无论是否触发插件。
17
22
  path: 'default.personal_cd'
18
23
  type: 'number'
19
24
  suffix: 秒
25
+ associated:
26
+ -
27
+ file: App
28
+ path: 'GroupConfig.GroupUserCD'
29
+ requirement: true
20
30
  -
21
31
  key: 机器人响应模式
22
32
  comment: 机器人响应模式,0-所有 1-仅@机器人 2-仅回应主人 3-仅回应前缀 4-前缀或@机器人 5-主人无前缀,群员前缀或@机器人
23
33
  path: 'default.mode'
24
34
  type: 'select'
35
+ associated:
36
+ -
37
+ file: App
38
+ path: 'GroupConfig.mode'
39
+ requirement: true
25
40
  multiple: false
26
41
  item:
27
42
  -
@@ -48,15 +63,30 @@ view:
48
63
  path: 'default.ailas'
49
64
  type: 'array'
50
65
  arrayType: 'text'
66
+ associated:
67
+ -
68
+ file: App
69
+ path: 'GroupConfig.alias'
70
+ requirement: true
51
71
  -
52
72
  key: 白名单插件
53
73
  comment: 白名单插件、功能,只有在白名单中的插件、功能才会响应
54
74
  path: 'default.enable'
55
75
  type: 'array'
56
76
  arrayType: 'text'
77
+ associated:
78
+ -
79
+ file: App
80
+ path: 'GroupConfig.enable'
81
+ requirement: true
57
82
  -
58
83
  key: 黑名单插件
59
84
  comment: 黑名单插件、功能,黑名单中的插件、功能不会响应
60
85
  path: 'default.disable'
61
86
  type: 'array'
62
87
  arrayType: 'text'
88
+ associated:
89
+ -
90
+ file: App
91
+ path: 'GroupConfig.disable'
92
+ requirement: true
package/lib/tools/init.js CHANGED
@@ -2,34 +2,64 @@
2
2
  import fs from 'fs'
3
3
  import path from 'path'
4
4
  import { karinDir } from '../core/dir.js'
5
- const pathList = ['./plugins', './config/config']
6
- for (const dir of pathList) { mkdir(dir) }
5
+ import { execSync } from 'child_process'
6
+ const pathList = ['./plugins', './config/config', './lib']
7
+ // 创建目录
8
+ pathList.forEach(dir => mkdir(dir))
7
9
  function mkdir (dirname) {
8
10
  if (fs.existsSync(dirname)) { return true }
9
- /** 递归自调用 */
10
11
  if (mkdir(path.dirname(dirname))) { fs.mkdirSync(dirname) }
11
12
  return true
12
13
  }
13
- // 删除这两个文件夹
14
+ // 创建 lib 目录并导出 node-karin 模块
15
+ fs.writeFileSync('./lib/index.js', `export * from 'node-karin'`)
16
+ // 删除指定目录并重新创建
14
17
  const delList = ['./config/defSet', './config/view']
15
- for (const dir of delList) {
18
+ delList.forEach(dir => {
16
19
  if (fs.existsSync(dir)) { fs.rmdirSync(dir, { recursive: true }) }
17
20
  mkdir(dir)
18
- const root = `${karinDir}${dir.replace('.', '')}`
21
+ const root = path.join(karinDir, dir.replace('.', ''))
19
22
  const files = fs.readdirSync(root).filter(file => file.endsWith('.yaml'))
20
- for (const file of files) {
21
- const path = `${dir}/${file}`
22
- const pathDef = `${root}/${file}`
23
- if (!fs.existsSync(path)) { fs.copyFileSync(pathDef, path) }
24
- }
25
- }
26
- // 修改package.json为esm模块
23
+ files.forEach(file => {
24
+ const destPath = path.join(dir, file)
25
+ const srcPath = path.join(root, file)
26
+ if (!fs.existsSync(destPath)) { fs.copyFileSync(srcPath, destPath) }
27
+ })
28
+ })
29
+ // 修改 package.json ESM 模块
27
30
  const pack = JSON.parse(fs.readFileSync('./package.json', 'utf-8'))
28
- // 解析包内的package.json文件
29
- const npmPack = JSON.parse(fs.readFileSync(`${karinDir}/package.json`, 'utf-8'))
31
+ const npmPack = JSON.parse(fs.readFileSync(path.join(karinDir, 'package.json'), 'utf-8'))
30
32
  npmPack.main = './node_modules/node-karin/lib/index.js'
31
33
  delete npmPack.bin
32
34
  delete npmPack.types
33
35
  npmPack.dependencies = pack.dependencies
34
36
  fs.writeFileSync('./package.json', JSON.stringify(npmPack, null, 2))
37
+ // 复制 pnpm-workspace.yaml 到根目录
38
+ fs.copyFileSync(path.join(karinDir, 'pnpm-workspace.yaml'), './pnpm-workspace.yaml')
39
+ // 检查是否安装 pnpm 并安装依赖
40
+ console.log('检查是否安装 pnpm...')
41
+ try {
42
+ const isPnpm = execSync('pnpm -v', { env: process.env }).toString().trim()
43
+ if (isPnpm) {
44
+ console.log('检查到 pnpm,开始安装依赖...')
45
+ } else {
46
+ installPnpm()
47
+ }
48
+ } catch {
49
+ installPnpm()
50
+ }
51
+ // 安装依赖
52
+ try {
53
+ execSync('pnpm install -P', { env: process.env, stdio: 'inherit' })
54
+ console.log('依赖安装完成~')
55
+ } catch {
56
+ console.log('安装依赖失败,请手动安装依赖!')
57
+ console.log('可尝试手动执行 【 pnpm install -P 】 安装依赖~')
58
+ console.log('如中国大陆用户安装失败,请尝试执行换源 【 npm config set registry https://registry.npmmirror.com 】后再安装依赖~')
59
+ }
35
60
  console.log('初始化完成~,请通过 【 node . 】 启动程序~')
61
+ function installPnpm () {
62
+ console.log('未检查到 pnpm,开始安装 pnpm...')
63
+ execSync('npm --registry=https://registry.npmmirror.com install pnpm -g', { env: process.env, stdio: 'inherit' })
64
+ console.log('pnpm 安装完成,开始安装依赖...')
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",
@@ -28,7 +28,8 @@
28
28
  "modules.d.ts",
29
29
  "LICENSE",
30
30
  "package.json",
31
- "README.md"
31
+ "README.md",
32
+ "pnpm-workspace.yaml"
32
33
  ],
33
34
  "workspaces": [
34
35
  "plugins/**"
@@ -0,0 +1,2 @@
1
+ packages:
2
+ - 'plugins/**'