Created
May 30, 2016 22:33
-
-
Save loafoe/f5be4c2a96262755a8deb777febcfdce to your computer and use it in GitHub Desktop.
Sample Hubot script to test hubot-matteruser DM capability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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