Skip to content

Commit

Permalink
fix(gbdialog): Renamed alpha command to alpha-VBA added documentation…
Browse files Browse the repository at this point in the history
… files.
  • Loading branch information
Rodrigo Rodriguez (pragmatismo.io) committed Dec 6, 2018
1 parent 9fb431c commit 9cd66b8
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 217 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions LOCALIZATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# Localization in General Bots

## .gbapp

The localization is done by adding a strings.ts file to the root of the .gbapp package.

Empty file added SAMPLES.md
Empty file.
465 changes: 326 additions & 139 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,32 @@
"async": "2.6.1",
"async-promises": "0.2.1",
"azure-arm-cognitiveservices": "2.4.0",
"azure-arm-resource": "7.2.0",
"azure-arm-resource": "7.2.1",
"azure-arm-search": "^1.3.0-preview",
"azure-arm-sql": "5.6.0",
"azure-arm-website": "5.7.0",
"bluebird": "^3.5.3",
"body-parser": "1.18.3",
"botbuilder": "^4.1.5",
"botbuilder-ai": "^4.1.5",
"botbuilder-azure": "^4.1.5",
"botbuilder": "^4.1.7",
"botbuilder-ai": "^4.1.7",
"botbuilder-azure": "^4.1.7",
"botbuilder-choices": "^4.0.0-preview1.2",
"botbuilder-dialogs": "^4.1.5",
"botbuilder-dialogs": "^4.1.7",
"botbuilder-prompts": "^4.0.0-preview1.2",
"botlib": "0.1.8",
"chai": "4.2.0",
"child_process": "^1.0.2",
"chokidar": "2.0.4",
"cli-spinner": "^0.2.8",
"csv-parse": "3.2.0",
"csv-parse": "4.0.1",
"dotenv-extended": "2.3.0",
"express": "4.16.4",
"express-promise-router": "3.0.3",
"fs-extra": "7.0.1",
"fs-walk": "0.0.2",
"ip": "^1.1.5",
"localize": "0.4.7",
"marked": "0.5.1",
"marked": "0.5.2",
"mocha": "5.2.0",
"mocha-typescript": "1.1.17",
"ms": "2.1.1",
Expand All @@ -88,7 +88,7 @@
"ngrok": "^3.1.0",
"nyc": "^13.1.0",
"opn": "^5.4.0",
"pragmatismo-io-framework": "1.0.18",
"pragmatismo-io-framework": "1.0.19",
"process-exists": "^3.1.0",
"public-ip": "^2.4.0",
"reflect-metadata": "0.1.12",
Expand All @@ -105,8 +105,8 @@
"ts-node": "7.0.1",
"typedoc": "0.13.0",
"typedoc-plugin-external-module-name": "^1.1.3",
"typedoc-plugin-markdown": "^1.1.18",
"typescript": "3.1.6",
"typedoc-plugin-markdown": "^1.1.19",
"typescript": "3.2.1",
"url-join": "4.0.0",
"vbscript-to-typescript": "^1.0.8",
"wait-until": "0.0.2",
Expand All @@ -117,17 +117,17 @@
"@semantic-release/changelog": "^3.0.1",
"@semantic-release/commit-analyzer": "^6.1.0",
"@semantic-release/git": "^7.0.5",
"@semantic-release/github": "^5.2.1",
"@semantic-release/github": "^5.2.5",
"@semantic-release/npm": "^5.1.1",
"@semantic-release/release-notes-generator": "^7.1.4",
"@types/chai": "4.1.7",
"@types/mocha": "5.2.5",
"@types/sequelize": "4.27.30",
"@types/sequelize": "4.27.32",
"@types/url-join": "0.8.2",
"@types/winston": "2.4.4",
"ban-sensitive-files": "1.9.2",
"chai": "^4.2.0",
"commitizen": "^3.0.4",
"commitizen": "^3.0.5",
"coveralls": "^3.0.2",
"cz-conventional-changelog": "^2.1.0",
"dependency-check": "3.2.1",
Expand All @@ -138,12 +138,12 @@
"nsp": "3.2.1",
"pre-git": "3.17.1",
"prettier-standard": "8.0.1",
"semantic-release": "^15.12.0",
"semantic-release": "^15.12.4",
"standard": "12.0.1",
"travis-deploy-once": "5.0.9",
"ts-loader": "^5.3.0",
"ts-loader": "^5.3.1",
"tslint": "^5.11.0",
"tslint-microsoft-contrib": "^5.2.1"
"tslint-microsoft-contrib": "^6.0.0"
},
"eslintConfig": {
"env": {
Expand Down
85 changes: 47 additions & 38 deletions packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,27 @@ export class AdminDialog extends IGBDialog {
const packageName = text.split(' ')[1];
const importer = new GBImporter(min.core);
const deployer = new GBDeployer(min.core, importer);
await deployer.undeployPackageFromLocalPath(
min.instance,
UrlJoin('packages', packageName)
);
await deployer.undeployPackageFromLocalPath(min.instance, UrlJoin('packages', packageName));
}

public static async deployPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) {
const packageName = text.split(' ')[1];
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
await deployer.deployPackageFromLocalPath(min,
UrlJoin(additionalPath, packageName)
);
await deployer.deployPackageFromLocalPath(min, UrlJoin(additionalPath, packageName));
}

public static async rebuildIndexPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) {
await deployer.rebuildIndex(min.instance);
}

public static async addConnectionCommand(text: any, min: GBMinInstance) {
const packageName = text.split(' ')[1];
const importer = new GBImporter(min.core);
const admin = new GBAdminService(min.core);
// TODO: await admin.addConnection
}


/**
* Setup dialogs flows and define services call.
*
Expand All @@ -87,23 +95,22 @@ export class AdminDialog extends IGBDialog {
async step => {
const locale = step.context.activity.locale;
const prompt = Messages[locale].authenticate;
await step.prompt('textPrompt', prompt);
return await step.next();

return await step.prompt('textPrompt', prompt);
},
async step => {
const locale = step.context.activity.locale;
const password = step.result;
if (
password === GBConfigService.get('ADMIN_PASS') &&
GBAdminService.StrongRegex.test(password)
) {

if (password === GBConfigService.get('ADMIN_PASS')) {
await step.context.sendActivity(Messages[locale].welcome);
await step.prompt('textPrompt', Messages[locale].which_task);

return await step.prompt('textPrompt', Messages[locale].which_task);
} else {
await step.prompt('textPrompt', Messages[locale].wrong_password);
await step.endDialog();
await step.context.sendActivity(Messages[locale].wrong_password);

return await step.endDialog();
}
return await step.next();
},
async step => {
const locale = step.context.activity.locale;
Expand All @@ -114,20 +121,32 @@ export class AdminDialog extends IGBDialog {
let unknownCommand = false;

if (text === 'quit') {
await step.replaceDialog('/');
return await step.replaceDialog('/');
} else if (cmdName === 'createFarm') {
await AdminDialog.createFarmCommand(text, deployer);
await step.replaceDialog('/admin', { firstRun: false });

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'deployPackage') {
await AdminDialog.deployPackageCommand(min, text, deployer);
await step.replaceDialog('/admin', { firstRun: false });

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'redeployPackage') {
await AdminDialog.undeployPackageCommand(text, min);
await AdminDialog.deployPackageCommand(min, text, deployer);
await step.replaceDialog('/admin', { firstRun: false });

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'rebuildIndex') {
await AdminDialog.rebuildIndexPackageCommand(min, text, deployer);

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'addConnection') {
await AdminDialog.addConnectionCommand(min, text, deployer);

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'undeployPackage') {
await AdminDialog.undeployPackageCommand(text, min);
await step.replaceDialog('/admin', { firstRun: false });

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'setupSecurity') {
await AdminDialog.setupSecurity(min, step);
} else {
Expand All @@ -137,31 +156,21 @@ export class AdminDialog extends IGBDialog {
if (unknownCommand) {
await step.context.sendActivity(Messages[locale].unknown_command);
} else {
await step.context.sendActivity(
Messages[locale].finshed_working(cmdName)
);
await step.context.sendActivity(Messages[locale].finshed_working(cmdName));
}
await step.endDialog();
await step.replaceDialog('/answer', { query: text });
return await step.next();

return await step.replaceDialog('/answer', { query: text });
}
])
);
}

private static async setupSecurity(min: any, step: any) {
const locale = step.activity.locale;
const state = `${min.instance.instanceId}${Math.floor(
Math.random() * 1000000000
)}`;
await min.adminService.setValue(
min.instance.instanceId,
'AntiCSRFAttackState',
state
);
const url = `https://login.microsoftonline.com/${
min.instance.authenticatorTenant
}/oauth2/authorize?client_id=${
const state = `${min.instance.instanceId}${Math.floor(Math.random() * 1000000000)}`;
await min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
const url = `https://login.microsoftonline.com/${min.instance.authenticatorTenant}/oauth2/authorize?client_id=${
min.instance.authenticatorClientId
}&response_type=code&redirect_uri=${min.instance.botEndpoint}/${
min.instance.botId
Expand Down
21 changes: 5 additions & 16 deletions packages/analytics.gblib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,11 @@ import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript';

export class GBAnalyticsPackage implements IGBPackage {

public sysPackages: IGBPackage[] = null;

public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {

}
public unloadPackage(core: IGBCoreService): void {

}
public loadBot(min: GBMinInstance): void {

}
public unloadBot(min: GBMinInstance): void {

}
public onNewSession(min: GBMinInstance, step: any): void {

}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void {}
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: any): void {}
}
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class GBMinService {
// Processes messages.
} else if (context.activity.type === 'message') {
// Checks for /admin request.
if (context.activity.text === 'vba') {
if (context.activity.text === 'alpha-vba') {
min.sandbox.context = context;
min.sandbox.step = step;
min.sandbox['bot'].bind(min.sandbox);
Expand Down
7 changes: 7 additions & 0 deletions packages/default.gbdialog/bot.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
'
' General Bots Copyright (c) Pragmatismo.io. All rights reserved.
' Licensed under the AGPL-3.0.
'
' This BASIC file is based on this JavaScript file by Rodrigo Ruotolo:
' -> http://jsfiddle.net/roderick/dym05hsy
'
' According to our dual licensing model, this program can be used either
' under the terms of the GNU Affero General Public License, version 3,
Expand All @@ -31,6 +34,8 @@
'
'****************************************************************************



talk ("How many installments do you want to pay your Credit?")
installments = hear ()

Expand Down Expand Up @@ -85,6 +90,8 @@ else
end if


' TODO: This must be reviewed in terms of financing logic.

nInstallments = parseInt(installments)
vAmmount = parseFloat(ammount)
initialPayment = parseFloat(vAmmount) * 0.3 ' 30% of the value
Expand Down

0 comments on commit 9cd66b8

Please sign in to comment.