Переворошил файлы (опять), закинул всё в докер
This commit is contained in:
parent
be76c08756
commit
c853cfb592
11 changed files with 135 additions and 54 deletions
63
config/config.go
Normal file
63
config/config.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/mattn/go-mastodon"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type KikiSettings struct {
|
||||
Instance string `yaml:"instance,omitempty"`
|
||||
RSSUri string `yaml:"rss_url,omitempty"`
|
||||
Redis struct {
|
||||
Address string `yaml:"address"`
|
||||
} `yaml:"redis"`
|
||||
}
|
||||
|
||||
type MastodonClientData struct {
|
||||
ClientID string `yaml:"clientID,omitempty"`
|
||||
ClientSecret string `yaml:"clientSecret,omitempty"`
|
||||
AccessToken string `yaml:"accessToken,omitempty"`
|
||||
Instance string `yaml:"instance,omitempty"`
|
||||
}
|
||||
|
||||
func GetKikiConfig(path string) KikiSettings {
|
||||
var kikiSettings KikiSettings
|
||||
|
||||
kikiConfigFile, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(kikiConfigFile, &kikiSettings)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
return kikiSettings
|
||||
}
|
||||
|
||||
func GetSecrets(path string) *mastodon.Config {
|
||||
var clientData MastodonClientData
|
||||
|
||||
secretConfig, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(secretConfig, &clientData)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
config := &mastodon.Config{
|
||||
Server: clientData.Instance,
|
||||
ClientID: clientData.ClientID,
|
||||
ClientSecret: clientData.ClientSecret,
|
||||
AccessToken: clientData.AccessToken,
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue