This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.go
45 lines (39 loc) · 1.55 KB
/
user.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
package botsbyuberswe
import (
"github.com/gempir/go-twitch-irc/v2"
"github.com/nicklaw5/helix"
"log"
"time"
)
// User represents a Twitch user connected to our application
type User struct {
TwitchID string `json:"twitch_id,omitempty"`
Email string `json:"email,omitempty"`
AccessCode string `json:"access_code,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenExpiry time.Time `json:"token_expiry,omitempty"`
Scopes []string `json:"scopes,omitempty"`
TokenType string `json:"token_type,omitempty"`
Channel Channel `json:"channel,omitempty"`
State State `json:"state,omitempty"`
Connected bool `json:"connected,omitempty"`
ConnectAttempts int `json:"connect_attempts,omitempty"`
BotToken string `json:"bot_token,omitempty"`
TwitchIRCClient *twitch.Client `json:"-"`
TwitchOAuthClient *helix.Client `json:"-"`
TwitchConnectFailures int `json:"twitch_connect_failures,omitempty"`
}
// store stores a User struct
func (u *User) store() error {
err := u.storeChannelIndex()
if err != nil {
log.Println(err)
return err
}
return storeStruct(u, "user", u.TwitchID)
}
// store stores a User struct
func (u *User) storeChannelIndex() error {
return storeStruct(u.TwitchID, "userChannel", u.Channel.Name)
}