Skip to content

Instantly share code, notes, and snippets.

@ridingintraffic
Last active October 28, 2016 21:08
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 ridingintraffic/0d8533f51dd0c18990e09539ddc9c103 to your computer and use it in GitHub Desktop.
Save ridingintraffic/0d8533f51dd0c18990e09539ddc9c103 to your computer and use it in GitHub Desktop.
module.exports = function (req, res, next) {
var userName = req.body.user_name;
var words = req.body.text;
var channel = req.body.channel_name;
var trigger = req.body.trigger_word;
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt:111.22.33.44')
var botPayload
var words = words.toLowerCase();
var splunkBunyan = require("../index");
var bunyan = require("bunyan");
...
if((words.indexOf("i am working on it") !=-1) || (words.indexOf("im working on it") !=-1) || (words.indexOf("Im workin on it") !=-1) ||(words.indexOf("I'm workin on it") !=-1) || (words.indexOf("im workin on it") !=-1) || (words.indexOf("i'm working on it") !=-1)){
client.on('connect', function () {
client.subscribe('siren/team01/status')
client.publish('siren/team01/status', 'off')
client.end()})
botPayload = {
text : 'thank you, ' + userName + '\nyour response has been noted and the lights are now off'
};
if (userName !== 'DevOps') {
return res.status(200).json(botPayload);
} else {
return res.status(200).end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment