~rek2/goTootRamdonVideo

4134289d0ecef1edd6e28fc8f8534a55625d6ac0 — rek2 3 years ago eca154f
add comments for clarity on algorithm
1 files changed, 9 insertions(+), 4 deletions(-)

M main.go
M main.go => main.go +9 -4
@@ 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