Skip to content

Instantly share code, notes, and snippets.

@loafoe
Created May 30, 2016 22:33
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 loafoe/f5be4c2a96262755a8deb777febcfdce to your computer and use it in GitHub Desktop.
Save loafoe/f5be4c2a96262755a8deb777febcfdce to your computer and use it in GitHub Desktop.
Sample Hubot script to test hubot-matteruser DM capability
# Description:
# Sends DMs to users
#
# Configuration:
# None
#
# Example using curl:
# curl -X POST -H "Content-Type: application/json" --data '{"msg": "Hello world!" }' http://hubot/dm/username
#
module.exports = (robot) ->
robot.router.post '/dm/:user', (req, res) ->
destUser = req.params.user
data = req.body
if data?.msg?
robot.send {room: destUser}, data.msg
res.send '{ "status": "message transmitted" }'
else
res.send '{ "status": "no message found" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment