-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitsEvent.go
47 lines (39 loc) · 935 Bytes
/
bitsEvent.go
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
package twitch
import (
"encoding/json"
"github.com/racerxdl/twitchled/twitch/twitchdata"
"time"
)
type BitsV2EventData struct {
ChannelId string
Data twitchdata.BitEventsV2
timestamp time.Time
}
func (e *BitsV2EventData) GetType() EventType {
return EventBits
}
func (e *BitsV2EventData) GetData() interface{} {
return e.Data
}
func (e *BitsV2EventData) AsMap() map[string]interface{} {
return map[string]interface{}{
"type": e.GetType(),
"data": e.GetData(),
"channel_id": e.ChannelId,
"timestamp": e.timestamp.Format(time.RFC3339),
}
}
func (e *BitsV2EventData) AsJson() string {
s, _ := json.Marshal(e.AsMap())
return string(s)
}
func (e *BitsV2EventData) Timestamp() time.Time {
return e.timestamp
}
func MakeBitsV2EventData(channelId string, data twitchdata.BitEventsV2) ChatEvent {
return &BitsV2EventData{
Data: data,
ChannelId: channelId,
timestamp: time.Now(),
}
}