1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | const converters_1 = require("./api/converters");
|
12 | class SlackbotDispatcher {
|
13 | constructor() {
|
14 | this.bots = new Map();
|
15 | this.interactive = (ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
16 | const body = converters_1.camel(JSON.parse(ctx.request.body.payload));
|
17 | const bot = this.bots.get(body.callbackId);
|
18 | const response = yield bot.onInteractiveMessage(body);
|
19 | ctx.body = response;
|
20 | });
|
21 | }
|
22 | add(id, bot) {
|
23 | this.bots.set(id, bot);
|
24 | }
|
25 | }
|
26 | exports.SlackbotDispatcher = SlackbotDispatcher;
|
27 |
|
\ | No newline at end of file |