Skip to content

Commit

Permalink
fix(all): fixed case-insensitivity for BASIC commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Dec 1, 2020
1 parent 4d80b8d commit b6aba26
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 43 deletions.
20 changes: 12 additions & 8 deletions packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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,
Expand All @@ -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));

Expand Down
13 changes: 7 additions & 6 deletions packages/azuredeployer.gbapp/services/AzureDeployerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ export class GBConversationalService {
}
}

GBLog.info(
`NLP NOT called: score: ${score} > required (nlpScore): ${min.instance.nlpScore}`
);

return false;
}

Expand Down
14 changes: 8 additions & 6 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}...`);
Expand All @@ -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 {
Expand Down Expand Up @@ -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) === '/') {
Expand All @@ -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.`
);
Expand Down
46 changes: 23 additions & 23 deletions vbscript-to-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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);
Expand All @@ -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 + "}";
Expand All @@ -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 + "`);";
Expand All @@ -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;

0 comments on commit b6aba26

Please sign in to comment.