-
Notifications
You must be signed in to change notification settings - Fork 1
/
followEvent.go
49 lines (41 loc) · 922 Bytes
/
followEvent.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
package twitch
import (
"encoding/json"
"time"
)
type FollowEventData struct {
ChannelId string
Username string
UserId string
timestamp time.Time
}
func (e *FollowEventData) GetType() EventType {
return EventFollow
}
func (e *FollowEventData) GetData() interface{} {
return e
}
func (e *FollowEventData) 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),
}
}
func (e *FollowEventData) AsJson() string {
s, _ := json.Marshal(e.AsMap())
return string(s)
}
func (e *FollowEventData) Timestamp() time.Time {
return e.timestamp
}
func MakeFollowEventData(channelId, username, userId string) ChatEvent {
return &FollowEventData{
ChannelId: channelId,
Username: username,
UserId: userId,
timestamp: time.Now(),
}
}