-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
35 lines (27 loc) · 1.03 KB
/
index.ts
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
import 'reflect-metadata';
import * as slack from 'serverless-slack';
import SlashCommandService from './lib/SlashCommandService';
import { NotificationService } from './lib/NotificationService';
import * as winston from 'winston';
winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, {
level: 'debug',
prettyPrint: true,
timestamp: true
});
exports.handler = slack.handler.bind(slack);
const slashCommandService = new SlashCommandService();
const notificationService = new NotificationService();
slack.on('slash_command', async (msg, bot) => {
await slashCommandService.process(msg, bot);
});
slack.on('interactive_message', async (msg, bot) => {
await slashCommandService.processAction(msg, bot);
});
slack.on('install_success', (payload) => {
notificationService.newCustomer(payload);
});
slack.on('install_error', (error,payload) => {
winston.debug(`install_error '${JSON.stringify(error)}' payload was '${JSON.stringify(payload)}'`);
//notificationService.newCustomerError(error,payload);
});