From 4134289d0ecef1edd6e28fc8f8534a55625d6ac0 Mon Sep 17 00:00:00 2001 From: rek2 Date: Fri, 22 Oct 2021 20:12:05 +0200 Subject: [PATCH] add comments for clarity on algorithm --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 421e8cc..45b3a4e 100644 --- a/main.go +++ b/main.go @@ -79,15 +79,20 @@ func mastodonTask(c *mastodon.Client, feedURL string, ignore []string) { // gets feeds feeds := parseFeed(feedURL) - // selects a ramdon item from the feed - //rand.Seed(time.Now().UnixNano()) - //randToot := feeds[rand.Intn(len(feeds))] var randToot theFeed var check int + // Algorith made up on the fly to // check if item contains ignore words + // it has to check for each of the words but stop when + // one of the words matches or + // it has already check the lenght of the string slice of ignored words + // then it ask for another rss item and repeats the check + // if no words are matched in the current item then randToot keeps its value + // and continues - rek2 for len(randToot.Title) <= 0 { + // selects a ramdon item from the feed rand.Seed(time.Now().UnixNano()) randToot = feeds[rand.Intn(len(feeds))] @@ -105,7 +110,7 @@ func mastodonTask(c *mastodon.Client, feedURL string, ignore []string) { } } randToot = theFeed{} - log.Println("salio del for loop en range") + log.Println("Ignored item against ignored words") } } // creates the formating of the toot -- 2.38.5