-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·35 lines (27 loc) · 907 Bytes
/
Copy pathapp.js
File metadata and controls
executable file
·35 lines (27 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const slackBot = require('slackbots');
const dotenv = require('dotenv').config();
const ConversationHelper = require('./helpers/conversation.helper');
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true });
const bot = new slackBot({
token: process.env.SLACK_BOT_TOKEN,
name: process.env.SLACK_BOT_NAME
});
// Wake Up Jarvis
bot.on('start', () => {
// Message Handler
bot.on('message', (data) => {
if(data.type !== 'message' || !data.user){
return;
}
return ConversationHelper.conversationMaster(data.text.toLowerCase(), data.user, '').then(response => {
bot.postTo(
response.channel,
response.message
)
});
});
// Troubleshoot Jarvis
// bot.on('error', (err) => console.log(err));
});