node-karin 0.12.1 → 0.12.2-5.pr.206.24448f3

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 (244) hide show
  1. package/CHANGELOG.md +1029 -0
  2. package/LICENSE +21 -674
  3. package/README.md +15 -42
  4. package/default/comment/config.json +34 -0
  5. package/default/comment/friendDirect.json +10 -0
  6. package/default/comment/groupGuild.json +11 -0
  7. package/default/comment/server.json +17 -0
  8. package/default/config/config.yaml +78 -0
  9. package/default/config/friendDirect.yaml +31 -0
  10. package/default/config/groupGuild.yaml +70 -0
  11. package/default/config/pm2.yaml +21 -0
  12. package/default/config/redis.yaml +19 -0
  13. package/default/config/server.yaml +47 -0
  14. package/default/view/group.yaml +73 -0
  15. package/lib/index.js +38 -8
  16. package/package.json +128 -124
  17. package/packages/module/art-template.cjs +11 -0
  18. package/packages/module/art-template.d.ts +1 -0
  19. package/packages/module/axios.cjs +22 -0
  20. package/packages/module/axios.d.ts +2 -0
  21. package/packages/module/chalk.cjs +22 -0
  22. package/packages/module/chalk.d.ts +2 -0
  23. package/packages/module/chokidar.cjs +22 -0
  24. package/packages/module/chokidar.d.ts +2 -0
  25. package/packages/module/commander.cjs +35 -0
  26. package/packages/module/commander.d.ts +3 -0
  27. package/packages/module/commander.js +3 -0
  28. package/packages/module/express.cjs +112 -0
  29. package/packages/module/express.d.ts +1 -0
  30. package/packages/module/express.js +1 -0
  31. package/packages/module/level.cjs +22 -0
  32. package/packages/module/level.d.ts +2 -0
  33. package/packages/module/lodash.cjs +11 -0
  34. package/packages/module/lodash.d.ts +1 -0
  35. package/packages/module/log4js.cjs +22 -0
  36. package/packages/module/log4js.d.ts +2 -0
  37. package/packages/module/moment.cjs +11 -0
  38. package/packages/module/moment.d.ts +1 -0
  39. package/packages/module/node-schedule.cjs +22 -0
  40. package/packages/module/node-schedule.d.ts +2 -0
  41. package/packages/module/redis.cjs +22 -0
  42. package/packages/module/redis.d.ts +2 -0
  43. package/packages/module/ws.cjs +28 -0
  44. package/packages/module/ws.d.ts +1 -0
  45. package/packages/module/ws.js +1 -0
  46. package/packages/module/yaml.cjs +22 -0
  47. package/packages/module/yaml.d.ts +2 -0
  48. package/config/defSet/App.yaml +0 -42
  49. package/config/defSet/config.yaml +0 -65
  50. package/config/defSet/group.yaml +0 -56
  51. package/config/defSet/pm2.yaml +0 -21
  52. package/config/defSet/redis.yaml +0 -18
  53. package/config/defSet/server.yaml +0 -42
  54. package/config/view/group.yaml +0 -92
  55. package/lib/adapter/index.d.ts +0 -2
  56. package/lib/adapter/index.js +0 -2
  57. package/lib/adapter/input/index.d.ts +0 -78
  58. package/lib/adapter/input/index.js +0 -205
  59. package/lib/adapter/onebot/11/convert.d.ts +0 -12
  60. package/lib/adapter/onebot/11/convert.js +0 -167
  61. package/lib/adapter/onebot/11/event.d.ts +0 -25
  62. package/lib/adapter/onebot/11/event.js +0 -442
  63. package/lib/adapter/onebot/11/index.d.ts +0 -508
  64. package/lib/adapter/onebot/11/index.js +0 -1047
  65. package/lib/cli/index.d.ts +0 -92
  66. package/lib/cli/index.js +0 -307
  67. package/lib/cli/init.d.ts +0 -2
  68. package/lib/cli/init.js +0 -22
  69. package/lib/cli/karin.d.ts +0 -2
  70. package/lib/cli/karin.js +0 -16
  71. package/lib/cli/pkg.d.ts +0 -4
  72. package/lib/cli/pkg.js +0 -14
  73. package/lib/cli/start.d.ts +0 -1
  74. package/lib/cli/start.js +0 -8
  75. package/lib/core/index.d.ts +0 -10
  76. package/lib/core/index.js +0 -10
  77. package/lib/core/init/config.d.ts +0 -43
  78. package/lib/core/init/config.js +0 -201
  79. package/lib/core/init/dir.d.ts +0 -4
  80. package/lib/core/init/dir.js +0 -7
  81. package/lib/core/init/init.d.ts +0 -1
  82. package/lib/core/init/init.js +0 -47
  83. package/lib/core/karin/karin.d.ts +0 -198
  84. package/lib/core/karin/karin.js +0 -226
  85. package/lib/core/listener/listener.d.ts +0 -145
  86. package/lib/core/listener/listener.js +0 -235
  87. package/lib/core/plugin/base.d.ts +0 -156
  88. package/lib/core/plugin/base.js +0 -131
  89. package/lib/core/plugin/loader.d.ts +0 -141
  90. package/lib/core/plugin/loader.js +0 -618
  91. package/lib/core/process/process.d.ts +0 -18
  92. package/lib/core/process/process.js +0 -96
  93. package/lib/core/server/server.d.ts +0 -25
  94. package/lib/core/server/server.js +0 -295
  95. package/lib/db/index.d.ts +0 -2
  96. package/lib/db/index.js +0 -2
  97. package/lib/db/level/level.d.ts +0 -19
  98. package/lib/db/level/level.js +0 -36
  99. package/lib/db/redis/redis.d.ts +0 -2
  100. package/lib/db/redis/redis.js +0 -135
  101. package/lib/db/redis/redis_level.d.ts +0 -112
  102. package/lib/db/redis/redis_level.js +0 -281
  103. package/lib/event/handler/base.d.ts +0 -42
  104. package/lib/event/handler/base.js +0 -200
  105. package/lib/event/handler/message.d.ts +0 -25
  106. package/lib/event/handler/message.js +0 -302
  107. package/lib/event/handler/notice.d.ts +0 -18
  108. package/lib/event/handler/notice.js +0 -214
  109. package/lib/event/handler/request.d.ts +0 -18
  110. package/lib/event/handler/request.js +0 -115
  111. package/lib/event/handler/review.d.ts +0 -55
  112. package/lib/event/handler/review.js +0 -386
  113. package/lib/event/index.d.ts +0 -5
  114. package/lib/event/index.js +0 -5
  115. package/lib/index.d.ts +0 -8
  116. package/lib/modules/art-template.d.ts +0 -1
  117. package/lib/modules/axios.d.ts +0 -2
  118. package/lib/modules/chalk.d.ts +0 -2
  119. package/lib/modules/chokidar.d.ts +0 -2
  120. package/lib/modules/commander.d.ts +0 -2
  121. package/lib/modules/commander.js +0 -2
  122. package/lib/modules/express.d.ts +0 -3
  123. package/lib/modules/express.js +0 -3
  124. package/lib/modules/level.d.ts +0 -2
  125. package/lib/modules/lodash.d.ts +0 -1
  126. package/lib/modules/log4js.d.ts +0 -2
  127. package/lib/modules/moment.d.ts +0 -1
  128. package/lib/modules/node-schedule.d.ts +0 -2
  129. package/lib/modules/redis.d.ts +0 -2
  130. package/lib/modules/ws.d.ts +0 -3
  131. package/lib/modules/ws.js +0 -3
  132. package/lib/modules/yaml.d.ts +0 -2
  133. package/lib/modules.d.ts +0 -15
  134. package/lib/modules.js +0 -15
  135. package/lib/render/app.d.ts +0 -56
  136. package/lib/render/app.js +0 -120
  137. package/lib/render/base.d.ts +0 -30
  138. package/lib/render/base.js +0 -69
  139. package/lib/render/client.d.ts +0 -41
  140. package/lib/render/client.js +0 -238
  141. package/lib/render/http.d.ts +0 -19
  142. package/lib/render/http.js +0 -50
  143. package/lib/render/index.d.ts +0 -6
  144. package/lib/render/index.js +0 -6
  145. package/lib/render/server.d.ts +0 -25
  146. package/lib/render/server.js +0 -101
  147. package/lib/render/wormhole.d.ts +0 -1
  148. package/lib/render/wormhole.js +0 -156
  149. package/lib/types/adapter/api.d.ts +0 -399
  150. package/lib/types/adapter/api.js +0 -1
  151. package/lib/types/adapter/base.d.ts +0 -560
  152. package/lib/types/adapter/base.js +0 -1
  153. package/lib/types/config/config.d.ts +0 -379
  154. package/lib/types/config/config.js +0 -1
  155. package/lib/types/element/element.d.ts +0 -565
  156. package/lib/types/element/element.js +0 -1
  157. package/lib/types/element/qqbot.d.ts +0 -123
  158. package/lib/types/element/qqbot.js +0 -1
  159. package/lib/types/event/contact.d.ts +0 -28
  160. package/lib/types/event/contact.js +0 -1
  161. package/lib/types/event/event.d.ts +0 -305
  162. package/lib/types/event/event.js +0 -1
  163. package/lib/types/event/index.d.ts +0 -12
  164. package/lib/types/event/index.js +0 -7
  165. package/lib/types/event/message.d.ts +0 -109
  166. package/lib/types/event/message.js +0 -74
  167. package/lib/types/event/notice.d.ts +0 -513
  168. package/lib/types/event/notice.js +0 -52
  169. package/lib/types/event/reply.d.ts +0 -50
  170. package/lib/types/event/reply.js +0 -1
  171. package/lib/types/event/request.d.ts +0 -126
  172. package/lib/types/event/request.js +0 -52
  173. package/lib/types/event/sender.d.ts +0 -44
  174. package/lib/types/event/sender.js +0 -1
  175. package/lib/types/index.d.ts +0 -13
  176. package/lib/types/index.js +0 -13
  177. package/lib/types/logger/logger.d.ts +0 -110
  178. package/lib/types/logger/logger.js +0 -1
  179. package/lib/types/onebot11/api.d.ts +0 -53
  180. package/lib/types/onebot11/api.js +0 -1
  181. package/lib/types/onebot11/event.d.ts +0 -619
  182. package/lib/types/onebot11/event.js +0 -2
  183. package/lib/types/onebot11/index.d.ts +0 -6
  184. package/lib/types/onebot11/index.js +0 -6
  185. package/lib/types/onebot11/params.d.ts +0 -609
  186. package/lib/types/onebot11/params.js +0 -1
  187. package/lib/types/onebot11/response.d.ts +0 -516
  188. package/lib/types/onebot11/response.js +0 -1
  189. package/lib/types/onebot11/segment.d.ts +0 -269
  190. package/lib/types/onebot11/segment.js +0 -1
  191. package/lib/types/onebot11/sender.d.ts +0 -59
  192. package/lib/types/onebot11/sender.js +0 -1
  193. package/lib/types/plugin/app.d.ts +0 -71
  194. package/lib/types/plugin/app.js +0 -1
  195. package/lib/types/plugin/plugin.d.ts +0 -473
  196. package/lib/types/plugin/plugin.js +0 -1
  197. package/lib/types/render/render.d.ts +0 -118
  198. package/lib/types/render/render.js +0 -1
  199. package/lib/types/type/global.d.ts +0 -25
  200. package/lib/types/type/global.js +0 -1
  201. package/lib/utils/common/common.d.ts +0 -236
  202. package/lib/utils/common/common.js +0 -708
  203. package/lib/utils/config/config.d.ts +0 -193
  204. package/lib/utils/config/config.js +0 -328
  205. package/lib/utils/config/updateVersion.d.ts +0 -33
  206. package/lib/utils/config/updateVersion.js +0 -145
  207. package/lib/utils/config/yamlEditor.d.ts +0 -101
  208. package/lib/utils/config/yamlEditor.js +0 -330
  209. package/lib/utils/core/handler.d.ts +0 -18
  210. package/lib/utils/core/handler.js +0 -46
  211. package/lib/utils/core/logger.d.ts +0 -3
  212. package/lib/utils/core/logger.js +0 -105
  213. package/lib/utils/core/segment.d.ts +0 -279
  214. package/lib/utils/core/segment.js +0 -451
  215. package/lib/utils/index.d.ts +0 -13
  216. package/lib/utils/index.js +0 -13
  217. package/lib/utils/tools/button.d.ts +0 -2
  218. package/lib/utils/tools/button.js +0 -27
  219. package/lib/utils/tools/exec.d.ts +0 -20
  220. package/lib/utils/tools/exec.js +0 -54
  221. package/lib/utils/tools/ffmpeg.d.ts +0 -12
  222. package/lib/utils/tools/ffmpeg.js +0 -25
  223. package/lib/utils/tools/restart.d.ts +0 -15
  224. package/lib/utils/tools/restart.js +0 -39
  225. package/lib/utils/tools/stop.d.ts +0 -7
  226. package/lib/utils/tools/stop.js +0 -13
  227. package/lib/utils/tools/update.d.ts +0 -67
  228. package/lib/utils/tools/update.js +0 -151
  229. /package/{config → default}/view/App.yaml +0 -0
  230. /package/{config → default}/view/config.yaml +0 -0
  231. /package/{config → default}/view/pm2.yaml +0 -0
  232. /package/{config → default}/view/redis.yaml +0 -0
  233. /package/{config → default}/view/server.yaml +0 -0
  234. /package/{lib/modules → packages/module}/art-template.js +0 -0
  235. /package/{lib/modules → packages/module}/axios.js +0 -0
  236. /package/{lib/modules → packages/module}/chalk.js +0 -0
  237. /package/{lib/modules → packages/module}/chokidar.js +0 -0
  238. /package/{lib/modules → packages/module}/level.js +0 -0
  239. /package/{lib/modules → packages/module}/lodash.js +0 -0
  240. /package/{lib/modules → packages/module}/log4js.js +0 -0
  241. /package/{lib/modules → packages/module}/moment.js +0 -0
  242. /package/{lib/modules → packages/module}/node-schedule.js +0 -0
  243. /package/{lib/modules → packages/module}/redis.js +0 -0
  244. /package/{lib/modules → packages/module}/yaml.js +0 -0
