Пример #1
0
func BasicDecision(s *session.Session, follows int, likes int, intervals int, done chan bool) {
	// Round robin the hashtags. Allows for manual weighting eg: [#dog,#dog,#cute]
	posts := http.GetPosts(s, s.GetHashtag(intervals))

	// Go from end to reduce collision
	// Doesn't bother checking
	i := 19
	for (likes > 0 || follows > 0) && i >= 0 {

		// Process likes
		if likes > 0 {
			go http.LikePosts(s, posts.Data[i].Id)
			likes--

			// Doing this seperately reaches larger audience
			// Never exceeds 12/11 at a given time
		} else if follows > 0 {
			go http.FollowUser(s, posts.Data[i].Id)
			follows--
		}

		// Decrement
		i--
	}

	// Indicate doneness
	done <- true
}
Пример #2
0
func IntelligentDecision(s *session.Session, follows int, likes int, intervals int, done chan bool) {

	// Still do round robin, but this time the hashtags are smart
	// and our choice is educated
	posts := http.GetPosts(s, s.GetHashtag(intervals))

	// Set up channels for async download/ processing from instagram
	next := make(chan *http.Posts)
	grp := make(chan *group)
	count := 0
	calls := 0
	go sort(s, grp, follows, likes, &calls, &count, done)
	go listen(s, grp, next, &calls, &count)
	next <- &posts
}