Now Playing Network Replies Feature

in #utopian-io6 years ago

Repository

https://github.com/alex-osman/nowplaying/

Pull Request

https://github.com/alex-osman/nowplaying/pull/68

New Features

Same song replies

The nowplaying bot now recognizes when a track has been seen before and includes the post in the reply.
image
As our library grows we will have more and more people posting about the same song and it's a great way to meet new people with similar music tastes.

Implementation

The reply function now calls a new function addTrackReply(post: Post, track: Track, playlist: Playlist) to generate a reply.

const posts = await this._database.getPostsByTrack(track)
const text = posts.map(post => `@${post.author} posted this song on [${dateformat(post.created, 'mmmm dS')}](${post.getLink()})!`)  

The posts variable is an array of posts that contain the same song. A string with a link to that post is created for each one.

The new database function getPostsByTrack selects all posts where track_id is the same

SELECT * FROM tracks INNER JOIN posts on postId=posts.id where spotify_id=?

Now Playing

Check out the #nowplaying community and bot in action here

Commits

https://github.com/alex-osman/nowplaying/commit/239f441831dac26d2205f0079e60bdfd83ee97b1
https://github.com/alex-osman/nowplaying/commit/72a17f2ba68c83cf732f81cd0296c38f0eb93cd2
https://github.com/alex-osman/nowplaying/commit/2bbe32287bf758a05da6631ea69907a4fd9b02d8

https://github.com/alex-osman

Sort:  

Hey @walnut1
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Thank you for your contribution.

  1. You were using array.forEach here https://github.com/alex-osman/nowplaying/commit/239f441831dac26d2205f0079e60bdfd83ee97b1#diff-7a4b922cffcef420a6101235ce72f371L98 and then changed to for loop is there any specific reason.

  2. It is better to remove console.log() messages and to use other means of testing
    https://github.com/alex-osman/nowplaying/commit/239f441831dac26d2205f0079e60bdfd83ee97b1#diff-7a4b922cffcef420a6101235ce72f371L141

  3. When you are parsing its better to write some details about it
    https://github.com/alex-osman/nowplaying/commit/239f441831dac26d2205f0079e60bdfd83ee97b1#diff-7a4b922cffcef420a6101235ce72f371R294

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks for reviewing @codingdefined. This is my first time contributing without the utopian.io website so I apologize if some things are not in the write place.

In regards to your first point, I changed the forEach to a for loop because the for loop is synchronous, and because steem requires 20 seconds between posting, the async forEach was causing issues when having to comment on many people's posts. This deserves a comment!

Good points with (2) and (3) and I will update those to be more clear. Thanks for taking the time to review this!

Thanks for entering this week's #nowplaying!
If you would like your song added to the weekly spotify playlist, reply to this comment in the following format:

Artist
Song

If you have multiple songs, make multiple replies to this comment

@walnut1 You have received a 100% upvote from @introbot because this post did not use any bidbots and you have not used bidbots in the last 30 days!

Upvoting this comment will help keep this service running.

I saw it working, it's a cool feature... thank you so much for the great effort you pay on this unique and amazing project @walnut1 :)

Congratulations @walnut1! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - The results, the winners and the prizes

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Cool new feature and a great way to connect people with similar musical interests. Keep up the good work. May Steem be with you.

Congratulations @walnut1! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.030
BTC 58183.32
ETH 2475.34
USDT 1.00
SBD 2.38