Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions slack-events-api-bots/archive/src/slack-send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ function sendToSlack(slackEvent, reply) {
return;
}

console.log("Handling this event for sending back:", slackEvent);

const slackMessage = {
token: slackEvent.authorization.bot_access_token,
channel: slackEvent.channel,
Expand All @@ -33,8 +31,6 @@ function sendToSlack(slackEvent, reply) {

const requestUrl = `https://slack.com/api/chat.postMessage?${qs.stringify(slackMessage)}`;

console.log("Prepared to send this to slack: ", requestUrl);

// Send message.
https.get(requestUrl, (res) => {
console.log (`OK: responded, slack gave ${res.statusCode}`);
Expand Down
7 changes: 2 additions & 5 deletions slack-events-api-bots/cliches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ exports.handler = function(event, context, callback){
return;
}

var page = unfluff(body);
console.log(page.text);
var page = unfluff(body);

var allPromise = Promise.all([
checkDataFile('681cliches', page),
Expand All @@ -33,7 +32,7 @@ exports.handler = function(event, context, callback){
allPromise.then(function(){
// console.log("all checked");
var reply = replyWith(cliche_list);
console.log(reply);
console.log("Replying to user.");
sendToSlack(event, reply);
callback(null, {} );
})
Expand Down Expand Up @@ -69,13 +68,11 @@ function checkDataFile(file, page){

// add the match string to the global list of cliches so far
cliche_list.push(matches[0]);
console.log("matched ", matches[0], " in ", file);

}

})
.on("end", function(){
// console.log(file + " done");
return resolve();
})
.on("error", function(error){
Expand Down
4 changes: 0 additions & 4 deletions slack-events-api-bots/databot/src/slack-send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ function sendToSlack(slackEvent, reply) {
console.log ('OK: nothing to say');
return;
}

console.log("Handling this event for sending back:", slackEvent);

const slackMessage = {
token: slackEvent.authorization.bot_access_token,
Expand All @@ -33,8 +31,6 @@ function sendToSlack(slackEvent, reply) {

const requestUrl = `https://slack.com/api/chat.postMessage?${qs.stringify(slackMessage)}`;

console.log("Prepared to send this to slack: ", requestUrl);

// Send message.
https.get(requestUrl, (res) => {
console.log (`OK: responded, slack gave ${res.statusCode}`);
Expand Down
4 changes: 0 additions & 4 deletions slack-events-api-bots/screenshot/src/slack-send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ function sendToSlack(slackEvent, reply) {
return;
}

console.log("Handling this event for sending back:", slackEvent);

const slackMessage = {
token: slackEvent.authorization.bot_access_token,
channel: slackEvent.channel,
Expand All @@ -33,8 +31,6 @@ function sendToSlack(slackEvent, reply) {

const requestUrl = `https://slack.com/api/chat.postMessage?${qs.stringify(slackMessage)}`;

console.log("Prepared to send this to slack: ", requestUrl);

// Send message.
https.get(requestUrl, (res) => {
console.log (`OK: responded, slack gave ${res.statusCode}`);
Expand Down
8 changes: 1 addition & 7 deletions slack-events-api-message-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ exports.handler = function (event, context, callback) {
return team.latestAuthorization().then(
(authorization) => {

console.log("Authorization is \n", JSON.stringify(authorization));

// add the authorization info to the event
event.authorization = authorization[0].details.bot;

Expand All @@ -32,8 +30,6 @@ exports.handler = function (event, context, callback) {

console.log('Team Verified, handling message');

console.log('Event is:', event);

// Extract command words.
const commandWords = event.text.trim().split(/\s+/);

Expand Down Expand Up @@ -68,7 +64,7 @@ exports.handler = function (event, context, callback) {

sendToSlack(event, event.nlp.fulfillment.speech);

console.log(`Event posted to ${event.stage} stage with\nverb '${event.command.verb}'\npredicate ${event.command.predicate}.`);
console.log(`Event posted to ${event.stage} stage with\nverb '${event.command.verb}'`);

return routeMessage(event).catch((message) => respondOnError(event, message) );
});
Expand All @@ -80,9 +76,7 @@ exports.handler = function (event, context, callback) {
.then(
function(){
db.sequelize.sync().then(function() {
// console.log("handles before:", process._getActiveHandles().length);
return db.sequelize.close().then(function() {
// console.log("handles after:", process._getActiveHandles().length);
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions slack-events-api-message-handler/lib/models/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ var TeamStore = function(Sequelize, options) {

TeamStore.prototype.close = function(){
return this.sequelize.sync().then(function() {
console.log("handles before:", process._getActiveHandles().length);
// console.log("handles before:", process._getActiveHandles().length);
return this.sequelize.close().then(function() {
console.log("handles after:", process._getActiveHandles().length);
// console.log("handles after:", process._getActiveHandles().length);
});
});
};
Expand Down
18 changes: 0 additions & 18 deletions slack-events-api-message-handler/src/handle-shared-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ const qs = require('querystring');
function handleSharedFile(slackEvent) {
return new Promise ((resolve, reject) => {

console.log("Handling this file data:", slackEvent);

// const fileData = {
// token: slackEvent.authorization.bot_access_token,
// file: slackEvent.file.,
// text: reply,
// };
// const requestUrl = `https://slack.com/api/chat.postMessage?${qs.stringify(slackMessage)}`;
//
// console.log("Prepared to send this to slack: ", requestUrl);
//
// // Send message.
// https.get(requestUrl, (res) => {
// resolve(`OK: responded, slack gave ${res.statusCode}`);
// }).on('error', (err) => {
// reject(`ERROR: responded, but slack gave ${err.message}`);
//
// });

});
}
Expand Down
6 changes: 2 additions & 4 deletions slack-events-api-message-handler/src/process-with-nlp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ const request = require('request');
function processWithNLP(slackEvent) {
return new Promise ((resolve, reject) => {

console.log("Sending to API.ai for processing: \n", slackEvent);

// slack links can arrive like this <http://nyc.gov>
// or this <http://nyc.gov|nyc.gov> ... so pulling out
// the core link in either case.
// also remove users and channels <@UABC123555>
// even at the end of a line
// and trim
const text_to_send = slackEvent.text.replace(/\|.*>/,'').replace(/<http(\S*)>/,'http$1').replace(/<@\S*>[ $]?/,'').trim();
const datetime = Date.now();

const content = {
"query": text_to_send,
"timezone": "America/New_York",
"lang": "en",
"sessionId": slackEvent.user
"sessionId": datetime
};

request.post({
Expand All @@ -36,7 +35,6 @@ function processWithNLP(slackEvent) {
return;
}

console.log("API.AI returned: \n", response);
resolve(body.result);
return;
});
Expand Down
4 changes: 0 additions & 4 deletions slack-events-api-message-handler/src/slack-send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ function sendToSlack(slackEvent, reply) {
if (!reply) {
reject('OK: nothing to say');
}

console.log("Handling this event for sending back:", slackEvent);

const slackMessage = {
token: slackEvent.authorization.bot_access_token,
Expand All @@ -19,8 +17,6 @@ function sendToSlack(slackEvent, reply) {
};
const requestUrl = `https://slack.com/api/chat.postMessage?${qs.stringify(slackMessage)}`;

console.log("Prepared to send this to slack: ", requestUrl);

// Send message.
https.get(requestUrl, (res) => {
resolve(`OK: responded, slack gave ${res.statusCode}`);
Expand Down