turnage / graw

Golang Reddit API Wrapper
MIT License
286 stars 50 forks source link

Fetching top/hot/controversial posts #25

Closed itsmehemant123 closed 7 years ago

itsmehemant123 commented 7 years ago

Any intention to support fetching posts via the other sort-orders? Or pulling on /new was intentional?

turnage commented 7 years ago

At least as part of the graw event feed, I don't intend to support other sort orders as they aren't strict. Posts may change orders in top, rising, or hot and then graw might feed them to bots twice. If you want to manually fetch in a different order, you can use the Scanner interface in the graw/reddit package e.g.:

harvest, err := bot.Listing("/r/rust/top")
if err != nil {
  fmt.Printf("lol no generics: %v", err)
} else {
  for _, post := harvest.Posts {
    // handle each post
  }
}

But be aware you may get duplicate posts and there's not a good way to know when it's appropriate to pull again (that I know of).

itsmehemant123 commented 7 years ago

Oh, that makes sense. Thanks!