Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pls Add a feature to get a random post from Top/hot/rising/new sorting #89

Open
MdKaif2782 opened this issue Jan 15, 2022 · 2 comments
Open

Comments

@MdKaif2782
Copy link

Using your Butter Smooth API for my discord bot.. Really a big help!
But the problem is its showing same posts for 2-3 times (specially for specified subreddit). It would be really good if it can be specified that by which sorting method a random meme will be generated like sort by Hot/new/Rising/Top/Gilded etc..

@ezzcodeezzlife
Copy link

would be a a great feature!

@geraldzm
Copy link

I think you can achieve this by passing the category ( top/hot/rising/new ) to the URL

func GetSubredditAPIURL(subreddit string, limit int) (url string) {
url = "https://oauth.reddit.com/r/" + subreddit + "/hot?limit=" + strconv.Itoa(limit)
return
}

like:

func GetSubredditAPIURL(subreddit string, limit int, category string) (url string) { 
 	url = "https://oauth.reddit.com/r/" + subreddit + "/"+category+"?limit=" + strconv.Itoa(limit) 
 	return 
} 

and you also need to add this new information to the cache

memes := redis.GetPostsFromCache(sub)

if err := redis.WritePostsToCache(sub, freshMemes); err != nil {
sentry.CaptureException(err)
}

like:

memes := redis.GetPostsFromCache(sub+category)
 if err := redis.WritePostsToCache(sub+category, freshMemes); err != nil { 
 	sentry.CaptureException(err) 
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants