-
Notifications
You must be signed in to change notification settings - Fork 3
/
AnchorLotEnd.ts
51 lines (48 loc) · 1.21 KB
/
AnchorLotEnd.ts
1
2
3
4
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
import type { EventInfo } from '../types/event'
import type { AnchorLotAward, Message } from '../types/message'
import { normalizeMessage } from '../utils/message'
export interface AnchorLotEndData {
/** 天选时刻Id */
id: number
/** 奖品 */
award: AnchorLotAward
/** 中奖用户信息 */
winners: {
/** 用户Id */
uid: number
/** 用户名 */
uname: string
/** 用户头像 */
face: string
/** 直播等级 */
level: number
/** 中奖数量 */
num: number
}[]
}
function dataProcessor(rawData: any): Message<AnchorLotEndData> {
const { data } = rawData
const newData: AnchorLotEndData = {
id: data.id,
award: {
name: data.award_name,
num: data.award_num,
type: data.award_type,
image: data.award_image,
priceText: data.award_price_text,
},
winners: data.award_users.map((user: any) => ({
uid: user.uid,
uname: user.uname,
face: user.face,
level: user.level,
num: user.num,
})),
}
return normalizeMessage(rawData.cmd, newData, rawData)
}
export const AnchorLotEndEvent: EventInfo<AnchorLotEndData> = {
cmdName: 'ANCHOR_LOT_AWARD',
handlerName: 'onAnchorLotEnd',
dataProcessor,
}