node-karin 0.12.13 → 0.12.15
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/lib/adapter/input/index.d.ts +1 -1
- package/lib/adapter/input/index.js +1 -1
- package/lib/adapter/onebot/11/event.js +90 -84
- package/lib/adapter/onebot/11/index.d.ts +89 -127
- package/lib/adapter/onebot/11/index.js +192 -254
- package/lib/cli/index.js +2 -2
- package/lib/core/init/config.js +1 -1
- package/lib/core/karin/karin.d.ts +21 -30
- package/lib/core/karin/karin.js +7 -9
- package/lib/core/listener/listener.js +11 -11
- package/lib/core/plugin/base.d.ts +7 -21
- package/lib/core/plugin/base.js +2 -6
- package/lib/core/plugin/loader.d.ts +5 -15
- package/lib/core/plugin/loader.js +5 -15
- package/lib/core/server/server.js +4 -4
- package/lib/event/handler/base.d.ts +1 -3
- package/lib/event/handler/base.js +1 -3
- package/lib/event/handler/message.js +9 -3
- package/lib/event/handler/notice.js +38 -32
- package/lib/event/handler/request.js +6 -6
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/modules.d.ts +2 -2
- package/lib/modules.js +3 -2
- package/lib/types/adapter/accept.d.ts +24 -0
- package/lib/types/adapter/accept.js +1 -0
- package/lib/types/adapter/api.d.ts +88 -264
- package/lib/types/adapter/base.d.ts +3 -3
- package/lib/types/config/config.d.ts +4 -12
- package/lib/types/element/element.d.ts +119 -349
- package/lib/types/element/qqbot.d.ts +4 -12
- package/lib/types/event/contact.d.ts +6 -12
- package/lib/types/event/event.d.ts +59 -163
- package/lib/types/event/message.d.ts +11 -31
- package/lib/types/event/message.js +10 -12
- package/lib/types/event/notice.d.ts +118 -325
- package/lib/types/event/notice.js +8 -10
- package/lib/types/event/request.d.ts +29 -66
- package/lib/types/event/request.js +8 -10
- package/lib/types/event/sender.d.ts +7 -21
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/onebot11/api.d.ts +49 -49
- package/lib/types/onebot11/event.d.ts +131 -347
- package/lib/types/onebot11/params.d.ts +184 -456
- package/lib/types/onebot11/response.d.ts +159 -381
- package/lib/types/onebot11/segment.d.ts +25 -75
- package/lib/types/onebot11/sender.d.ts +13 -39
- package/lib/types/plugin/app.d.ts +7 -11
- package/lib/types/plugin/plugin.d.ts +55 -165
- package/lib/types/render/render.d.ts +16 -48
- package/lib/utils/common/common.js +4 -2
- package/lib/utils/config/config.js +1 -1
- package/lib/utils/core/logger.js +3 -3
- package/lib/utils/core/segment.d.ts +28 -59
- package/lib/utils/core/segment.js +26 -30
- package/lib/utils/tools/restart.d.ts +3 -3
- package/lib/utils/tools/restart.js +5 -5
- package/package.json +1 -2
|
@@ -1,95 +1,61 @@
|
|
|
1
1
|
import { KarinEventType, BaseEventDataType, EventType, RequestSubType } from './event.js';
|
|
2
|
-
/**
|
|
3
|
-
* - 好友申请
|
|
4
|
-
*/
|
|
2
|
+
/** 好友申请 */
|
|
5
3
|
export interface PrivateApplyType {
|
|
6
|
-
/**
|
|
7
|
-
* - 申请者uid
|
|
8
|
-
*/
|
|
4
|
+
/** 申请者uid */
|
|
9
5
|
applier_uid: string;
|
|
10
|
-
/**
|
|
11
|
-
* - 申请者uin
|
|
12
|
-
*/
|
|
6
|
+
/** 申请者uin */
|
|
13
7
|
applier_uin: string;
|
|
14
|
-
/**
|
|
15
|
-
* - 申请理由
|
|
16
|
-
*/
|
|
8
|
+
/** 申请理由 */
|
|
17
9
|
message: string;
|
|
10
|
+
/** 请求 flag,在调用处理请求的 API 时需要传入 */
|
|
11
|
+
flag: string;
|
|
18
12
|
}
|
|
19
|
-
/**
|
|
20
|
-
* - 群申请
|
|
21
|
-
*/
|
|
13
|
+
/** 群申请 */
|
|
22
14
|
export interface GroupApply {
|
|
23
|
-
/**
|
|
24
|
-
* - 群ID
|
|
25
|
-
*/
|
|
15
|
+
/** 群ID */
|
|
26
16
|
group_id: string;
|
|
27
|
-
/**
|
|
28
|
-
* - 申请者uid
|
|
29
|
-
*/
|
|
17
|
+
/** 申请者uid */
|
|
30
18
|
applier_uid: string;
|
|
31
|
-
/**
|
|
32
|
-
* - 申请者uin
|
|
33
|
-
*/
|
|
19
|
+
/** 申请者uin */
|
|
34
20
|
applier_uin: string;
|
|
35
|
-
/**
|
|
36
|
-
* - 邀请者uid
|
|
37
|
-
*/
|
|
21
|
+
/** 邀请者uid */
|
|
38
22
|
inviter_uid: string;
|
|
39
|
-
/**
|
|
40
|
-
* - 邀请者uin
|
|
41
|
-
*/
|
|
23
|
+
/** 邀请者uin */
|
|
42
24
|
inviter_uin: string;
|
|
43
|
-
/**
|
|
44
|
-
* - 申请理由
|
|
45
|
-
*/
|
|
25
|
+
/** 申请理由 */
|
|
46
26
|
reason: string;
|
|
27
|
+
/** 请求 flag,在调用处理请求的 API 时需要传入 */
|
|
28
|
+
flag: string;
|
|
47
29
|
}
|
|
48
|
-
/**
|
|
49
|
-
* - 邀请入群
|
|
50
|
-
*/
|
|
30
|
+
/** 邀请入群 */
|
|
51
31
|
export interface GroupInvite {
|
|
52
|
-
/**
|
|
53
|
-
* - 群ID
|
|
54
|
-
*/
|
|
32
|
+
/** 群ID */
|
|
55
33
|
group_id: string;
|
|
56
|
-
/**
|
|
57
|
-
* - 邀请者uid
|
|
58
|
-
*/
|
|
34
|
+
/** 邀请者uid */
|
|
59
35
|
inviter_uid: string;
|
|
60
|
-
/**
|
|
61
|
-
* - 邀请者uin
|
|
62
|
-
*/
|
|
36
|
+
/** 邀请者uin */
|
|
63
37
|
inviter_uin: string;
|
|
38
|
+
/** 请求 flag,在调用处理请求的 API 时需要传入 */
|
|
39
|
+
flag: string;
|
|
64
40
|
}
|
|
65
|
-
/**
|
|
66
|
-
* - 通知事件子类型
|
|
67
|
-
*/
|
|
41
|
+
/** 通知事件子类型 */
|
|
68
42
|
export interface RequestType {
|
|
69
43
|
[RequestSubType.PrivateApply]: PrivateApplyType;
|
|
70
44
|
[RequestSubType.GroupApply]: GroupApply;
|
|
71
45
|
[RequestSubType.InvitedGroup]: GroupInvite;
|
|
72
46
|
}
|
|
73
|
-
/**
|
|
74
|
-
* - 请求事件基类
|
|
75
|
-
*/
|
|
47
|
+
/** 请求事件基类 */
|
|
76
48
|
export interface KarinRequestEventBase extends KarinEventType {
|
|
77
49
|
event: EventType.Request;
|
|
78
50
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
type RequestEvent<T extends RequestSubType> = KarinRequestEventBase & {
|
|
51
|
+
/** 辅助类型,用于生成 KarinRequestEvent 的联合类型来自动推导content的类型 */
|
|
52
|
+
export type RequestEvent<T extends RequestSubType> = KarinRequestEventBase & {
|
|
83
53
|
sub_event: T;
|
|
84
54
|
content: RequestType[T];
|
|
85
55
|
};
|
|
86
|
-
/**
|
|
87
|
-
* - 请求事件定义
|
|
88
|
-
*/
|
|
56
|
+
/** 请求事件定义 */
|
|
89
57
|
export type KarinRequestType = RequestEvent<RequestSubType.GroupApply> | RequestEvent<RequestSubType.InvitedGroup> | RequestEvent<RequestSubType.PrivateApply>;
|
|
90
|
-
/**
|
|
91
|
-
* - 创建一个请求事件
|
|
92
|
-
*/
|
|
58
|
+
/** 创建一个请求事件 */
|
|
93
59
|
export declare class KarinRequest implements KarinRequestEventBase {
|
|
94
60
|
self_id: KarinRequestType['self_id'];
|
|
95
61
|
user_id: KarinRequestType['user_id'];
|
|
@@ -115,12 +81,9 @@ export declare class KarinRequest implements KarinRequestEventBase {
|
|
|
115
81
|
bot: KarinRequestType['bot'];
|
|
116
82
|
content: RequestType[RequestSubType];
|
|
117
83
|
raw_event: KarinRequestType['raw_event'];
|
|
118
|
-
constructor({ self_id, user_id, group_id, time, contact, sender, sub_event, event_id, content, raw_event, }: BaseEventDataType & {
|
|
84
|
+
constructor({ self_id: selfId, user_id: userId, group_id: groupId, time, contact, sender, sub_event: subEvent, event_id: eventId, content, raw_event: rawEvent, }: BaseEventDataType & {
|
|
119
85
|
sub_event: KarinRequestType['sub_event'];
|
|
120
|
-
/**
|
|
121
|
-
* - 事件对应的内容参数
|
|
122
|
-
*/
|
|
86
|
+
/** 事件对应的内容参数 */
|
|
123
87
|
content: KarinRequestType['content'];
|
|
124
88
|
});
|
|
125
89
|
}
|
|
126
|
-
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - 创建一个请求事件
|
|
3
|
-
*/
|
|
1
|
+
/** 创建一个请求事件 */
|
|
4
2
|
export class KarinRequest {
|
|
5
3
|
self_id;
|
|
6
4
|
user_id;
|
|
@@ -26,17 +24,17 @@ export class KarinRequest {
|
|
|
26
24
|
bot;
|
|
27
25
|
content;
|
|
28
26
|
raw_event;
|
|
29
|
-
constructor({ self_id, user_id, group_id = '', time, contact, sender, sub_event, event_id, content, raw_event, }) {
|
|
30
|
-
this.raw_event =
|
|
31
|
-
this.self_id =
|
|
32
|
-
this.user_id =
|
|
33
|
-
this.group_id = contact.scene === 'group' ? (contact.peer ||
|
|
27
|
+
constructor({ self_id: selfId, user_id: userId, group_id: groupId = '', time, contact, sender, sub_event: subEvent, event_id: eventId, content, raw_event: rawEvent, }) {
|
|
28
|
+
this.raw_event = rawEvent;
|
|
29
|
+
this.self_id = selfId;
|
|
30
|
+
this.user_id = userId;
|
|
31
|
+
this.group_id = contact.scene === 'group' ? (contact.peer || groupId) : groupId;
|
|
34
32
|
this.time = time;
|
|
35
33
|
this.event = "request" /* EventType.Request */;
|
|
36
|
-
this.event_id =
|
|
34
|
+
this.event_id = eventId;
|
|
37
35
|
this.contact = contact;
|
|
38
36
|
this.sender = sender;
|
|
39
|
-
this.sub_event =
|
|
37
|
+
this.sub_event = subEvent;
|
|
40
38
|
this.content = content;
|
|
41
39
|
this.isMaster = false;
|
|
42
40
|
this.isAdmin = false;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - 群身份枚举 值不存在时为unknown
|
|
3
|
-
*/
|
|
1
|
+
/** 群身份枚举 值不存在时为unknown */
|
|
4
2
|
export declare const enum Role {
|
|
5
3
|
Owner = "owner",
|
|
6
4
|
Admin = "admin",
|
|
7
5
|
Member = "member",
|
|
8
6
|
Unknown = "unknown"
|
|
9
7
|
}
|
|
10
|
-
/**
|
|
11
|
-
* - 权限类型枚举
|
|
12
|
-
*/
|
|
8
|
+
/** 权限类型枚举 */
|
|
13
9
|
export declare const enum Permission {
|
|
14
10
|
All = "all",
|
|
15
11
|
Master = "master",
|
|
@@ -17,24 +13,14 @@ export declare const enum Permission {
|
|
|
17
13
|
GroupOwner = "group.owner",
|
|
18
14
|
GroupAdmin = "group.admin"
|
|
19
15
|
}
|
|
20
|
-
/**
|
|
21
|
-
* - 事件发送者信息
|
|
22
|
-
*/
|
|
16
|
+
/** 事件发送者信息 */
|
|
23
17
|
export interface Sender {
|
|
24
|
-
/**
|
|
25
|
-
* - 发送者uid
|
|
26
|
-
*/
|
|
18
|
+
/** 发送者uid */
|
|
27
19
|
uid: string;
|
|
28
|
-
/**
|
|
29
|
-
* - 发送者uin
|
|
30
|
-
*/
|
|
20
|
+
/** 发送者uin */
|
|
31
21
|
uin: string;
|
|
32
|
-
/**
|
|
33
|
-
* - 发送者昵称
|
|
34
|
-
*/
|
|
22
|
+
/** 发送者昵称 */
|
|
35
23
|
nick: string | '';
|
|
36
|
-
/**
|
|
37
|
-
* - 发送者在群的角色身份
|
|
38
|
-
*/
|
|
24
|
+
/** 发送者在群的角色身份 */
|
|
39
25
|
role: Role;
|
|
40
26
|
}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* OneBot11公开Api
|
|
3
3
|
*/
|
|
4
4
|
export declare const enum OB11Api {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
5
|
+
sendPrivateMsg = "send_private_msg",
|
|
6
|
+
sendGroupMsg = "send_group_msg",
|
|
7
|
+
sendMsg = "send_msg",
|
|
8
|
+
deleteMsg = "delete_msg",
|
|
9
|
+
getMsg = "get_msg",
|
|
10
|
+
getForwardMsg = "get_forward_msg",
|
|
11
|
+
sendLike = "send_like",
|
|
12
|
+
setGroupKick = "set_group_kick",
|
|
13
|
+
setGroupBan = "set_group_ban",
|
|
14
|
+
setGroupAnonymousBan = "set_group_anonymous_ban",
|
|
15
|
+
setGroupWholeBan = "set_group_whole_ban",
|
|
16
|
+
setGroupAdmin = "set_group_admin",
|
|
17
|
+
setGroupAnonymous = "set_group_anonymous",
|
|
18
|
+
setGroupCard = "set_group_card",
|
|
19
|
+
setGroupName = "set_group_name",
|
|
20
|
+
setGroupLeave = "set_group_leave",
|
|
21
|
+
setGroupSpecialTitle = "set_group_special_title",
|
|
22
|
+
setFriendAddRequest = "set_friend_add_request",
|
|
23
|
+
setGroupAddRequest = "set_group_add_request",
|
|
24
|
+
getLoginInfo = "get_login_info",
|
|
25
|
+
getStrangerInfo = "get_stranger_info",
|
|
26
|
+
getFriendList = "get_friend_list",
|
|
27
|
+
getGroupInfo = "get_group_info",
|
|
28
|
+
getGroupList = "get_group_list",
|
|
29
|
+
getGroupMemberInfo = "get_group_member_info",
|
|
30
|
+
getGroupMemberList = "get_group_member_list",
|
|
31
|
+
getGroupHonorInfo = "get_group_honor_info",
|
|
32
|
+
getCookies = "get_cookies",
|
|
33
|
+
getCsrfToken = "get_csrf_token",
|
|
34
|
+
getCredentials = "get_credentials",
|
|
35
|
+
getRecord = "get_record",
|
|
36
|
+
getImage = "get_image",
|
|
37
|
+
canSendImage = "can_send_image",
|
|
38
|
+
canSendRecord = "can_send_record",
|
|
39
|
+
getStatus = "get_status",
|
|
40
|
+
getVersionInfo = "get_version_info",
|
|
41
|
+
setRestart = "set_restart",
|
|
42
|
+
cleanCache = "clean_cache",
|
|
43
|
+
getVersion = "get_version",
|
|
44
|
+
sendForwardMsg = "send_forward_msg",
|
|
45
|
+
getFriendMsgHistory = "get_friend_msg_history",
|
|
46
|
+
getGroupMsgHistory = "get_group_msg_history",
|
|
47
|
+
setMsgEmojiLike = "set_msg_emoji_like",
|
|
48
|
+
uploadGroupFile = "upload_group_file",
|
|
49
|
+
uploadPrivateFile = "upload_private_file",
|
|
50
|
+
getEssenceMsgList = "get_essence_msg_list",
|
|
51
|
+
setEssenceMsg = "set_essence_msg",
|
|
52
|
+
deleteEssenceMsg = "delete_essence_msg"
|
|
53
53
|
}
|