@mrlingxd/koishi-plugin-adapter-onebot 0.1.0 → 0.2.1
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/bot/cqcode.d.ts +204 -5
- package/lib/bot/cqcode.js +1 -1
- package/lib/bot/index.d.ts +35 -19
- package/lib/bot/index.js +89 -53
- package/lib/bot/message.d.ts +4 -4
- package/lib/bot/message.js +58 -57
- package/lib/http.d.ts +5 -6
- package/lib/http.js +5 -7
- package/lib/index.d.ts +12 -8
- package/lib/index.js +2 -3
- package/lib/internal.d.ts +132 -0
- package/lib/{types.js → internal.js} +6 -57
- package/lib/types/device.d.ts +8 -0
- package/lib/types/device.js +1 -0
- package/lib/types/enum.d.ts +65 -0
- package/lib/types/enum.js +70 -0
- package/lib/types/event/base.d.ts +26 -0
- package/lib/types/event/base.js +20 -0
- package/lib/types/event/message.d.ts +44 -0
- package/lib/types/event/message.js +11 -0
- package/lib/types/event/meta.d.ts +34 -0
- package/lib/types/event/meta.js +1 -0
- package/lib/types/event/notice.d.ts +256 -0
- package/lib/types/event/notice.js +40 -0
- package/lib/types/event/request.d.ts +30 -0
- package/lib/types/event/request.js +11 -0
- package/lib/types/group.d.ts +43 -0
- package/lib/types/group.js +1 -0
- package/lib/types/index.d.ts +334 -0
- package/lib/types/index.js +10 -0
- package/lib/types/sender.d.ts +43 -0
- package/lib/types/sender.js +10 -0
- package/lib/types/user.d.ts +16 -0
- package/lib/types/user.js +1 -0
- package/lib/utils.d.ts +15 -11
- package/lib/utils.js +209 -201
- package/lib/ws.d.ts +9 -10
- package/lib/ws.js +2 -4
- package/package.json +4 -7
- package/lib/bot/base.d.ts +0 -36
- package/lib/bot/base.js +0 -66
- package/lib/bot/qqguild.d.ts +0 -31
- package/lib/bot/qqguild.js +0 -66
- package/lib/types.d.ts +0 -474
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
/** 消息子类型 */
|
|
3
|
+
export declare enum SubType {
|
|
4
|
+
/** 好友 */
|
|
5
|
+
Friend = "friend",
|
|
6
|
+
/** 群聊 */
|
|
7
|
+
Normal = "normal",
|
|
8
|
+
/** 匿名 */
|
|
9
|
+
Anonymous = "anonymous",
|
|
10
|
+
/** 群中自身发送 */
|
|
11
|
+
GroupSelf = "group_self",
|
|
12
|
+
/** 群临时会话 */
|
|
13
|
+
Group = "group",
|
|
14
|
+
/** 系统提示 */
|
|
15
|
+
Notice = "notice"
|
|
16
|
+
}
|
|
17
|
+
/** 基础事件 */
|
|
18
|
+
export interface BaseEvent<T extends EventType> {
|
|
19
|
+
/** 事件发生的时间戳 */
|
|
20
|
+
time: number;
|
|
21
|
+
/** 收到事件的机器人 QQ 号 */
|
|
22
|
+
self_id: number;
|
|
23
|
+
/** 上报类型 */
|
|
24
|
+
post_type: T;
|
|
25
|
+
}
|
|
26
|
+
export declare function isBaseEvent(event: any): event is BaseEvent<EventType>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** 消息子类型 */
|
|
2
|
+
export var SubType;
|
|
3
|
+
(function (SubType) {
|
|
4
|
+
/** 好友 */
|
|
5
|
+
SubType["Friend"] = "friend";
|
|
6
|
+
/** 群聊 */
|
|
7
|
+
SubType["Normal"] = "normal";
|
|
8
|
+
/** 匿名 */
|
|
9
|
+
SubType["Anonymous"] = "anonymous";
|
|
10
|
+
/** 群中自身发送 */
|
|
11
|
+
SubType["GroupSelf"] = "group_self";
|
|
12
|
+
/** 群临时会话 */
|
|
13
|
+
SubType["Group"] = "group";
|
|
14
|
+
/** 系统提示 */
|
|
15
|
+
SubType["Notice"] = "notice";
|
|
16
|
+
})(SubType || (SubType = {}));
|
|
17
|
+
// 类型守卫
|
|
18
|
+
export function isBaseEvent(event) {
|
|
19
|
+
return event && typeof event === "object" && "post_type" in event && "time" in event && "self_id" in event;
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CQCode } from "../../bot/cqcode";
|
|
2
|
+
import { EventType } from "../enum";
|
|
3
|
+
import { Anonymous, GroupSender, Sender } from "../sender";
|
|
4
|
+
import { BaseEvent, SubType } from "./base";
|
|
5
|
+
/** 消息事件接口 */
|
|
6
|
+
interface BaseMessageEvent<S extends Sender | GroupSender, M extends "private" | "group"> extends BaseEvent<EventType.MESSAGE | EventType.MESSAGE_SENT> {
|
|
7
|
+
/** 消息类型 */
|
|
8
|
+
message_type: M;
|
|
9
|
+
/** 消息子类型 */
|
|
10
|
+
sub_type: SubType;
|
|
11
|
+
/** 消息 ID */
|
|
12
|
+
message_id: number;
|
|
13
|
+
/** 发送者 QQ 号 */
|
|
14
|
+
user_id: number;
|
|
15
|
+
/** 消息内容 */
|
|
16
|
+
message: string | CQCode[];
|
|
17
|
+
/** 原始消息内容 */
|
|
18
|
+
raw_message: string;
|
|
19
|
+
/** 字体 */
|
|
20
|
+
font: number;
|
|
21
|
+
/** 发送人信息 */
|
|
22
|
+
sender: S;
|
|
23
|
+
/** 更多字段 */
|
|
24
|
+
[property: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare function isMessageEvent(event: BaseEvent<EventType>): event is MessageEvent;
|
|
27
|
+
export declare function isPrivateMessageEvent(event: BaseEvent<EventType>): event is PrivateMessageEvent;
|
|
28
|
+
export declare function isGroupMessageEvent(event: BaseEvent<EventType>): event is GroupMessageEvent;
|
|
29
|
+
/** 私聊消息事件 */
|
|
30
|
+
export interface PrivateMessageEvent extends BaseMessageEvent<Sender, "private"> {
|
|
31
|
+
/** 更多字段 */
|
|
32
|
+
[property: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** 群消息事件 */
|
|
35
|
+
export interface GroupMessageEvent extends BaseMessageEvent<GroupSender, "group"> {
|
|
36
|
+
/** 群号 */
|
|
37
|
+
group_id: number;
|
|
38
|
+
/** 匿名信息 */
|
|
39
|
+
anonymous?: Anonymous;
|
|
40
|
+
/** 更多字段 */
|
|
41
|
+
[property: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export type MessageEvent = PrivateMessageEvent | GroupMessageEvent;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
// 类型守卫
|
|
3
|
+
export function isMessageEvent(event) {
|
|
4
|
+
return event.post_type === EventType.MESSAGE || event.post_type === EventType.MESSAGE_SENT;
|
|
5
|
+
}
|
|
6
|
+
export function isPrivateMessageEvent(event) {
|
|
7
|
+
return isMessageEvent(event) && event.message_type === "private";
|
|
8
|
+
}
|
|
9
|
+
export function isGroupMessageEvent(event) {
|
|
10
|
+
return isMessageEvent(event) && event.message_type === "group";
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
import { BaseEvent } from "./base";
|
|
3
|
+
/** 元事件 */
|
|
4
|
+
interface MetaEvent<meta_event_type extends "lifecycle" | "heartbeat"> extends BaseEvent<EventType.META> {
|
|
5
|
+
/** 元事件类型 */
|
|
6
|
+
meta_event_type: meta_event_type;
|
|
7
|
+
}
|
|
8
|
+
/** 心跳包 */
|
|
9
|
+
export interface HeartbeatMetaEvent extends MetaEvent<"heartbeat"> {
|
|
10
|
+
/** 心跳状态 */
|
|
11
|
+
status: {
|
|
12
|
+
/**
|
|
13
|
+
* 当前 QQ 在线
|
|
14
|
+
*
|
|
15
|
+
* undefined 表示无法查询到在线状态
|
|
16
|
+
*/
|
|
17
|
+
online?: boolean;
|
|
18
|
+
/** 状态符合预期,意味着各模块正常运行、功能正常,且 QQ 在线 */
|
|
19
|
+
good: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** 距离上一次心跳包的时间(单位是毫秒) */
|
|
22
|
+
interval: number;
|
|
23
|
+
}
|
|
24
|
+
/** 生命周期 */
|
|
25
|
+
export interface LifecycleMetaEvent extends MetaEvent<"lifecycle"> {
|
|
26
|
+
/** 子类型
|
|
27
|
+
*
|
|
28
|
+
* - enable: 启用
|
|
29
|
+
* - disable: 禁用
|
|
30
|
+
* - connect: 连接成功
|
|
31
|
+
*/
|
|
32
|
+
sub_type: "enable" | "disable" | "connect";
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Device } from "../device";
|
|
2
|
+
import { EventType } from "../enum";
|
|
3
|
+
import { BaseEvent } from "./base";
|
|
4
|
+
/**
|
|
5
|
+
* 通知事件类型
|
|
6
|
+
*/
|
|
7
|
+
export declare enum NoticeType {
|
|
8
|
+
/** 群文件上传事件 */
|
|
9
|
+
GROUP_UPLOAD = "group_upload",
|
|
10
|
+
/** 群管理员变动事件*/
|
|
11
|
+
GROUP_ADMIN = "group_admin",
|
|
12
|
+
/** 群成员减少事件 */
|
|
13
|
+
GROUP_DECREASE = "group_decrease",
|
|
14
|
+
/** 群成员增加事件 */
|
|
15
|
+
GROUP_INCREASE = "group_increase",
|
|
16
|
+
/** 群禁言事件 */
|
|
17
|
+
GROUP_BAN = "group_ban",
|
|
18
|
+
/** 群消息撤回事件 */
|
|
19
|
+
GROUP_RECALL = "group_recall",
|
|
20
|
+
/** 好友添加事件 */
|
|
21
|
+
FRIEND_ADD = "friend_add",
|
|
22
|
+
/** 好友消息撤回事件 */
|
|
23
|
+
FRIEND_RECALL = "friend_recall",
|
|
24
|
+
/** 特殊通知事件 */
|
|
25
|
+
NOTIFY = "notify",
|
|
26
|
+
/** 群名片变更(go-cqhttp 扩展事件) */
|
|
27
|
+
GROUP_CARD = "group_card",
|
|
28
|
+
/** 接收到离线文件(go-cqhttp 扩展事件) */
|
|
29
|
+
OFFLINE_FILE = "offline_file",
|
|
30
|
+
/** 其他客户端在线状态变更(go-cqhttp 扩展事件) */
|
|
31
|
+
CLIENT_STATUS = "client_status",
|
|
32
|
+
/** 精华消息变更(go-cqhttp 扩展事件)*/
|
|
33
|
+
GROUP_ESSENCE = "essence"
|
|
34
|
+
}
|
|
35
|
+
/** 通知事件 */
|
|
36
|
+
interface NoticeEvent<notice_type extends NoticeType> extends BaseEvent<EventType.NOTICE> {
|
|
37
|
+
/** 通知类型 */
|
|
38
|
+
notice_type: notice_type;
|
|
39
|
+
}
|
|
40
|
+
export declare function isNoticeEvent(event: BaseEvent<EventType>): event is AllNoticeEvents;
|
|
41
|
+
/** 群文件信息 */
|
|
42
|
+
export interface GroupUploadFile {
|
|
43
|
+
/** 文件 ID */
|
|
44
|
+
id: string;
|
|
45
|
+
/** 文件名 */
|
|
46
|
+
name: string;
|
|
47
|
+
/** 文件大小,单位字节 */
|
|
48
|
+
size: number;
|
|
49
|
+
/** 业务ID */
|
|
50
|
+
busid: number;
|
|
51
|
+
}
|
|
52
|
+
/** 群文件上传 */
|
|
53
|
+
export interface GroupUploadNotice extends NoticeEvent<NoticeType.GROUP_UPLOAD> {
|
|
54
|
+
/** 群号 */
|
|
55
|
+
group_id: number;
|
|
56
|
+
/** 发送者 QQ 号 */
|
|
57
|
+
user_id: number;
|
|
58
|
+
}
|
|
59
|
+
/** 群管理员变动 */
|
|
60
|
+
export interface GroupAdminNotice extends NoticeEvent<NoticeType.GROUP_ADMIN> {
|
|
61
|
+
/**
|
|
62
|
+
* 事件子类型
|
|
63
|
+
*
|
|
64
|
+
* - set: 设置管理员
|
|
65
|
+
* - unset: 取消管理员
|
|
66
|
+
*/
|
|
67
|
+
sub_type: "set" | "unset";
|
|
68
|
+
/** 群号 */
|
|
69
|
+
group_id: number;
|
|
70
|
+
/** 管理员 QQ 号 */
|
|
71
|
+
user_id: number;
|
|
72
|
+
}
|
|
73
|
+
/** 群成员减少 */
|
|
74
|
+
export interface GroupDecreaseNotice extends NoticeEvent<NoticeType.GROUP_DECREASE> {
|
|
75
|
+
/**
|
|
76
|
+
* 事件子类型
|
|
77
|
+
*
|
|
78
|
+
* - leave: 主动退群
|
|
79
|
+
* - kick: 成员被踢
|
|
80
|
+
* - kick_me: 登录号被踢
|
|
81
|
+
*/
|
|
82
|
+
sub_type: "leave" | "kick" | "kick_me";
|
|
83
|
+
/** 群号 */
|
|
84
|
+
group_id: number;
|
|
85
|
+
/**
|
|
86
|
+
* 操作者 QQ 号
|
|
87
|
+
*
|
|
88
|
+
* 对于主动退群的成员,该字段为操作者本人 QQ 号
|
|
89
|
+
*/
|
|
90
|
+
operator_id: number;
|
|
91
|
+
/** 离开者 QQ 号 */
|
|
92
|
+
user_id: number;
|
|
93
|
+
}
|
|
94
|
+
/** 群成员增加 */
|
|
95
|
+
export interface GroupIncreaseNotice extends NoticeEvent<NoticeType.GROUP_INCREASE> {
|
|
96
|
+
/**
|
|
97
|
+
* 事件子类型
|
|
98
|
+
*
|
|
99
|
+
* - approve: 管理员同意入群
|
|
100
|
+
* - invite: 成员邀请入群
|
|
101
|
+
*/
|
|
102
|
+
sub_type: "approve" | "invite";
|
|
103
|
+
/** 群号 */
|
|
104
|
+
group_id: number;
|
|
105
|
+
/** 操作者 QQ 号 */
|
|
106
|
+
operator_id: number;
|
|
107
|
+
/** 加入者 QQ 号 */
|
|
108
|
+
user_id: number;
|
|
109
|
+
}
|
|
110
|
+
/** 群禁言 */
|
|
111
|
+
export interface GroupBanNotice extends NoticeEvent<NoticeType.GROUP_BAN> {
|
|
112
|
+
/**
|
|
113
|
+
* 事件子类型
|
|
114
|
+
*
|
|
115
|
+
* - ban: 禁言
|
|
116
|
+
* - lift_ban: 解除禁言
|
|
117
|
+
* */
|
|
118
|
+
sub_type: "ban" | "lift_ban";
|
|
119
|
+
/** 群号 */
|
|
120
|
+
group_id: number;
|
|
121
|
+
/** 操作者 QQ 号 */
|
|
122
|
+
operator_id: number;
|
|
123
|
+
/** 被禁言 QQ 号,0 代表全员禁言 */
|
|
124
|
+
user_id: number;
|
|
125
|
+
/** 禁言时长,单位秒(全员禁言为时为-1) */
|
|
126
|
+
duration: number;
|
|
127
|
+
}
|
|
128
|
+
/** 群消息撤回 */
|
|
129
|
+
export interface GroupRecallNotice extends NoticeEvent<NoticeType.GROUP_RECALL> {
|
|
130
|
+
/** 群号 */
|
|
131
|
+
group_id: number;
|
|
132
|
+
/** 消息发送者 QQ 号 */
|
|
133
|
+
user_id: number;
|
|
134
|
+
/** 操作者 QQ 号 */
|
|
135
|
+
operator_id: number;
|
|
136
|
+
/** 被撤回的消息 ID */
|
|
137
|
+
message_id: number;
|
|
138
|
+
}
|
|
139
|
+
/** 戳一戳 */
|
|
140
|
+
export interface NotifyPokeNotice extends NoticeEvent<NoticeType.NOTIFY> {
|
|
141
|
+
/** 提示类型 */
|
|
142
|
+
sub_type: "poke";
|
|
143
|
+
/** 发送者 QQ 号 */
|
|
144
|
+
user_id: number;
|
|
145
|
+
/** 被戳者 QQ 号 */
|
|
146
|
+
target_id: number;
|
|
147
|
+
}
|
|
148
|
+
export declare function isGroupPokeNotice(event: NoticeEvent<NoticeType.NOTIFY>): event is NotifyGroupPokeNotice;
|
|
149
|
+
/** 群内戳一戳 */
|
|
150
|
+
export interface NotifyGroupPokeNotice extends NotifyPokeNotice {
|
|
151
|
+
/** 群号 */
|
|
152
|
+
group_id: number;
|
|
153
|
+
}
|
|
154
|
+
/** 群红包运气王 */
|
|
155
|
+
export interface NotifyLuckyKingNotice extends NoticeEvent<NoticeType.NOTIFY> {
|
|
156
|
+
/** 提示类型 */
|
|
157
|
+
sub_type: "lucky_king";
|
|
158
|
+
/** 群号 */
|
|
159
|
+
group_id: number;
|
|
160
|
+
/** 红包发送者 QQ 号 */
|
|
161
|
+
user_id: number;
|
|
162
|
+
/** 运气王 QQ 号 */
|
|
163
|
+
target_id: number;
|
|
164
|
+
}
|
|
165
|
+
/** 群成员荣誉变更 */
|
|
166
|
+
export interface NotifyHonorNotice extends NoticeEvent<NoticeType.NOTIFY> {
|
|
167
|
+
/** 提示类型 */
|
|
168
|
+
sub_type: "honor";
|
|
169
|
+
/** 群号 */
|
|
170
|
+
group_id: number;
|
|
171
|
+
/**
|
|
172
|
+
* 荣誉类型
|
|
173
|
+
*
|
|
174
|
+
* - talkative: 龙王
|
|
175
|
+
* - performer: 群聊之火
|
|
176
|
+
* - emotion: 快乐源泉
|
|
177
|
+
*/
|
|
178
|
+
honor_type: "talkative" | "performer" | "emotion";
|
|
179
|
+
/** 成员 QQ 号 */
|
|
180
|
+
user_id: number;
|
|
181
|
+
}
|
|
182
|
+
/** 群成员头衔变更(go-cqhttp 扩展事件) */
|
|
183
|
+
export interface NotifyTitleNotice extends NoticeEvent<NoticeType.NOTIFY> {
|
|
184
|
+
/** 提示类型 */
|
|
185
|
+
sub_type: "title";
|
|
186
|
+
/** 群号 */
|
|
187
|
+
group_id: number;
|
|
188
|
+
/** 变更头衔的用户 QQ 号 */
|
|
189
|
+
user_id: number;
|
|
190
|
+
/** 变更后的头衔 */
|
|
191
|
+
title: string;
|
|
192
|
+
}
|
|
193
|
+
/** 好友添加 */
|
|
194
|
+
export interface FriendAddNotice extends NoticeEvent<NoticeType.FRIEND_ADD> {
|
|
195
|
+
/** 新添加好友 QQ 号 */
|
|
196
|
+
user_id: number;
|
|
197
|
+
}
|
|
198
|
+
/** 好友消息撤回 */
|
|
199
|
+
export interface FriendRecallNotice extends NoticeEvent<NoticeType.FRIEND_RECALL> {
|
|
200
|
+
/** 好友 QQ 号 */
|
|
201
|
+
user_id: number;
|
|
202
|
+
/** 被撤回的消息 ID */
|
|
203
|
+
message_id: number;
|
|
204
|
+
}
|
|
205
|
+
/** 群名片变更(go-cqhttp 扩展事件) */
|
|
206
|
+
export interface GroupCardNotice extends NoticeEvent<NoticeType.GROUP_CARD> {
|
|
207
|
+
/** 群号 */
|
|
208
|
+
group_id: number;
|
|
209
|
+
/** 成员 QQ 号 */
|
|
210
|
+
user_id: number;
|
|
211
|
+
/** 变更后的群名片 */
|
|
212
|
+
card_new: string;
|
|
213
|
+
/** 变更前的群名片 */
|
|
214
|
+
card_old: string;
|
|
215
|
+
}
|
|
216
|
+
/** 接收到离线文件(go-cqhttp 扩展事件) */
|
|
217
|
+
export interface OfflineFileNotice extends NoticeEvent<NoticeType.OFFLINE_FILE> {
|
|
218
|
+
/** 发送者 QQ 号 */
|
|
219
|
+
user_id: number;
|
|
220
|
+
/** 文件数据 */
|
|
221
|
+
file: {
|
|
222
|
+
/** 文件名 */
|
|
223
|
+
name: string;
|
|
224
|
+
/** 文件大小,单位字节 */
|
|
225
|
+
size: number;
|
|
226
|
+
/** 文件下载 URL */
|
|
227
|
+
url: string;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/** 其他客户端在线状态变更(go-cqhttp 扩展事件) */
|
|
231
|
+
export interface ClientStatusNotice extends NoticeEvent<NoticeType.CLIENT_STATUS> {
|
|
232
|
+
/** 客户端信息 */
|
|
233
|
+
client: Device;
|
|
234
|
+
/** 当前是否在线 */
|
|
235
|
+
online: boolean;
|
|
236
|
+
}
|
|
237
|
+
/** 精华消息变更(go-cqhttp 扩展事件)*/
|
|
238
|
+
export interface GroupEssenceNotice extends NoticeEvent<NoticeType.GROUP_ESSENCE> {
|
|
239
|
+
/**
|
|
240
|
+
* 事件子类型
|
|
241
|
+
*
|
|
242
|
+
* - add: 添加精华消息
|
|
243
|
+
* - delete: 删除精华消息
|
|
244
|
+
*/
|
|
245
|
+
sub_type: "add" | "delete";
|
|
246
|
+
/** 群号 */
|
|
247
|
+
group_id: number;
|
|
248
|
+
/** 消息发送者 ID */
|
|
249
|
+
sender_id: number;
|
|
250
|
+
/** 操作者 QQ 号 */
|
|
251
|
+
operator_id: number;
|
|
252
|
+
/** 消息 ID */
|
|
253
|
+
message_id: number;
|
|
254
|
+
}
|
|
255
|
+
export type AllNoticeEvents = GroupUploadNotice | GroupAdminNotice | GroupDecreaseNotice | GroupIncreaseNotice | GroupBanNotice | GroupRecallNotice | NotifyPokeNotice | NotifyGroupPokeNotice | NotifyLuckyKingNotice | NotifyHonorNotice | NotifyTitleNotice | FriendAddNotice | FriendRecallNotice | GroupCardNotice | OfflineFileNotice | ClientStatusNotice | GroupEssenceNotice;
|
|
256
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
/**
|
|
3
|
+
* 通知事件类型
|
|
4
|
+
*/
|
|
5
|
+
export var NoticeType;
|
|
6
|
+
(function (NoticeType) {
|
|
7
|
+
/** 群文件上传事件 */
|
|
8
|
+
NoticeType["GROUP_UPLOAD"] = "group_upload";
|
|
9
|
+
/** 群管理员变动事件*/
|
|
10
|
+
NoticeType["GROUP_ADMIN"] = "group_admin";
|
|
11
|
+
/** 群成员减少事件 */
|
|
12
|
+
NoticeType["GROUP_DECREASE"] = "group_decrease";
|
|
13
|
+
/** 群成员增加事件 */
|
|
14
|
+
NoticeType["GROUP_INCREASE"] = "group_increase";
|
|
15
|
+
/** 群禁言事件 */
|
|
16
|
+
NoticeType["GROUP_BAN"] = "group_ban";
|
|
17
|
+
/** 群消息撤回事件 */
|
|
18
|
+
NoticeType["GROUP_RECALL"] = "group_recall";
|
|
19
|
+
/** 好友添加事件 */
|
|
20
|
+
NoticeType["FRIEND_ADD"] = "friend_add";
|
|
21
|
+
/** 好友消息撤回事件 */
|
|
22
|
+
NoticeType["FRIEND_RECALL"] = "friend_recall";
|
|
23
|
+
/** 特殊通知事件 */
|
|
24
|
+
NoticeType["NOTIFY"] = "notify";
|
|
25
|
+
/** 群名片变更(go-cqhttp 扩展事件) */
|
|
26
|
+
NoticeType["GROUP_CARD"] = "group_card";
|
|
27
|
+
/** 接收到离线文件(go-cqhttp 扩展事件) */
|
|
28
|
+
NoticeType["OFFLINE_FILE"] = "offline_file";
|
|
29
|
+
/** 其他客户端在线状态变更(go-cqhttp 扩展事件) */
|
|
30
|
+
NoticeType["CLIENT_STATUS"] = "client_status";
|
|
31
|
+
/** 精华消息变更(go-cqhttp 扩展事件)*/
|
|
32
|
+
NoticeType["GROUP_ESSENCE"] = "essence";
|
|
33
|
+
})(NoticeType || (NoticeType = {}));
|
|
34
|
+
// 类型守卫
|
|
35
|
+
export function isNoticeEvent(event) {
|
|
36
|
+
return event.post_type === EventType.NOTICE;
|
|
37
|
+
}
|
|
38
|
+
export function isGroupPokeNotice(event) {
|
|
39
|
+
return event.group_id !== undefined;
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
import { BaseEvent } from "./base";
|
|
3
|
+
/** 请求事件 */
|
|
4
|
+
export interface RequestEvent<request_type extends "friend" | "group"> extends BaseEvent<EventType.REQUEST> {
|
|
5
|
+
/** 请求类型 */
|
|
6
|
+
request_type: request_type;
|
|
7
|
+
/** 发送者 QQ 号 */
|
|
8
|
+
user_id: number;
|
|
9
|
+
/** 验证信息 */
|
|
10
|
+
comment: string;
|
|
11
|
+
/** 请求标识符 */
|
|
12
|
+
flag: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function isRequestEvent(event: BaseEvent<EventType>): event is RequestEvent<"friend" | "group">;
|
|
15
|
+
export declare function isFriendRequest(event: BaseEvent<EventType>): event is FriendRequest;
|
|
16
|
+
export declare function isGroupRequest(event: BaseEvent<EventType>): event is GroupRequest;
|
|
17
|
+
/** 加好友请求 */
|
|
18
|
+
export interface FriendRequest extends RequestEvent<"friend"> {
|
|
19
|
+
}
|
|
20
|
+
/** 加群请求/邀请 */
|
|
21
|
+
export interface GroupRequest extends RequestEvent<"group"> {
|
|
22
|
+
/** 事件子类型
|
|
23
|
+
*
|
|
24
|
+
* - add: 加群请求
|
|
25
|
+
* - invite: 邀请登录号入群
|
|
26
|
+
*/
|
|
27
|
+
sub_type: "add" | "invite";
|
|
28
|
+
/** 群号 */
|
|
29
|
+
group_id: number;
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventType } from "../enum";
|
|
2
|
+
// 类型守卫
|
|
3
|
+
export function isRequestEvent(event) {
|
|
4
|
+
return event.post_type === EventType.REQUEST;
|
|
5
|
+
}
|
|
6
|
+
export function isFriendRequest(event) {
|
|
7
|
+
return isRequestEvent(event) && event.request_type === "friend";
|
|
8
|
+
}
|
|
9
|
+
export function isGroupRequest(event) {
|
|
10
|
+
return isRequestEvent(event) && event.request_type === "group";
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { GroupMemberRole } from "./enum";
|
|
2
|
+
import { UserInfo } from "./user";
|
|
3
|
+
export interface GroupInfo {
|
|
4
|
+
/** 群号 */
|
|
5
|
+
group_id: number;
|
|
6
|
+
/** 群名称 */
|
|
7
|
+
group_name: string;
|
|
8
|
+
/** 成员数量 */
|
|
9
|
+
member_count: number;
|
|
10
|
+
/** 最大成员数量 */
|
|
11
|
+
max_member_count: number;
|
|
12
|
+
/** 更多字段 */
|
|
13
|
+
[property: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 群成员信息
|
|
17
|
+
*/
|
|
18
|
+
export interface GroupMemberInfo extends UserInfo {
|
|
19
|
+
/** 群号 */
|
|
20
|
+
group_id: number;
|
|
21
|
+
/** 群名片/备注 */
|
|
22
|
+
card?: string;
|
|
23
|
+
/** 地区 */
|
|
24
|
+
area?: string;
|
|
25
|
+
/** 加群时间戳 */
|
|
26
|
+
join_time: number;
|
|
27
|
+
/** 最后发言时间戳 */
|
|
28
|
+
last_sent_time: number;
|
|
29
|
+
/** 成员等级 */
|
|
30
|
+
level: number;
|
|
31
|
+
/** 角色 */
|
|
32
|
+
role: GroupMemberRole;
|
|
33
|
+
/** 是否不良记录成员 */
|
|
34
|
+
unfriendly?: boolean;
|
|
35
|
+
/** 专属头衔 */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** 专属头衔过期时间戳(0 表示永不过期) */
|
|
38
|
+
title_expire_time?: number;
|
|
39
|
+
/** 是否允许修改群名片 */
|
|
40
|
+
card_changeable?: boolean;
|
|
41
|
+
/** 更多字段 */
|
|
42
|
+
[property: string]: unknown;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|