fix(core.gbapp): #372 fix.
This commit is contained in:
parent
49d47f6e6c
commit
dfd6981907
2 changed files with 33 additions and 31 deletions
|
@ -1230,7 +1230,7 @@ export class DialogKeywords {
|
||||||
GBLog.info(`BASIC: Markdown file ${filename} not found on database for ${min.instance.botId}.`);
|
GBLog.info(`BASIC: Markdown file ${filename} not found on database for ${min.instance.botId}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await min.conversationalService['playMarkdown'](min, md, DialogKeywords.getChannel(), mobile);
|
await min.conversationalService['playMarkdown'](min, md, DialogKeywords.getChannel(), null, mobile);
|
||||||
} else {
|
} else {
|
||||||
const gbaiName = DialogKeywords.getGBAIPath(min.botId, `gbkb`);
|
const gbaiName = DialogKeywords.getGBAIPath(min.botId, `gbkb`);
|
||||||
|
|
||||||
|
|
|
@ -308,10 +308,10 @@ export class GBConversationalService {
|
||||||
step: GBDialogStep,
|
step: GBDialogStep,
|
||||||
mobile: string,
|
mobile: string,
|
||||||
url: string,
|
url: string,
|
||||||
caption: string,
|
caption: string,
|
||||||
channel: string
|
channel: string
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return await this.sendFile(min, step, mobile, url , caption);
|
return await this.sendFile(min, step, mobile, url, caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendFile(
|
public async sendFile(
|
||||||
|
@ -393,23 +393,23 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (min.instance.smsKey && min.instance.smsSecret) {
|
if (min.instance.smsKey && min.instance.smsSecret) {
|
||||||
return new Promise((resolve: any, reject: any): any => {
|
return new Promise((resolve: any, reject: any): any => {
|
||||||
const nexmo = new Nexmo({
|
const nexmo = new Nexmo({
|
||||||
apiKey: min.instance.smsKey,
|
apiKey: min.instance.smsKey,
|
||||||
apiSecret: min.instance.smsSecret
|
apiSecret: min.instance.smsSecret
|
||||||
|
});
|
||||||
|
// tslint:disable-next-line:no-unsafe-any
|
||||||
|
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, {}, (err, data) => {
|
||||||
|
const message = data.messages ? data.messages[0] : {};
|
||||||
|
if (err || message['error-text']) {
|
||||||
|
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`);
|
||||||
|
reject(message['error-text']);
|
||||||
|
} else {
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
// tslint:disable-next-line:no-unsafe-any
|
}
|
||||||
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, {}, (err, data) => {
|
|
||||||
const message = data.messages ? data.messages[0] : {};
|
|
||||||
if (err || message['error-text']) {
|
|
||||||
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`);
|
|
||||||
reject(message['error-text']);
|
|
||||||
} else {
|
|
||||||
resolve(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ export class GBConversationalService {
|
||||||
return new Promise<string>(async (resolve, reject) => {
|
return new Promise<string>(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const oggFile = new Readable();
|
const oggFile = new Readable();
|
||||||
oggFile._read = () => {}; // _read is required but you can noop it
|
oggFile._read = () => { }; // _read is required but you can noop it
|
||||||
oggFile.push(buffer);
|
oggFile.push(buffer);
|
||||||
oggFile.push(null);
|
oggFile.push(null);
|
||||||
|
|
||||||
|
@ -526,10 +526,12 @@ export class GBConversationalService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async playMarkdown(min: GBMinInstance, answer: string, channel: string, step: GBDialogStep, mobile: string) {
|
public async playMarkdown(min: GBMinInstance, answer: string, channel: string,
|
||||||
|
step: GBDialogStep, mobile: string) {
|
||||||
|
|
||||||
const sec = new SecService();
|
const sec = new SecService();
|
||||||
const user = await sec.getUserFromSystemId(mobile?mobile:step.context.activity.from.id);
|
const user = await sec.getUserFromSystemId(mobile ? mobile : step.context.activity.from.id);
|
||||||
|
|
||||||
let text = answer;
|
let text = answer;
|
||||||
|
|
||||||
// Calls language translator.
|
// Calls language translator.
|
||||||
|
@ -904,7 +906,7 @@ export class GBConversationalService {
|
||||||
const key = min.core.getParam<string>(min.instance, 'spellcheckerKey', null);
|
const key = min.core.getParam<string>(min.instance, 'spellcheckerKey', null);
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
text = text.charAt(0).toUpperCase() + text.slice(1);
|
text = text.charAt(0).toUpperCase() + text.slice(1);
|
||||||
const data = await AzureText.getSpelledText(key, text);
|
const data = await AzureText.getSpelledText(key, text);
|
||||||
if (data !== text) {
|
if (data !== text) {
|
||||||
GBLog.info(`Spelling>: ${data}`);
|
GBLog.info(`Spelling>: ${data}`);
|
||||||
|
@ -916,7 +918,7 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async translate(min: GBMinInstance, text: string, language: string): Promise<string> {
|
public async translate(min: GBMinInstance, text: string, language: string): Promise<string> {
|
||||||
|
|
||||||
const translatorEnabled = () => {
|
const translatorEnabled = () => {
|
||||||
if (min.instance.params) {
|
if (min.instance.params) {
|
||||||
const params = JSON.parse(min.instance.params);
|
const params = JSON.parse(min.instance.params);
|
||||||
|
@ -996,7 +998,7 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async handleText (min, user, step, text: string){
|
public static async handleText(min, user, step, text: string) {
|
||||||
const sec = new SecService();
|
const sec = new SecService();
|
||||||
|
|
||||||
text = text.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi, '');
|
text = text.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi, '');
|
||||||
|
@ -1065,7 +1067,7 @@ export class GBConversationalService {
|
||||||
const groupSpell = group ? await min.core.getParam(
|
const groupSpell = group ? await min.core.getParam(
|
||||||
min.instance,
|
min.instance,
|
||||||
'Group Spell',
|
'Group Spell',
|
||||||
false): false;
|
false) : false;
|
||||||
|
|
||||||
if (textProcessed !== text && group && groupSpell) {
|
if (textProcessed !== text && group && groupSpell) {
|
||||||
await min.whatsAppDirectLine.sendToDevice(group, `Spell: ${text}`);
|
await min.whatsAppDirectLine.sendToDevice(group, `Spell: ${text}`);
|
||||||
|
@ -1129,11 +1131,11 @@ export class GBConversationalService {
|
||||||
GBLog.verbose(`Translated text(prompt): ${text}.`);
|
GBLog.verbose(`Translated text(prompt): ${text}.`);
|
||||||
}
|
}
|
||||||
if (step.activeDialog.state.options['kind'] === 'file') {
|
if (step.activeDialog.state.options['kind'] === 'file') {
|
||||||
|
|
||||||
return await step.prompt('attachmentPrompt', {});
|
return await step.prompt('attachmentPrompt', {});
|
||||||
} else {
|
} else {
|
||||||
await this.sendText(min, step, text);
|
await this.sendText(min, step, text);
|
||||||
return await step.prompt('textPrompt', {});
|
return await step.prompt('textPrompt', {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,8 +1231,8 @@ export class GBConversationalService {
|
||||||
*/
|
*/
|
||||||
public async sendOnConversation(min: GBMinInstance, user: GuaribasUser, message: any) {
|
public async sendOnConversation(min: GBMinInstance, user: GuaribasUser, message: any) {
|
||||||
if (message['buttons'] || message['sections']) {
|
if (message['buttons'] || message['sections']) {
|
||||||
await min['whatsAppDirectLine'].sendToDevice(user.userSystemId, message, user.conversationReference );
|
await min['whatsAppDirectLine'].sendToDevice(user.userSystemId, message, user.conversationReference);
|
||||||
} else if (user.conversationReference.startsWith('spaces')) {
|
} else if (user.conversationReference.startsWith('spaces')) {
|
||||||
await min['googleDirectLine'].sendToDevice(user.userSystemId, null, user.conversationReference, message);
|
await min['googleDirectLine'].sendToDevice(user.userSystemId, null, user.conversationReference, message);
|
||||||
} else {
|
} else {
|
||||||
const ref = JSON.parse(user.conversationReference);
|
const ref = JSON.parse(user.conversationReference);
|
||||||
|
|
Loading…
Add table
Reference in a new issue