From 2b043760204965f336789480a6f1ef891165ff3c Mon Sep 17 00:00:00 2001 From: Kristen Borges Date: Wed, 3 Jul 2019 16:29:02 -0700 Subject: [PATCH] Update replies- fix grammar, include redirect link --- scripts/suggest.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/suggest.js b/scripts/suggest.js index a098191d..0addf91f 100644 --- a/scripts/suggest.js +++ b/scripts/suggest.js @@ -38,20 +38,28 @@ module.exports = function(robot) { let user = res.message.user let userSuggestion = res.match[1] + let targetFlowLink = FLOW_URL.replace( + /{flowName}/, + targetFlowName.toLowerCase(), + ) + let redirectToTargetFlowMessage = `You can try again from a public flow, or join us in [${targetFlowName}](${targetFlowLink}) and chat with us about your idea there.` + if (typeof res.message.room === "undefined") { - return res.send("Sorry, this command only works from flows, not DMs") + return res.send( + `Sorry, this command only works from flows, not DMs.\n${redirectToTargetFlowMessage}`, + ) } let flowData = getRoomInfoFromIdOrName(robot, res.message.room) if (flowData.access_mode === "invitation") { return res.send( - "Sorry, this command only works from public flows, to protect the privacy of your invite-only flow", + `Sorry, this command only works from public flows, to protect the privacy of your invite-only flow.\n\n${redirectToTargetFlowMessage}`, ) } if (!userSuggestion) { res.send( - "Yes? I'm listening.... \n(Please try again: this time add your suggestion after the `suggest` command)", + "Yes? I'm listening.... \n(Please try again: this time add your suggestion after the `suggest` command).", ) return } @@ -64,7 +72,7 @@ module.exports = function(robot) { ).replace(/{threadId}/, sourceThreadId) // post suggestion message & related info targetFlowName - let formattedSuggestion = `@${res.message.user.name} just made a suggestion in ${sourceFlow}:\n>${userSuggestion}\n\nSee [original thread](${sourceThreadLink})` + let formattedSuggestion = `@${res.message.user.name} just made a suggestion in ${sourceFlow}:\n>${userSuggestion}\n\nSee [original thread](${sourceThreadLink}).` let envelope = { user: "", room: targetFlowId, @@ -73,10 +81,6 @@ module.exports = function(robot) { // TODO: get link to this post robot.send(envelope, formattedSuggestion) - let targetFlowLink = FLOW_URL.replace( - /{flowName}/, - targetFlowName.toLowerCase(), - ) // then respond in source suggestion thread // TODO: add link to post in TARGET_FLOW res.send(