-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
41 lines (33 loc) · 816 Bytes
/
server.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
34
35
36
37
38
39
const SlackBot=require('slackbots')
const axios=require('axios')
const dotenv=require('dotenv')
dotenv.config()
const bot = new SlackBot({
token: `${process.env.BOT_TOKEN}`,
name: 'deca'
})
bot.on('start', () => {
const params = {
icon_emoji: ':robot_face:'
}
bot.postMessageToChannel(
'random',
'Get inspired while working with @deca',
params
);
})
bot.on('message', (data) => {
const params = {
icon_emoji: ':male-technologist:'
}
if(data.type== 'desktop_notification'&&(data.title)=='deca') {
bot.postMessageToChannel(
data.subtitle.slice(1,),
data.content.replace('@deca',''),
params
)
}
})
bot.on('error',(err)=>{
console.log(err)
})