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.
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