-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (29 loc) · 958 Bytes
/
index.js
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
var Bot = require('slackbots');
const BOT_TOKEN = process.env.BOT_TOKEN;
const BOT_NAME = process.env.BOT_NAME || 'yellingbot';
var settings = {
token: BOT_TOKEN,
name: BOT_NAME,
};
var bot = new Bot(settings);
bot.on('start', function() {
bot.getChannels().then(({ channels }) => {
bot.getGroups()
.then(({ groups }) => {
return channels
.filter(c => c.is_member)
.concat(groups).map(g => g.id);
})
.then(groupsIds => {
bot.on('message', (data) => {
if (data.type === 'message'
&& data.username !== 'yellingbot'
&& groupsIds.includes(data.channel)
&& data.text !== data.text.toUpperCase()){
bot.postMessage(data.channel, `HEY!! YOU SHOULD YELL HERE!!! BE NICE AND FOLLOW THE RULES!!`);
}
});
console.log('Yelling Bot is Up and Running!');
});
});
});