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 pathbot.go
39 lines (34 loc) · 1.46 KB
/
bot.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
package botsbyuberswe
import (
"github.com/gempir/go-twitch-irc/v2"
"github.com/nicklaw5/helix"
"time"
)
// Bot represents twitch users connected via the botCallback route. These should post in users channels, Users should never post in channels
type Bot struct {
Name string `json:"name,omitempty"`
UserChannelName string `json:"user_channel_name,omitempty"`
TwitchIRCClient *twitch.Client `json:"-"`
TwitchOAuthClient *helix.Client `json:"-"`
TwitchConnectFailures int `json:"twitch_connect_failures,omitempty"`
AccessCode string `json:"access_code,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
Connected bool `json:"connected,omitempty"`
ConnectAttempts int `json:"connect_attempts,omitempty"`
UserTwitchID string `json:"user_twitch_id,omitempty"`
TokenExpiry time.Time `json:"token_expiry,omitempty"`
}
// BotToken is used to identify which user the bot should link to when using the botCallback route
type BotToken struct {
Token string
TwitchID string
}
// store stores a Bot struct in the database
func (b *Bot) store() error {
return storeStruct(b, "bot", b.UserTwitchID)
}
// store stores a BotToken struct in the database
func (b *BotToken) store() error {
return storeStruct(b, "bottoken", b.Token)
}