@@ -1,236 +0,0 @@
1
- import fs from 'fs';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { Readable } from 'stream';
4
- import { ButtonElement, ButtonType, dirName, KarinElement, NodeElement, KeyBoardElement } from '../../types/index.js';
5
- export interface NpmInfo {
6
- plugin: string;
7
- path: string;
8
- file: string;
9
- isMain: boolean;
10
- }
11
- /**
12
- * 常用方法
13
- */
14
- export declare class Common {
15
- streamPipeline: (stream1: Readable, stream2: fs.WriteStream) => Promise<void>;
16
- constructor();
17
- /**
18
- * 休眠函数
19
- * @param ms 毫秒
20
- */
21
- sleep(ms: number): Promise<unknown>;
22
- /**
23
- * 下载保存文件
24
- * @param fileUrl 下载地址
25
- * @param savePath 保存路径
26
- * @param param axios参数
27
- */
28
- downFile(fileUrl: string, savePath: string, param?: AxiosRequestConfig): Promise<boolean>;
29
- /**
30
- * 对axios进行简单封装,超时、错误后返回null,不会抛出异常
31
- * @param url 请求地址
32
- * @param type 请求类型
33
- * @param param axios参数
34
- */
35
- axios(url: string, type?: 'get' | 'post', param?: AxiosRequestConfig): Promise<any | null>;
36
- /**
37
- * 递归创建目录
38
- * @param dirname - 要创建的文件夹路径
39
- */
40
- mkdir(dirname: string): boolean;
41
- /**
42
- * 标准化文件路径
43
- * @param file - 相对路径
44
- * @param isDir - 返回绝对路径
45
- * @param isFile - 添加file://前缀
46
- * @returns 标准化后的路径
47
- */
48
- absPath(file: string, isDir?: boolean, isFile?: boolean): string;
49
- /**
50
- * 判断是否为文件夹
51
- * @param path - 路径
52
- * @returns 返回true为文件夹
53
- */
54
- isDir(path: string): boolean;
55
- /**
56
- * 判断是否为插件包
57
- * @param path - 路径
58
- * @returns 返回true为插件包
59
- */
60
- isPlugin(path: string): boolean;
61
- /**
62
- * 去掉相对路径的前缀和后缀
63
- * @param root - 相对路径路径
64
- */
65
- getRelPath(root: string): string;
66
- /**
67
- * 判断路径是否存在
68
- * @param path - 路径
69
- * @returns 返回true为存在
70
- */
71
- exists(path: string): boolean;
72
- /**
73
- * - 解析json文件
74
- * @param file - 文件路径
75
- * @param isThrow - 解析失败是否抛出错误
76
- */
77
- readJson(file: string, isThrow?: boolean): any;
78
- /**
79
- * - 写入json文件
80
- * @param file - 文件路径
81
- * @param data - 要写入的数据
82
- */
83
- writeJson(file: string, data: any): boolean;
84
- /**
85
- * - 解析yaml文件
86
- * @param file - 文件路径
87
- */
88
- readYaml(file: string): any;
89
- /**
90
- * - 写入yaml文件
91
- * @param file - 文件路径
92
- * @param data - 要写入的数据
93
- */
94
- writeYaml(file: string, data: any): boolean;
95
- /**
96
- * 传入插件名称 返回解析后的package.json的内容
97
- * @param name - 插件名称
98
- */
99
- pkgJson(name: string): {
100
- name: string;
101
- version: string;
102
- [key: string]: any;
103
- } | null;
104
- /**
105
- * 输入包名 返回包根目录的绝对路径 仅简单查找
106
- * @param name - 包名
107
- * @param _path - 导入包的路径 此项适用于在插件中读取插件的依赖包
108
- * @returns - 包根目录的绝对路径
109
- * @example
110
- * common.pkgroot('axios')
111
- * common.pkgroot('axios', import.meta.url)
112
- */
113
- pkgroot(name: string, _path?: string): string;
114
- /**
115
- * 根据文件后缀名从指定路径下读取符合要求的文件
116
- * @param path - 路径
117
- * @param ext - 后缀名、或后缀名列表
118
- * @example common.readDir('./plugins', '.js')
119
- * @example common.readDir('./plugins', ['.js', '.ts'])
120
- */
121
- readDir(_path: string, ext: string | string[]): string[] | null;
122
- /**
123
- * 根据传入的 import.meta.url 计算相对于项目根目录的路径,返回需要的 '../' 层级。
124
- * @param url - import.meta.url
125
- * @returns 相对路径的层级数量,用 '../' 表示
126
- * @example
127
- * // 在 plugins/karin-plugin-example/index.ts 中使用
128
- * common.urlToPath(import.meta.url) // 返回 '../../'
129
- */
130
- urlToPath(url: string): string;
131
- /**
132
- * 传入相对路径 分割为两部分 1为文件夹路径 2为文件名 文件夹路径无前缀开头
133
- * @param _path - 路径
134
- */
135
- splitPath(_path: string): {
136
- dir: string;
137
- pop: string;
138
- };
139
- /**
140
- * 将文件转换为不带前缀的base64字符串
141
- * @param file - 文件路径或Buffer对象、可读流对象、http地址、base64://字符串
142
- * @param options - 选项 http为true时返回http地址
143
- * @returns 返回base64字符串
144
- */
145
- base64(file: string | Buffer | Readable, options?: {
146
- http: boolean;
147
- }): Promise<string>;
148
- /**
149
- * 将文件转换为Buffer对象 仅支持标准格式
150
- * @param file - 文件路径或Buffer对象、可读流对象、http地址、base64://字符串
151
- * @param options - 选项 http为true时返回http地址
152
- * @returns - 返回Buffer对象
153
- */
154
- buffer<T extends {
155
- http: boolean;
156
- }>(file: string | Buffer | Readable, options?: T): Promise<T extends {
157
- http: true;
158
- } ? string : Buffer>;
159
- /**
160
- * 将数据流对象转换为Buffer对象
161
- * @param {stream.Readable} stream - 要转换的数据流对象
162
- * @returns {Promise<Buffer>} - 返回Buffer
163
- */
164
- stream(stream: Readable): Promise<Buffer>;
165
- /**
166
- * 标准化发送的消息内容
167
- * @param elements - 消息内容
168
- */
169
- makeMessage(elements: string | KarinElement | (string | KarinElement)[]): Array<KarinElement>;
170
- /**
171
- * 制作简单转发,返回segment.node[]。仅简单包装node,也可以自己组装
172
- * @param elements
173
- * @param fakeUin 转发用户的QQ号 必填
174
- * @param fakeNick 转发用户显示的昵称 必填
175
- */
176
- makeForward(elements: KarinElement | KarinElement[], fakeUin: string, fakeNick: string): Array<NodeElement>;
177
- /**
178
- * 获取git插件列表
179
- * @param isPack - 是否屏蔽不带package.json的插件,默认为false
180
- */
181
- getPlugins(isPack?: boolean): Array<dirName>;
182
- /**
183
- * 获取git插件列表
184
- * @param isPack - 是否屏蔽不带package.json的插件,默认为false
185
- */
186
- getGitPlugins(isPack?: boolean): Array<dirName>;
187
- /**
188
- * 获取npm插件列表
189
- * @param showDetails - 是否返回详细信息
190
- * 默认只返回插件npm包名,为true时返回详细的{dir, name}[]
191
- */
192
- getNpmPlugins<T extends boolean>(showDetails: T): Promise<T extends true ? NpmInfo[] : string[]>;
193
- /**
194
- * 获取运行时间
195
- */
196
- uptime(): string;
197
- /**
198
- * 传入一个时间戳
199
- * 返回距今已过去的时间
200
- * @param time - 时间戳
201
- *
202
- * @example
203
- * common.formatTime(1620000000)
204
- * // -> '18天'
205
- */
206
- formatTime(time: number): string;
207
- /**
208
- * 构建消息体日志
209
- * @param - 消息体
210
- */
211
- makeMessageLog(message: Array<KarinElement>): string;
212
- /**
213
- * 更新yaml文件
214
- * @param filePath - 文件路径
215
- * @param settings - 设置项
216
- */
217
- updateYaml(filePath: string, settings: {
218
- /** 键路径 */
219
- key: string;
220
- /** 要写入的 */
221
- val: any;
222
- /** 需要写入的注释 */
223
- comment: string;
224
- }[]): void;
225
- /**
226
- * karin按钮转换为QQBot官方按钮 返回官方按钮结构
227
- * @param button - 按钮
228
- */
229
- buttonToQQBot(button: ButtonElement | KeyBoardElement): Array<{
230
- buttons: Array<ButtonType>;
231
- }>;
232
- }
233
- /**
234
- * 常用方法
235
- */
236
- export declare const common: Common;