multi_feed #6

Merged
B4D_US3R merged 4 commits from multi_feed into master 2025-05-12 07:21:31 +00:00
2 changed files with 22 additions and 18 deletions
Showing only changes of commit 47242e5431 - Show all commits

View file

@ -9,10 +9,12 @@ import (
) )
type KikiSettings struct { type KikiSettings struct {
Instance string `yaml:"instance,omitempty"` Instance string `yaml:"instance,omitempty"`
RSSUri string `yaml:"rss_url,omitempty"` RSSURLs []struct {
Sensitive bool `yaml:"sensitive,omitempty"` Url string `yaml:"url,omitempty"`
Redis struct { Sensitive bool `yaml:"sensitive,omitempty"`
} `yaml:"rss_urls,omitempty"`
Redis struct {
Address string `yaml:"address"` Address string `yaml:"address"`
} `yaml:"redis"` } `yaml:"redis"`
} }

View file

@ -74,28 +74,30 @@ func main() {
if file_watcher.IsFileChange(&lastFileMod, confFile) { if file_watcher.IsFileChange(&lastFileMod, confFile) {
log.Println(lastFileMod) log.Println(lastFileMod)
log.Println("RSS ленты перечитаны") 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 { for _, post := range newPost {
inStack, err := stacker.CheckInRedis(rdb, post.GUID) 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)
if err != nil { if err != nil {
log.Println(err) 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)
}
} }
} }
} }