New Features
Waiting 20 seconds between posts
This pull request stabilizes and cleans up the code relating to the spotify-reply integration. Rather than reading and processing all comments asynchronously, the code now runs through each reply synchronously and pauses 20 seconds between replies.
Before:

After:

Approaches
The simplest approach would be to delay each run by 20 seconds. However, that means if we have 20 contestants it would take 20*20 = 2 minutes and 40 seconds to read the replies. 50 contestants would be 16 minutes and 40 seconds. This approach does not scale well.
I could asynchornously loop through all replies and separate out the ones that nowplaying needs to respond to. Then I could synchronously loop through the list and reply with a delay between each. This takes 20 seconds per post we have to respond to, and we can't do any better than that with steem's limitations.
What I chose to do was a synchronous for loop
for (const post of authorReplies) {
await someFunction()
}
I have never experimented with the for-of loop before - it's very concise and easy to use. It is comparable to .forEach except that it runs in sequence, meaning we can return or break or continue. And if you throw an await in there, it will wait for it to resolve before continuing.
Next Steps
There is still more to be done regarding spotify replies. Right now spotify supports an "artist search" and a "track search". I have been using "track search" with ${artistName} ${trackName} which gives pretty good results. This needs to be smarter, and should probably use "track search" with ${trackName} and then search the tracks for an artist name that's similar to ${artistName}.
There is also a bit of a "bug" with the current week. If I run the bot today and do not touch it, it will always think it's week 17. This means that posts are approved if they upvoted week 17's post, not the current weeks post. This became very obvious when one user missed a week that I ran the bot, and participated in the next two weeks. Because she did not upvoted the post in which the bot was running, her posts were never getting approved even though she upvoted the next weekly posts.
Now Playing
Check out the #nowplaying community and bot in action here
Posted on Utopian.io - Rewarding Open Source Contributors
👍
Hi @walnut1, unfortunately your contribution has been rejected for the following reason
Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.
[utopian-moderator]
Okay, I have created a different contribution which contains multiple pull requests