Last active
August 29, 2015 14:27
-
-
Save kmoe/5bea5b846bece9a77ef5 to your computer and use it in GitHub Desktop.
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
module['exports'] = function kahootHighFive (hook) { | |
var request = require('request'); | |
var params = hook.params; | |
console.log(params); | |
var store = hook.datastore; | |
if (params.token === hook.env.highfive_token) { | |
var originalChannelRequestParams = { | |
uri: hook.env.highfive_url, | |
method: 'POST', | |
json: { | |
"text": "@" + params.user_name + " sent a high five to " + params.text, | |
"parse": "full", | |
"unfurl_links": "true", | |
"channel": "#" + params.channel_name | |
} | |
}; | |
request(originalChannelRequestParams, function (error, response, body) { | |
hook.res.end(); | |
}); | |
if (params.channel_name !== "kahoodos") { | |
var kahoodosRequestParams = { | |
uri: hook.env.highfive_url, | |
method: 'POST', | |
json: { | |
"text": "@" + params.user_name + " sent a high five to " + params.text, | |
"parse": "full", | |
"unfurl_links": "true" | |
} | |
}; | |
request(kahoodosRequestParams, function (error, response, body) { | |
hook.res.end(); | |
}); | |
} | |
} else { | |
hook.res.end("Please contact Katy with the following error: Incorrect token."); | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment