-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathGUARD_BUY.ts
46 lines (42 loc) · 1.03 KB
/
GUARD_BUY.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
import type { Message, User } from '../types/app'
import type { GuardLevel } from '../types/const'
import type { GUARD_BUY as DataType } from 'tiny-bilibili-ws'
export interface GuardBuyMsg {
user: User
/** 礼物id */
gift_id: number
/** 礼物名称 */
gift_name: string
/** 大航海信息 */
guard_level: GuardLevel
/** 价格,RMB */
price: number
/** 等级生效时间 */
start_time: number
/** 等级过期时间 */
end_time: number
}
const parser = (data: DataType): GuardBuyMsg => {
const rawData = data.data
return {
user: {
uid: rawData.uid,
uname: rawData.username,
},
gift_id: rawData.gift_id,
gift_name: rawData.gift_name,
guard_level: rawData.guard_level,
price: rawData.price,
start_time: rawData.start_time,
end_time: rawData.end_time,
}
}
export const GUARD_BUY = {
parser,
eventName: 'GUARD_BUY' as const,
handlerName: 'onGuardBuy' as const,
}
export type Handler = {
/** 舰长上舰消息 */
onGuardBuy: (msg: Message<GuardBuyMsg>) => void
}