Skip to content

Commit 9a1d8e7

Browse files
committed
Incremented package.json version and updated LKG build.
1 parent bc090eb commit 9a1d8e7

15 files changed

+97
-58
lines changed

Node/core/lib/DefaultLocalizer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ var DefaultLocalizer = (function () {
66
function DefaultLocalizer() {
77
}
88
DefaultLocalizer.prototype.initialize = function (settings) {
9-
if (!settings) {
10-
return;
11-
}
9+
if (settings === void 0) { settings = {}; }
1210
if (settings.botLocalePath) {
1311
this.botLocalePath = settings.botLocalePath.toLowerCase();
1412
if (this.botLocalePath.charAt(this.botLocalePath.length - 1) != '/') {

Node/core/lib/Session.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ var Session = (function (_super) {
6666
if (!this.message.type) {
6767
this.message.type = consts.messageType;
6868
}
69-
logger.debug("loading localizer for: " + this.message.textLocale);
70-
this.localizer.load(this.message.textLocale, function (err) {
69+
var locale = this.preferredLocale();
70+
this.localizer.load(locale, function (err) {
7171
if (err) {
7272
_this.error(err);
7373
}
@@ -78,30 +78,41 @@ var Session = (function (_super) {
7878
return this;
7979
};
8080
Session.prototype.error = function (err) {
81-
err = err instanceof Error ? err : new Error(err.toString());
8281
logger.info(this, 'session.error()');
83-
this.endConversation(this.options.dialogErrorMessage || 'Oops. Something went wrong and we need to start over.');
82+
if (this.options.dialogErrorMessage) {
83+
this.endConversation(this.options.dialogErrorMessage);
84+
}
85+
else {
86+
var locale = this.preferredLocale();
87+
this.endConversation(this.localizer.gettext(locale, 'default_error', consts.Library.system));
88+
}
89+
var m = err.toString();
90+
err = err instanceof Error ? err : new Error(m);
8491
this.emit('error', err);
8592
return this;
8693
};
8794
Session.prototype.preferredLocale = function (locale, callback) {
8895
if (locale) {
8996
this._locale = locale;
97+
if (this.userData) {
98+
this.userData[consts.Data.PreferredLocale] = locale;
99+
}
90100
if (this.localizer) {
91101
this.localizer.load(locale, callback);
92102
}
93103
}
94-
else {
95-
if (!this._locale) {
96-
if (this.message && this.message.textLocale) {
97-
this._locale = this.message.textLocale;
98-
}
99-
else if (this.localizer) {
100-
this._locale = this.localizer.defaultLocale();
101-
}
104+
else if (!this._locale) {
105+
if (this.userData && this.userData[consts.Data.PreferredLocale]) {
106+
this._locale = this.userData[consts.Data.PreferredLocale];
107+
}
108+
else if (this.message && this.message.textLocale) {
109+
this._locale = this.message.textLocale;
110+
}
111+
else if (this.localizer) {
112+
this._locale = this.localizer.defaultLocale();
102113
}
103-
return this._locale;
104114
}
115+
return this._locale;
105116
};
106117
Session.prototype.gettext = function (messageid) {
107118
var args = [];
@@ -158,7 +169,7 @@ var Session = (function (_super) {
158169
this.prepareMessage(m);
159170
this.batch.push(m);
160171
logger.info(this, 'session.sendTyping()');
161-
this.startBatch();
172+
this.sendBatch();
162173
return this;
163174
};
164175
Session.prototype.messageSent = function () {
@@ -358,6 +369,9 @@ var Session = (function (_super) {
358369
if (_this.batchStarted) {
359370
_this.startBatch();
360371
}
372+
if (callback) {
373+
callback(err);
374+
}
361375
}
362376
}
363377
else {

Node/core/lib/botbuilder.d.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,29 +335,29 @@ export interface ILocalizer {
335335

336336
/**
337337
* Loads a localized string for the specified language.
338-
* @param language Desired language of the string to return.
338+
* @param locale Desired locale of the string to return.
339339
* @param msgid String to use as a key in the localized string table. Typically this will just be the english version of the string.
340340
* @param namespace (Optional) namespace for the msgid keys.
341341
*/
342-
trygettext(language: string, msgid: string, namespace?: string): string;
342+
trygettext(locale: string, msgid: string, namespace?: string): string;
343343

344344
/**
345345
* Loads a localized string for the specified language.
346-
* @param language Desired language of the string to return.
346+
* @param locale Desired locale of the string to return.
347347
* @param msgid String to use as a key in the localized string table. Typically this will just be the english version of the string.
348348
* @param namespace (Optional) namespace for the msgid keys.
349349
*/
350-
gettext(language: string, msgid: string, namespace?: string): string;
350+
gettext(locale: string, msgid: string, namespace?: string): string;
351351

352352
/**
353353
* Loads the plural form of a localized string for the specified language.
354-
* @param language Desired language of the string to return.
354+
* @param locale Desired locale of the string to return.
355355
* @param msgid Singular form of the string to use as a key in the localized string table.
356356
* @param msgid_plural Plural form of the string to use as a key in the localized string table.
357357
* @param count Count to use when determining whether the singular or plural form of the string should be used.
358358
* @param namespace (Optional) namespace for the msgid and msgid_plural keys.
359359
*/
360-
ngettext(language: string, msgid: string, msgid_plural: string, count: number, namespace?: string): string;
360+
ngettext(locale: string, msgid: string, msgid_plural: string, count: number, namespace?: string): string;
361361
}
362362

363363
/** Persisted session state used to track a conversations dialog stack. */
@@ -1435,7 +1435,7 @@ export class ThumbnailCard implements IIsAttachment {
14351435
toAttachment(): IAttachment;
14361436
}
14371437

1438-
/** Card builder class that simplifies building hero cards. Hero cards contain the same information as a thumbnail card, just with a larger more pronounced layout for the cards imagess. */
1438+
/** Card builder class that simplifies building hero cards. Hero cards contain the same information as a thumbnail card, just with a larger more pronounced layout for the cards images. */
14391439
export class HeroCard extends ThumbnailCard {
14401440

14411441
/**
@@ -1964,6 +1964,12 @@ export class IntentDialog extends Dialog {
19641964
* @param dialogArgs (Optional) arguments to pass the dialog that started when `dialogId` is a _{string}_.
19651965
*/
19661966
onDefault(dialogId: string|IDialogWaterfallStep[]|IDialogWaterfallStep, dialogArgs?: any): IntentDialog;
1967+
1968+
/**
1969+
* Adds a new recognizer plugin to the intent dialog.
1970+
* @param plugin The recognizer to add.
1971+
*/
1972+
recognizer(plugin: IIntentRecognizer): IntentDialog;
19671973
}
19681974

19691975
/**
@@ -2370,4 +2376,4 @@ export class BotConnectorBot extends Dialog {
23702376
/** __DEPRECATED__ use [UniversalBot](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.universalbot) and a [ConsoleConnector](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.consoleconnector) instead. */
23712377
export class TextBot extends Dialog {
23722378
replyReceived(session: Session, recognizeResult?: IRecognizeResult): void;
2373-
}
2379+
}

Node/core/lib/botbuilder.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var img = require('./cards/CardImage');
1919
var rc = require('./cards/ReceiptCard');
2020
var signin = require('./cards/SigninCard');
2121
var thumb = require('./cards/ThumbnailCard');
22+
var kb = require('./cards/Keyboard');
2223
var middleware = require('./middleware/Middleware');
2324
exports.Session = ses.Session;
2425
exports.Message = msg.Message;
@@ -32,6 +33,7 @@ exports.ReceiptItem = rc.ReceiptItem;
3233
exports.Fact = rc.Fact;
3334
exports.SigninCard = signin.SigninCard;
3435
exports.ThumbnailCard = thumb.ThumbnailCard;
36+
exports.Keyboard = kb.Keyboard;
3537
exports.Dialog = dialog.Dialog;
3638
exports.ResumeReason = dialog.ResumeReason;
3739
exports.DialogAction = actions.DialogAction;

Node/core/lib/bots/ChatConnector.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ var ChatConnector = (function () {
3636
_this.verifyBotFramework(req, res);
3737
}
3838
else {
39-
var requestData = [];
39+
var requestData = '';
4040
req.on('data', function (chunk) {
41-
requestData.push(chunk)
42-
}).on('end', function () {
43-
req.body = Buffer.concat(body).toString();
41+
requestData += chunk;
42+
});
43+
req.on('end', function () {
44+
req.body = JSON.parse(requestData);
4445
_this.verifyBotFramework(req, res);
4546
});
4647
}
@@ -243,7 +244,8 @@ var ChatConnector = (function () {
243244
callback(null, data);
244245
}
245246
else {
246-
callback(err instanceof Error ? err : new Error(err.toString()), null);
247+
var m = err.toString();
248+
callback(err instanceof Error ? err : new Error(m), null);
247249
}
248250
});
249251
}
@@ -322,7 +324,8 @@ var ChatConnector = (function () {
322324
callback(null);
323325
}
324326
else {
325-
callback(err instanceof Error ? err : new Error(err.toString()));
327+
var m = err.toString();
328+
callback(err instanceof Error ? err : new Error(m));
326329
}
327330
}
328331
});

Node/core/lib/bots/ConsoleConnector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var ConsoleConnector = (function () {
4040
ConsoleConnector.prototype.onEvent = function (handler) {
4141
this.handler = handler;
4242
};
43-
ConsoleConnector.prototype.send = function (messages, cb) {
43+
ConsoleConnector.prototype.send = function (messages, done) {
4444
for (var i = 0; i < messages.length; i++) {
4545
if (this.replyCnt++ > 0) {
4646
console.log();
@@ -58,6 +58,7 @@ var ConsoleConnector = (function () {
5858
}
5959
}
6060
}
61+
done(null);
6162
};
6263
ConsoleConnector.prototype.startConversation = function (address, cb) {
6364
var adr = utils.clone(address);

Node/core/lib/bots/Library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var Library = (function () {
4343
l = this.libraries[lib];
4444
}
4545
else {
46-
for (name in this.libraries) {
46+
for (var name in this.libraries) {
4747
l = this.libraries[name].library(lib);
4848
if (l) {
4949
break;

Node/core/lib/bots/UniversalBot.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ var UniversalBot = (function (_super) {
3737
}
3838
if (connector) {
3939
this.connector(consts.defaultConnector, connector);
40-
var asStorage = connector;
41-
if (!this.settings.storage &&
42-
typeof asStorage.getData === 'function' &&
43-
typeof asStorage.saveData === 'function') {
44-
this.settings.storage = asStorage;
45-
}
4640
}
4741
}
4842
UniversalBot.prototype.set = function (name, value) {
@@ -58,6 +52,12 @@ var UniversalBot = (function (_super) {
5852
if (connector) {
5953
this.connectors[channelId || consts.defaultConnector] = c = connector;
6054
c.onEvent(function (events, cb) { return _this.receive(events, cb); });
55+
var asStorage = connector;
56+
if (!this.settings.storage &&
57+
typeof asStorage.getData === 'function' &&
58+
typeof asStorage.saveData === 'function') {
59+
this.settings.storage = asStorage;
60+
}
6161
}
6262
else if (this.connectors.hasOwnProperty(channelId)) {
6363
c = this.connectors[channelId];
@@ -199,7 +199,7 @@ var UniversalBot = (function (_super) {
199199
}, _this.errorLogger(done));
200200
}
201201
else if (done) {
202-
done;
202+
done(null);
203203
}
204204
}));
205205
};
@@ -393,7 +393,8 @@ var UniversalBot = (function (_super) {
393393
};
394394
};
395395
UniversalBot.prototype.emitError = function (err) {
396-
var e = err instanceof Error ? err : new Error(err.toString());
396+
var m = err.toString();
397+
var e = err instanceof Error ? err : new Error(m);
397398
if (this.listenerCount('error') > 0) {
398399
this.emit('error', e);
399400
}

Node/core/lib/consts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ exports.Data = {
2020
WaterfallStep: 'BotBuilder.Data.WaterfallStep',
2121
Form: 'BotBuilder.Data.Form',
2222
Field: 'BotBuilder.Data.Field',
23-
FirstRunVersion: 'BotBuilder.Data.FirstRunVersion'
23+
FirstRunVersion: 'BotBuilder.Data.FirstRunVersion',
24+
PreferredLocale: 'BotBuilder.Data.PreferredLocale'
2425
};
2526
exports.DialogId = {
2627
Prompts: 'BotBuilder:Prompts',

Node/core/lib/dialogs/DialogAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function waterfall(steps) {
126126
}
127127
else if (steps && steps.length > 0) {
128128
try {
129-
logger.info(s, 'waterfall() step %d of %d', 0, steps.length);
129+
logger.info(s, 'waterfall() step %d of %d', 1, steps.length);
130130
s.dialogData[consts.Data.WaterfallStep] = 0;
131131
steps[0](s, r, skip);
132132
}

Node/core/lib/dialogs/IntentDialog.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ var IntentDialog = (function (_super) {
197197
}
198198
return this;
199199
};
200+
IntentDialog.prototype.recognizer = function (plugin) {
201+
this.options.recognizers.push(plugin);
202+
return this;
203+
};
200204
IntentDialog.prototype.recognizeInParallel = function (context, done) {
201205
var _this = this;
202206
var result = { score: 0.0, intent: null };
@@ -217,7 +221,8 @@ var IntentDialog = (function (_super) {
217221
done(null, result);
218222
}
219223
else {
220-
done(err instanceof Error ? err : new Error(err.toString()), null);
224+
var m = err.toString();
225+
done(err instanceof Error ? err : new Error(m), null);
221226
}
222227
});
223228
};
@@ -273,7 +278,8 @@ var IntentDialog = (function (_super) {
273278
}
274279
};
275280
IntentDialog.prototype.emitError = function (session, err) {
276-
err = err instanceof Error ? err : new Error(err.toString());
281+
var m = err.toString();
282+
err = err instanceof Error ? err : new Error(m);
277283
session.error(err);
278284
};
279285
return IntentDialog;

Node/core/lib/dialogs/LuisRecognizer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ var LuisRecognizer = (function () {
8383
callback(null, result.intents, result.entities);
8484
}
8585
else {
86-
callback(err instanceof Error ? err : new Error(err.toString()));
86+
var m = err.toString();
87+
callback(err instanceof Error ? err : new Error(m));
8788
}
8889
}
8990
catch (e) {

0 commit comments

Comments
 (0)