1 | ;
|
2 | /**
|
3 | * @module botkit
|
4 | */
|
5 | /**
|
6 | * Copyright (c) Microsoft Corporation. All rights reserved.
|
7 | * Licensed under the MIT License.
|
8 | */
|
9 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
10 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
11 | return new (P || (P = Promise))(function (resolve, reject) {
|
12 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
13 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
14 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
15 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
16 | });
|
17 | };
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | /**
|
20 | * This class is used to provide easy access to common actions taken on active BotkitConversation instances.
|
21 | * These objects are passed into handlers bound to BotkitConversations using .before .onChange and conditional handler functions passed to .ask and .addQuestion
|
22 | * Grants access to convo.vars convo.gotoThread() convo.setVar() and convo.repeat().
|
23 | */
|
24 | class BotkitDialogWrapper {
|
25 | constructor(dc, step) {
|
26 | this.dc = dc;
|
27 | this.step = step;
|
28 | this.vars = this.step.values;
|
29 | }
|
30 | /**
|
31 | * Jump immediately to the first message in a different thread.
|
32 | * @param thread Name of a thread
|
33 | */
|
34 | gotoThread(thread) {
|
35 | return __awaiter(this, void 0, void 0, function* () {
|
36 | this.step.index = 0;
|
37 | this.step.thread = thread;
|
38 | });
|
39 | }
|
40 | /**
|
41 | * Repeat the last message sent on the next turn.
|
42 | */
|
43 | repeat() {
|
44 | return __awaiter(this, void 0, void 0, function* () {
|
45 | // move back one step next turn the bot will repeat with the last message sent.
|
46 | this.step.index--;
|
47 | });
|
48 | }
|
49 | /**
|
50 | * Stop the dialog.
|
51 | */
|
52 | stop() {
|
53 | return __awaiter(this, void 0, void 0, function* () {
|
54 | // set this to 1 bigger than the total length of the thread.
|
55 | this.step.index = this.step.threadLength + 1;
|
56 | });
|
57 | }
|
58 | /**
|
59 | * Set the value of a variable that will be available to messages in the conversation.
|
60 | * Equivalent to convo.vars.key = val;
|
61 | * Results in {{vars.key}} being replaced with the value in val.
|
62 | * @param key the name of the variable
|
63 | * @param val the value for the variable
|
64 | */
|
65 | setVar(key, val) {
|
66 | this.vars[key] = val;
|
67 | }
|
68 | }
|
69 | exports.BotkitDialogWrapper = BotkitDialogWrapper;
|
70 | //# sourceMappingURL=dialogWrapper.js.map |
\ | No newline at end of file |