Skip to content

Commit

Permalink
Update replies- fix grammar, include redirect link
Browse files Browse the repository at this point in the history
  • Loading branch information
kb0rg committed Jul 3, 2019
1 parent 3a9395b commit 2b04376
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 2b04376

Please sign in to comment.