node-karin 0.0.3 → 0.1.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.
Files changed (109) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +57 -57
  3. package/config/defSet/App.yaml +37 -37
  4. package/config/defSet/config.yaml +43 -43
  5. package/config/defSet/group.yaml +18 -18
  6. package/config/defSet/pm2.yaml +21 -21
  7. package/config/defSet/server.yaml +42 -42
  8. package/config/view/App.yaml +74 -74
  9. package/config/view/config.yaml +100 -100
  10. package/config/view/group.yaml +62 -62
  11. package/config/view/pm2.yaml +41 -41
  12. package/config/view/redis.yaml +25 -25
  13. package/config/view/server.yaml +93 -93
  14. package/lib/adapter/onebot/onebot11.d.ts +430 -430
  15. package/lib/adapter/onebot/onebot11.js +1265 -1302
  16. package/lib/core/dir.d.ts +1 -0
  17. package/lib/core/dir.js +4 -0
  18. package/lib/core/init.js +4 -4
  19. package/lib/core/karin.d.ts +72 -72
  20. package/lib/core/karin.js +51 -51
  21. package/lib/core/listener.d.ts +121 -121
  22. package/lib/core/listener.js +178 -178
  23. package/lib/core/plugin.app.d.ts +15 -15
  24. package/lib/core/plugin.app.js +18 -18
  25. package/lib/core/plugin.d.ts +182 -182
  26. package/lib/core/plugin.js +132 -132
  27. package/lib/core/plugin.loader.d.ts +149 -149
  28. package/lib/core/plugin.loader.js +451 -451
  29. package/lib/core/server.d.ts +26 -26
  30. package/lib/core/server.js +209 -209
  31. package/lib/db/level.d.ts +20 -20
  32. package/lib/db/level.js +36 -36
  33. package/lib/db/redis.d.ts +41 -41
  34. package/lib/db/redis.js +131 -131
  35. package/lib/db/redis_level.d.ts +113 -113
  36. package/lib/db/redis_level.js +274 -274
  37. package/lib/event/event.d.ts +138 -138
  38. package/lib/event/event.handler.d.ts +29 -29
  39. package/lib/event/event.handler.js +138 -138
  40. package/lib/event/event.js +120 -120
  41. package/lib/event/message.d.ts +102 -102
  42. package/lib/event/message.handler.d.ts +25 -25
  43. package/lib/event/message.handler.js +237 -237
  44. package/lib/event/message.js +69 -69
  45. package/lib/event/notice.d.ts +49 -49
  46. package/lib/event/notice.js +14 -14
  47. package/lib/event/request.d.ts +49 -49
  48. package/lib/event/request.js +14 -14
  49. package/lib/event/review.handler.d.ts +54 -54
  50. package/lib/event/review.handler.js +374 -374
  51. package/lib/index.d.ts +24 -23
  52. package/lib/index.js +40 -40
  53. package/lib/renderer/app.d.ts +53 -53
  54. package/lib/renderer/app.js +88 -88
  55. package/lib/renderer/base.d.ts +30 -30
  56. package/lib/renderer/base.js +68 -68
  57. package/lib/renderer/client.d.ts +30 -30
  58. package/lib/renderer/client.js +155 -155
  59. package/lib/renderer/http.d.ts +19 -19
  60. package/lib/renderer/http.js +50 -50
  61. package/lib/renderer/server.d.ts +42 -42
  62. package/lib/renderer/server.js +110 -110
  63. package/lib/renderer/wormhole.d.ts +1 -1
  64. package/lib/renderer/wormhole.js +154 -154
  65. package/lib/tools/init.d.ts +2 -0
  66. package/lib/tools/init.js +31 -0
  67. package/lib/types/adapter.d.ts +575 -575
  68. package/lib/types/adapter.js +1 -1
  69. package/lib/types/config.d.ts +327 -327
  70. package/lib/types/config.js +1 -1
  71. package/lib/types/element.d.ts +576 -576
  72. package/lib/types/element.js +1 -1
  73. package/lib/types/index.d.ts +8 -8
  74. package/lib/types/index.js +8 -8
  75. package/lib/types/logger.d.ts +109 -109
  76. package/lib/types/logger.js +1 -1
  77. package/lib/types/onebots11.d.ts +1371 -1371
  78. package/lib/types/onebots11.js +1 -1
  79. package/lib/types/plugin.d.ts +282 -282
  80. package/lib/types/plugin.js +1 -1
  81. package/lib/types/render.d.ts +111 -111
  82. package/lib/types/render.js +1 -1
  83. package/lib/types/reply.d.ts +40 -40
  84. package/lib/types/reply.js +1 -1
  85. package/lib/types/types.d.ts +898 -898
  86. package/lib/types/types.js +1 -1
  87. package/lib/utils/YamlEditor.d.ts +62 -62
  88. package/lib/utils/YamlEditor.js +197 -197
  89. package/lib/utils/button.d.ts +49 -49
  90. package/lib/utils/button.js +75 -75
  91. package/lib/utils/common.d.ts +123 -123
  92. package/lib/utils/common.js +396 -396
  93. package/lib/utils/config.d.ts +72 -72
  94. package/lib/utils/config.js +259 -254
  95. package/lib/utils/exec.d.ts +22 -22
  96. package/lib/utils/exec.js +36 -36
  97. package/lib/utils/ffmpeg.d.ts +12 -12
  98. package/lib/utils/ffmpeg.js +25 -25
  99. package/lib/utils/handler.d.ts +76 -76
  100. package/lib/utils/handler.js +98 -98
  101. package/lib/utils/logger.d.ts +3 -3
  102. package/lib/utils/logger.js +104 -104
  103. package/lib/utils/segment.d.ts +276 -276
  104. package/lib/utils/segment.js +420 -420
  105. package/lib/utils/update.d.ts +69 -69
  106. package/lib/utils/update.js +145 -145
  107. package/lib/utils/updateVersion.d.ts +33 -33
  108. package/lib/utils/updateVersion.js +140 -140
  109. package/package.json +95 -91
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1,62 +1,62 @@
1
- import Yaml from 'yaml';
2
- export default class YamlEditor {
3
- filePath: string;
4
- document: Yaml.Document;
5
- constructor(filePath: string);
6
- load(): void;
7
- /**
8
- * 获取指定路径的值
9
- * @param path - 路径,用点号分隔,例如:'a.b.c'
10
- */
11
- get(path: string): any;
12
- /**
13
- * 设置指定路径的值
14
- * @param path - 路径,用点号分隔,例如:'a.b.c'
15
- * @param value - 要设置的值
16
- */
17
- set(path: string | string[], value: string): null | undefined;
18
- /**
19
- * 向指定路径添加新值
20
- * @param path - 路径,用点号分隔,例如:'a.b.c'
21
- * @param value - 要添加的值
22
- */
23
- add(path: string | string[], value: string): void;
24
- /**
25
- * 删除指定路径
26
- * @param path - 路径,用点号分隔,例如:'a.b.c'
27
- * @returns 是否删除成功
28
- */
29
- del(path: string | string[]): boolean;
30
- /**
31
- * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
32
- * @param path - 路径,用点号分隔,例如:'a.b.c'
33
- * @param value - 要添加的值
34
- * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
35
- */
36
- append(path: string | string[], value: string, prepend?: boolean): void;
37
- /**
38
- * 检查指定路径的键是否存在
39
- * @param path - 路径,用点号分隔
40
- */
41
- has(path: string | string[]): boolean;
42
- /**
43
- * 查询指定路径中是否包含指定的值
44
- * @param path - 路径,用点号分隔
45
- * @param value - 要查询的值
46
- */
47
- hasVal(path: string | string[], value: any): boolean;
48
- /**
49
- * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
50
- * @param value - 要新增的元素
51
- */
52
- pusharr(value: any): false | undefined;
53
- /**
54
- * 根据索引从根节点数组删除元素
55
- * @param index - 要删除元素的索引
56
- */
57
- delarr(index: number): boolean;
58
- /**
59
- * 保存文件
60
- */
61
- save(): void;
62
- }
1
+ import Yaml from 'yaml';
2
+ export default class YamlEditor {
3
+ filePath: string;
4
+ document: Yaml.Document;
5
+ constructor(filePath: string);
6
+ load(): void;
7
+ /**
8
+ * 获取指定路径的值
9
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
10
+ */
11
+ get(path: string): any;
12
+ /**
13
+ * 设置指定路径的值
14
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
15
+ * @param value - 要设置的值
16
+ */
17
+ set(path: string | string[], value: string): null | undefined;
18
+ /**
19
+ * 向指定路径添加新值
20
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
21
+ * @param value - 要添加的值
22
+ */
23
+ add(path: string | string[], value: string): void;
24
+ /**
25
+ * 删除指定路径
26
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
27
+ * @returns 是否删除成功
28
+ */
29
+ del(path: string | string[]): boolean;
30
+ /**
31
+ * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
32
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
33
+ * @param value - 要添加的值
34
+ * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
35
+ */
36
+ append(path: string | string[], value: string, prepend?: boolean): void;
37
+ /**
38
+ * 检查指定路径的键是否存在
39
+ * @param path - 路径,用点号分隔
40
+ */
41
+ has(path: string | string[]): boolean;
42
+ /**
43
+ * 查询指定路径中是否包含指定的值
44
+ * @param path - 路径,用点号分隔
45
+ * @param value - 要查询的值
46
+ */
47
+ hasVal(path: string | string[], value: any): boolean;
48
+ /**
49
+ * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
50
+ * @param value - 要新增的元素
51
+ */
52
+ pusharr(value: any): false | undefined;
53
+ /**
54
+ * 根据索引从根节点数组删除元素
55
+ * @param index - 要删除元素的索引
56
+ */
57
+ delarr(index: number): boolean;
58
+ /**
59
+ * 保存文件
60
+ */
61
+ save(): void;
62
+ }
@@ -1,208 +1,208 @@
1
- /*
2
- * YamlEditor - 一个用于编辑 YAML 文件的类
3
- * 本代码由 ChatGPT4 提供
4
- * https://github.com/OpenAI
5
- */
6
- import fs from 'fs'
7
- import Yaml from 'yaml'
8
- import lodash from 'lodash'
9
- import logger from './logger.js'
10
- export default class YamlEditor {
11
- filePath
12
- document
13
- constructor (filePath) {
14
- this.filePath = filePath
15
- this.load()
1
+ /*
2
+ * YamlEditor - 一个用于编辑 YAML 文件的类
3
+ * 本代码由 ChatGPT4 提供
4
+ * https://github.com/OpenAI
5
+ */
6
+ import fs from 'fs'
7
+ import Yaml from 'yaml'
8
+ import lodash from 'lodash'
9
+ import logger from './logger.js'
10
+ export default class YamlEditor {
11
+ filePath
12
+ document
13
+ constructor (filePath) {
14
+ this.filePath = filePath
15
+ this.load()
16
16
  }
17
-
18
- load () {
19
- try {
20
- const fileContents = fs.readFileSync(this.filePath, 'utf8')
21
- this.document = Yaml.parseDocument(fileContents)
22
- logger.debug('[YamlEditor] 文件加载成功')
23
- } catch (error) {
24
- logger.error(`[YamlEditor] 加载文件时出错:${error}`)
25
- }
17
+
18
+ load () {
19
+ try {
20
+ const fileContents = fs.readFileSync(this.filePath, 'utf8')
21
+ this.document = Yaml.parseDocument(fileContents)
22
+ logger.debug('[YamlEditor] 文件加载成功')
23
+ } catch (error) {
24
+ logger.error(`[YamlEditor] 加载文件时出错:${error}`)
25
+ }
26
26
  }
27
-
28
- /**
29
- * 获取指定路径的值
30
- * @param path - 路径,用点号分隔,例如:'a.b.c'
31
- */
32
- get (path) {
33
- try {
34
- if (!path) { return this.document.toJSON() }
35
- return lodash.get(this.document.toJSON(), path)
36
- } catch (error) {
37
- logger.error(`[YamlEditor] 获取数据时出错:${error}`)
38
- return null
39
- }
27
+
28
+ /**
29
+ * 获取指定路径的值
30
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
31
+ */
32
+ get (path) {
33
+ try {
34
+ if (!path) { return this.document.toJSON() }
35
+ return lodash.get(this.document.toJSON(), path)
36
+ } catch (error) {
37
+ logger.error(`[YamlEditor] 获取数据时出错:${error}`)
38
+ return null
39
+ }
40
40
  }
41
-
42
- /**
43
- * 设置指定路径的值
44
- * @param path - 路径,用点号分隔,例如:'a.b.c'
45
- * @param value - 要设置的值
46
- */
47
- set (path, value) {
48
- try {
49
- path = typeof path === 'string' ? path.split('.') : path
50
- this.document.setIn(path, value)
51
- } catch (error) {
52
- logger.error(`[YamlEditor] 设置数据时出错:${error}`)
53
- return null
54
- }
41
+
42
+ /**
43
+ * 设置指定路径的值
44
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
45
+ * @param value - 要设置的值
46
+ */
47
+ set (path, value) {
48
+ try {
49
+ path = typeof path === 'string' ? path.split('.') : path
50
+ this.document.setIn(path, value)
51
+ } catch (error) {
52
+ logger.error(`[YamlEditor] 设置数据时出错:${error}`)
53
+ return null
54
+ }
55
55
  }
56
-
57
- /**
58
- * 向指定路径添加新值
59
- * @param path - 路径,用点号分隔,例如:'a.b.c'
60
- * @param value - 要添加的值
61
- */
62
- add (path, value) {
63
- try {
64
- path = typeof path === 'string' ? path.split('.') : path
65
- this.document.addIn(path, value)
66
- logger.debug(`[YamlEditor] 已在 ${path} 添加新的值`)
67
- } catch (error) {
68
- logger.error(`[YamlEditor] 添加数据时出错:${error}`)
69
- }
56
+
57
+ /**
58
+ * 向指定路径添加新值
59
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
60
+ * @param value - 要添加的值
61
+ */
62
+ add (path, value) {
63
+ try {
64
+ path = typeof path === 'string' ? path.split('.') : path
65
+ this.document.addIn(path, value)
66
+ logger.debug(`[YamlEditor] 已在 ${path} 添加新的值`)
67
+ } catch (error) {
68
+ logger.error(`[YamlEditor] 添加数据时出错:${error}`)
69
+ }
70
70
  }
71
-
72
- /**
73
- * 删除指定路径
74
- * @param path - 路径,用点号分隔,例如:'a.b.c'
75
- * @returns 是否删除成功
76
- */
77
- del (path) {
78
- try {
79
- path = typeof path === 'string' ? path.split('.') : path
80
- this.document.deleteIn(path)
81
- return true
82
- } catch (error) {
83
- logger.error(`[YamlEditor] 删除数据时出错:${error}`)
84
- return false
85
- }
71
+
72
+ /**
73
+ * 删除指定路径
74
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
75
+ * @returns 是否删除成功
76
+ */
77
+ del (path) {
78
+ try {
79
+ path = typeof path === 'string' ? path.split('.') : path
80
+ this.document.deleteIn(path)
81
+ return true
82
+ } catch (error) {
83
+ logger.error(`[YamlEditor] 删除数据时出错:${error}`)
84
+ return false
85
+ }
86
86
  }
87
-
88
- /**
89
- * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
90
- * @param path - 路径,用点号分隔,例如:'a.b.c'
91
- * @param value - 要添加的值
92
- * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
93
- */
94
- append (path, value, prepend = false) {
95
- try {
96
- path = typeof path === 'string' ? path.split('.') : path || []
97
- let current = this.document.getIn(path)
98
- if (!current) {
99
- current = new Yaml.YAMLSeq()
100
- this.document.setIn(path, current)
101
- } else if (!(current instanceof Yaml.YAMLSeq)) {
102
- throw new Error('[YamlEditor] 指定的路径不是数组')
103
- } else {
104
- if (prepend) {
105
- current.items.unshift(value)
106
- } else {
107
- current.add(value)
108
- }
109
- }
110
- logger.debug(`[YamlEditor] 已向 ${path} 数组${prepend ? '开头' : '末尾'}添加新元素:${value}`)
111
- } catch (error) {
112
- logger.error(`[YamlEditor] 向数组添加元素时出错:${error}`)
113
- }
87
+
88
+ /**
89
+ * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
90
+ * @param path - 路径,用点号分隔,例如:'a.b.c'
91
+ * @param value - 要添加的值
92
+ * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
93
+ */
94
+ append (path, value, prepend = false) {
95
+ try {
96
+ path = typeof path === 'string' ? path.split('.') : path || []
97
+ let current = this.document.getIn(path)
98
+ if (!current) {
99
+ current = new Yaml.YAMLSeq()
100
+ this.document.setIn(path, current)
101
+ } else if (!(current instanceof Yaml.YAMLSeq)) {
102
+ throw new Error('[YamlEditor] 指定的路径不是数组')
103
+ } else {
104
+ if (prepend) {
105
+ current.items.unshift(value)
106
+ } else {
107
+ current.add(value)
108
+ }
109
+ }
110
+ logger.debug(`[YamlEditor] 已向 ${path} 数组${prepend ? '开头' : '末尾'}添加新元素:${value}`)
111
+ } catch (error) {
112
+ logger.error(`[YamlEditor] 向数组添加元素时出错:${error}`)
113
+ }
114
114
  }
115
-
116
- /**
117
- * 检查指定路径的键是否存在
118
- * @param path - 路径,用点号分隔
119
- */
120
- has (path) {
121
- try {
122
- path = typeof path === 'string' ? path.split('.') : path
123
- return this.document.hasIn(path)
124
- } catch (error) {
125
- logger.error(`[YamlEditor] 检查路径是否存在时出错:${error}`)
126
- return false
127
- }
115
+
116
+ /**
117
+ * 检查指定路径的键是否存在
118
+ * @param path - 路径,用点号分隔
119
+ */
120
+ has (path) {
121
+ try {
122
+ path = typeof path === 'string' ? path.split('.') : path
123
+ return this.document.hasIn(path)
124
+ } catch (error) {
125
+ logger.error(`[YamlEditor] 检查路径是否存在时出错:${error}`)
126
+ return false
127
+ }
128
128
  }
129
-
130
- /**
131
- * 查询指定路径中是否包含指定的值
132
- * @param path - 路径,用点号分隔
133
- * @param value - 要查询的值
134
- */
135
- hasVal (path, value) {
136
- try {
137
- path = typeof path === 'string' ? path.split('.') : path
138
- const current = this.document.getIn(path)
139
- if (!current) { return false }
140
- /** 检查当前节点是否包含指定的值 */
141
- if (current instanceof Yaml.YAMLSeq) {
142
- /** 如果是序列,遍历序列查找值 */
143
- return current.items.some(item => lodash.isEqual(item.toJSON(), value))
144
- } else if (current instanceof Yaml.YAMLMap) {
145
- /** 如果是映射,检查每个值 */
146
- return Array.from(current.values()).some((v) => lodash.isEqual(v.toJSON(), value))
147
- } else {
148
- /** 否则,直接比较值 */
149
- return lodash.isEqual(current, value)
150
- }
151
- } catch (error) {
152
- logger.error(`[YamlEditor] 检查路径 ${path} 是否包含值时出错:${error}`)
153
- return false
154
- }
129
+
130
+ /**
131
+ * 查询指定路径中是否包含指定的值
132
+ * @param path - 路径,用点号分隔
133
+ * @param value - 要查询的值
134
+ */
135
+ hasVal (path, value) {
136
+ try {
137
+ path = typeof path === 'string' ? path.split('.') : path
138
+ const current = this.document.getIn(path)
139
+ if (!current) { return false }
140
+ /** 检查当前节点是否包含指定的值 */
141
+ if (current instanceof Yaml.YAMLSeq) {
142
+ /** 如果是序列,遍历序列查找值 */
143
+ return current.items.some(item => lodash.isEqual(item.toJSON(), value))
144
+ } else if (current instanceof Yaml.YAMLMap) {
145
+ /** 如果是映射,检查每个值 */
146
+ return Array.from(current.values()).some((v) => lodash.isEqual(v.toJSON(), value))
147
+ } else {
148
+ /** 否则,直接比较值 */
149
+ return lodash.isEqual(current, value)
150
+ }
151
+ } catch (error) {
152
+ logger.error(`[YamlEditor] 检查路径 ${path} 是否包含值时出错:${error}`)
153
+ return false
154
+ }
155
155
  }
156
-
157
- /**
158
- * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
159
- * @param value - 要新增的元素
160
- */
161
- pusharr (value) {
162
- try {
163
- if (!(this.document.contents instanceof Yaml.YAMLSeq)) {
164
- // 如果根节点不是数组,则将其转换为数组
165
- this.document.contents = new Yaml.YAMLSeq()
166
- logger.debug('[YamlEditor] 根节点已转换为数组')
167
- }
168
- this.document.contents.add(value)
169
- logger.debug('[YamlEditor] 已向根节点数组新增元素:', value)
170
- } catch (error) {
171
- logger.error(`[YamlEditor] 向根节点数组新增元素时出错:${error}`)
172
- return false
173
- }
156
+
157
+ /**
158
+ * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
159
+ * @param value - 要新增的元素
160
+ */
161
+ pusharr (value) {
162
+ try {
163
+ if (!(this.document.contents instanceof Yaml.YAMLSeq)) {
164
+ // 如果根节点不是数组,则将其转换为数组
165
+ this.document.contents = new Yaml.YAMLSeq()
166
+ logger.debug('[YamlEditor] 根节点已转换为数组')
167
+ }
168
+ this.document.contents.add(value)
169
+ logger.debug('[YamlEditor] 已向根节点数组新增元素:', value)
170
+ } catch (error) {
171
+ logger.error(`[YamlEditor] 向根节点数组新增元素时出错:${error}`)
172
+ return false
173
+ }
174
174
  }
175
-
176
- /**
177
- * 根据索引从根节点数组删除元素
178
- * @param index - 要删除元素的索引
179
- */
180
- delarr (index) {
181
- try {
182
- if (!(this.document.contents instanceof Yaml.YAMLSeq)) {
183
- throw new Error('[YamlEditor] 根节点不是数组')
184
- }
185
- if (index < 0 || index >= this.document.contents.items.length) {
186
- throw new Error('[YamlEditor] 索引超出范围')
187
- }
188
- this.document.contents.items.splice(index, 1)
189
- logger.debug('[YamlEditor] 已根据索引从根节点数组删除元素,索引:', index)
190
- return true
191
- } catch (error) {
192
- logger.error(`[YamlEditor] 根据索引删除根节点数组元素时出错:${error}`)
193
- return false
194
- }
175
+
176
+ /**
177
+ * 根据索引从根节点数组删除元素
178
+ * @param index - 要删除元素的索引
179
+ */
180
+ delarr (index) {
181
+ try {
182
+ if (!(this.document.contents instanceof Yaml.YAMLSeq)) {
183
+ throw new Error('[YamlEditor] 根节点不是数组')
184
+ }
185
+ if (index < 0 || index >= this.document.contents.items.length) {
186
+ throw new Error('[YamlEditor] 索引超出范围')
187
+ }
188
+ this.document.contents.items.splice(index, 1)
189
+ logger.debug('[YamlEditor] 已根据索引从根节点数组删除元素,索引:', index)
190
+ return true
191
+ } catch (error) {
192
+ logger.error(`[YamlEditor] 根据索引删除根节点数组元素时出错:${error}`)
193
+ return false
194
+ }
195
195
  }
196
-
197
- /**
198
- * 保存文件
199
- */
200
- save () {
201
- try {
202
- fs.writeFileSync(this.filePath, this.document.toString())
203
- logger.info('[YamlEditor] 文件已保存')
204
- } catch (error) {
205
- logger.error(`[YamlEditor] 保存文件时出错:${error}`)
206
- }
207
- }
208
- }
196
+
197
+ /**
198
+ * 保存文件
199
+ */
200
+ save () {
201
+ try {
202
+ fs.writeFileSync(this.filePath, this.document.toString())
203
+ logger.info('[YamlEditor] 文件已保存')
204
+ } catch (error) {
205
+ logger.error(`[YamlEditor] 保存文件时出错:${error}`)
206
+ }
207
+ }
208
+ }
@@ -1,49 +1,49 @@
1
- import { Plugin, dirName, fileName } from '../types/plugin.js';
2
- import { KarinMessage } from '../event/message.js';
3
- declare const _default: {
4
- Apps: Array<{
5
- App: new () => Plugin;
6
- name: string;
7
- priority: number;
8
- file: {
9
- dir: dirName;
10
- name: fileName;
11
- };
12
- rule: Array<{
13
- reg: RegExp;
14
- fnc: string;
15
- }>;
16
- }>;
17
- add({ name, dir, App, Class }: {
18
- dir: dirName;
19
- name: fileName;
20
- App: new () => Plugin;
21
- Class: Plugin;
22
- }): void;
23
- /**
24
- * 卸载按钮
25
- * @param {string} dir 插件目录
26
- * @param {string} name 插件文件名称
27
- */
28
- del(dir: dirName, name: fileName): {
29
- App: new () => Plugin;
30
- name: string;
31
- priority: number;
32
- file: {
33
- dir: dirName;
34
- name: fileName;
35
- };
36
- rule: Array<{
37
- reg: RegExp;
38
- fnc: string;
39
- }>;
40
- }[];
41
- update({ dir, name, App, Class }: {
42
- dir: dirName;
43
- name: fileName;
44
- App: new () => Plugin;
45
- Class: Plugin;
46
- }): void;
47
- get(e: KarinMessage): Promise<any[]>;
48
- };
49
- export default _default;
1
+ import { Plugin, dirName, fileName } from '../types/plugin.js';
2
+ import { KarinMessage } from '../event/message.js';
3
+ declare const _default: {
4
+ Apps: Array<{
5
+ App: new () => Plugin;
6
+ name: string;
7
+ priority: number;
8
+ file: {
9
+ dir: dirName;
10
+ name: fileName;
11
+ };
12
+ rule: Array<{
13
+ reg: RegExp;
14
+ fnc: string;
15
+ }>;
16
+ }>;
17
+ add({ name, dir, App, Class }: {
18
+ dir: dirName;
19
+ name: fileName;
20
+ App: new () => Plugin;
21
+ Class: Plugin;
22
+ }): void;
23
+ /**
24
+ * 卸载按钮
25
+ * @param {string} dir 插件目录
26
+ * @param {string} name 插件文件名称
27
+ */
28
+ del(dir: dirName, name: fileName): {
29
+ App: new () => Plugin;
30
+ name: string;
31
+ priority: number;
32
+ file: {
33
+ dir: dirName;
34
+ name: fileName;
35
+ };
36
+ rule: Array<{
37
+ reg: RegExp;
38
+ fnc: string;
39
+ }>;
40
+ }[];
41
+ update({ dir, name, App, Class }: {
42
+ dir: dirName;
43
+ name: fileName;
44
+ App: new () => Plugin;
45
+ Class: Plugin;
46
+ }): void;
47
+ get(e: KarinMessage): Promise<any[]>;
48
+ };
49
+ export default _default;