@polyv/chat 2.1.0-rc-20251023.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/index.cjs.js +19 -0
- package/index.es.d.ts +1934 -0
- package/index.es.js +7060 -0
- package/index.umd.js +19 -0
- package/package.json +9 -0
package/index.es.d.ts
ADDED
|
@@ -0,0 +1,1934 @@
|
|
|
1
|
+
import { DataExportRecordData } from '@polyv/vue-components';
|
|
2
|
+
import { EmotionParser } from '@polyv/emotion-sdk';
|
|
3
|
+
import { EventEmitter } from '@polyv/utils/es/event';
|
|
4
|
+
import { PolyvSocket } from '@polyv/socket';
|
|
5
|
+
import { SocketUserType } from '@polyv/socket';
|
|
6
|
+
|
|
7
|
+
export declare interface AttendanceData extends ChatMessageUser {
|
|
8
|
+
/**
|
|
9
|
+
* 排序号
|
|
10
|
+
*/
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare interface AttendanceListResult {
|
|
15
|
+
/**
|
|
16
|
+
* 列表
|
|
17
|
+
*/
|
|
18
|
+
list: AttendanceData[];
|
|
19
|
+
/**
|
|
20
|
+
* 总数
|
|
21
|
+
*/
|
|
22
|
+
total: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare interface BanIpOptions {
|
|
26
|
+
/** ip */
|
|
27
|
+
ip: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 被封禁的 ip 数据 */
|
|
31
|
+
export declare interface BannedIpData {
|
|
32
|
+
/** ip 地址 */
|
|
33
|
+
clientIp: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare interface BannedUserData {
|
|
37
|
+
/** 用户 id */
|
|
38
|
+
userId: string;
|
|
39
|
+
/** 昵称 */
|
|
40
|
+
nick: string;
|
|
41
|
+
/** ip 地址 */
|
|
42
|
+
clientIp: string;
|
|
43
|
+
/** 是否被平台封禁 */
|
|
44
|
+
platformProhibited: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare interface BannedUserListOptions {
|
|
48
|
+
/** 关键词 */
|
|
49
|
+
keyword?: string;
|
|
50
|
+
/** 页数 */
|
|
51
|
+
pageNumber?: number;
|
|
52
|
+
/** 每页数量 */
|
|
53
|
+
pageSize?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export declare interface BanUserOptions {
|
|
57
|
+
/** 用户 id */
|
|
58
|
+
userId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare interface CancelTopMsgOptions {
|
|
62
|
+
/** 置顶 id */
|
|
63
|
+
id: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 支持回复的消息来源 */
|
|
67
|
+
export declare const canQuoteMsgSource: readonly [ChatMsgSource.Speak, ChatMsgSource.Image, ChatMsgSource.File, ChatMsgSource.Redpaper, ChatMsgSource.CustomServer, ChatMsgSource.Emotion];
|
|
68
|
+
|
|
69
|
+
/** 支持置顶的消息来源 */
|
|
70
|
+
export declare const canTopMsgSource: readonly [ChatMsgSource.Speak];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 频道消息特效设置
|
|
74
|
+
*/
|
|
75
|
+
export declare interface ChannelEffectSetting {
|
|
76
|
+
/** 访问特效开关 */
|
|
77
|
+
visitEffectEnabled: boolean;
|
|
78
|
+
/** 用户访问直播间 */
|
|
79
|
+
joinVisitEffectTip: string;
|
|
80
|
+
/** 购买转化特效开关 */
|
|
81
|
+
productEffectEnabled: boolean;
|
|
82
|
+
/** 用户点击商品-普通商品 */
|
|
83
|
+
clickOrdinaryProductEffectTip: string;
|
|
84
|
+
/** 用户点击商品-金融商品 */
|
|
85
|
+
clickFinancialProductEffectTip: string;
|
|
86
|
+
/** 用户点击商品-职位商品 */
|
|
87
|
+
clickJobProductEffectTip: string;
|
|
88
|
+
/** 用户下单商品-普通商品 */
|
|
89
|
+
orderProductEffectTip: string;
|
|
90
|
+
/** 参与互动特效开关 */
|
|
91
|
+
interactionEffectEnabled: boolean;
|
|
92
|
+
/** 用户签到成功 */
|
|
93
|
+
checkinInteractionEffectTip: string;
|
|
94
|
+
/** 用户打赏成功特效 */
|
|
95
|
+
donateInteractionEffectTip: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export declare interface ChatDefaultResource {
|
|
99
|
+
/**
|
|
100
|
+
* 观众默认头像
|
|
101
|
+
*/
|
|
102
|
+
defaultViewerAvatar: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 聊天室消息中的用户信息
|
|
107
|
+
*/
|
|
108
|
+
export declare interface ChatMessageUser<T extends SocketUserType = SocketUserType> {
|
|
109
|
+
/**
|
|
110
|
+
* 用户 id
|
|
111
|
+
* @description 系统消息或自定义消息中的 userId 固定为 system
|
|
112
|
+
*/
|
|
113
|
+
userId: string;
|
|
114
|
+
/**
|
|
115
|
+
* 昵称
|
|
116
|
+
*/
|
|
117
|
+
nick: string;
|
|
118
|
+
/**
|
|
119
|
+
* 头像
|
|
120
|
+
*/
|
|
121
|
+
pic?: string;
|
|
122
|
+
/**
|
|
123
|
+
* 身份
|
|
124
|
+
*/
|
|
125
|
+
userType: T;
|
|
126
|
+
/**
|
|
127
|
+
* 头衔
|
|
128
|
+
*/
|
|
129
|
+
actor?: string;
|
|
130
|
+
/**
|
|
131
|
+
* 是否被禁言
|
|
132
|
+
*/
|
|
133
|
+
banned?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 用户 ip
|
|
136
|
+
*/
|
|
137
|
+
clientIp?: string;
|
|
138
|
+
/**
|
|
139
|
+
* 标签
|
|
140
|
+
*/
|
|
141
|
+
label?: {
|
|
142
|
+
/** 提问区标签 */
|
|
143
|
+
question: string[];
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class ChatModuleBase {
|
|
148
|
+
protected _plvChat: PolyvChat;
|
|
149
|
+
constructor(_plvChat: PolyvChat);
|
|
150
|
+
protected get _plvSocket(): PolyvSocket;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 聊天室消息公用基础类型
|
|
155
|
+
*/
|
|
156
|
+
export declare interface ChatMsgCommonBasicType<S extends ChatMsgSource> {
|
|
157
|
+
/** 消息唯一标识 */
|
|
158
|
+
id: string;
|
|
159
|
+
/** 消息来源 */
|
|
160
|
+
msgSource: S;
|
|
161
|
+
/** 消息时间 */
|
|
162
|
+
time: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 聊天室消息公用类型
|
|
167
|
+
*/
|
|
168
|
+
export declare interface ChatMsgCommonType<S extends ChatMsgSource> extends ChatMsgCommonBasicType<S> {
|
|
169
|
+
/** 用户信息 */
|
|
170
|
+
user: ChatMessageUser;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 聊天室消息类型 - 自定义消息(客户端)
|
|
175
|
+
* @source {@link ChatMsgSource.CustomClient}
|
|
176
|
+
*/
|
|
177
|
+
export declare interface ChatMsgCustomClientType<D extends object = object> extends ChatMsgCommonType<ChatMsgSource.CustomClient>, CustomClientMsgData<D> {
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 聊天室消息类型 - 自定义消息(服务端)
|
|
182
|
+
* @source {@link ChatMsgSource.CustomServer}
|
|
183
|
+
*/
|
|
184
|
+
export declare interface ChatMsgCustomServerType extends ChatMsgCommonType<ChatMsgSource.CustomServer> {
|
|
185
|
+
/**
|
|
186
|
+
* 消息内容
|
|
187
|
+
*/
|
|
188
|
+
content: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 聊天室消息类型 - 特效消息
|
|
193
|
+
* @source {@link ChatMsgSource.Effect}
|
|
194
|
+
*/
|
|
195
|
+
export declare interface ChatMsgEffectType extends ChatMsgCommonBasicType<ChatMsgSource.Effect> {
|
|
196
|
+
data: unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 聊天室消息类型 - 表情
|
|
201
|
+
* @source {@link ChatMsgSource.Emotion}
|
|
202
|
+
*/
|
|
203
|
+
export declare interface ChatMsgEmotionType extends ChatMsgCommonType<ChatMsgSource.Emotion>, ChatMsgSendStatus {
|
|
204
|
+
/**
|
|
205
|
+
* 表情 id
|
|
206
|
+
*/
|
|
207
|
+
emotionId: string;
|
|
208
|
+
/**
|
|
209
|
+
* 表情图片地址
|
|
210
|
+
*/
|
|
211
|
+
emotionUrl: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 聊天室消息类型 - 文件分享
|
|
216
|
+
* @source {@link ChatMsgSource.File}
|
|
217
|
+
*/
|
|
218
|
+
export declare interface ChatMsgFileType extends ChatMsgCommonType<ChatMsgSource.File> {
|
|
219
|
+
/**
|
|
220
|
+
* 文件下载地址
|
|
221
|
+
*/
|
|
222
|
+
fileUrl: string;
|
|
223
|
+
/**
|
|
224
|
+
* 文件名称
|
|
225
|
+
*/
|
|
226
|
+
fileName: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 聊天室消息类型 - 图片
|
|
231
|
+
* @source {@link ChatMsgSource.Image}
|
|
232
|
+
*/
|
|
233
|
+
export declare interface ChatMsgImageType extends ChatMsgCommonType<ChatMsgSource.Image>, ChatMsgSendStatus {
|
|
234
|
+
/**
|
|
235
|
+
* 图片 id
|
|
236
|
+
*/
|
|
237
|
+
imageId: string;
|
|
238
|
+
/**
|
|
239
|
+
* 图片地址
|
|
240
|
+
*/
|
|
241
|
+
imageUrl: string;
|
|
242
|
+
/**
|
|
243
|
+
* 图片尺寸
|
|
244
|
+
*/
|
|
245
|
+
size?: {
|
|
246
|
+
width: number;
|
|
247
|
+
height: number;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* 本地发送消息的图片地址
|
|
251
|
+
*/
|
|
252
|
+
localImageUrl?: string;
|
|
253
|
+
/**
|
|
254
|
+
* 是否违规
|
|
255
|
+
*/
|
|
256
|
+
isIllegal?: boolean;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 课堂激励点赞数据
|
|
261
|
+
*/
|
|
262
|
+
export declare interface ChatMsgMotivationLikeData {
|
|
263
|
+
/**
|
|
264
|
+
* 激励者Id
|
|
265
|
+
*/
|
|
266
|
+
motivatorId: string;
|
|
267
|
+
/**
|
|
268
|
+
* 激励者昵称
|
|
269
|
+
*/
|
|
270
|
+
motivatorNick: string;
|
|
271
|
+
/**
|
|
272
|
+
* 被激励者Id
|
|
273
|
+
*/
|
|
274
|
+
motivatedId: string;
|
|
275
|
+
/**
|
|
276
|
+
* 被激励者昵称
|
|
277
|
+
*/
|
|
278
|
+
motivatedNick: string;
|
|
279
|
+
/**
|
|
280
|
+
* 激励点赞类型来源
|
|
281
|
+
*/
|
|
282
|
+
type: MotivationLikeType;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 聊天室消息类型 - 课堂激励点赞消息
|
|
287
|
+
* @source {@link ChatMsgSource.MotivationLike}
|
|
288
|
+
*/
|
|
289
|
+
export declare interface ChatMsgMotivationLikeType extends ChatMsgMotivationLikeData, ChatMsgCommonBasicType<ChatMsgSource.MotivationLike> {
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 聊天室红包数据类型
|
|
294
|
+
*/
|
|
295
|
+
export declare interface ChatMsgRedpaperData {
|
|
296
|
+
/** 红包数量 */
|
|
297
|
+
number: number;
|
|
298
|
+
/** 祝福语 */
|
|
299
|
+
content: string;
|
|
300
|
+
/** 红包类型 */
|
|
301
|
+
type: RedpackType;
|
|
302
|
+
/** 红包缓存 id */
|
|
303
|
+
redCacheId: string;
|
|
304
|
+
/** 红包 id */
|
|
305
|
+
redpackId: string;
|
|
306
|
+
/** 红包总金额 */
|
|
307
|
+
totalAmount?: number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* 聊天室消息类型 - 红包领取
|
|
312
|
+
* @source {@link ChatMsgSource.RedpaperReceive}
|
|
313
|
+
*/
|
|
314
|
+
export declare interface ChatMsgRedpaperReceiveType extends ChatMsgCommonBasicType<ChatMsgSource.RedpaperReceive> {
|
|
315
|
+
/**
|
|
316
|
+
* 领取用户的昵称
|
|
317
|
+
*/
|
|
318
|
+
nick: string;
|
|
319
|
+
/**
|
|
320
|
+
* 红包类型
|
|
321
|
+
*/
|
|
322
|
+
type: RedpackType;
|
|
323
|
+
/**
|
|
324
|
+
* 是否已领取完毕
|
|
325
|
+
*/
|
|
326
|
+
isOver: boolean;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 聊天室消息类型 - 红包
|
|
331
|
+
* @source {@link ChatMsgSource.Redpaper}
|
|
332
|
+
*/
|
|
333
|
+
export declare interface ChatMsgRedpaperType extends ChatMsgCommonType<ChatMsgSource.Redpaper>, ChatMsgRedpaperData {
|
|
334
|
+
/**
|
|
335
|
+
* 红包的用户标签 id
|
|
336
|
+
*/
|
|
337
|
+
userLabels?: number[];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 聊天室消息类型 - 打赏
|
|
342
|
+
* @source {@link ChatMsgSource.Reward}
|
|
343
|
+
*/
|
|
344
|
+
export declare interface ChatMsgRewardType extends ChatMsgCommonType<ChatMsgSource.Reward> {
|
|
345
|
+
/**
|
|
346
|
+
* 打赏礼物图片
|
|
347
|
+
*/
|
|
348
|
+
gimg: string;
|
|
349
|
+
/**
|
|
350
|
+
* 打赏数量
|
|
351
|
+
*/
|
|
352
|
+
goodNum: number;
|
|
353
|
+
/**
|
|
354
|
+
* 打赏类型
|
|
355
|
+
*/
|
|
356
|
+
donateType: DonateType;
|
|
357
|
+
/**
|
|
358
|
+
* 打赏道具名称或现金打赏金额
|
|
359
|
+
*/
|
|
360
|
+
rewardContent: string;
|
|
361
|
+
/**
|
|
362
|
+
* 是否自己的打赏
|
|
363
|
+
*/
|
|
364
|
+
isSelf: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* 聊天室消息发送状态类型
|
|
369
|
+
*/
|
|
370
|
+
export declare interface ChatMsgSendStatus {
|
|
371
|
+
/**
|
|
372
|
+
* 是否本地发送的消息
|
|
373
|
+
*/
|
|
374
|
+
isLocal?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* 是否已经发送完成
|
|
377
|
+
* */
|
|
378
|
+
isSended?: boolean;
|
|
379
|
+
/**
|
|
380
|
+
* 是否发送失败
|
|
381
|
+
*/
|
|
382
|
+
isSendFailed?: boolean;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 聊天消息来源
|
|
387
|
+
*
|
|
388
|
+
* 通过聊天室消息事件 `ChatEvents.ChatMessage`、聊天历史记录 Api `getChatHistory` 等获取的聊天消息类型均为 ChatMsgSource 类型
|
|
389
|
+
* 所有消息数据都有对应的消息来源 `msgSource` 字段,该字段为 `ChatMsgSource` 枚举,开发者可根据该字段显示相应的消息样式。
|
|
390
|
+
*/
|
|
391
|
+
export declare enum ChatMsgSource {
|
|
392
|
+
/**
|
|
393
|
+
* 发言消息
|
|
394
|
+
* @service ✓
|
|
395
|
+
*/
|
|
396
|
+
Speak = "speak",
|
|
397
|
+
/**
|
|
398
|
+
* 图片消息
|
|
399
|
+
* @service ✓
|
|
400
|
+
*/
|
|
401
|
+
Image = "image",
|
|
402
|
+
/**
|
|
403
|
+
* 表情图片消息
|
|
404
|
+
* @service ✓
|
|
405
|
+
*/
|
|
406
|
+
Emotion = "emotion",
|
|
407
|
+
/**
|
|
408
|
+
* 打赏消息
|
|
409
|
+
* @service ✓
|
|
410
|
+
*/
|
|
411
|
+
Reward = "reward",
|
|
412
|
+
/**
|
|
413
|
+
* 文件分享消息
|
|
414
|
+
* @service ✓
|
|
415
|
+
*/
|
|
416
|
+
File = "file",
|
|
417
|
+
/**
|
|
418
|
+
* 红包消息
|
|
419
|
+
* @service ✓
|
|
420
|
+
*/
|
|
421
|
+
Redpaper = "redpaper",
|
|
422
|
+
/**
|
|
423
|
+
* 红包领取消息
|
|
424
|
+
* @service ×
|
|
425
|
+
*/
|
|
426
|
+
RedpaperReceive = "redpaperReceive",
|
|
427
|
+
/**
|
|
428
|
+
* 自定义消息(服务端)
|
|
429
|
+
* @service ✓
|
|
430
|
+
*/
|
|
431
|
+
CustomServer = "customServer",
|
|
432
|
+
/**
|
|
433
|
+
* 自定义消息(客户端)
|
|
434
|
+
* @service ✓
|
|
435
|
+
*/
|
|
436
|
+
CustomClient = "customClient",
|
|
437
|
+
/**
|
|
438
|
+
* 系统消息
|
|
439
|
+
* @service ×
|
|
440
|
+
*/
|
|
441
|
+
System = "system",
|
|
442
|
+
/**
|
|
443
|
+
* 课堂激励点赞消息
|
|
444
|
+
* @service ×
|
|
445
|
+
*/
|
|
446
|
+
MotivationLike = "motivationLike",
|
|
447
|
+
/**
|
|
448
|
+
* 消息特效
|
|
449
|
+
* @service ×
|
|
450
|
+
*/
|
|
451
|
+
Effect = "effect"
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** 支持回复的消息来源 */
|
|
455
|
+
export declare type ChatMsgSourceByQuote = typeof canQuoteMsgSource[number];
|
|
456
|
+
|
|
457
|
+
/** 支持置顶的消息来源 */
|
|
458
|
+
export declare type ChatMsgSourceByTop = typeof canTopMsgSource[number];
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* 聊天室消息类型 - 发言
|
|
462
|
+
* @source {@link ChatMsgSource.Speak}
|
|
463
|
+
*/
|
|
464
|
+
export declare interface ChatMsgSpeakType extends ChatMsgCommonType<ChatMsgSource.Speak>, ChatMsgSendStatus {
|
|
465
|
+
/**
|
|
466
|
+
* 发言内容
|
|
467
|
+
*/
|
|
468
|
+
content: string;
|
|
469
|
+
/**
|
|
470
|
+
* 回复内容
|
|
471
|
+
*/
|
|
472
|
+
quote?: ChatMsgTypeByQuote;
|
|
473
|
+
/**
|
|
474
|
+
* 是否超长文本
|
|
475
|
+
* */
|
|
476
|
+
isOverLength?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* 当前翻译的语言
|
|
479
|
+
*/
|
|
480
|
+
translateLanguage?: TranslateLanguage;
|
|
481
|
+
/**
|
|
482
|
+
* 各种语言翻译后的内容
|
|
483
|
+
*/
|
|
484
|
+
translateResult?: TranslatedContents;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* 聊天室消息类型 - 系统消息
|
|
489
|
+
* @source {@link ChatMsgSource.System}
|
|
490
|
+
*/
|
|
491
|
+
export declare interface ChatMsgSystemType extends ChatMsgCommonBasicType<ChatMsgSource.System> {
|
|
492
|
+
/**
|
|
493
|
+
* 消息内容
|
|
494
|
+
*/
|
|
495
|
+
content: string;
|
|
496
|
+
/**
|
|
497
|
+
* 系统消息类型
|
|
498
|
+
*/
|
|
499
|
+
type?: SystemMsgType;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** 聊天室消息类型 */
|
|
503
|
+
export declare type ChatMsgType = ChatMsgTypeMap[keyof ChatMsgTypeMap];
|
|
504
|
+
|
|
505
|
+
/** 支持回复的消息类型 */
|
|
506
|
+
export declare type ChatMsgTypeByQuote = ChatMsgTypeMap[ChatMsgSourceByQuote];
|
|
507
|
+
|
|
508
|
+
/** 支持置顶的消息类型 */
|
|
509
|
+
export declare type ChatMsgTypeByTop = ChatMsgTypeMap[ChatMsgSourceByTop];
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* 聊天消息绑定关系
|
|
513
|
+
*/
|
|
514
|
+
export declare type ChatMsgTypeMap = {
|
|
515
|
+
[ChatMsgSource.Speak]: ChatMsgSpeakType;
|
|
516
|
+
[ChatMsgSource.File]: ChatMsgFileType;
|
|
517
|
+
[ChatMsgSource.Image]: ChatMsgImageType;
|
|
518
|
+
[ChatMsgSource.Emotion]: ChatMsgEmotionType;
|
|
519
|
+
[ChatMsgSource.Reward]: ChatMsgRewardType;
|
|
520
|
+
[ChatMsgSource.Redpaper]: ChatMsgRedpaperType;
|
|
521
|
+
[ChatMsgSource.RedpaperReceive]: ChatMsgRedpaperReceiveType;
|
|
522
|
+
[ChatMsgSource.CustomServer]: ChatMsgCustomServerType;
|
|
523
|
+
[ChatMsgSource.CustomClient]: ChatMsgCustomClientType;
|
|
524
|
+
[ChatMsgSource.System]: ChatMsgSystemType;
|
|
525
|
+
[ChatMsgSource.MotivationLike]: ChatMsgMotivationLikeType;
|
|
526
|
+
[ChatMsgSource.Effect]: ChatMsgEffectType;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 可用于发送的聊天消息类型
|
|
531
|
+
*/
|
|
532
|
+
export declare type ChatMsgTypeWithSendStatus = ChatMsgSpeakType | ChatMsgEmotionType | ChatMsgImageType;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* 聊天请求历史数据模式
|
|
536
|
+
*/
|
|
537
|
+
export declare enum ChatRequestHistoryMode {
|
|
538
|
+
/** 加载旧数据 */
|
|
539
|
+
Prev = "prev",
|
|
540
|
+
/** 加载新数据 */
|
|
541
|
+
Next = "next"
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
declare class ChatSocketFilter extends FilterBase {
|
|
545
|
+
constructor(plvChat: PolyvChat);
|
|
546
|
+
private __emitChatMessage;
|
|
547
|
+
/** 过滤回复 */
|
|
548
|
+
private __filterQuote;
|
|
549
|
+
/** 过滤发言消息 */
|
|
550
|
+
private __filterSpeakMsg;
|
|
551
|
+
/** 过滤发言(文件)sdk 消息 */
|
|
552
|
+
private __filterFileMsg;
|
|
553
|
+
/** 过滤图片消息 */
|
|
554
|
+
private __filterChatImgMsg;
|
|
555
|
+
/** 过滤表情消息 */
|
|
556
|
+
private __filterEmotionMsg;
|
|
557
|
+
/** 过滤打赏消息 */
|
|
558
|
+
private __filterRewardMsg;
|
|
559
|
+
/** 过滤红包消息 */
|
|
560
|
+
private __filterRedpaperMsg;
|
|
561
|
+
/** 过滤红包领取消息 */
|
|
562
|
+
private __filterRedpaperReceiveMsg;
|
|
563
|
+
/** 过滤自定义消息(服务端) */
|
|
564
|
+
private __filterCustomServerMsg;
|
|
565
|
+
/** 过滤自定义消息(客户端) */
|
|
566
|
+
private __filterCustomClientMsg;
|
|
567
|
+
/** 过滤课堂激励点赞消息 */
|
|
568
|
+
private __filterMotivationLikeMsg;
|
|
569
|
+
/** 过滤置顶消息 */
|
|
570
|
+
__filterSpeakTopMsg(speakTop: InternalSpeakTopData): TopingMsgData[];
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* 聊天室状态信息
|
|
575
|
+
*/
|
|
576
|
+
export declare interface ChatStatusInfo {
|
|
577
|
+
/**
|
|
578
|
+
* 聊天室是否已关闭
|
|
579
|
+
*/
|
|
580
|
+
chatRoomIsClosed: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* 自动翻译的语言语种
|
|
583
|
+
*/
|
|
584
|
+
autoTranslateLanguage?: TranslateLanguage;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export declare interface ChoiceImageFileSendOptions {
|
|
588
|
+
/**
|
|
589
|
+
* 选择图片文件后回调
|
|
590
|
+
*/
|
|
591
|
+
choiceCallback?: () => void;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* 结果类型
|
|
596
|
+
*/
|
|
597
|
+
export declare type CommonResult<FailReason extends string = string, SuccessData extends object = object> = ResultSuccess<SuccessData> | ResultFail<FailReason>;
|
|
598
|
+
|
|
599
|
+
export declare interface CustomClientMsgData<D extends object = object> {
|
|
600
|
+
/**
|
|
601
|
+
* 自定义事件
|
|
602
|
+
*/
|
|
603
|
+
EVENT: string;
|
|
604
|
+
/**
|
|
605
|
+
* 版本
|
|
606
|
+
*/
|
|
607
|
+
version: number;
|
|
608
|
+
/**
|
|
609
|
+
* 自定义数据
|
|
610
|
+
*/
|
|
611
|
+
data: D;
|
|
612
|
+
/**
|
|
613
|
+
* 提示
|
|
614
|
+
*/
|
|
615
|
+
tips: string;
|
|
616
|
+
/**
|
|
617
|
+
* 是否加入历史数据
|
|
618
|
+
*/
|
|
619
|
+
joinHistoryList: boolean;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export declare interface DeleteMsgOptions {
|
|
623
|
+
/** 消息唯一标识 */
|
|
624
|
+
id: string;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* 打赏类型
|
|
629
|
+
*/
|
|
630
|
+
export declare enum DonateType {
|
|
631
|
+
/**
|
|
632
|
+
* 现金打赏
|
|
633
|
+
*/
|
|
634
|
+
Cash = "cash",
|
|
635
|
+
/**
|
|
636
|
+
* 礼物打赏(包含现金礼物和积分礼物)
|
|
637
|
+
*/
|
|
638
|
+
Good = "good"
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
declare class DownloadModule extends ChatModuleBase {
|
|
642
|
+
private __refId;
|
|
643
|
+
/**
|
|
644
|
+
* 设置关联ID
|
|
645
|
+
* @param refId 关联ID
|
|
646
|
+
*/
|
|
647
|
+
setRefId(refId: string): void;
|
|
648
|
+
/**
|
|
649
|
+
* 获取关联ID
|
|
650
|
+
*/
|
|
651
|
+
getRefId(): string;
|
|
652
|
+
/**
|
|
653
|
+
* 导出到勤/缺勤名单
|
|
654
|
+
*/
|
|
655
|
+
exportAttendanceList(): Promise<void>;
|
|
656
|
+
/**
|
|
657
|
+
* 获取到勤/缺勤导出记录
|
|
658
|
+
*/
|
|
659
|
+
getAttendanceDownloadRecord(options?: GetAttendanceDownloadRecordOptions): Promise<PageContent<DataExportRecordData>>;
|
|
660
|
+
/**
|
|
661
|
+
* 导出在线列表
|
|
662
|
+
*/
|
|
663
|
+
exportOnlineList(): Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* 导出白名单观看情况
|
|
666
|
+
*/
|
|
667
|
+
exportWhiteList(): Promise<void>;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* 表情图片数据
|
|
672
|
+
*/
|
|
673
|
+
export declare interface EmotionImageData {
|
|
674
|
+
/**
|
|
675
|
+
* id
|
|
676
|
+
*/
|
|
677
|
+
id: string;
|
|
678
|
+
/**
|
|
679
|
+
* 名称
|
|
680
|
+
*/
|
|
681
|
+
title: string;
|
|
682
|
+
/**
|
|
683
|
+
* 在线图片地址
|
|
684
|
+
*/
|
|
685
|
+
url: string;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
declare class EmotionModule extends ChatModuleBase {
|
|
689
|
+
private __emotionParser?;
|
|
690
|
+
/**
|
|
691
|
+
* 加载表情解析器
|
|
692
|
+
*/
|
|
693
|
+
setupEmotionParser(): Promise<void>;
|
|
694
|
+
/**
|
|
695
|
+
* 获取黄脸表情节点
|
|
696
|
+
*
|
|
697
|
+
* 开发者可通过 `getEmotionFaceDomList` 方法获取节点并插入到页面容器中。
|
|
698
|
+
*
|
|
699
|
+
* 监听容器的点击事件并调用 {@link getEmotionFaceClickTarget} 方法可获取观众点击时的黄脸表情。
|
|
700
|
+
* @returns 黄脸表情 dom 节点
|
|
701
|
+
* @example
|
|
702
|
+
* ```js
|
|
703
|
+
* const containerElem = document.querySelector('容器选择器');
|
|
704
|
+
* // 插入表情节点
|
|
705
|
+
* const elems = watchCore.chat.getEmotionFaceDomList();
|
|
706
|
+
* containerElem.appendChild(elems);
|
|
707
|
+
* // 监听容器节点的点击事件
|
|
708
|
+
* containerElem.addEventListener('click', function(event) {
|
|
709
|
+
* const title = watchCore.emotion.getEmotionFaceClickTarget(event);
|
|
710
|
+
* console.log('点击的表情', title);
|
|
711
|
+
* });
|
|
712
|
+
* ```
|
|
713
|
+
*/
|
|
714
|
+
getEmotionFaceDomList(isZhCN?: boolean): HTMLElement;
|
|
715
|
+
/**
|
|
716
|
+
* 获取点击事件中的黄脸表情
|
|
717
|
+
*
|
|
718
|
+
* 用于获取观众点击黄脸表情容器时的表情对象,获取后插入到观众正在输入的聊天消息文本中。
|
|
719
|
+
* @param event 点击事件
|
|
720
|
+
* @returns 黄脸表情字符
|
|
721
|
+
* @example
|
|
722
|
+
* ```js
|
|
723
|
+
* // 观众正在输入的聊天消息
|
|
724
|
+
* const inputMsg = '今天天气真好';
|
|
725
|
+
*
|
|
726
|
+
* // 监听容器节点的点击事件
|
|
727
|
+
* containerElem.addEventListener('click', function(event) {
|
|
728
|
+
* const title = watchCore.emotion.getEmotionFaceClickTarget(event);
|
|
729
|
+
* if (title) {
|
|
730
|
+
* console.log('点击的表情', title); // 如:[呲牙]、[害羞]
|
|
731
|
+
* inputMsg = inputMsg + title;
|
|
732
|
+
* }
|
|
733
|
+
* });
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
736
|
+
getEmotionFaceClickTarget(event: Event): string | undefined;
|
|
737
|
+
/**
|
|
738
|
+
* 把表情名称转成中文
|
|
739
|
+
* @param content 发言内容
|
|
740
|
+
* @returns 转换后的内容
|
|
741
|
+
* @example
|
|
742
|
+
* ```js
|
|
743
|
+
* // 聊天发言内容
|
|
744
|
+
* let content = '[微笑]';
|
|
745
|
+
* // 返回转换后的内容
|
|
746
|
+
* let translatedContent = await chatTarget.emotion.translateEmotions(content);
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
translateEmotions(content: string, isZhCN?: boolean): string;
|
|
750
|
+
/**
|
|
751
|
+
* 获取表情解析器
|
|
752
|
+
*/
|
|
753
|
+
getEmotionParser(): EmotionParser | undefined;
|
|
754
|
+
private __getEmotionImagePromise?;
|
|
755
|
+
/**
|
|
756
|
+
* 获取表情图片列表
|
|
757
|
+
*/
|
|
758
|
+
getEmotionImages(): Promise<EmotionImageData[]>;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
declare class FilterBase {
|
|
762
|
+
protected _plvChat: PolyvChat;
|
|
763
|
+
constructor(_plvChat: PolyvChat);
|
|
764
|
+
/** 过滤用户昵称 */
|
|
765
|
+
protected _filterNick(nick: string): string;
|
|
766
|
+
/** 过滤用户信息 */
|
|
767
|
+
_filterUser(user: ChatMessageUser): ChatMessageUser;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export declare interface GetAttendanceDownloadRecordOptions {
|
|
771
|
+
pageNumber?: number;
|
|
772
|
+
pageSize?: number;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
export declare interface GetAttendanceListOptions {
|
|
776
|
+
/**
|
|
777
|
+
* 搜索关键词
|
|
778
|
+
*/
|
|
779
|
+
keyword?: string;
|
|
780
|
+
/**
|
|
781
|
+
* 获取数量,传入 `keyword` 时,该选项会失效
|
|
782
|
+
* @default 10
|
|
783
|
+
*/
|
|
784
|
+
count?: number;
|
|
785
|
+
/**
|
|
786
|
+
* 搜索类型, attendance: 出勤, absence: 缺勤
|
|
787
|
+
* @default attendance
|
|
788
|
+
*/
|
|
789
|
+
searchType?: 'attendance' | 'absence';
|
|
790
|
+
/**
|
|
791
|
+
* 排序号
|
|
792
|
+
*/
|
|
793
|
+
score?: number;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
export declare interface GetChatHistoryByTimeOptions {
|
|
797
|
+
/**
|
|
798
|
+
* 时间戳
|
|
799
|
+
*/
|
|
800
|
+
timestamp?: number;
|
|
801
|
+
/**
|
|
802
|
+
* 时间戳相对应的数量
|
|
803
|
+
* @default 1
|
|
804
|
+
*/
|
|
805
|
+
count?: number;
|
|
806
|
+
/**
|
|
807
|
+
* 获取的数量
|
|
808
|
+
* @default 10
|
|
809
|
+
*/
|
|
810
|
+
size?: number;
|
|
811
|
+
/**
|
|
812
|
+
* 排除的消息类型
|
|
813
|
+
* @description 目前仅支持 {@link ChatMsgSource.CustomServer}、{@link ChatMsgSource.Reward}、{@link ChatMsgSource.Redpaper}
|
|
814
|
+
*/
|
|
815
|
+
exclude?: ChatMsgSource[];
|
|
816
|
+
/**
|
|
817
|
+
* 聊天请求历史数据模式
|
|
818
|
+
* @default ChatRequestHistoryMode.Prev
|
|
819
|
+
*/
|
|
820
|
+
mode?: ChatRequestHistoryMode;
|
|
821
|
+
/**
|
|
822
|
+
* 是否获取禁言状态
|
|
823
|
+
* @default false
|
|
824
|
+
*/
|
|
825
|
+
getBanStatus?: boolean;
|
|
826
|
+
/**
|
|
827
|
+
* 是否只获取特殊身份消息
|
|
828
|
+
* @default false
|
|
829
|
+
*/
|
|
830
|
+
onlySpecialMsg?: boolean;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export declare interface GetChatHistoryByWorkWechatTagIdOptions {
|
|
834
|
+
/**
|
|
835
|
+
* 时间戳
|
|
836
|
+
*/
|
|
837
|
+
timestamp?: number;
|
|
838
|
+
/**
|
|
839
|
+
* 获取的数量
|
|
840
|
+
* @default 10
|
|
841
|
+
*/
|
|
842
|
+
size?: number;
|
|
843
|
+
/**
|
|
844
|
+
* 聊天请求历史数据模式
|
|
845
|
+
* @default ChatRequestHistoryMode.Prev
|
|
846
|
+
*/
|
|
847
|
+
mode?: ChatRequestHistoryMode;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export declare interface GetOnlineListOptions {
|
|
851
|
+
/**
|
|
852
|
+
* 搜索关键词
|
|
853
|
+
*/
|
|
854
|
+
keyword?: string;
|
|
855
|
+
/**
|
|
856
|
+
* 获取数量
|
|
857
|
+
* @default 10
|
|
858
|
+
*/
|
|
859
|
+
count?: number;
|
|
860
|
+
/**
|
|
861
|
+
* 是否获取禁言状态
|
|
862
|
+
* @default false
|
|
863
|
+
*/
|
|
864
|
+
getBanStatus?: boolean;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
export declare interface GetSpeakOriginalContentOptions {
|
|
868
|
+
/**
|
|
869
|
+
* 发言消息
|
|
870
|
+
*/
|
|
871
|
+
chatMsg: ChatMsgSpeakType;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* 历史消息模块
|
|
876
|
+
*/
|
|
877
|
+
declare class HistoryModule extends ChatModuleBase {
|
|
878
|
+
/**
|
|
879
|
+
* 聊天历史消息是否加密
|
|
880
|
+
*/
|
|
881
|
+
private __chatHistoryEncrypt;
|
|
882
|
+
private __apiFilter;
|
|
883
|
+
constructor(plvChat: PolyvChat);
|
|
884
|
+
/**
|
|
885
|
+
* 设置聊天历史消息是否加密
|
|
886
|
+
* @param chatHistoryEncrypt 聊天历史消息是否加密
|
|
887
|
+
*/
|
|
888
|
+
setChatHistoryEncrypt(chatHistoryEncrypt: boolean): void;
|
|
889
|
+
/**
|
|
890
|
+
* 根据时间戳获取聊天历史消息
|
|
891
|
+
* @param options 获取选项
|
|
892
|
+
*/
|
|
893
|
+
getChatHistoryByTime(options?: GetChatHistoryByTimeOptions): Promise<ChatMsgType[]>;
|
|
894
|
+
/**
|
|
895
|
+
* 获取传入到后端接口的 exclude
|
|
896
|
+
* @param exclude 排除类型数组
|
|
897
|
+
*/
|
|
898
|
+
private __getHistoryExclude;
|
|
899
|
+
getChatHistoryByWorkWechatTagId(options?: GetChatHistoryByWorkWechatTagIdOptions): Promise<ChatMsgType[]>;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
declare interface InternalSpeakTopData {
|
|
903
|
+
/** 置顶 id */
|
|
904
|
+
id: number;
|
|
905
|
+
/** 置顶操作者头衔 */
|
|
906
|
+
topActor: string;
|
|
907
|
+
/** 头衔 */
|
|
908
|
+
actor: string;
|
|
909
|
+
/** 发言内容 */
|
|
910
|
+
content: string;
|
|
911
|
+
/** 昵称 */
|
|
912
|
+
nick: string;
|
|
913
|
+
/** 头像 */
|
|
914
|
+
pic: string;
|
|
915
|
+
/** 消息 id */
|
|
916
|
+
speakId: string;
|
|
917
|
+
/** 用户 id */
|
|
918
|
+
userId: string;
|
|
919
|
+
/** 用户类型 */
|
|
920
|
+
userType: SocketUserType;
|
|
921
|
+
/** 另外置顶的消息 */
|
|
922
|
+
others?: InternalSpeakTopData[];
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/** 是否为服务端消息 */
|
|
926
|
+
export declare const isServiceMsgMap: Record<ChatMsgSource, boolean>;
|
|
927
|
+
|
|
928
|
+
/** 被踢出聊天室的用户数据 */
|
|
929
|
+
export declare interface KickedUserData {
|
|
930
|
+
/** 用户 id */
|
|
931
|
+
userId: string;
|
|
932
|
+
/** 昵称 */
|
|
933
|
+
nick: string;
|
|
934
|
+
/** ip 地址 */
|
|
935
|
+
clientIp: string;
|
|
936
|
+
/** 是否被平台封禁 */
|
|
937
|
+
platformProhibited: boolean;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export declare interface KickUserOptions {
|
|
941
|
+
/** 用户 id */
|
|
942
|
+
userId: string;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
export declare enum ManageFailReason {
|
|
946
|
+
/** 未知错误 */
|
|
947
|
+
UnknownError = "UnknownError",
|
|
948
|
+
/** 已被平台封禁 */
|
|
949
|
+
PlatformProhibited = "PlatformProhibited"
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* 管理模块
|
|
954
|
+
*/
|
|
955
|
+
declare class ManageModule extends ChatModuleBase {
|
|
956
|
+
private __isListened;
|
|
957
|
+
/**
|
|
958
|
+
* 监听管理相关事件
|
|
959
|
+
*
|
|
960
|
+
* sdk sdk 内部不会自动监听管理事件,如使用管理功能,需要手动触发监听
|
|
961
|
+
*/
|
|
962
|
+
listenManageEvent(): void;
|
|
963
|
+
/**
|
|
964
|
+
* 删除消息
|
|
965
|
+
* @param options 删除选项
|
|
966
|
+
*/
|
|
967
|
+
deleteMsg(options: DeleteMsgOptions): Promise<CommonResult<ManageFailReason>>;
|
|
968
|
+
/**
|
|
969
|
+
* 清空聊天室
|
|
970
|
+
*/
|
|
971
|
+
clearMsg(): Promise<CommonResult<ManageFailReason>>;
|
|
972
|
+
/**
|
|
973
|
+
* 禁言用户
|
|
974
|
+
* @param options 禁言选项
|
|
975
|
+
*/
|
|
976
|
+
banUser(options: BanUserOptions): Promise<CommonResult<ManageFailReason>>;
|
|
977
|
+
/**
|
|
978
|
+
* 取消禁言用户
|
|
979
|
+
* @param options 取消禁言选项
|
|
980
|
+
*/
|
|
981
|
+
cancelBanUser(options: BanUserOptions): Promise<CommonResult<ManageFailReason>>;
|
|
982
|
+
/**
|
|
983
|
+
* 获取被禁言的用户列表
|
|
984
|
+
* @param options 获取被禁言的用户列表选项
|
|
985
|
+
*/
|
|
986
|
+
getBannedUserList(options?: BannedUserListOptions): Promise<PageContent<BannedUserData>>;
|
|
987
|
+
/**
|
|
988
|
+
* 禁言 ip
|
|
989
|
+
* @param options 禁言选项
|
|
990
|
+
*/
|
|
991
|
+
banIp(options: BanIpOptions): Promise<CommonResult<ManageFailReason>>;
|
|
992
|
+
/**
|
|
993
|
+
* 取消禁言 ip
|
|
994
|
+
* @param options 取消禁言选项
|
|
995
|
+
*/
|
|
996
|
+
cancelBanIp(options: BanIpOptions): Promise<CommonResult<ManageFailReason>>;
|
|
997
|
+
/**
|
|
998
|
+
* 获取已被禁言的 ip 列表
|
|
999
|
+
*/
|
|
1000
|
+
getBannedIpList(): Promise<{
|
|
1001
|
+
contents: BannedIpData[];
|
|
1002
|
+
}>;
|
|
1003
|
+
/**
|
|
1004
|
+
* 踢出用户
|
|
1005
|
+
* @param options 踢出选项
|
|
1006
|
+
*/
|
|
1007
|
+
kickUser(options: KickUserOptions): Promise<CommonResult<ManageFailReason>>;
|
|
1008
|
+
/**
|
|
1009
|
+
* 取消踢出用户
|
|
1010
|
+
* @param options 取消踢出选项
|
|
1011
|
+
*/
|
|
1012
|
+
cancelKickUser(options: KickUserOptions): Promise<CommonResult<ManageFailReason>>;
|
|
1013
|
+
/**
|
|
1014
|
+
* 获取被踢出聊天室的用户列表
|
|
1015
|
+
*/
|
|
1016
|
+
getKickedUserList(): Promise<{
|
|
1017
|
+
contents: KickedUserData[];
|
|
1018
|
+
}>;
|
|
1019
|
+
/**
|
|
1020
|
+
* 激励点赞
|
|
1021
|
+
* @param options 激励点赞选项
|
|
1022
|
+
*/
|
|
1023
|
+
motivateLike(options: MotivateLikeOptions): Promise<void>;
|
|
1024
|
+
/**
|
|
1025
|
+
* 置顶消息
|
|
1026
|
+
* @param options 置顶选项
|
|
1027
|
+
*/
|
|
1028
|
+
topMsg(options: TopMsgOptions): Promise<void>;
|
|
1029
|
+
/**
|
|
1030
|
+
* 取消置顶消息
|
|
1031
|
+
* @param options 取消置顶选项
|
|
1032
|
+
*/
|
|
1033
|
+
cancelTopMsg(options: CancelTopMsgOptions): Promise<void>;
|
|
1034
|
+
/**
|
|
1035
|
+
* 设置聊天室全体禁言
|
|
1036
|
+
* @param options 设置选项
|
|
1037
|
+
*/
|
|
1038
|
+
setChatSwitch(options: SetChatSwitchOptions): Promise<CommonResult<ManageFailReason>>;
|
|
1039
|
+
/**
|
|
1040
|
+
* 推送发言消息到问答
|
|
1041
|
+
* @param options 推送选项
|
|
1042
|
+
*/
|
|
1043
|
+
pushMsgToQa(options: PushMsgToQaOptions): Promise<CommonResult<ManageFailReason>>;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* 消息模块
|
|
1048
|
+
*/
|
|
1049
|
+
declare class MessageModule extends ChatModuleBase {
|
|
1050
|
+
/** 置顶中的消息 */
|
|
1051
|
+
topingMsgs: TopingMsgData[];
|
|
1052
|
+
constructor(plvChat: PolyvChat);
|
|
1053
|
+
/**
|
|
1054
|
+
* 是否为服务端消息
|
|
1055
|
+
* @param chatMsg 聊天消息
|
|
1056
|
+
* @returns 是否为服务端消息
|
|
1057
|
+
*/
|
|
1058
|
+
isServiceMsg(chatMsg: ChatMsgType): boolean;
|
|
1059
|
+
/**
|
|
1060
|
+
* 是否可被引用回复
|
|
1061
|
+
* @param chatMsg 聊天消息
|
|
1062
|
+
* @returns 是否可被引用回复
|
|
1063
|
+
*/
|
|
1064
|
+
canQuoteMsg(chatMsg: ChatMsgType): chatMsg is ChatMsgTypeByQuote;
|
|
1065
|
+
/**
|
|
1066
|
+
* 是否可被置顶
|
|
1067
|
+
* @param chatMsg 聊天消息
|
|
1068
|
+
* @returns 是否可被置顶
|
|
1069
|
+
*/
|
|
1070
|
+
canTopMsg(chatMsg: ChatMsgType): chatMsg is ChatMsgTypeByTop;
|
|
1071
|
+
/**
|
|
1072
|
+
* 转换发言内容
|
|
1073
|
+
*
|
|
1074
|
+
* 通过 `parseSpeakContent` 将观众发言中的表情、链接转换成 html 元素。
|
|
1075
|
+
*
|
|
1076
|
+
* 转换顺序:parseLink > removeEmotion > parseEmotion > parseLineBreak
|
|
1077
|
+
* @param content 发言内容
|
|
1078
|
+
* @param options 转换选项
|
|
1079
|
+
* @returns 转换后的 html 字符
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```js
|
|
1082
|
+
* // 转换链接
|
|
1083
|
+
* plvChat.message.parseSpeakContent('这是我们的官网地址:https://www.polyv.net/', { parseLink: true });
|
|
1084
|
+
* // 转换后的字符串:这是我们的官网地址:<a target="_blank" rel="noopener" href="https://www.polyv.net/">https://www.polyv.net/</a>
|
|
1085
|
+
*
|
|
1086
|
+
* // 移除表情
|
|
1087
|
+
* plvChat.message.parseSpeakContent('今天天气真好[呲牙]', { removeEmotion: true });
|
|
1088
|
+
* // 转换后的字符串:今天天气真好
|
|
1089
|
+
*
|
|
1090
|
+
* // 转换表情
|
|
1091
|
+
* plvChat.message.parseSpeakContent('今天天气真好[呲牙]', { parseEmotion: true });
|
|
1092
|
+
* // 转换后的字符串:今天天气真好<img src="黄脸表情图片地址" alt="呲牙" class="plv-emotion-img" />
|
|
1093
|
+
*
|
|
1094
|
+
* // 将换行符转成 <br />
|
|
1095
|
+
* plvChat.message.parseSpeakContent('这是一段文字\n这是另一段文字', { parseLineBreak: true });
|
|
1096
|
+
* // 转换后的字符串:这是一段文字<br />这是另一段文字
|
|
1097
|
+
* ```
|
|
1098
|
+
*/
|
|
1099
|
+
parseSpeakContent(content: string, options?: ParseOptions): string;
|
|
1100
|
+
/**
|
|
1101
|
+
* 完整的消息文本记录对象
|
|
1102
|
+
*/
|
|
1103
|
+
private __fullMessageRecord;
|
|
1104
|
+
/**
|
|
1105
|
+
* 获取超长消息的完整文本
|
|
1106
|
+
*
|
|
1107
|
+
* 讲师可发送超过 2000 字的文本消息,该消息为超长文本消息(通过 `chatMsg.isOverLength === true` 判断),`chat` 提供消息文本只会返回前 1000 字的消息字符串,如需展示完整的消息文本,可调用该方法获取。
|
|
1108
|
+
* @param id 聊天消息 id
|
|
1109
|
+
* @param chatMsg 聊天消息,在未超过服务端聊天文本长度或者请求异常时会使用聊天消息内容返回 [v0.11.0 新增]
|
|
1110
|
+
* @example
|
|
1111
|
+
* ```ts
|
|
1112
|
+
* import { ChatMsgSpeakType } from '@polyv/live-watch-sdk';
|
|
1113
|
+
*
|
|
1114
|
+
* async function getFullMessageText(chatMsg: ChatMsgSpeakType): Promise<string> {
|
|
1115
|
+
* if (!chatMsg.isOverLength) {
|
|
1116
|
+
* throw new Error('该消息非超长文本');
|
|
1117
|
+
* }
|
|
1118
|
+
*
|
|
1119
|
+
* const result = await plvChat.message.getFullMessage(chatMsg.id, chatMsg);
|
|
1120
|
+
* console.log('完整的文本', result);
|
|
1121
|
+
* return result;
|
|
1122
|
+
* }
|
|
1123
|
+
* ```
|
|
1124
|
+
*/
|
|
1125
|
+
getFullMessage(chatMsg: ChatMsgSpeakType): Promise<string>;
|
|
1126
|
+
/**
|
|
1127
|
+
* 翻译发言消息
|
|
1128
|
+
* @param options 翻译选项
|
|
1129
|
+
*/
|
|
1130
|
+
translateSpeak(options: TranslateSpeakOptions): Promise<TranslateSpeakResult>;
|
|
1131
|
+
/**
|
|
1132
|
+
* 获取发言消息的原始内容
|
|
1133
|
+
* @param options 选项
|
|
1134
|
+
*/
|
|
1135
|
+
getSpeakOriginalContent(options: GetSpeakOriginalContentOptions): Promise<string | undefined>;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export declare interface MotivateLikeOptions {
|
|
1139
|
+
/**
|
|
1140
|
+
* 激励类型
|
|
1141
|
+
*/
|
|
1142
|
+
type?: MotivationLikeType;
|
|
1143
|
+
/**
|
|
1144
|
+
* 被激励者Id
|
|
1145
|
+
*/
|
|
1146
|
+
motivatedId: string;
|
|
1147
|
+
/**
|
|
1148
|
+
* 消息 id
|
|
1149
|
+
*/
|
|
1150
|
+
chatMsgId?: string;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/** 激励类型来源 */
|
|
1154
|
+
export declare enum MotivationLikeType {
|
|
1155
|
+
/** 消息发言 */
|
|
1156
|
+
Speak = "speak",
|
|
1157
|
+
/** 连麦 */
|
|
1158
|
+
Mic = "mic"
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
export declare interface OnlineListResult {
|
|
1162
|
+
/** 在线总人数 */
|
|
1163
|
+
total: number;
|
|
1164
|
+
/** 在线列表 */
|
|
1165
|
+
onlineList: ChatMessageUser[];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
declare class OnlineModule extends ChatModuleBase {
|
|
1169
|
+
/**
|
|
1170
|
+
* 获取在线列表
|
|
1171
|
+
* @param options 获取选项
|
|
1172
|
+
*/
|
|
1173
|
+
getOnlineList(options?: GetOnlineListOptions): Promise<OnlineListResult>;
|
|
1174
|
+
private __getOnlineListByKeyword;
|
|
1175
|
+
/**
|
|
1176
|
+
* 获取在线列表(普通)
|
|
1177
|
+
*/
|
|
1178
|
+
private __getOnlineListByNormal;
|
|
1179
|
+
/**
|
|
1180
|
+
* 获取到勤/缺勤列表
|
|
1181
|
+
* @param options 获取选项
|
|
1182
|
+
*/
|
|
1183
|
+
getAttendanceList(options: GetAttendanceListOptions): Promise<AttendanceListResult>;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* 分页数据
|
|
1188
|
+
*/
|
|
1189
|
+
export declare interface PageContent<I = unknown> {
|
|
1190
|
+
/** 当前页数 */
|
|
1191
|
+
pageNumber: number;
|
|
1192
|
+
/** 每页数量 */
|
|
1193
|
+
pageSize: number;
|
|
1194
|
+
/** 总记录数 */
|
|
1195
|
+
totalItems: number;
|
|
1196
|
+
/** 总页数 */
|
|
1197
|
+
totalPages: number;
|
|
1198
|
+
/** 内容列表 */
|
|
1199
|
+
contents: I[];
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* 转换选项
|
|
1204
|
+
*/
|
|
1205
|
+
export declare interface ParseOptions {
|
|
1206
|
+
/**
|
|
1207
|
+
* 是否转换链接
|
|
1208
|
+
* @default false
|
|
1209
|
+
*/
|
|
1210
|
+
parseLink?: boolean;
|
|
1211
|
+
/**
|
|
1212
|
+
* 移除表情内容
|
|
1213
|
+
* @default false
|
|
1214
|
+
*/
|
|
1215
|
+
removeEmotion?: boolean;
|
|
1216
|
+
/**
|
|
1217
|
+
* 是否转换表情
|
|
1218
|
+
* @default false
|
|
1219
|
+
*/
|
|
1220
|
+
parseEmotion?: boolean;
|
|
1221
|
+
/**
|
|
1222
|
+
* 是否转换换行符
|
|
1223
|
+
* @default false
|
|
1224
|
+
*/
|
|
1225
|
+
parseLineBreak?: boolean;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/** 根据来源获取聊天消息类型 */
|
|
1229
|
+
export declare type PickChatMsgType<S extends ChatMsgSource> = ChatMsgTypeMap[S];
|
|
1230
|
+
|
|
1231
|
+
export declare class PolyvChat {
|
|
1232
|
+
plvSocket: PolyvSocket;
|
|
1233
|
+
config: PolyvChatConfig;
|
|
1234
|
+
PolyvChatEvent: typeof PolyvChatEvent;
|
|
1235
|
+
ChatMsgSource: typeof ChatMsgSource;
|
|
1236
|
+
DonateType: typeof DonateType;
|
|
1237
|
+
RedpackType: typeof RedpackType;
|
|
1238
|
+
SystemMsgType: typeof SystemMsgType;
|
|
1239
|
+
ChatRequestHistoryMode: typeof ChatRequestHistoryMode;
|
|
1240
|
+
ManageFailReason: typeof ManageFailReason;
|
|
1241
|
+
TranslateLanguage: typeof TranslateLanguage;
|
|
1242
|
+
eventEmitter: EventEmitter<PolyvChatEventRelations, PolyvChatEvent>;
|
|
1243
|
+
__socketFilter: ChatSocketFilter;
|
|
1244
|
+
private __socketHandler;
|
|
1245
|
+
/** 表情模块 */
|
|
1246
|
+
emotion: EmotionModule;
|
|
1247
|
+
/** 历史消息模块 */
|
|
1248
|
+
history: HistoryModule;
|
|
1249
|
+
/** 消息模块 */
|
|
1250
|
+
message: MessageModule;
|
|
1251
|
+
/** 状态模块 */
|
|
1252
|
+
status: StatusModule;
|
|
1253
|
+
/** 工具模块 */
|
|
1254
|
+
utils: UtilsModule;
|
|
1255
|
+
/** 发送模块 */
|
|
1256
|
+
sender: SenderModule;
|
|
1257
|
+
/** 管理模块 */
|
|
1258
|
+
manage: ManageModule;
|
|
1259
|
+
/** 在线列表模块 */
|
|
1260
|
+
online: OnlineModule;
|
|
1261
|
+
/** 下载导出模块 */
|
|
1262
|
+
download: DownloadModule;
|
|
1263
|
+
constructor(plvSocket: PolyvSocket, config?: PolyvChatConfig);
|
|
1264
|
+
/** 是否设置完成 */
|
|
1265
|
+
setuped: boolean;
|
|
1266
|
+
/**
|
|
1267
|
+
* 设置聊天室
|
|
1268
|
+
*/
|
|
1269
|
+
setup(): Promise<void>;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
export declare interface PolyvChatConfig {
|
|
1273
|
+
/**
|
|
1274
|
+
* 频道消息特效设置
|
|
1275
|
+
*/
|
|
1276
|
+
effectSetting?: ChannelEffectSetting;
|
|
1277
|
+
/**
|
|
1278
|
+
* 聊天历史消息是否加密
|
|
1279
|
+
* @default false
|
|
1280
|
+
*/
|
|
1281
|
+
chatHistoryEncrypt?: boolean;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
export declare enum PolyvChatEvent {
|
|
1285
|
+
/**
|
|
1286
|
+
* 聊天室初始完成
|
|
1287
|
+
*/
|
|
1288
|
+
ChatInitialized = "ChatInitialized",
|
|
1289
|
+
/**
|
|
1290
|
+
* 状态信息更新事件
|
|
1291
|
+
*/
|
|
1292
|
+
StatusInfoUpdate = "StatusInfoUpdate",
|
|
1293
|
+
/**
|
|
1294
|
+
* 聊天消息事件
|
|
1295
|
+
*/
|
|
1296
|
+
ChatMessage = "ChatMessage",
|
|
1297
|
+
/**
|
|
1298
|
+
* 删除某条聊天消息
|
|
1299
|
+
*/
|
|
1300
|
+
RemoveChatMsg = "RemoveChatMsg",
|
|
1301
|
+
/**
|
|
1302
|
+
* 清空聊天室
|
|
1303
|
+
*/
|
|
1304
|
+
ClearMsgHistory = "ClearMsgHistory",
|
|
1305
|
+
/**
|
|
1306
|
+
* 关闭聊天室
|
|
1307
|
+
*/
|
|
1308
|
+
CloseChatRoom = "CloseChatRoom",
|
|
1309
|
+
/**
|
|
1310
|
+
* 打开聊天室
|
|
1311
|
+
*/
|
|
1312
|
+
OpenChatRoom = "OpenChatRoom",
|
|
1313
|
+
/**
|
|
1314
|
+
* 替换聊天消息事件
|
|
1315
|
+
*/
|
|
1316
|
+
ReplaceChatMessage = "ReplaceChatMessage",
|
|
1317
|
+
/**
|
|
1318
|
+
* 当前观众发送消息
|
|
1319
|
+
*/
|
|
1320
|
+
SelfSendMessage = "SelfSendMessage",
|
|
1321
|
+
/**
|
|
1322
|
+
* 用户被禁言
|
|
1323
|
+
*/
|
|
1324
|
+
UserBanned = "UserBanned",
|
|
1325
|
+
/**
|
|
1326
|
+
* 用户被取消禁言
|
|
1327
|
+
*/
|
|
1328
|
+
UserCancelBanned = "UserCancelBanned",
|
|
1329
|
+
/**
|
|
1330
|
+
* ip 被禁言
|
|
1331
|
+
*/
|
|
1332
|
+
IpBanned = "IpBanned",
|
|
1333
|
+
/**
|
|
1334
|
+
* ip 被取消禁言
|
|
1335
|
+
*/
|
|
1336
|
+
IpCancelBanned = "IpCancelBanned",
|
|
1337
|
+
/**
|
|
1338
|
+
* 用户被踢出聊天室
|
|
1339
|
+
*/
|
|
1340
|
+
UserKicked = "UserKicked",
|
|
1341
|
+
/**
|
|
1342
|
+
* 用户被取消踢出聊天室
|
|
1343
|
+
*/
|
|
1344
|
+
UserCancelKicked = "UserCancelKicked",
|
|
1345
|
+
/**
|
|
1346
|
+
* 置顶消息事件
|
|
1347
|
+
*/
|
|
1348
|
+
TopMsg = "TopMsg",
|
|
1349
|
+
/**
|
|
1350
|
+
* 设置自动翻译语言
|
|
1351
|
+
*/
|
|
1352
|
+
SetAutoTranslateLanguage = "SetAutoTranslateLanguage",
|
|
1353
|
+
/**
|
|
1354
|
+
* 商品点击事件
|
|
1355
|
+
*/
|
|
1356
|
+
ProductClick = "ProductClick",
|
|
1357
|
+
/**
|
|
1358
|
+
* 商品下单数量事件
|
|
1359
|
+
*/
|
|
1360
|
+
ProductBuyTimes = "ProductBuyTimes"
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
export declare type PolyvChatEventRelations = {
|
|
1364
|
+
[PolyvChatEvent.StatusInfoUpdate]: {
|
|
1365
|
+
/**
|
|
1366
|
+
* 状态信息
|
|
1367
|
+
*/
|
|
1368
|
+
statusInfo: ChatStatusInfo;
|
|
1369
|
+
};
|
|
1370
|
+
[PolyvChatEvent.ChatMessage]: {
|
|
1371
|
+
/**
|
|
1372
|
+
* 聊天消息对象
|
|
1373
|
+
*/
|
|
1374
|
+
chatMsg: ChatMsgType;
|
|
1375
|
+
};
|
|
1376
|
+
[PolyvChatEvent.RemoveChatMsg]: {
|
|
1377
|
+
/**
|
|
1378
|
+
* 删除的消息 id
|
|
1379
|
+
*/
|
|
1380
|
+
id: string;
|
|
1381
|
+
};
|
|
1382
|
+
[PolyvChatEvent.ReplaceChatMessage]: {
|
|
1383
|
+
/**
|
|
1384
|
+
* 替换的消息 id
|
|
1385
|
+
*/
|
|
1386
|
+
id: string;
|
|
1387
|
+
/**
|
|
1388
|
+
* 新的消息对象
|
|
1389
|
+
*/
|
|
1390
|
+
chatMsg: ChatMsgType;
|
|
1391
|
+
};
|
|
1392
|
+
[PolyvChatEvent.SelfSendMessage]: {
|
|
1393
|
+
/**
|
|
1394
|
+
* 发送的消息对象
|
|
1395
|
+
*/
|
|
1396
|
+
chatMsg: ChatMsgTypeWithSendStatus;
|
|
1397
|
+
};
|
|
1398
|
+
[PolyvChatEvent.UserBanned]: {
|
|
1399
|
+
/**
|
|
1400
|
+
* 用户 id
|
|
1401
|
+
*/
|
|
1402
|
+
userId: string;
|
|
1403
|
+
};
|
|
1404
|
+
[PolyvChatEvent.UserCancelBanned]: {
|
|
1405
|
+
/**
|
|
1406
|
+
* 用户 id
|
|
1407
|
+
*/
|
|
1408
|
+
userId: string;
|
|
1409
|
+
};
|
|
1410
|
+
[PolyvChatEvent.IpBanned]: {
|
|
1411
|
+
/**
|
|
1412
|
+
* ip
|
|
1413
|
+
*/
|
|
1414
|
+
ip: string;
|
|
1415
|
+
};
|
|
1416
|
+
[PolyvChatEvent.IpCancelBanned]: {
|
|
1417
|
+
/**
|
|
1418
|
+
* ip
|
|
1419
|
+
*/
|
|
1420
|
+
ip: string;
|
|
1421
|
+
};
|
|
1422
|
+
[PolyvChatEvent.UserKicked]: {
|
|
1423
|
+
/**
|
|
1424
|
+
* 用户 id
|
|
1425
|
+
*/
|
|
1426
|
+
userId: string;
|
|
1427
|
+
};
|
|
1428
|
+
[PolyvChatEvent.UserCancelKicked]: {
|
|
1429
|
+
/**
|
|
1430
|
+
* 用户 id
|
|
1431
|
+
*/
|
|
1432
|
+
userId: string;
|
|
1433
|
+
};
|
|
1434
|
+
[PolyvChatEvent.TopMsg]: {
|
|
1435
|
+
/**
|
|
1436
|
+
* 置顶消息
|
|
1437
|
+
*/
|
|
1438
|
+
topingMsgs: TopingMsgData[];
|
|
1439
|
+
};
|
|
1440
|
+
[PolyvChatEvent.SetAutoTranslateLanguage]: {
|
|
1441
|
+
/**
|
|
1442
|
+
* 自动翻译语言
|
|
1443
|
+
*/
|
|
1444
|
+
language: TranslateLanguage | undefined;
|
|
1445
|
+
};
|
|
1446
|
+
[PolyvChatEvent.ProductClick]: {
|
|
1447
|
+
/**
|
|
1448
|
+
* 用户昵称
|
|
1449
|
+
*/
|
|
1450
|
+
nickname: string;
|
|
1451
|
+
/**
|
|
1452
|
+
* 商品 id
|
|
1453
|
+
*/
|
|
1454
|
+
productId: string;
|
|
1455
|
+
/**
|
|
1456
|
+
* 商品名称
|
|
1457
|
+
*/
|
|
1458
|
+
name: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* 商品类型
|
|
1461
|
+
*/
|
|
1462
|
+
type: string;
|
|
1463
|
+
};
|
|
1464
|
+
[PolyvChatEvent.ProductBuyTimes]: {
|
|
1465
|
+
/**
|
|
1466
|
+
* 首个下单观众昵称
|
|
1467
|
+
*/
|
|
1468
|
+
nickname: string;
|
|
1469
|
+
/**
|
|
1470
|
+
* 次数
|
|
1471
|
+
*/
|
|
1472
|
+
count: number;
|
|
1473
|
+
/**
|
|
1474
|
+
* 商品 id
|
|
1475
|
+
*/
|
|
1476
|
+
productId: string;
|
|
1477
|
+
/**
|
|
1478
|
+
* 商品名称
|
|
1479
|
+
*/
|
|
1480
|
+
productName: string;
|
|
1481
|
+
/**
|
|
1482
|
+
* 商品类型
|
|
1483
|
+
*/
|
|
1484
|
+
productType: string;
|
|
1485
|
+
};
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1488
|
+
export declare interface PushMsgToQaOptions {
|
|
1489
|
+
/** 发言消息 */
|
|
1490
|
+
chatMsg: ChatMsgSpeakType;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* 红包类型
|
|
1495
|
+
*/
|
|
1496
|
+
export declare enum RedpackType {
|
|
1497
|
+
/**
|
|
1498
|
+
* 用户 - 普通红包
|
|
1499
|
+
*/
|
|
1500
|
+
Normal = "normal",
|
|
1501
|
+
/**
|
|
1502
|
+
* 开播端 - 普通红包
|
|
1503
|
+
*/
|
|
1504
|
+
OfficialNormal = "official_normal",
|
|
1505
|
+
/**
|
|
1506
|
+
* 开播端 - 口令红包
|
|
1507
|
+
*/
|
|
1508
|
+
Password = "password",
|
|
1509
|
+
/**
|
|
1510
|
+
* 开播端 - 红包雨
|
|
1511
|
+
*/
|
|
1512
|
+
Rain = "rain",
|
|
1513
|
+
/**
|
|
1514
|
+
* 开播端 - 积分普通红包
|
|
1515
|
+
*/
|
|
1516
|
+
ScoreOfficialNormal = "score_official_normal",
|
|
1517
|
+
/**
|
|
1518
|
+
* 开播端 - 积分口令红包
|
|
1519
|
+
*/
|
|
1520
|
+
ScorePassword = "score_password",
|
|
1521
|
+
/**
|
|
1522
|
+
* 开播端 - 积分红包雨
|
|
1523
|
+
*/
|
|
1524
|
+
ScoreRain = "score_rain",
|
|
1525
|
+
/**
|
|
1526
|
+
* 开播端 - 积分答题红包
|
|
1527
|
+
*/
|
|
1528
|
+
ScoreQuestion = "score_question",
|
|
1529
|
+
/**
|
|
1530
|
+
* 开播端 - 答题红包
|
|
1531
|
+
*/
|
|
1532
|
+
Question = "question",
|
|
1533
|
+
/**
|
|
1534
|
+
* 开播端 - 支付宝口令普通红包
|
|
1535
|
+
*/
|
|
1536
|
+
AlipayPasswordOfficialNormal = "alipay_password_official_normal",
|
|
1537
|
+
/**
|
|
1538
|
+
* 任务奖励
|
|
1539
|
+
*/
|
|
1540
|
+
TaskWard = "TASK_REWARD"
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* 失败结果
|
|
1545
|
+
*/
|
|
1546
|
+
export declare interface ResultFail<FailReason extends string> {
|
|
1547
|
+
success: false;
|
|
1548
|
+
/** 失败原因 */
|
|
1549
|
+
failReason: FailReason;
|
|
1550
|
+
/** 失败消息 */
|
|
1551
|
+
failMessage?: string;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
export declare type ResultSuccess<SuccessData extends object = object> = ResultSuccessBasic & SuccessData;
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* 成功的结果
|
|
1558
|
+
*/
|
|
1559
|
+
export declare interface ResultSuccessBasic {
|
|
1560
|
+
success: true;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
export declare interface SendCustomServerMsgOptions {
|
|
1564
|
+
/**
|
|
1565
|
+
* 自定义消息内容
|
|
1566
|
+
*/
|
|
1567
|
+
content: string;
|
|
1568
|
+
/**
|
|
1569
|
+
* 是否加入聊天历史
|
|
1570
|
+
* @default true
|
|
1571
|
+
*/
|
|
1572
|
+
joinHistoryList?: boolean;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* 发送图片表情参数
|
|
1577
|
+
*/
|
|
1578
|
+
export declare interface SendEmotionImageMsgOptions extends SendMsgCommonOptions<ChatMsgEmotionType> {
|
|
1579
|
+
/**
|
|
1580
|
+
* 表情 id
|
|
1581
|
+
*/
|
|
1582
|
+
emotionId: string;
|
|
1583
|
+
/**
|
|
1584
|
+
* 表情图片地址
|
|
1585
|
+
*/
|
|
1586
|
+
emotionUrl: string;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
declare class SenderModule extends ChatModuleBase {
|
|
1590
|
+
/**
|
|
1591
|
+
* 获取当前观众的聊天室用户信息
|
|
1592
|
+
*/
|
|
1593
|
+
private __getCurrentChatMsgUserData;
|
|
1594
|
+
private __afterSendSocket;
|
|
1595
|
+
/**
|
|
1596
|
+
* 生成本地消息
|
|
1597
|
+
* @param source 消息来源
|
|
1598
|
+
* @param options 选项参数
|
|
1599
|
+
* @returns
|
|
1600
|
+
*/
|
|
1601
|
+
generateLocalMsg<S extends SendMsgSourceType>(source: S, options: SendMsgRealtions[S]): Promise<PickChatMsgType<S>>;
|
|
1602
|
+
/**
|
|
1603
|
+
* 发送文本消息
|
|
1604
|
+
*
|
|
1605
|
+
* 用于观众进行聊天发言,调用过程中会触发 {@link ChatEvents.ChatMessage} 聊天消息事件。
|
|
1606
|
+
* @category 发送聊天消息
|
|
1607
|
+
* @param options 发言参数
|
|
1608
|
+
* @returns 发送到服务器后的消息对象
|
|
1609
|
+
* @example
|
|
1610
|
+
* ```ts
|
|
1611
|
+
* import { ChatMsgSpeakType } from '@polyv/chat';
|
|
1612
|
+
* // 发送的文本
|
|
1613
|
+
* const content = '今天天气真好[呲牙][酷]';
|
|
1614
|
+
* // 被回复的消息
|
|
1615
|
+
* const currentQuoteMsg: ChatMsgSpeakType | undefined = undefined;
|
|
1616
|
+
* // 发送消息
|
|
1617
|
+
* chatTarget.sender.sendSpeakMsg({
|
|
1618
|
+
* content,
|
|
1619
|
+
* quoteMsg: currentQuoteMsg,
|
|
1620
|
+
* });
|
|
1621
|
+
* ```
|
|
1622
|
+
*/
|
|
1623
|
+
sendSpeakMsg(options: SendSpeakMsgOptions): Promise<ChatMsgSpeakType>;
|
|
1624
|
+
/**
|
|
1625
|
+
* 发送图片消息
|
|
1626
|
+
*
|
|
1627
|
+
* 用于观众发送图片消息,调用过程中会触发 {@link PolyvChatEvents.ChatMessage} 聊天消息事件。
|
|
1628
|
+
* @category 发送聊天消息
|
|
1629
|
+
* @param options 发送图片参数
|
|
1630
|
+
* @returns 发送到服务器后的图片消息对象
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```js
|
|
1633
|
+
* import { uuidV4 } from '@utils-ts/string';
|
|
1634
|
+
* // 图片 id
|
|
1635
|
+
* const imageId = uuidV4();
|
|
1636
|
+
* // 图片地址
|
|
1637
|
+
* const imageUrl = '发送到图片地址,需要带有协议';
|
|
1638
|
+
* // 图片地址
|
|
1639
|
+
* const size = { width: 200, height: 100 };
|
|
1640
|
+
* // 发送图片消息
|
|
1641
|
+
* chatTarget.sender.sendImageMsg({ imageId, imageUrl, size });
|
|
1642
|
+
* ```
|
|
1643
|
+
*/
|
|
1644
|
+
sendImageMsg(options: SendImageMsgOptions): Promise<ChatMsgImageType>;
|
|
1645
|
+
/**
|
|
1646
|
+
* 选择图片文件并发送图片消息
|
|
1647
|
+
*/
|
|
1648
|
+
choiceImageFileSend(options?: ChoiceImageFileSendOptions): Promise<ChatMsgImageType[]>;
|
|
1649
|
+
/**
|
|
1650
|
+
* 发送表情图片消息
|
|
1651
|
+
*
|
|
1652
|
+
* 通过 `getEmotionImages` 方法获取表情图片列表后,通过列表项的 `id`、`url` 发送表情图片消息,调用过程中会触发 {@link PolyvChatEvents.ChatMessage} 聊天消息事件。
|
|
1653
|
+
*
|
|
1654
|
+
* 开发者可通过 {@link getEmotionImages} 获取表情图片列表。
|
|
1655
|
+
* @category 发送聊天消息
|
|
1656
|
+
* @param options 发送表情图片参数
|
|
1657
|
+
* @returns 发送到服务器后的消息对象
|
|
1658
|
+
* @example
|
|
1659
|
+
* ```js
|
|
1660
|
+
* // 获取表情图片列表
|
|
1661
|
+
* const emotionImages = await chatTarget.emotion.getEmotionImages();
|
|
1662
|
+
* // 发送表情图片
|
|
1663
|
+
* const item = emotionImages[2];
|
|
1664
|
+
* chatTarget.sender.sendEmotionImageMsg({ emotionId: item.id, emotionUrl: item.url });
|
|
1665
|
+
* ```
|
|
1666
|
+
*/
|
|
1667
|
+
sendEmotionImageMsg(options: SendEmotionImageMsgOptions): Promise<ChatMsgEmotionType>;
|
|
1668
|
+
/**
|
|
1669
|
+
* 发送系统消息
|
|
1670
|
+
*
|
|
1671
|
+
* 用于发送系统消息到聊天区,注意该消息并不会发送到服务端,调用过程中会触发 {@link PolyvChatEvent.ChatMessage} 聊天消息事件。
|
|
1672
|
+
* @param content 消息内容
|
|
1673
|
+
* @param type 系统消息类型
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```js
|
|
1676
|
+
* chatTarget.sender.sendSystemMsg('聊天室已关闭');
|
|
1677
|
+
* ```
|
|
1678
|
+
*/
|
|
1679
|
+
sendSystemMsg(content: string, type?: SystemMsgType): void;
|
|
1680
|
+
/**
|
|
1681
|
+
* 发送自定义消息(服务端)
|
|
1682
|
+
* @param options
|
|
1683
|
+
*/
|
|
1684
|
+
sendCustomServerMsg(options: SendCustomServerMsgOptions): Promise<void>;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* 发送图片参数
|
|
1689
|
+
*/
|
|
1690
|
+
export declare interface SendImageMsgOptions extends SendMsgCommonOptions<ChatMsgImageType> {
|
|
1691
|
+
/**
|
|
1692
|
+
* 图片 id,建议使用 uuid(v4) 生成
|
|
1693
|
+
*/
|
|
1694
|
+
imageId: string;
|
|
1695
|
+
/**
|
|
1696
|
+
* 图片地址
|
|
1697
|
+
*/
|
|
1698
|
+
imageUrl: string;
|
|
1699
|
+
/**
|
|
1700
|
+
* 图片尺寸
|
|
1701
|
+
*/
|
|
1702
|
+
size?: {
|
|
1703
|
+
width: number;
|
|
1704
|
+
height: number;
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
export declare interface SendMsgCommonOptions<L extends ChatMsgType = ChatMsgType> {
|
|
1709
|
+
/**
|
|
1710
|
+
* 本地 id
|
|
1711
|
+
*/
|
|
1712
|
+
localId?: string;
|
|
1713
|
+
/**
|
|
1714
|
+
* 本地消息
|
|
1715
|
+
*/
|
|
1716
|
+
localMsg?: L;
|
|
1717
|
+
/**
|
|
1718
|
+
* 广播本地消息
|
|
1719
|
+
* @default true
|
|
1720
|
+
*/
|
|
1721
|
+
emitLocalMsg?: boolean;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
export declare type SendMsgRealtions = {
|
|
1725
|
+
[ChatMsgSource.Speak]: SendSpeakMsgOptions;
|
|
1726
|
+
[ChatMsgSource.Image]: SendImageMsgOptions;
|
|
1727
|
+
[ChatMsgSource.Emotion]: SendEmotionImageMsgOptions;
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
export declare type SendMsgRealtionsGenerateObj = {
|
|
1731
|
+
[key in SendMsgSourceType]: (_options: SendMsgRealtions[key]) => Promise<PickChatMsgType<key>>;
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
export declare type SendMsgSourceType = keyof SendMsgRealtions;
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* 发言参数
|
|
1738
|
+
*/
|
|
1739
|
+
export declare interface SendSpeakMsgOptions extends SendMsgCommonOptions<ChatMsgSpeakType> {
|
|
1740
|
+
/**
|
|
1741
|
+
* 发言内容
|
|
1742
|
+
*/
|
|
1743
|
+
content: string;
|
|
1744
|
+
/**
|
|
1745
|
+
* 引用的消息
|
|
1746
|
+
*/
|
|
1747
|
+
quoteMsg?: ChatMsgType;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
export declare interface SetAutoTranslateOptions {
|
|
1751
|
+
/**
|
|
1752
|
+
* 翻译的语言, undefined 表示关闭自动翻译
|
|
1753
|
+
*/
|
|
1754
|
+
language: TranslateLanguage | undefined;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
export declare interface SetChatSwitchOptions {
|
|
1758
|
+
/** 是否开启 */
|
|
1759
|
+
enabled: boolean;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* 状态模块
|
|
1764
|
+
*/
|
|
1765
|
+
declare class StatusModule extends ChatModuleBase {
|
|
1766
|
+
private __statusInfo;
|
|
1767
|
+
generateStatusInfo(): ChatStatusInfo;
|
|
1768
|
+
constructor(plvChat: PolyvChat);
|
|
1769
|
+
/**
|
|
1770
|
+
* 获取状态信息
|
|
1771
|
+
*/
|
|
1772
|
+
getStatusInfo(): ChatStatusInfo;
|
|
1773
|
+
private __updateStatusInfo;
|
|
1774
|
+
/**
|
|
1775
|
+
* 设置自动翻译
|
|
1776
|
+
* @param options 设置选项
|
|
1777
|
+
*/
|
|
1778
|
+
setAutoTranslate(options: SetAutoTranslateOptions): Promise<void>;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* 系统消息类型
|
|
1783
|
+
*/
|
|
1784
|
+
export declare enum SystemMsgType {
|
|
1785
|
+
/**
|
|
1786
|
+
* 聊天区通知
|
|
1787
|
+
*/
|
|
1788
|
+
ChatRoomIntroduction = "chat-room-introduction"
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
export declare interface TopingMsgData {
|
|
1792
|
+
/** 置顶 id */
|
|
1793
|
+
id: number;
|
|
1794
|
+
/** 置顶操作者头衔 */
|
|
1795
|
+
topActor: string;
|
|
1796
|
+
/** 被置顶的消息 */
|
|
1797
|
+
chatMsg: ChatMsgTypeByTop;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
export declare interface TopMsgOptions {
|
|
1801
|
+
/** 消息 id */
|
|
1802
|
+
msgId: string;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
export declare type TranslatedContents = {
|
|
1806
|
+
[lang in TranslateLanguage]?: string;
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* 翻译的语言
|
|
1811
|
+
*/
|
|
1812
|
+
export declare enum TranslateLanguage {
|
|
1813
|
+
/** 中文 */
|
|
1814
|
+
Chinese = "Chinese",
|
|
1815
|
+
/** 英文 */
|
|
1816
|
+
English = "English",
|
|
1817
|
+
/** 日文 */
|
|
1818
|
+
Japanese = "Japanese",
|
|
1819
|
+
/** 韩文 */
|
|
1820
|
+
Korean = "Korean",
|
|
1821
|
+
/** 俄文 */
|
|
1822
|
+
Russian = "Russian"
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
export declare interface TranslateSpeakOptions {
|
|
1826
|
+
/**
|
|
1827
|
+
* 发言消息
|
|
1828
|
+
*/
|
|
1829
|
+
chatMsg: ChatMsgSpeakType;
|
|
1830
|
+
/**
|
|
1831
|
+
* 目标语言
|
|
1832
|
+
*/
|
|
1833
|
+
language: TranslateLanguage;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
export declare interface TranslateSpeakResult {
|
|
1837
|
+
/**
|
|
1838
|
+
* 翻译后的语言
|
|
1839
|
+
*/
|
|
1840
|
+
language: TranslateLanguage;
|
|
1841
|
+
/**
|
|
1842
|
+
* 翻译后的内容
|
|
1843
|
+
*/
|
|
1844
|
+
content: string;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
export declare interface UploadImageResult {
|
|
1848
|
+
/** 图片 id */
|
|
1849
|
+
imageId: string;
|
|
1850
|
+
/** 图片地址 */
|
|
1851
|
+
imageUrl: string;
|
|
1852
|
+
/** 图片尺寸 */
|
|
1853
|
+
size: {
|
|
1854
|
+
width: number;
|
|
1855
|
+
height: number;
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* 多图片上传失败结果
|
|
1861
|
+
*/
|
|
1862
|
+
export declare interface UploadMultiImageFailResult {
|
|
1863
|
+
/** 图片id */
|
|
1864
|
+
imageId: string;
|
|
1865
|
+
/** 图片预览url */
|
|
1866
|
+
previewSrc: string;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
export declare interface UploadMultiImageOptions {
|
|
1870
|
+
/** 上传限制,默认为 9 张 */
|
|
1871
|
+
maxLimit?: number;
|
|
1872
|
+
/** 上传准备完成回调 */
|
|
1873
|
+
ready?: (result: UploadMultiImageReadyResult) => void;
|
|
1874
|
+
/** 上传完成回调,每上传完一张图片就会回调一次 */
|
|
1875
|
+
success?: (result: UploadMultiImageSuccessResult) => void;
|
|
1876
|
+
/** 上传失败回调,不影响后续图片上传 */
|
|
1877
|
+
fail?: (err: Error, result: UploadMultiImageFailResult) => void;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* 多图片上传准备结果(已完成图片选择)
|
|
1882
|
+
*/
|
|
1883
|
+
export declare interface UploadMultiImageReadyResult {
|
|
1884
|
+
/** 图片id */
|
|
1885
|
+
imageId: string;
|
|
1886
|
+
/** 图片预览url */
|
|
1887
|
+
previewSrc: string;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
export declare interface UploadMultiImageResult {
|
|
1891
|
+
/** 上传成功的图片集合 */
|
|
1892
|
+
successUploadImages: UploadMultiImageSuccessResult[];
|
|
1893
|
+
/** 上传失败的图片集合 */
|
|
1894
|
+
failUploadImages: UploadMultiImageFailResult[];
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* 多图片上传完成结果
|
|
1899
|
+
*/
|
|
1900
|
+
export declare type UploadMultiImageSuccessResult = UploadImageResult;
|
|
1901
|
+
|
|
1902
|
+
declare class UtilsModule extends ChatModuleBase {
|
|
1903
|
+
private __uploadImgCtrl;
|
|
1904
|
+
constructor(plvChat: PolyvChat);
|
|
1905
|
+
private __setUploadImgChannelId;
|
|
1906
|
+
/**
|
|
1907
|
+
* 选择图片文件并上传多张图片
|
|
1908
|
+
*/
|
|
1909
|
+
uploadMultiImage(params?: UploadMultiImageOptions): Promise<UploadMultiImageResult>;
|
|
1910
|
+
/**
|
|
1911
|
+
* 根据文件直接上传图片
|
|
1912
|
+
*/
|
|
1913
|
+
directUploadImage(file: File | null): Promise<UploadImageResult>;
|
|
1914
|
+
/**
|
|
1915
|
+
* 翻译文本
|
|
1916
|
+
* @param text 需要翻译的文本
|
|
1917
|
+
*/
|
|
1918
|
+
translateText(text: string): Promise<string>;
|
|
1919
|
+
private __genResourceUrl;
|
|
1920
|
+
/**
|
|
1921
|
+
* 获取默认资源
|
|
1922
|
+
* @returns 默认资源
|
|
1923
|
+
*/
|
|
1924
|
+
getDefaultResource(): ChatDefaultResource;
|
|
1925
|
+
private __svgaMap;
|
|
1926
|
+
/**
|
|
1927
|
+
* 获取默认打赏 svga 地址
|
|
1928
|
+
* @param chatMsg 打赏消息
|
|
1929
|
+
* @returns 默认打赏 svga 地址
|
|
1930
|
+
*/
|
|
1931
|
+
getDefaultDonateSvgaUrl(chatMsg: ChatMsgRewardType): Promise<string | undefined>;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
export { }
|