Last active
November 3, 2016 14:28
-
-
Save codePrincess/9009724c774cb611ba5c15bf18d3d5e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(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