Skip to content

Instantly share code, notes, and snippets.

@lukaszlenart
Last active March 27, 2018 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszlenart/09dec14ca6b58b390e3e05684d9dc1ce to your computer and use it in GitHub Desktop.
Save lukaszlenart/09dec14ca6b58b390e3e05684d9dc1ce to your computer and use it in GitHub Desktop.
robot.respond /show survey$/i, (msg) ->
msg.finish()
loadSurveys()
.then (surveys) ->
attachments = []
attachments.push
title: survey.fullName
title_link: survey.linkToResult()
attachments
.then (attachments) ->
response = undefined
if attachments.length > 0
response =
text: "Here is a list of active surveys:"
attachments: attachments
username: robot.name
as_user: true
else
response = "There are not active surveys."
response
.then (response) ->
robot.logger.info JSON.stringify(response)
msg.send response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment