diff --git a/packages/admin.gbapp/services/GBAdminService.ts b/packages/admin.gbapp/services/GBAdminService.ts index 18227251..09d02878 100644 --- a/packages/admin.gbapp/services/GBAdminService.ts +++ b/packages/admin.gbapp/services/GBAdminService.ts @@ -108,7 +108,7 @@ export class GBAdminService implements IGBAdminService { lowerCaseAlpha: true, number: true, specialCharacter: true, - minimumLength: 12, + minimumLength: 14, maximumLength: 14 }; let password = passwordGenerator.generatePassword(options); @@ -124,7 +124,21 @@ export class GBAdminService implements IGBAdminService { lowerCaseAlpha: true, number: false, specialCharacter: false, - minimumLength: 12, + minimumLength: 14, + maximumLength: 14 + }; + + return passwordGenerator.generatePassword(options); + } + + public static getNumberIdentifier() { + const passwordGenerator = new PasswordGenerator(); + const options = { + upperCaseAlpha: false, + lowerCaseAlpha: false, + number: true, + specialCharacter: false, + minimumLength: 14, maximumLength: 14 }; @@ -226,7 +240,7 @@ export class GBAdminService implements IGBAdminService { return path.indexOf('sharepoint.com') > 0; } - public async publish(min: GBMinInstance, packageName: string, republish: boolean): Promise {} + public async publish(min: GBMinInstance, packageName: string, republish: boolean): Promise { } public static async deployPackageCommand(min: GBMinInstance, text: string, deployer: IGBDeployer) { const packageName = text.split(' ')[1]; diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index a04c169f..2f940050 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -470,7 +470,7 @@ export class GBConversationalService { text = text.toLowerCase().replace('who\'s', 'who is'); text = text.toLowerCase().replace('what\'s', 'what is'); - + const model = new LuisRecognizer({ applicationId: min.instance.nlpAppId, endpointKey: min.instance.nlpKey, @@ -640,21 +640,26 @@ export class GBConversationalService { } public async sendText(min: GBMinInstance, step, text) { + await this['sendTextWithOptions'](min, step, text, true); + } + + public async sendTextWithOptions(min: GBMinInstance, step, text, translate) { const member = step.context.activity.from; const user = await min.userProfile.get(step.context, {}); const systemUser = user.systemUser; - text = await min.conversationalService.translate( - min, - text, - systemUser.locale - ? systemUser.locale - : min.core.getParam(min.instance, 'Locale', GBConfigService.get('LOCALE')) - ); - GBLog.info(`Translated text(sendText): ${text}.`); + if (translate) { + text = await min.conversationalService.translate( + min, + text, + systemUser.locale + ? systemUser.locale + : min.core.getParam(min.instance, 'Locale', GBConfigService.get('LOCALE')) + ); + GBLog.info(`Translated text(sendText): ${text}.`); + } const analytics = new AnalyticsService(); - analytics.createMessage(min.instance.instanceId, user.conversation, null, text); if (!isNaN(member.id)) { diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index af58ebac..77a678a7 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -77,6 +77,7 @@ import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirect import fs = require('fs'); import { GuaribasConversationMessage } from '../../analytics.gblib/models'; import { GBVMService } from './GBVMService'; +import { GBAdminService } from '../../admin.gbapp/services/GBAdminService'; /** * Minimal service layer for a bot. @@ -802,7 +803,7 @@ export class GBMinService { ); let keepTextList = []; - + const replacementToken = GBAdminService['getNumberIdentifier'](); if (keepTextList) { keepTextList = keepTextList.concat(keepText.split(';')); } @@ -818,7 +819,7 @@ export class GBMinService { let i = 0; await CollectionUtil.asyncForEach(keepTextList, item => { i++; - text = text.replace(new RegExp(item.trim(), 'gi'), `KEEPTEXT${i}`); + text = text.replace(new RegExp(item.trim(), 'gi'), `${replacementToken}${i}`); }); } text = await min.conversationalService.spellCheck(min, text); @@ -868,7 +869,7 @@ export class GBMinService { let i = 0; await CollectionUtil.asyncForEach(keepTextList, item => { i++; - text = text.replace(new RegExp(`\\bKEEPTEXT${i}\\b`, 'gi'), item.trim()); + text = text.replace(new RegExp(`\\b${replacementToken}${i}\\b`, 'gi'), item.trim()); }); }