-
Notifications
You must be signed in to change notification settings - Fork 1
/
channelUpdateEvent.go
66 lines (56 loc) · 1.43 KB
/
channelUpdateEvent.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package twitch
import (
"encoding/json"
"time"
)
type ChannelUpdateEventData struct {
ChannelId string
Username string
UserId string
Title string
Language string
CategoryId string
CategoryName string
IsMature bool
timestamp time.Time
}
func (e *ChannelUpdateEventData) GetType() EventType {
return EventChannelUpdate
}
func (e *ChannelUpdateEventData) GetData() interface{} {
return e
}
func (e *ChannelUpdateEventData) AsMap() map[string]interface{} {
return map[string]interface{}{
"type": e.GetType(),
"username": e.Username,
"user_id": e.UserId,
"channel_id": e.ChannelId,
"timestamp": e.timestamp.Format(time.RFC3339),
"title": e.Title,
"language": e.Language,
"category_id": e.CategoryId,
"category_name": e.CategoryName,
"is_mature": e.IsMature,
}
}
func (e *ChannelUpdateEventData) AsJson() string {
s, _ := json.Marshal(e.AsMap())
return string(s)
}
func (e *ChannelUpdateEventData) Timestamp() time.Time {
return e.timestamp
}
func MakeChannelUpdateEventData(channelId, username, userId, title, language, categoryId, categoryName string, isMature bool) ChatEvent {
return &ChannelUpdateEventData{
ChannelId: channelId,
Username: username,
UserId: userId,
Title: title,
Language: language,
CategoryId: categoryId,
CategoryName: categoryName,
IsMature: isMature,
timestamp: time.Now(),
}
}