diff --git a/src/untappd-friends.js b/src/untappd-friends.js index fc0d96f..3c06b29 100755 --- a/src/untappd-friends.js +++ b/src/untappd-friends.js @@ -292,6 +292,31 @@ module.exports = (robot) => { contents.push(chunk); }); + // Congratulate the users that "run the board" + if (countToReturn > 1) { + const uniqueUsers = []; + const uniqueLocations = []; + obj.response.checkins.items.forEach((checkin) => { + if (!uniqueUsers.includes(formatDisplayName(checkin.user))) { + uniqueUsers.push(formatDisplayName(checkin.user)); + } + if (!uniqueLocations.includes(checkin.venue.venue_name)) { + uniqueLocations.push(checkin.venue.venue_name); + } + }); + if (uniqueLocations.length === 1 && uniqueLocations[0]) { + contents.push({ + text: `🏆 Congratulations to ${uniqueUsers.join(' + ')} for running the board at ${uniqueLocations[0]}! 🍻`, + fallback: `🏆 Congratulations to ${uniqueUsers.join(' + ')} for running the board at ${uniqueLocations[0]}! 🍻`, + }); + } else if (uniqueUsers.length === 1) { + contents.push({ + text: `🏆 Congratulations to ${uniqueUsers[0]} for running the board! 🍻`, + fallback: `🏆 Congratulations to ${uniqueUsers[0]} for running the board! 🍻`, + }); + } + } + // Slack formatting if (/slack/i.test(robot.adapterName)) { robot.messageRoom(msg.message.room, { attachments: contents, unfurl_links: false }); diff --git a/test/untappd-friends-slack_test.js b/test/untappd-friends-slack_test.js index 1b73069..bc21f5d 100644 --- a/test/untappd-friends-slack_test.js +++ b/test/untappd-friends-slack_test.js @@ -87,6 +87,10 @@ describe('hubot-untappd-friends for slack', () => { title_link: 'https://untappd.com/user/heathseals/checkin/578869664', ts: 1522406504, }, + { + text: '🏆 Congratulations to heath (heathseals) for running the board! 🍻', + fallback: '🏆 Congratulations to heath (heathseals) for running the board! 🍻', + }, ], unfurl_links: false, }, diff --git a/test/untappd-friends_test.js b/test/untappd-friends_test.js index 7412e13..1a2331d 100644 --- a/test/untappd-friends_test.js +++ b/test/untappd-friends_test.js @@ -64,6 +64,7 @@ describe('hubot-untappd-friends', () => { ['alice', '@hubot untappd'], ['hubot', 'heath (heathseals) was drinking Blonde Ale (Blonde Ale - 5%) by Gara Guzu Brewery at 49 Çukurcuma - an hour ago'], ['hubot', 'heath (heathseals) was drinking Efes Pilsen (Pilsner - Other - 5%) by Anadolu Efes at DERALIYE OTTOMAN CUISINE - 8 hours ago'], + ['hubot', '🏆 Congratulations to heath (heathseals) for running the board! 🍻'], ]); done(); } catch (err) {