1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | const botbuilder_1 = require("botbuilder");
|
20 | const botframework_connector_1 = require("botframework-connector");
|
21 | const teamsHelpers_1 = require("./teamsHelpers");
|
22 | const os = require("os");
|
23 | const pjson = require('../package.json');
|
24 |
|
25 | const ARCHITECTURE = os.arch();
|
26 | const TYPE = os.type();
|
27 | const RELEASE = os.release();
|
28 | const NODE_VERSION = process.version;
|
29 | const USER_AGENT = `Microsoft-BotFramework/3.1 Botkit/${pjson.version} ` +
|
30 | `(Node.js,Version=${NODE_VERSION}; ${TYPE} ${RELEASE}; ${ARCHITECTURE})`;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | class BotkitBotFrameworkAdapter extends botbuilder_1.BotFrameworkAdapter {
|
38 | constructor() {
|
39 | super(...arguments);
|
40 | this.botkit_worker = teamsHelpers_1.TeamsBotWorker;
|
41 | }
|
42 | |
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | createConnectorClient(serviceUrl) {
|
49 | const client = new botframework_connector_1.ConnectorClient(this.credentials, { baseUri: serviceUrl, userAgent: USER_AGENT });
|
50 | return client;
|
51 | }
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | createTokenApiClient(serviceUrl) {
|
59 | const client = new botframework_connector_1.TokenApiClient(this.credentials, { baseUri: serviceUrl, userAgent: USER_AGENT });
|
60 | return client;
|
61 | }
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | getChannels(context) {
|
69 | return __awaiter(this, void 0, void 0, function* () {
|
70 | if (context.activity.channelData && context.activity.channelData.team) {
|
71 | const channels = yield botbuilder_1.TeamsInfo.getTeamChannels(context);
|
72 | return channels ? channels.map((c) => { if (!c.name) {
|
73 | c.name = 'General';
|
74 | } return c; }) : [];
|
75 | }
|
76 | else {
|
77 | console.error('getChannels cannot be called from unknown team');
|
78 | return [];
|
79 | }
|
80 | });
|
81 | }
|
82 | }
|
83 | exports.BotkitBotFrameworkAdapter = BotkitBotFrameworkAdapter;
|
84 |
|
\ | No newline at end of file |