node-karin 0.6.2 → 0.6.4

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
@@ -75,7 +75,7 @@ export class AdapterInput {
75
75
  },
76
76
  elements: [{ type: 'text', text: elements }],
77
77
  contact: {
78
- scene: 'private',
78
+ scene: 'friend',
79
79
  peer: 'input',
80
80
  sub_peer: '',
81
81
  },
@@ -124,7 +124,7 @@ export class KritorGrpc {
124
124
  const uid = data.operator_uid;
125
125
  const uin = data.operator_uin;
126
126
  const contact = {
127
- scene: 'private',
127
+ scene: 'friend',
128
128
  peer: uid,
129
129
  sub_peer: '',
130
130
  };
@@ -162,7 +162,7 @@ export class KritorGrpc {
162
162
  const uid = data.operator_uid;
163
163
  const uin = data.operator_uin;
164
164
  const contact = {
165
- scene: 'private',
165
+ scene: 'friend',
166
166
  peer: uid,
167
167
  sub_peer: '',
168
168
  };
@@ -196,7 +196,7 @@ export class KritorGrpc {
196
196
  const uid = data.operator_uid;
197
197
  const uin = data.operator_uin;
198
198
  const contact = {
199
- scene: 'private',
199
+ scene: 'friend',
200
200
  peer: uid,
201
201
  sub_peer: '',
202
202
  };
@@ -772,7 +772,7 @@ export class KritorGrpc {
772
772
  /** scene映射表 */
773
773
  const sceneMap = {
774
774
  [kritor.common.Scene.GROUP]: 'group',
775
- [kritor.common.Scene.FRIEND]: 'private',
775
+ [kritor.common.Scene.FRIEND]: 'friend',
776
776
  [kritor.common.Scene.GUILD]: 'guild',
777
777
  [kritor.common.Scene.NEARBY]: 'nearby',
778
778
  [kritor.common.Scene.STRANGER]: 'stranger',
@@ -786,7 +786,7 @@ export class KritorGrpc {
786
786
  };
787
787
  /*
788
788
  0=群聊 1=私聊 2=频道 5=附近的人 6=陌生人 10=群临时会话
789
- 0=group 1=private 2=guild 5=nearby 6=stranger 10=stranger_from_group
789
+ 0=group 1=friend 2=guild 5=nearby 6=stranger 10=stranger_from_group
790
790
  */
791
791
  const scene = sceneMap[contact.scene];
792
792
  const role = roleMap[sender.role];
@@ -112,7 +112,6 @@ export declare class AdapterOneBot11 implements KarinAdapter {
112
112
  * 获取消息
113
113
  * @param _contact - ob11无需提供contact参数
114
114
  * @param message_id - 消息ID
115
- * @returns {Promise<object>} - 消息内容
116
115
  */
117
116
  GetMessage(_contact: contact, message_id: string): Promise<any>;
118
117
  /**
@@ -188,7 +188,7 @@ export class AdapterOneBot11 {
188
188
  },
189
189
  elements: this.AdapterConvertKarin(data.message),
190
190
  contact: {
191
- scene: (data.message_type === 'private' ? 'private' : 'group'),
191
+ scene: (data.message_type === 'private' ? 'friend' : 'group'),
192
192
  peer: data.message_type === 'private' ? data.sender.user_id : data.group_id,
193
193
  sub_peer: '',
194
194
  },
@@ -237,7 +237,7 @@ export class AdapterOneBot11 {
237
237
  role: '',
238
238
  };
239
239
  const contact = {
240
- scene: ('group_id' in data ? 'group' : 'private'),
240
+ scene: ('group_id' in data ? 'group' : 'friend'),
241
241
  peer: 'group_id' in data ? data.group_id : data.user_id,
242
242
  sub_peer: '',
243
243
  };
@@ -478,7 +478,7 @@ export class AdapterOneBot11 {
478
478
  user_id: data.user_id + '',
479
479
  time: data.time,
480
480
  contact: {
481
- scene: 'private',
481
+ scene: 'friend',
482
482
  peer: data.user_id + '',
483
483
  sub_peer: '',
484
484
  },
@@ -811,7 +811,6 @@ export class AdapterOneBot11 {
811
811
  * 获取消息
812
812
  * @param _contact - ob11无需提供contact参数
813
813
  * @param message_id - 消息ID
814
- * @returns {Promise<object>} - 消息内容
815
814
  */
816
815
  async GetMessage(_contact, message_id) {
817
816
  let res = await this.SendApi('get_msg', { message_id });
@@ -820,7 +819,7 @@ export class AdapterOneBot11 {
820
819
  message_id: res.message_id,
821
820
  message_seq: res.message_id,
822
821
  contact: {
823
- scene: res.message_type === 'group' ? 'group' : 'private',
822
+ scene: res.message_type === 'group' ? 'group' : 'friend',
824
823
  peer: res.sender.user_id, // 拿不到group_id...
825
824
  },
826
825
  sender: {
@@ -1,5 +1,5 @@
1
1
  import { KarinMessage } from '../event/message.js';
2
- import { Permission, PluginApps, KarinElement } from '../types/index.js';
2
+ import { Permission, PluginApps, KarinElement, contact, KarinRenderType } from '../types/index.js';
3
3
  type FncFunction = (e: KarinMessage) => Promise<boolean>;
4
4
  type FncElement = string | KarinElement | Array<KarinElement>;
5
5
  export interface OptionsCommand {
@@ -107,5 +107,17 @@ export declare class Karin {
107
107
  */
108
108
  priority?: number;
109
109
  }): PluginApps;
110
+ /**
111
+ * 构建contact
112
+ * @param peer - 群号或者id
113
+ * @param isGroup - 是否是群聊
114
+ * @param sub_peer - 子id
115
+ */
116
+ contact(peer: string, isGroup?: boolean, sub_peer?: string): contact;
117
+ /**
118
+ * - 渲染
119
+ * @param options - 渲染参数
120
+ */
121
+ render(options: KarinRenderType): Promise<string | string[]>;
110
122
  }
111
123
  export {};
package/lib/core/karin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import PluginApp from './plugin.app.js'
2
2
  import { common } from '../utils/index.js'
3
+ import { render } from '../render/index.js'
3
4
  export class Karin {
4
5
  /**
5
6
  * - 快速构建命令
@@ -99,4 +100,33 @@ export class Karin {
99
100
  }
100
101
  return PluginApp(data)
101
102
  }
103
+
104
+ /**
105
+ * 构建contact
106
+ * @param peer - 群号或者id
107
+ * @param isGroup - 是否是群聊
108
+ * @param sub_peer - 子id
109
+ */
110
+ contact (peer, isGroup = true, sub_peer) {
111
+ if (isGroup) {
112
+ return {
113
+ scene: 'group',
114
+ peer,
115
+ sub_peer: sub_peer || '',
116
+ }
117
+ }
118
+ return {
119
+ scene: 'friend',
120
+ peer,
121
+ sub_peer: sub_peer || '',
122
+ }
123
+ }
124
+
125
+ /**
126
+ * - 渲染
127
+ * @param options - 渲染参数
128
+ */
129
+ render (options) {
130
+ return render.render(options)
131
+ }
102
132
  }
@@ -198,7 +198,7 @@ export class MessageHandler extends EventHandler {
198
198
  /** 管理员 */
199
199
  this.e.isAdmin = true
200
200
  }
201
- if (this.e.contact.scene === 'private') {
201
+ if (this.e.contact.scene === 'friend') {
202
202
  this.e.isPrivate = true
203
203
  this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`
204
204
  logger.bot('info', this.e.self_id, `私聊:[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`)
@@ -32,7 +32,7 @@ export default class NoticeHandler extends EventHandler {
32
32
  /** 管理员 */
33
33
  this.e.isAdmin = true
34
34
  }
35
- if (this.e.contact.scene === 'private') {
35
+ if (this.e.contact.scene === 'friend') {
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}`)
@@ -32,7 +32,7 @@ export default class RequestHandler extends EventHandler {
32
32
  /** 管理员 */
33
33
  this.e.isAdmin = true
34
34
  }
35
- if (this.e.contact.scene === 'private') {
35
+ if (this.e.contact.scene === 'friend') {
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}`)
@@ -8,7 +8,7 @@ export type Event = 'message' | 'notice' | 'request' | 'meta_event' | 'message_s
8
8
  /**
9
9
  * - 事件来源
10
10
  */
11
- export type Scene = 'group' | 'private' | 'guild' | 'nearby' | 'stranger' | 'stranger_from_group';
11
+ export type Scene = 'group' | 'friend' | 'guild' | 'nearby' | 'stranger' | 'stranger_from_group';
12
12
  /**
13
13
  * - 类型映射
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",