diff --git a/config/config.go b/config/config.go index b84cd21..dd8b353 100644 --- a/config/config.go +++ b/config/config.go @@ -9,10 +9,12 @@ import ( ) type KikiSettings struct { - Instance string `yaml:"instance,omitempty"` - RSSUri string `yaml:"rss_url,omitempty"` - Sensitive bool `yaml:"sensitive,omitempty"` - Redis struct { + Instance string `yaml:"instance,omitempty"` + RSSURLs []struct { + Url string `yaml:"url,omitempty"` + Sensitive bool `yaml:"sensitive,omitempty"` + } `yaml:"rss_urls,omitempty"` + Redis struct { Address string `yaml:"address"` } `yaml:"redis"` } diff --git a/service/kiki.go b/service/kiki.go index bb462ce..52901a9 100644 --- a/service/kiki.go +++ b/service/kiki.go @@ -74,28 +74,30 @@ func main() { if file_watcher.IsFileChange(&lastFileMod, confFile) { log.Println(lastFileMod) log.Println("RSS ленты перечитаны") - kikiConfig.RSSUri = config.GetKikiConfig(confFile).RSSUri + kikiConfig.RSSURLs = config.GetKikiConfig(confFile).RSSURLs } - newPosts := tooter.NewsText(kikiConfig.RSSUri) + for _, rssUrl := range kikiConfig.RSSURLs { + newPost := tooter.NewsText(rssUrl.Url) - for _, post := range newPosts { - inStack, err := stacker.CheckInRedis(rdb, post.GUID) - if err != nil { - log.Println(err) - } - - if !inStack { - log.Println(post.Description) - - toot, err := tooter.CreateToot(*mastoClient, post, kikiConfig.Sensitive) + for _, post := range newPost { + inStack, err := stacker.CheckInRedis(rdb, post.GUID) if err != nil { log.Println(err) } - tooter.CreatePost(*mastoClient, toot) + if !inStack { + log.Println(post.Description) - stacker.SetToRedis(rdb, post.GUID, post.Description) + toot, err := tooter.CreateToot(*mastoClient, post, rssUrl.Sensitive) + if err != nil { + log.Println(err) + } + + tooter.CreatePost(*mastoClient, toot) + + stacker.SetToRedis(rdb, post.GUID, post.Description) + } } } }