new(basic.gbalib): New SET TRANSLATOR ON | OFF coded.
This commit is contained in:
parent
c1fe708aa7
commit
568c781d1d
3 changed files with 22 additions and 7 deletions
|
@ -177,6 +177,18 @@ export class DialogKeywords {
|
||||||
await this.min.userProfile.set(step.context, user);
|
await this.min.userProfile.set(step.context, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines translator behaviour.
|
||||||
|
*
|
||||||
|
* @example SET TRANSLATOR ON | OFF
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async setTranslatorOn(step, on) {
|
||||||
|
const user = await this.min.userProfile.get(step.context, {});
|
||||||
|
user.basicOptions.translatorOn = (on.trim() === "on");
|
||||||
|
await this.min.userProfile.set(step.context, user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the user acquired by WhatsApp API.
|
* Returns the name of the user acquired by WhatsApp API.
|
||||||
*/
|
*/
|
||||||
|
@ -252,7 +264,8 @@ export class DialogKeywords {
|
||||||
* Talks to the user by using the specified text.
|
* Talks to the user by using the specified text.
|
||||||
*/
|
*/
|
||||||
public async talk(step, text: string) {
|
public async talk(step, text: string) {
|
||||||
return await this.min.conversationalService.sendText(this.min, step, text);
|
await this.min.conversationalService['sendTextWithOptions'](this.min, step, text,
|
||||||
|
this.user.basicOptions.translatorOn, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -247,6 +247,10 @@ export class GBVMService extends GBService {
|
||||||
code = code.replace(/(set max lines)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
|
code = code.replace(/(set max lines)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
|
||||||
return `setMaxLines (step, ${$3})\n`;
|
return `setMaxLines (step, ${$3})\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
code = code.replace(/(set translator)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
|
||||||
|
return `setTranslatorOn (step, "${$3.toLowerCase()}")\n`;
|
||||||
|
});
|
||||||
|
|
||||||
code = code.replace(/set\s(.*)/gi, ($0, $1, $2) => {
|
code = code.replace(/set\s(.*)/gi, ($0, $1, $2) => {
|
||||||
return `sys().set (${$1})`;
|
return `sys().set (${$1})`;
|
||||||
|
@ -449,6 +453,9 @@ export class GBVMService extends GBService {
|
||||||
code = code.replace(/("[^"]*"|'[^']*')|\bsetMaxLines\b/gi, ($0, $1) => {
|
code = code.replace(/("[^"]*"|'[^']*')|\bsetMaxLines\b/gi, ($0, $1) => {
|
||||||
return $1 === undefined ? 'this.setMaxLines' : $1;
|
return $1 === undefined ? 'this.setMaxLines' : $1;
|
||||||
});
|
});
|
||||||
|
code = code.replace(/("[^"]*"|'[^']*')|\bsetTranslatorOn\b/gi, ($0, $1) => {
|
||||||
|
return $1 === undefined ? 'this.setTranslatorOn' : $1;
|
||||||
|
});
|
||||||
code = code.replace(/("[^"]*"|'[^']*')|\btransfer\b/gi, ($0, $1) => {
|
code = code.replace(/("[^"]*"|'[^']*')|\btransfer\b/gi, ($0, $1) => {
|
||||||
return $1 === undefined ? 'this.transfer' : $1;
|
return $1 === undefined ? 'this.transfer' : $1;
|
||||||
});
|
});
|
||||||
|
@ -692,11 +699,6 @@ export class GBVMService extends GBService {
|
||||||
const promise = min.cbMap[id].promise;
|
const promise = min.cbMap[id].promise;
|
||||||
delete min.cbMap[id];
|
delete min.cbMap[id];
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// if (step.activeDialog.state.options.previousResolve != undefined) {
|
|
||||||
// step.activeDialog.state.options.previousResolve();
|
|
||||||
// }
|
|
||||||
|
|
||||||
const opts = await promise(step, result);
|
const opts = await promise(step, result);
|
||||||
if (Object.keys(min.cbMap).length) {
|
if (Object.keys(min.cbMap).length) {
|
||||||
return await step.replaceDialog('/hear', opts);
|
return await step.replaceDialog('/hear', opts);
|
||||||
|
|
|
@ -751,7 +751,7 @@ export class GBMinService {
|
||||||
user.subjects = [];
|
user.subjects = [];
|
||||||
user.cb = undefined;
|
user.cb = undefined;
|
||||||
user.welcomed = false;
|
user.welcomed = false;
|
||||||
user.basicOptions = { maxLines: 100 };
|
user.basicOptions = { maxLines: 100, translatorOn: true };
|
||||||
|
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue