2019-05-10 08:21:59 +00:00
|
|
|
package settings
|
|
|
|
|
2019-05-10 08:53:58 +00:00
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2019-05-10 08:21:59 +00:00
|
|
|
const (
|
2019-06-23 13:12:35 +00:00
|
|
|
version = "4.0.0"
|
|
|
|
twitchUser = "galchedbot"
|
|
|
|
twitchIRCRoom = "galched"
|
2019-05-10 12:55:43 +00:00
|
|
|
discordTokenPath = "./tokens/.discordtoken"
|
2019-06-23 13:12:35 +00:00
|
|
|
twitchTokenPath = "./tokens/.twitchtoken"
|
2019-05-10 12:55:43 +00:00
|
|
|
subdayDataPath = "./backups/subday"
|
2019-05-10 12:16:35 +00:00
|
|
|
|
|
|
|
// Permitted roles in discord for subday
|
|
|
|
subRole1 = "433672344737677322"
|
|
|
|
subRole2 = "433680494635515904"
|
|
|
|
galchedRole = "301467455497175041"
|
|
|
|
smorcRole = "301470784491356172"
|
2019-05-10 08:21:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Settings struct {
|
2019-05-10 12:55:43 +00:00
|
|
|
Version string
|
|
|
|
DiscordToken string
|
2019-06-23 13:12:35 +00:00
|
|
|
TwitchUser string
|
|
|
|
TwitchIRCRoom string
|
|
|
|
TwitchToken string
|
2019-05-10 12:55:43 +00:00
|
|
|
SubdayDataPath string
|
|
|
|
PermittedRoles []string
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-05-10 08:53:58 +00:00
|
|
|
func New() (*Settings, error) {
|
|
|
|
discordToken, err := ioutil.ReadFile(discordTokenPath)
|
|
|
|
if err != nil {
|
2019-05-10 12:16:35 +00:00
|
|
|
log.Print("settings: cannot read discord token file", err)
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|
2019-06-23 13:12:35 +00:00
|
|
|
twitchToken, err := ioutil.ReadFile(twitchTokenPath)
|
|
|
|
if err != nil {
|
|
|
|
log.Print("settings: cannot read twitch token file", err)
|
|
|
|
}
|
2019-05-10 08:53:58 +00:00
|
|
|
|
|
|
|
return &Settings{
|
2019-05-10 12:55:43 +00:00
|
|
|
Version: version,
|
|
|
|
DiscordToken: string(discordToken),
|
2019-06-23 13:12:35 +00:00
|
|
|
TwitchToken: string(twitchToken),
|
|
|
|
TwitchUser: twitchUser,
|
|
|
|
TwitchIRCRoom: twitchIRCRoom,
|
2019-05-10 12:55:43 +00:00
|
|
|
SubdayDataPath: subdayDataPath,
|
|
|
|
PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole},
|
2019-05-10 08:53:58 +00:00
|
|
|
}, nil
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|