fix(all): fixed case-insensitivity for BASIC commands.

This commit is contained in:
Rodrigo Rodriguez 2020-11-30 21:25:29 -03:00
parent 4d80b8d295
commit b6aba266f6
5 changed files with 54 additions and 43 deletions

View file

@ -172,7 +172,7 @@ export class AdminDialog extends IGBDialog {
await min.conversationalService.sendText(min, step, Messages[locale].finished_working);
}
} catch (error) {
await min.conversationalService.sendText(min, step, error.message?error.message: error);
await min.conversationalService.sendText(min, step, error.message ? error.message : error);
}
await step.replaceDialog('/ask', { isReturning: true });
}
@ -346,6 +346,11 @@ export class AdminDialog extends IGBDialog {
async step => {
step.activeDialog.state.authenticatorAuthorityHostUrl = step.result;
min.instance.authenticatorTenant =
step.activeDialog.state.authenticatorTenant;
min.instance.authenticatorAuthorityHostUrl =
step.activeDialog.state.authenticatorAuthorityHostUrl;
await min.adminService.updateSecurityInfo(
min.instance.instanceId,
step.activeDialog.state.authenticatorTenant,
@ -358,13 +363,12 @@ export class AdminDialog extends IGBDialog {
min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
const url = `https://login.microsoftonline.com/${
step.activeDialog.state.authenticatorTenant
}/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${urlJoin(
min.instance.botEndpoint,
min.instance.botId,
'/token'
)}&state=${state}&response_mode=query`;
const url = `https://login.microsoftonline.com/${step.activeDialog.state.authenticatorTenant
}/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${urlJoin(
min.instance.botEndpoint,
min.instance.botId,
'/token'
)}&state=${state}&response_mode=query`;
await min.conversationalService.sendText(min, step, Messages[locale].consent(url));

View file

@ -388,7 +388,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
GBLog.info(`Deploying Bot Storage...`);
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
const administratorPassword = GBAdminService.getRndPassword();
const storageServer = `${name.toLowerCase()}-storage-server`;
const storageServer = `${name.toLowerCase()}-storage-server.database.windows.net`;
const storageName = `${name}-storage`;
await this.createStorageServer(name, storageServer, administratorLogin,
administratorPassword, storageServer, instance.cloudLocation
@ -416,11 +416,12 @@ export class AzureDeployerService implements IGBInstallationDeployer {
instance.speechEndpoint = speech.endpoint;
instance.speechKey = keys.key1;
GBLog.info(`Deploying SpellChecker...`);
const spellChecker = await this.createSpellChecker(name, `${name}-spellchecker`);
keys = await this.cognitiveClient.accounts.listKeys(name, spellChecker.name);
instance.spellcheckerKey = keys.key1;
instance.spellcheckerEndpoint = spellChecker.endpoint;
// TODO: https://github.com/Azure/azure-rest-api-specs/issues/11460
// GBLog.info(`Deploying SpellChecker...`);
// const spellChecker = await this.createSpellChecker(name, `${name}-spellchecker`);
// keys = await this.cognitiveClient.accounts.listKeys(name, spellChecker.name);
// instance.spellcheckerKey = keys.key1;
// instance.spellcheckerEndpoint = spellChecker.endpoint;
GBLog.info(`Deploying Text Analytics...`);
const textAnalytics = await this.createTextAnalytics(name, `${name}-textanalytics`, instance.cloudLocation);

View file

@ -533,6 +533,10 @@ export class GBConversationalService {
}
}
GBLog.info(
`NLP NOT called: score: ${score} > required (nlpScore): ${min.instance.nlpScore}`
);
return false;
}

View file

@ -165,10 +165,6 @@ export class GBMinService {
if (user === null) {
user = await sec.ensureUser(activeMin.instance.instanceId, id, senderName, '', 'whatsapp', senderName);
await (activeMin as any).whatsAppDirectLine.sendToDevice(
id,
`Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar? Pode me falar que eu te ouço, me manda um aúdio.`
);
let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
@ -177,6 +173,10 @@ export class GBMinService {
await (activeMin as any).whatsAppDirectLine.received(req, res);
}
else {
await (activeMin as any).whatsAppDirectLine.sendToDevice(
id,
`Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar? Pode me falar que eu te ouço, me manda um aúdio.`
);
res.end();
}
} else {
@ -744,7 +744,6 @@ export class GBMinService {
const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;
const simpleLocale = context.activity.locale.substring(0, 2);
if (isVMCall) {
await GBVMService.callVM(context.activity.text, min, step, this.deployer);
} else if (context.activity.text.charAt(0) === '/') {
@ -770,7 +769,10 @@ export class GBMinService {
} else if (context.activity.text.startsWith('{"title"')) {
await step.beginDialog('/menu', JSON.parse(context.activity.text));
// Otherwise, continue to the active dialog in the stack.
} else if (!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`))) {
} else if (
!(await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`)) &&
process.env.GBKB_ENABLE_AUTO_PUBLISH === "true"
) {
await min.conversationalService.sendText(min, step,
`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`
);

View file

@ -20,7 +20,7 @@ function convert(input, name) {
exports.convert = convert;
function convertImports(input, name) {
var items = [];
var result = input.replace(/<!-- #include file="(.*?\/)?(.*?).asp" -->/g, function (input, group1, group2) {
var result = input.replace(/<!-- #include file="(.*?\/)?(.*?).asp" -->/gi, function (input, group1, group2) {
var path = group1 || './';
var file = "" + path + group2;
items.push({ name: group2, path: file });
@ -38,7 +38,7 @@ function convertImports(input, name) {
}
exports.convertImports = convertImports;
function convertCode(input) {
var result = input.replace(/<%([^=][\s\S]*?)%>/g, function (input, group1) {
var result = input.replace(/<%([^=][\s\S]*?)%>/gi, function (input, group1) {
var code = group1;
code = convertComments(code);
code = convertIfStatements(code);
@ -54,7 +54,7 @@ function convertCode(input) {
}
exports.convertCode = convertCode;
function convertExpressions(input) {
var result = input.replace(/<%=([\s\S]*?)%>/g, function (input, group1) {
var result = input.replace(/<%=([\s\S]*?)%>/gi, function (input, group1) {
var content = convertPRec(group1);
content = convertPLan(content);
return "${" + content + "}";
@ -63,7 +63,7 @@ function convertExpressions(input) {
}
exports.convertExpressions = convertExpressions;
function convertStrings(input) {
var result = input.replace(/%>([\s\S]+?)<%/g, "\nResponse.Write(`$1`);\n");
var result = input.replace(/%>([\s\S]+?)<%/gi, "\nResponse.Write(`$1`);\n");
// Entire document is a string
if (result.indexOf("<%") === -1) {
result = "Response.Write(`" + result + "`);";
@ -85,72 +85,72 @@ function convertStrings(input) {
exports.convertStrings = convertStrings;
function convertComments(input) {
var result = '';
var splitted = input.split(/(".*")/gm);
var splitted = input.split(/(".*")/gim);
for (var _i = 0, splitted_1 = splitted; _i < splitted_1.length; _i++) {
var part = splitted_1[_i];
if (part.indexOf("\"") === 0) {
result += part;
}
else {
result += part.replace(/'/g, "//");
result += part.replace(/'/gi, "//");
}
}
return result;
}
exports.convertComments = convertComments;
function convertIfStatements(input) {
var result = input.replace(/if +(.*?) +then/g, function (input, group1) {
var result = input.replace(/if +(.*?) +then/gi, function (input, group1) {
var condition = convertConditions(group1);
return "\nif (" + condition + ") {\n";
});
result = result.replace(/end if/g, "\n}\n");
result = result.replace(/else(?!{)/g, "\n}\nelse {\n");
result = result.replace(/end if/gi, "\n}\n");
result = result.replace(/else(?!{)/gi, "\n}\nelse {\n");
return result;
}
exports.convertIfStatements = convertIfStatements;
function convertSwitchStatements(input) {
var result = input.replace(/select case +(.*)/g, "\nswitch ($1) {\n");
result = result.replace(/end select/g, "\n}\n");
var result = input.replace(/select case +(.*)/gi, "\nswitch ($1) {\n");
result = result.replace(/end select/gi, "\n}\n");
return result;
}
exports.convertSwitchStatements = convertSwitchStatements;
function convertFunctions(input) {
var result = input.replace(/function +(.*)\((.*)\)/g, "\n$1 = ($2) => {\n");
result = result.replace(/end function/g, "\n}\n");
var result = input.replace(/function +(.*)\((.*)\)/gi, "\n$1 = ($2) => {\n");
result = result.replace(/end function/gi, "\n}\n");
return result;
}
exports.convertFunctions = convertFunctions;
function convertForStatements(input) {
var result = input.replace(/for +(.*to.*)/g, "\nfor ($1) {\n");
result = result.replace(/^ *next *$/gm, "}\n");
var result = input.replace(/for +(.*to.*)/gi, "\nfor ($1) {\n");
result = result.replace(/^ *next *$/gim, "}\n");
return result;
}
exports.convertForStatements = convertForStatements;
function convertConditions(input) {
var result = input.replace(/ +and +/g, " && ");
result = result.replace(/ +or +/g, " || ");
result = result.replace(/ +<> +/g, " !== ");
result = result.replace(/ += +/g, " === ");
var result = input.replace(/ +and +/gi, " && ");
result = result.replace(/ +or +/gi, " || ");
result = result.replace(/ +<> +/gi, " !== ");
result = result.replace(/ += +/gi, " === ");
return result;
}
exports.convertConditions = convertConditions;
function convertLoops(input) {
var result = input.replace(/do while +(.*)/g, function (input, group1) {
var result = input.replace(/do while +(.*)/gi, function (input, group1) {
var condition = convertConditions(group1);
return "\nwhile (" + condition + ") {\n";
});
result = result.replace(/^ *loop *$/gm, "}\n");
result = result.replace(/^ *loop *$/gim, "}\n");
return result;
}
exports.convertLoops = convertLoops;
function convertPRec(input) {
var result = input.replace(/(p_rec\("\S+?"\))/g, "$1.Value");
var result = input.replace(/(p_rec\("\S+?"\))/gi, "$1.Value");
return result;
}
exports.convertPRec = convertPRec;
function convertPLan(input) {
var result = input.replace(/(l_\S+?)\(p_lan\)/g, "$1[p_lan]");
var result = input.replace(/(l_\S+?)\(p_lan\)/gi, "$1[p_lan]");
return result;
}
exports.convertPLan = convertPLan;