node-karin 0.0.3 → 0.1.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.
Files changed (105) 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/init.js +4 -4
  17. package/lib/core/karin.d.ts +72 -72
  18. package/lib/core/karin.js +51 -51
  19. package/lib/core/listener.d.ts +121 -121
  20. package/lib/core/listener.js +178 -178
  21. package/lib/core/plugin.app.d.ts +15 -15
  22. package/lib/core/plugin.app.js +18 -18
  23. package/lib/core/plugin.d.ts +182 -182
  24. package/lib/core/plugin.js +132 -132
  25. package/lib/core/plugin.loader.d.ts +149 -149
  26. package/lib/core/plugin.loader.js +451 -451
  27. package/lib/core/server.d.ts +26 -26
  28. package/lib/core/server.js +209 -209
  29. package/lib/db/level.d.ts +20 -20
  30. package/lib/db/level.js +36 -36
  31. package/lib/db/redis.d.ts +41 -41
  32. package/lib/db/redis.js +131 -131
  33. package/lib/db/redis_level.d.ts +113 -113
  34. package/lib/db/redis_level.js +274 -274
  35. package/lib/event/event.d.ts +138 -138
  36. package/lib/event/event.handler.d.ts +29 -29
  37. package/lib/event/event.handler.js +138 -138
  38. package/lib/event/event.js +120 -120
  39. package/lib/event/message.d.ts +102 -102
  40. package/lib/event/message.handler.d.ts +25 -25
  41. package/lib/event/message.handler.js +237 -237
  42. package/lib/event/message.js +69 -69
  43. package/lib/event/notice.d.ts +49 -49
  44. package/lib/event/notice.js +14 -14
  45. package/lib/event/request.d.ts +49 -49
  46. package/lib/event/request.js +14 -14
  47. package/lib/event/review.handler.d.ts +54 -54
  48. package/lib/event/review.handler.js +374 -374
  49. package/lib/index.d.ts +23 -23
  50. package/lib/index.js +39 -40
  51. package/lib/renderer/app.d.ts +53 -53
  52. package/lib/renderer/app.js +88 -88
  53. package/lib/renderer/base.d.ts +30 -30
  54. package/lib/renderer/base.js +68 -68
  55. package/lib/renderer/client.d.ts +30 -30
  56. package/lib/renderer/client.js +155 -155
  57. package/lib/renderer/http.d.ts +19 -19
  58. package/lib/renderer/http.js +50 -50
  59. package/lib/renderer/server.d.ts +42 -42
  60. package/lib/renderer/server.js +110 -110
  61. package/lib/renderer/wormhole.d.ts +1 -1
  62. package/lib/renderer/wormhole.js +154 -154
  63. package/lib/types/adapter.d.ts +575 -575
  64. package/lib/types/adapter.js +1 -1
  65. package/lib/types/config.d.ts +327 -327
  66. package/lib/types/config.js +1 -1
  67. package/lib/types/element.d.ts +576 -576
  68. package/lib/types/element.js +1 -1
  69. package/lib/types/index.d.ts +8 -8
  70. package/lib/types/index.js +8 -8
  71. package/lib/types/logger.d.ts +109 -109
  72. package/lib/types/logger.js +1 -1
  73. package/lib/types/onebots11.d.ts +1371 -1371
  74. package/lib/types/onebots11.js +1 -1
  75. package/lib/types/plugin.d.ts +282 -282
  76. package/lib/types/plugin.js +1 -1
  77. package/lib/types/render.d.ts +111 -111
  78. package/lib/types/render.js +1 -1
  79. package/lib/types/reply.d.ts +40 -40
  80. package/lib/types/reply.js +1 -1
  81. package/lib/types/types.d.ts +898 -898
  82. package/lib/types/types.js +1 -1
  83. package/lib/utils/YamlEditor.d.ts +62 -62
  84. package/lib/utils/YamlEditor.js +197 -197
  85. package/lib/utils/button.d.ts +49 -49
  86. package/lib/utils/button.js +75 -75
  87. package/lib/utils/common.d.ts +123 -123
  88. package/lib/utils/common.js +396 -396
  89. package/lib/utils/config.d.ts +72 -72
  90. package/lib/utils/config.js +254 -254
  91. package/lib/utils/exec.d.ts +22 -22
  92. package/lib/utils/exec.js +36 -36
  93. package/lib/utils/ffmpeg.d.ts +12 -12
  94. package/lib/utils/ffmpeg.js +25 -25
  95. package/lib/utils/handler.d.ts +76 -76
  96. package/lib/utils/handler.js +98 -98
  97. package/lib/utils/logger.d.ts +3 -3
  98. package/lib/utils/logger.js +104 -104
  99. package/lib/utils/segment.d.ts +276 -276
  100. package/lib/utils/segment.js +420 -420
  101. package/lib/utils/update.d.ts +69 -69
  102. package/lib/utils/update.js +145 -145
  103. package/lib/utils/updateVersion.d.ts +33 -33
  104. package/lib/utils/updateVersion.js +140 -140
  105. package/package.json +92 -91
@@ -1,104 +1,104 @@
1
- import fs from 'fs'
2
- import chalk from 'chalk'
3
- import log4js from 'log4js'
4
- import Cfg from './config.js'
5
- const logsDir = './logs'
6
- if (!fs.existsSync(logsDir)) { fs.mkdirSync(logsDir) }
7
- const { log_level, log_days_Keep, log4jsCfg } = Cfg.Config
8
- const level = log_level || log4jsCfg.level || 'info'
9
- const daysToKeep = log_days_Keep || log4jsCfg.daysToKeep || 7
10
- const { overall, fragments, maxLogSize } = log4jsCfg
11
- const defaultOptions = { appenders: ['console'], level, enableCallStack: process.env.KarinMode === 'dev' }
12
- const options = {
13
- appenders: {
14
- console: {
15
- type: 'console',
16
- layout: {
17
- type: 'pattern',
18
- pattern: `%[[Karin][%d{hh:mm:ss.SSS}][%4.4p]%] ${process.env.KarinMode === 'dev' ? '[%f{3}:%l] ' : ''}%m`,
19
- },
20
- },
21
- },
22
- categories: { default: defaultOptions },
23
- }
24
- if (overall) {
25
- defaultOptions.appenders.unshift('overall')
26
- options.appenders.overall = {
27
- /** 输出到文件 */
28
- type: 'file',
29
- filename: 'logs/logger',
30
- pattern: 'yyyy-MM-dd.log',
31
- /** 日期后缀 */
32
- keepFileExt: true,
33
- /** 日志文件名中包含日期模式 */
34
- alwaysIncludePattern: true,
35
- /** 日志文件保留天数 */
36
- daysToKeep,
37
- /** 日志输出格式 */
38
- layout: {
39
- type: 'pattern',
40
- pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m',
41
- },
42
- }
43
- }
44
- if (fragments) {
45
- defaultOptions.appenders.unshift('fragments')
46
- options.appenders.fragments = {
47
- type: 'file',
48
- filename: 'logs/app.log',
49
- pattern: 'MM-dd.log',
50
- keepFileExt: true,
51
- alwaysIncludePattern: true,
52
- daysToKeep,
53
- maxLogSize: (maxLogSize || 30) * 1024 * 1024,
54
- /** 最大文件数 */
55
- numBackups: 9999999,
56
- /** 日志输出格式 */
57
- layout: {
58
- type: 'pattern',
59
- pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m',
60
- },
61
- }
62
- }
63
- log4js.configure(options)
64
- const logger = log4js.getLogger('default')
65
- logger.chalk = chalk
66
- logger.red = chalk.red
67
- logger.green = chalk.green
68
- logger.yellow = chalk.yellow
69
- logger.blue = chalk.blue
70
- logger.magenta = chalk.magenta
71
- logger.cyan = chalk.cyan
72
- logger.white = chalk.white
73
- logger.gray = chalk.gray
74
- logger.violet = chalk.hex('#868ECC')
75
- logger.fnc = chalk.hex(Cfg.Config.log_color || '#FFFF00')
76
- logger.bot = (level, id, ...args) => {
77
- switch (level) {
78
- case 'trace':
79
- logger.trace(logger.violet(`[Bot:${id}] `), ...args)
80
- break
81
- case 'debug':
82
- logger.debug(logger.violet(`[Bot:${id}] `), ...args)
83
- break
84
- case 'mark':
85
- logger.mark(logger.violet(`[Bot:${id}] `), ...args)
86
- break
87
- case 'info':
88
- logger.info(logger.violet(`[Bot:${id}] `), ...args)
89
- break
90
- case 'warn':
91
- logger.warn(logger.violet(`[Bot:${id}] `), ...args)
92
- break
93
- case 'error':
94
- logger.error(logger.violet(`[Bot:${id}] `), ...args)
95
- break
96
- case 'fatal':
97
- logger.fatal(logger.violet(`[Bot:${id}] `), ...args)
98
- break
99
- default:
100
- logger.info(logger.violet(`[Bot:${id}] `), ...args)
101
- }
102
- }
103
- global.logger = logger
104
- export default logger
1
+ import fs from 'fs'
2
+ import chalk from 'chalk'
3
+ import log4js from 'log4js'
4
+ import Cfg from './config.js'
5
+ const logsDir = './logs'
6
+ if (!fs.existsSync(logsDir)) { fs.mkdirSync(logsDir) }
7
+ const { log_level, log_days_Keep, log4jsCfg } = Cfg.Config
8
+ const level = log_level || log4jsCfg.level || 'info'
9
+ const daysToKeep = log_days_Keep || log4jsCfg.daysToKeep || 7
10
+ const { overall, fragments, maxLogSize } = log4jsCfg
11
+ const defaultOptions = { appenders: ['console'], level, enableCallStack: process.env.KarinMode === 'dev' }
12
+ const options = {
13
+ appenders: {
14
+ console: {
15
+ type: 'console',
16
+ layout: {
17
+ type: 'pattern',
18
+ pattern: `%[[Karin][%d{hh:mm:ss.SSS}][%4.4p]%] ${process.env.KarinMode === 'dev' ? '[%f{3}:%l] ' : ''}%m`,
19
+ },
20
+ },
21
+ },
22
+ categories: { default: defaultOptions },
23
+ }
24
+ if (overall) {
25
+ defaultOptions.appenders.unshift('overall')
26
+ options.appenders.overall = {
27
+ /** 输出到文件 */
28
+ type: 'file',
29
+ filename: 'logs/logger',
30
+ pattern: 'yyyy-MM-dd.log',
31
+ /** 日期后缀 */
32
+ keepFileExt: true,
33
+ /** 日志文件名中包含日期模式 */
34
+ alwaysIncludePattern: true,
35
+ /** 日志文件保留天数 */
36
+ daysToKeep,
37
+ /** 日志输出格式 */
38
+ layout: {
39
+ type: 'pattern',
40
+ pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m',
41
+ },
42
+ }
43
+ }
44
+ if (fragments) {
45
+ defaultOptions.appenders.unshift('fragments')
46
+ options.appenders.fragments = {
47
+ type: 'file',
48
+ filename: 'logs/app.log',
49
+ pattern: 'MM-dd.log',
50
+ keepFileExt: true,
51
+ alwaysIncludePattern: true,
52
+ daysToKeep,
53
+ maxLogSize: (maxLogSize || 30) * 1024 * 1024,
54
+ /** 最大文件数 */
55
+ numBackups: 9999999,
56
+ /** 日志输出格式 */
57
+ layout: {
58
+ type: 'pattern',
59
+ pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m',
60
+ },
61
+ }
62
+ }
63
+ log4js.configure(options)
64
+ const logger = log4js.getLogger('default')
65
+ logger.chalk = chalk
66
+ logger.red = chalk.red
67
+ logger.green = chalk.green
68
+ logger.yellow = chalk.yellow
69
+ logger.blue = chalk.blue
70
+ logger.magenta = chalk.magenta
71
+ logger.cyan = chalk.cyan
72
+ logger.white = chalk.white
73
+ logger.gray = chalk.gray
74
+ logger.violet = chalk.hex('#868ECC')
75
+ logger.fnc = chalk.hex(Cfg.Config.log_color || '#FFFF00')
76
+ logger.bot = (level, id, ...args) => {
77
+ switch (level) {
78
+ case 'trace':
79
+ logger.trace(logger.violet(`[Bot:${id}] `), ...args)
80
+ break
81
+ case 'debug':
82
+ logger.debug(logger.violet(`[Bot:${id}] `), ...args)
83
+ break
84
+ case 'mark':
85
+ logger.mark(logger.violet(`[Bot:${id}] `), ...args)
86
+ break
87
+ case 'info':
88
+ logger.info(logger.violet(`[Bot:${id}] `), ...args)
89
+ break
90
+ case 'warn':
91
+ logger.warn(logger.violet(`[Bot:${id}] `), ...args)
92
+ break
93
+ case 'error':
94
+ logger.error(logger.violet(`[Bot:${id}] `), ...args)
95
+ break
96
+ case 'fatal':
97
+ logger.fatal(logger.violet(`[Bot:${id}] `), ...args)
98
+ break
99
+ default:
100
+ logger.info(logger.violet(`[Bot:${id}] `), ...args)
101
+ }
102
+ }
103
+ global.logger = logger
104
+ export default logger