-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (30 loc) · 968 Bytes
/
app.js
File metadata and controls
36 lines (30 loc) · 968 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
36
require('dotenv').config();
const SLACKTOKEN = process.env.SLACKTOKEN;
const { RTMClient } = require('@slack/rtm-api');
const { WebClient } = require('@slack/web-api');
const handle = require('./handle.js');
var restify = require('restify');
const tools = require('./tools.js');
// Initilise RTM and Web clients
const rtm = new RTMClient(SLACKTOKEN);
const web = new WebClient(SLACKTOKEN);
// Connect to Slack
(async () => {
const { self, team } = await rtm.start();
})();
rtm.on('message', function (event) {
if (event.subtype == 'message_changed') return;
if (event.type !== 'message') return;
if (event.bot_id) return;
if (!event.text.startsWith(`<@${this.activeUserId}>`)) return;
handle.message(event, this, web);
});
rtm.on('reaction_added', function(event){
handle.reaction_added(event, this, web);
})
rtm.on('error', (err) => {
handle.error(err, rtm, web)
})
rtm.on('block_payloads', function(event) {
console.log('bloack payload detected');
});