Skip to content

Instantly share code, notes, and snippets.

@kmoe
Last active August 29, 2015 14:27
Show Gist options
  • Save kmoe/5bea5b846bece9a77ef5 to your computer and use it in GitHub Desktop.
Save kmoe/5bea5b846bece9a77ef5 to your computer and use it in GitHub Desktop.
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