node-karin 0.7.2 → 0.8.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/config/defSet/App.yaml +5 -0
- package/config/defSet/config.yaml +7 -0
- package/config/view/App.yaml +60 -67
- package/config/view/config.yaml +128 -60
- package/config/view/redis.yaml +15 -20
- package/config/view/server.yaml +66 -86
- package/lib/event/event.handler.d.ts +4 -0
- package/lib/event/event.handler.js +16 -0
- package/lib/event/message.handler.js +2 -0
- package/lib/event/notice.handler.js +1 -0
- package/lib/event/request.handler.js +1 -0
- package/lib/event/review.handler.d.ts +5 -0
- package/lib/event/review.handler.js +17 -0
- package/lib/types/config.d.ts +15 -0
- package/lib/utils/config.js +4 -0
- package/package.json +1 -1
package/config/defSet/App.yaml
CHANGED
package/config/view/App.yaml
CHANGED
|
@@ -1,74 +1,67 @@
|
|
|
1
1
|
name: 应用配置
|
|
2
2
|
view:
|
|
3
|
-
-
|
|
4
|
-
key: 黑名单
|
|
3
|
+
- key: 黑名单
|
|
5
4
|
comment: 黑名单相关
|
|
6
|
-
path:
|
|
7
|
-
type:
|
|
5
|
+
path: "BlackList"
|
|
6
|
+
type: "group"
|
|
8
7
|
part:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
path: 'BlackList.GroupMsgLog'
|
|
21
|
-
type: 'boolean'
|
|
22
|
-
-
|
|
23
|
-
key: 白名单
|
|
8
|
+
- key: 黑名单用户
|
|
9
|
+
path: "BlackList.users"
|
|
10
|
+
type: "boolean"
|
|
11
|
+
- key: 黑名单群聊
|
|
12
|
+
path: "BlackList.groups"
|
|
13
|
+
type: "boolean"
|
|
14
|
+
- key: 消息日志黑名单群聊
|
|
15
|
+
comment: 设置后不会打印该群的消息日志
|
|
16
|
+
path: "BlackList.GroupMsgLog"
|
|
17
|
+
type: "boolean"
|
|
18
|
+
- key: 白名单
|
|
24
19
|
comment: 白名单相关
|
|
25
|
-
path:
|
|
26
|
-
type:
|
|
20
|
+
path: "WhiteList"
|
|
21
|
+
type: "group"
|
|
27
22
|
part:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
key: 群聊
|
|
43
|
-
path: 'GroupConfig'
|
|
44
|
-
type: 'group'
|
|
23
|
+
- key: 白名单用户
|
|
24
|
+
path: "WhiteList.users"
|
|
25
|
+
type: "boolean"
|
|
26
|
+
- key: 白名单群聊
|
|
27
|
+
path: "WhiteList.groups"
|
|
28
|
+
type: "boolean"
|
|
29
|
+
- key: 消息日志白名单群聊
|
|
30
|
+
comment: 消息日志白名单群聊 设置后只会打印该群的消息日志
|
|
31
|
+
path: "WhiteList.GroupMsgLog"
|
|
32
|
+
type: "boolean"
|
|
33
|
+
- key: 群聊
|
|
34
|
+
path: "GroupConfig"
|
|
35
|
+
type: "group"
|
|
45
36
|
part:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
37
|
+
- key: 消息冷却时间
|
|
38
|
+
comment: 群聊中所有消息冷却时间
|
|
39
|
+
path: "GroupConfig.GroupCD"
|
|
40
|
+
type: "boolean"
|
|
41
|
+
- key: 个人消息冷却时间
|
|
42
|
+
comment: 群聊中 每个人的消息冷却时间
|
|
43
|
+
path: "GroupConfig.GroupUserCD"
|
|
44
|
+
type: "boolean"
|
|
45
|
+
- key: 机器人响应模式
|
|
46
|
+
path: "GroupConfig.mode"
|
|
47
|
+
type: "boolean"
|
|
48
|
+
- key: 机器人前缀
|
|
49
|
+
comment: 机器人前缀 设置后前缀+指令触发机器人
|
|
50
|
+
path: "GroupConfig.alias"
|
|
51
|
+
type: "boolean"
|
|
52
|
+
- key: 白名单插件、功能
|
|
53
|
+
comment: 白名单插件、功能,只有在白名单中的插件、功能才会响应
|
|
54
|
+
path: "GroupConfig.enable"
|
|
55
|
+
type: "boolean"
|
|
56
|
+
- key: 黑名单插件、功能
|
|
57
|
+
comment: 黑名单插件、功能,黑名单中的插件、功能不会响应
|
|
58
|
+
path: "GroupConfig.disable"
|
|
59
|
+
type: "boolean"
|
|
60
|
+
- key: 私聊
|
|
61
|
+
path: "PrivateConfig"
|
|
62
|
+
type: "group"
|
|
63
|
+
part:
|
|
64
|
+
- key: 是否开启私聊
|
|
65
|
+
comment: 是否开启私聊
|
|
66
|
+
path: "PrivateConfig.enable"
|
|
67
|
+
type: "boolean"
|
package/config/view/config.yaml
CHANGED
|
@@ -1,102 +1,170 @@
|
|
|
1
1
|
name: 通用配置
|
|
2
2
|
view:
|
|
3
|
-
- key:
|
|
4
|
-
comment:
|
|
5
|
-
path:
|
|
6
|
-
type:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
- key: 日志配置
|
|
4
|
+
comment: log4js日志配置
|
|
5
|
+
path: log4jsCfg
|
|
6
|
+
type: group
|
|
7
|
+
part:
|
|
8
|
+
- key: 日志等级
|
|
9
|
+
comment: 日志等级:trace,debug,info,warn,fatal,mark,error,off
|
|
10
|
+
path: log_level
|
|
11
|
+
type: select
|
|
12
|
+
multiple: false
|
|
13
|
+
item:
|
|
14
|
+
- name: Trace
|
|
15
|
+
value: trace
|
|
16
|
+
- name: Debug
|
|
17
|
+
value: ebug
|
|
18
|
+
- name: Info
|
|
19
|
+
value: info
|
|
20
|
+
- name: Warn
|
|
21
|
+
value: warn
|
|
22
|
+
- name: Fatal
|
|
23
|
+
value: fatal
|
|
24
|
+
- name: Mark
|
|
25
|
+
value: mark
|
|
26
|
+
- name: Error
|
|
27
|
+
value: error
|
|
28
|
+
- name: Off
|
|
29
|
+
value: off
|
|
30
|
+
- key: 日志保留天数
|
|
31
|
+
path: log_days_Keep
|
|
32
|
+
type: number
|
|
33
|
+
- key: 整体化
|
|
34
|
+
comment: 将日志输出到一个文件(一天为一个文件) 日志较多的情况下不建议与碎片化同时开启
|
|
35
|
+
path: overall
|
|
36
|
+
type: boolean
|
|
37
|
+
- key: 碎片化
|
|
38
|
+
comment: 将日志分片,达到指定大小后自动切割 日志较多的情况下不建议与整体化同时开启
|
|
39
|
+
path: fragments
|
|
40
|
+
type: boolean
|
|
41
|
+
- key: 日志文件最大大小
|
|
42
|
+
comment: 日志文件最大大小 MB
|
|
43
|
+
path: maxLogSize
|
|
44
|
+
type: number
|
|
45
|
+
|
|
46
|
+
- key: 后台进程
|
|
47
|
+
comment: 关闭后台进程失败后是否继续启动 继续启动会导致多进程
|
|
48
|
+
path: multi_progress
|
|
49
|
+
type: boolean
|
|
50
|
+
|
|
51
|
+
- key: 控制台插件日志颜色
|
|
52
|
+
comment: 控制台触发插件日志颜色 十六进制 默认#FFFF00 不支持热更新
|
|
53
|
+
path: log_color
|
|
54
|
+
type: text
|
|
55
|
+
|
|
56
|
+
- key: 私聊设置
|
|
57
|
+
comment: 私聊设置
|
|
58
|
+
path: private
|
|
59
|
+
type: group
|
|
60
|
+
part:
|
|
61
|
+
- key: 关闭私聊提示词
|
|
62
|
+
comment: 关闭私聊后回复的提示词 为空则不回复
|
|
63
|
+
path: tips
|
|
64
|
+
type: text
|
|
65
|
+
- key: 关闭私聊白名单
|
|
66
|
+
comment: 关闭私聊后的用户白名单
|
|
67
|
+
path: white_list
|
|
68
|
+
type: array
|
|
69
|
+
|
|
70
|
+
- key: input适配器配置
|
|
71
|
+
comment: input适配器配置 以下所有配置均不支持热更新
|
|
72
|
+
path: AdapterInput
|
|
73
|
+
type: group
|
|
74
|
+
part:
|
|
75
|
+
- key: 是否启用
|
|
76
|
+
comment: 是否启动input适配器
|
|
77
|
+
path: enable
|
|
78
|
+
type: boolean
|
|
79
|
+
- key: 是否转为文件
|
|
80
|
+
comment: 是否将语音、图片、视频消息转为文件 转为文件后可通过url访问
|
|
81
|
+
path: msgToFile
|
|
82
|
+
type: boolean
|
|
83
|
+
- key: url访问token
|
|
84
|
+
comment: url访问token 如果为 AdapterInput 每次启动后会重新生成
|
|
85
|
+
path: token
|
|
86
|
+
type: text
|
|
87
|
+
- key: 访问ip
|
|
88
|
+
comment: 访问ip
|
|
89
|
+
path: ip
|
|
90
|
+
type: text
|
|
91
|
+
|
|
28
92
|
- key: ffmpeg路径
|
|
29
93
|
comment: ffmpeg配置 用于音视频处理
|
|
30
|
-
path:
|
|
31
|
-
type:
|
|
94
|
+
path: ffmpeg_path
|
|
95
|
+
type: text
|
|
96
|
+
|
|
32
97
|
- key: ffprobe路径
|
|
33
98
|
comment: ffmpeg配置 用于音视频处理
|
|
34
|
-
path:
|
|
35
|
-
type:
|
|
99
|
+
path: ffprobe_path
|
|
100
|
+
type: text
|
|
101
|
+
|
|
36
102
|
- key: 主人列表
|
|
37
103
|
comment: 主人列表 主权限
|
|
38
|
-
path:
|
|
39
|
-
type:
|
|
40
|
-
arrayType:
|
|
104
|
+
path: master
|
|
105
|
+
type: array
|
|
106
|
+
arrayType: number
|
|
107
|
+
|
|
41
108
|
- key: 管理员列表
|
|
42
109
|
comment: 管理员列表 子权限
|
|
43
|
-
path:
|
|
44
|
-
type:
|
|
45
|
-
arrayType:
|
|
110
|
+
path: admin
|
|
111
|
+
type: array
|
|
112
|
+
arrayType: number
|
|
113
|
+
|
|
46
114
|
- key: 黑名单
|
|
47
115
|
comment: 黑名单相关
|
|
48
|
-
path:
|
|
49
|
-
type:
|
|
116
|
+
path: BlackList
|
|
117
|
+
type: group
|
|
50
118
|
part:
|
|
51
119
|
- key: 黑名单用户
|
|
52
|
-
path:
|
|
53
|
-
type:
|
|
54
|
-
arrayType:
|
|
120
|
+
path: BlackList.users
|
|
121
|
+
type: array
|
|
122
|
+
arrayType: number
|
|
55
123
|
associated:
|
|
56
124
|
- file: App
|
|
57
|
-
path:
|
|
125
|
+
path: BlackList.users
|
|
58
126
|
requirement: true
|
|
59
127
|
- key: 黑名单群聊
|
|
60
|
-
path:
|
|
61
|
-
type:
|
|
62
|
-
arrayType:
|
|
128
|
+
path: BlackList.groups
|
|
129
|
+
type: array
|
|
130
|
+
arrayType: number
|
|
63
131
|
associated:
|
|
64
132
|
- file: App
|
|
65
|
-
path:
|
|
133
|
+
path: BlackList.groups
|
|
66
134
|
requirement: true
|
|
67
135
|
- key: 消息日志黑名单群聊
|
|
68
136
|
comment: 设置后不会打印该群的消息日志
|
|
69
|
-
path:
|
|
70
|
-
type:
|
|
71
|
-
arrayType:
|
|
137
|
+
path: BlackList.GroupMsgLog
|
|
138
|
+
type: array
|
|
139
|
+
arrayType: number
|
|
72
140
|
associated:
|
|
73
141
|
- file: App
|
|
74
|
-
path:
|
|
142
|
+
path: BlackList.GroupMsgLog
|
|
75
143
|
requirement: true
|
|
76
144
|
- key: 白名单
|
|
77
145
|
comment: 白名单相关
|
|
78
|
-
path:
|
|
79
|
-
type:
|
|
146
|
+
path: WhiteList
|
|
147
|
+
type: group
|
|
80
148
|
part:
|
|
81
149
|
- key: 白名单用户
|
|
82
|
-
path:
|
|
83
|
-
type:
|
|
150
|
+
path: WhiteList.users
|
|
151
|
+
type: boolean
|
|
84
152
|
associated:
|
|
85
153
|
- file: App
|
|
86
|
-
path:
|
|
154
|
+
path: WhiteList.users
|
|
87
155
|
requirement: true
|
|
88
156
|
- key: 白名单群聊
|
|
89
|
-
path:
|
|
90
|
-
type:
|
|
157
|
+
path: WhiteList.groups
|
|
158
|
+
type: boolean
|
|
91
159
|
associated:
|
|
92
160
|
- file: App
|
|
93
|
-
path:
|
|
161
|
+
path: WhiteList.groups
|
|
94
162
|
requirement: true
|
|
95
163
|
- key: 消息日志白名单群聊
|
|
96
164
|
comment: 消息日志白名单群聊 设置后只会打印该群的消息日志
|
|
97
|
-
path:
|
|
98
|
-
type:
|
|
165
|
+
path: WhiteList.GroupMsgLog
|
|
166
|
+
type: boolean
|
|
99
167
|
associated:
|
|
100
168
|
- file: App
|
|
101
|
-
path:
|
|
169
|
+
path: WhiteList.GroupMsgLog
|
|
102
170
|
requirement: true
|
package/config/view/redis.yaml
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
name: 数据库配置
|
|
2
2
|
view:
|
|
3
|
-
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type: 'number'
|
|
11
|
-
-
|
|
12
|
-
key: redis用户名
|
|
3
|
+
- key: redis地址
|
|
4
|
+
path: "host"
|
|
5
|
+
type: "text"
|
|
6
|
+
- key: redis端口
|
|
7
|
+
path: "port"
|
|
8
|
+
type: "number"
|
|
9
|
+
- key: redis用户名
|
|
13
10
|
comment: redis用户名,可以为空
|
|
14
|
-
path:
|
|
15
|
-
type:
|
|
16
|
-
-
|
|
17
|
-
key: redis密码
|
|
11
|
+
path: "username"
|
|
12
|
+
type: "text"
|
|
13
|
+
- key: redis密码
|
|
18
14
|
comment: redis密码,没有密码可以为空
|
|
19
|
-
path:
|
|
20
|
-
type:
|
|
21
|
-
-
|
|
22
|
-
key: 数据库
|
|
15
|
+
path: "password"
|
|
16
|
+
type: "password"
|
|
17
|
+
- key: 数据库
|
|
23
18
|
comment: 运行中第几个redis数据库
|
|
24
|
-
path:
|
|
25
|
-
type:
|
|
19
|
+
path: "db"
|
|
20
|
+
type: "number"
|
package/config/view/server.yaml
CHANGED
|
@@ -1,93 +1,73 @@
|
|
|
1
1
|
name: 服务配置
|
|
2
2
|
view:
|
|
3
|
-
-
|
|
4
|
-
key: 热更新是否重启服务
|
|
3
|
+
- key: 热更新是否重启服务
|
|
5
4
|
comment: 当前文件热更新是否重启http、grpc服务
|
|
6
|
-
path:
|
|
7
|
-
type:
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: 'group'
|
|
5
|
+
path: "HotUpdate"
|
|
6
|
+
type: "boolean"
|
|
7
|
+
- key: http 服务器配置
|
|
8
|
+
path: "http"
|
|
9
|
+
type: "group"
|
|
12
10
|
part:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
key: grpc 服务器配置
|
|
23
|
-
path: 'grpc'
|
|
24
|
-
type: 'group'
|
|
11
|
+
- key: 监听地址
|
|
12
|
+
path: "http.host"
|
|
13
|
+
type: "text"
|
|
14
|
+
- key: 端口
|
|
15
|
+
path: "http.port"
|
|
16
|
+
type: "number"
|
|
17
|
+
- key: grpc 服务器配置
|
|
18
|
+
path: "grpc"
|
|
19
|
+
type: "group"
|
|
25
20
|
part:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key: websocket 服务器配置
|
|
37
|
-
path: 'websocket'
|
|
38
|
-
type: 'group'
|
|
21
|
+
- key: 监听地址
|
|
22
|
+
path: "grpc.host"
|
|
23
|
+
type: "text"
|
|
24
|
+
- key: Api请求超时时间
|
|
25
|
+
path: "grpc.timeout"
|
|
26
|
+
type: "number"
|
|
27
|
+
suffix: 秒
|
|
28
|
+
- key: websocket 服务器配置
|
|
29
|
+
path: "websocket"
|
|
30
|
+
type: "group"
|
|
39
31
|
part:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
arrayType: 'text'
|
|
61
|
-
-
|
|
62
|
-
key: HTTP渲染器配置
|
|
63
|
-
path: 'HttpRender'
|
|
64
|
-
type: 'group'
|
|
32
|
+
- key: API请求超时时间
|
|
33
|
+
path: "websocket.timeout"
|
|
34
|
+
type: "number"
|
|
35
|
+
suffix: 秒
|
|
36
|
+
- key: websocket 渲染器地址
|
|
37
|
+
comment: ws://127.0.0.1:7005/ws/render
|
|
38
|
+
path: "websocket.render"
|
|
39
|
+
type: "array"
|
|
40
|
+
arrayType: "text"
|
|
41
|
+
- key: onebot11 正向WebSocket地址
|
|
42
|
+
path: "websocket.OneBot11Host"
|
|
43
|
+
type: "array"
|
|
44
|
+
arrayType: "text"
|
|
45
|
+
- key: onebot12 正向WebSocket地址
|
|
46
|
+
path: "websocket.OneBot12Host"
|
|
47
|
+
type: "array"
|
|
48
|
+
arrayType: "text"
|
|
49
|
+
- key: HTTP渲染器配置
|
|
50
|
+
path: "HttpRender"
|
|
51
|
+
type: "group"
|
|
65
52
|
part:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type: 'text'
|
|
88
|
-
-
|
|
89
|
-
key: Wormhole代理地址
|
|
90
|
-
comment: 无公网IP环境的情况下使用
|
|
91
|
-
path: 'HttpRender.WormholeClient'
|
|
92
|
-
type: 'text'
|
|
93
|
-
|
|
53
|
+
- key: 是否开启http渲染
|
|
54
|
+
path: "HttpRender.enable"
|
|
55
|
+
type: "boolean"
|
|
56
|
+
- key: karin端Api地址
|
|
57
|
+
comment: 公网 > 局域网 > 127
|
|
58
|
+
path: "HttpRender.host"
|
|
59
|
+
type: "url"
|
|
60
|
+
- key: karin-puppeteer渲染器 post请求地址
|
|
61
|
+
path: "HttpRender.post"
|
|
62
|
+
type: "url"
|
|
63
|
+
- key: karin-puppeteer渲染器 post请求token
|
|
64
|
+
path: "HttpRender.token"
|
|
65
|
+
type: "text"
|
|
66
|
+
- key: 请求的非html或非有效路径的返回内容
|
|
67
|
+
comment: 可以填http地址 例如:https://ys.mihoyo.com
|
|
68
|
+
path: "HttpRender.not_found"
|
|
69
|
+
type: "text"
|
|
70
|
+
- key: Wormhole代理地址
|
|
71
|
+
comment: 无公网IP环境的情况下使用
|
|
72
|
+
path: "HttpRender.WormholeClient"
|
|
73
|
+
type: "text"
|
|
@@ -43,6 +43,22 @@ export default class EventHandler {
|
|
|
43
43
|
return false
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* 处理私聊功能 功能开启返回true
|
|
48
|
+
*/
|
|
49
|
+
private () {
|
|
50
|
+
/** 检查私聊是否开启 */
|
|
51
|
+
if (this.e.user_id !== 'input' && this.e.isPrivate && !review.Private()) {
|
|
52
|
+
/** 用户处于白名单 */
|
|
53
|
+
if (config.Config?.private?.white_list?.includes(String(this.e.user_id))) { return true }
|
|
54
|
+
/** 不处于白名单 检查是否存在提示词 */
|
|
55
|
+
if (config.Config?.private?.tips) { this.e.reply(config.Config.private.tips) }
|
|
56
|
+
logger.debug('[消息拦截] 私聊功能未开启')
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
/**
|
|
47
63
|
* 根据事件类型过滤事件
|
|
48
64
|
*/
|
|
@@ -36,6 +36,7 @@ export default class NoticeHandler extends EventHandler {
|
|
|
36
36
|
this.e.isPrivate = true
|
|
37
37
|
this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`
|
|
38
38
|
logger.bot('info', this.e.self_id, `${logger.green('私聊通知: ')}[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`)
|
|
39
|
+
if (!this.private()) { return }
|
|
39
40
|
} else if (this.e.contact.scene === 'group') {
|
|
40
41
|
this.e.isGroup = true
|
|
41
42
|
this.e.logText = `[Group:${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})]`
|
|
@@ -36,6 +36,7 @@ export default class RequestHandler extends EventHandler {
|
|
|
36
36
|
this.e.isPrivate = true
|
|
37
37
|
this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`
|
|
38
38
|
logger.bot('info', this.e.self_id, `${logger.green('私聊请求: ')}[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`)
|
|
39
|
+
if (!this.private()) { return }
|
|
39
40
|
} else if (this.e.contact.scene === 'group') {
|
|
40
41
|
this.e.isGroup = true
|
|
41
42
|
this.e.logText = `[Group:${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})]`
|
|
@@ -20,6 +20,7 @@ export declare const review: {
|
|
|
20
20
|
UserEnable: (e: KarinEventTypes) => boolean;
|
|
21
21
|
GroupMsgPrint: (e: KarinEventTypes) => boolean;
|
|
22
22
|
PluginEnable: (app: PluginApps, config: GroupCfg) => boolean;
|
|
23
|
+
Private: () => boolean;
|
|
23
24
|
main(): void;
|
|
24
25
|
/**
|
|
25
26
|
* 群聊黑白名单 允许哪个群触发事件
|
|
@@ -47,4 +48,8 @@ export declare const review: {
|
|
|
47
48
|
* 前缀、别名
|
|
48
49
|
*/
|
|
49
50
|
"__#1@#alias"(): true | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 私聊功能
|
|
53
|
+
*/
|
|
54
|
+
"__#1@#Private"(): true | undefined;
|
|
50
55
|
};
|
|
@@ -16,6 +16,7 @@ export const review = new (class Handler {
|
|
|
16
16
|
UserEnable
|
|
17
17
|
GroupMsgPrint
|
|
18
18
|
PluginEnable
|
|
19
|
+
Private
|
|
19
20
|
constructor () {
|
|
20
21
|
/** 群聊所有消息cd */
|
|
21
22
|
this.GroupCD = {}
|
|
@@ -35,6 +36,8 @@ export const review = new (class Handler {
|
|
|
35
36
|
this.GroupMsgPrint = e => true
|
|
36
37
|
/** 插件黑白名单 哪个插件可以被触发 */
|
|
37
38
|
this.PluginEnable = (app, config) => true
|
|
39
|
+
/** 私聊功能 */
|
|
40
|
+
this.Private = () => false
|
|
38
41
|
// 延迟1秒执行
|
|
39
42
|
setTimeout(() => {
|
|
40
43
|
this.main()
|
|
@@ -51,6 +54,7 @@ export const review = new (class Handler {
|
|
|
51
54
|
this.#UserEnable()
|
|
52
55
|
this.#GroupMsgPrint()
|
|
53
56
|
this.#PluginEnable()
|
|
57
|
+
this.#Private()
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -366,4 +370,17 @@ export const review = new (class Handler {
|
|
|
366
370
|
/** 未启用 */
|
|
367
371
|
this.alias = () => true
|
|
368
372
|
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 私聊功能
|
|
376
|
+
*/
|
|
377
|
+
#Private () {
|
|
378
|
+
/** 启用 */
|
|
379
|
+
if (this.App.PrivateConfig?.enable) {
|
|
380
|
+
this.Private = () => true
|
|
381
|
+
return true
|
|
382
|
+
}
|
|
383
|
+
/** 未启用 */
|
|
384
|
+
this.Private = () => false
|
|
385
|
+
}
|
|
369
386
|
})()
|
package/lib/types/config.d.ts
CHANGED
|
@@ -97,6 +97,13 @@ export interface App {
|
|
|
97
97
|
*/
|
|
98
98
|
disable: boolean;
|
|
99
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* 私聊
|
|
102
|
+
*/
|
|
103
|
+
PrivateConfig: {
|
|
104
|
+
/** 是否开启私聊 */
|
|
105
|
+
enable: boolean;
|
|
106
|
+
};
|
|
100
107
|
}
|
|
101
108
|
export interface Config {
|
|
102
109
|
/**
|
|
@@ -210,6 +217,14 @@ export interface Config {
|
|
|
210
217
|
*/
|
|
211
218
|
maxLogSize: number;
|
|
212
219
|
};
|
|
220
|
+
private: {
|
|
221
|
+
/** 是否开启私聊 */
|
|
222
|
+
enable: boolean;
|
|
223
|
+
/** 关闭私聊后回复的提示词 为空则不回复 */
|
|
224
|
+
tips: string;
|
|
225
|
+
/** 关闭私聊后的用户白名单 */
|
|
226
|
+
white_list: string[];
|
|
227
|
+
};
|
|
213
228
|
}
|
|
214
229
|
export interface Server {
|
|
215
230
|
/**
|
package/lib/utils/config.js
CHANGED
|
@@ -181,6 +181,10 @@ export const config = new (class Cfg {
|
|
|
181
181
|
},
|
|
182
182
|
master: data.master.map((i) => String(i)),
|
|
183
183
|
admin: data.admin.map((i) => String(i)),
|
|
184
|
+
private: {
|
|
185
|
+
white_list: data.private.white_list.map((i) => String(i)),
|
|
186
|
+
tips: data.private.tips,
|
|
187
|
+
},
|
|
184
188
|
}
|
|
185
189
|
/** 缓存 */
|
|
186
190
|
this.change.set(key, Config)
|