Skip to content

Instantly share code, notes, and snippets.

@codePrincess
Last active November 3, 2016 14:28
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 codePrincess/9009724c774cb611ba5c15bf18d3d5e5 to your computer and use it in GitHub Desktop.
Save codePrincess/9009724c774cb611ba5c15bf18d3d5e5 to your computer and use it in GitHub Desktop.
module.exports = function(context, req) {
context.log('push data:', req.body);
var str = req.body;
var results = str.split("&");
var slackText = getParam(results, "text").replace(/\+/g, " ").replace(/mytodo/g, "");
var userName = getParam(results, "user_name").replace(/\+/g, " ");
context.log(getParam(results, "token"));
context.log(getParam(results, "channel_name"));
context.log(userName);
context.log(slackText);
context.log(getParam(results, "trigger_word"));
context.bindings.output = {
title: slackText,
details: "from " + userName,
completed: false
}
context.done();
};
function getParam (array, paramName) {
for (i = 0; i < array.length; i++) {
var res = array[i];
if (res.includes(paramName)) {
var param = res.substring(res.indexOf("=")+1);
return param;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment