diff --git a/packages/basic.gblib/services/GBVMService.ts b/packages/basic.gblib/services/GBVMService.ts index 6806499f..c26475a4 100644 --- a/packages/basic.gblib/services/GBVMService.ts +++ b/packages/basic.gblib/services/GBVMService.ts @@ -525,8 +525,6 @@ export class GBVMService extends GBService { const channel = this.channel; const ENTER = this.ENTER; const headers = this.headers; - let data = this.data; - let list = this.list; let httpUsername = this.httpUsername; let httpPs = this.httpPs; let today = this.today; @@ -1107,8 +1105,6 @@ export class GBVMService extends GBService { sandbox['from'] = await dk.userMobile({ pid }); sandbox['ENTER'] = String.fromCharCode(13); sandbox['headers'] = {}; - sandbox['data'] = {}; - sandbox['list'] = []; sandbox['httpUsername'] = ''; sandbox['httpPs'] = ''; sandbox['pid'] = pid; diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index d550fda5..4e143883 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -648,9 +648,15 @@ export class GBConversationalService { }); } - public async fillAndBroadcastTemplate(min: GBMinInstance, step: GBDialogStep, mobile: string, text) { + public async fillAndBroadcastTemplate(min: GBMinInstance, mobile: string, text) { + + let isMedia = text.toLowerCase().endsWith('.jpg') || text.toLowerCase().endsWith('.jpeg') + || text.toLowerCase().endsWith('.png'); + + let image = isMedia ? + /(.*)\n/gmi.exec(text)[0].trim(): + text; - let image = /(.*)\n/gmi.exec(text)[0].trim(); const gbaiName = DialogKeywords.getGBAIPath(min.botId); const fileUrl = urlJoin(process.env.BOT_URL,'kb', gbaiName, `${min.botId}.gbkb`, 'images', image); @@ -658,11 +664,13 @@ export class GBConversationalService { ? image : fileUrl; - text = text.substring(image.length).trim(); - text = text.replace(/\n/g, "\\n"); + if (!isMedia){ + text = text.substring(image.length).trim(); + text = text.replace(/\n/g, "\\n"); + } let data = { - name: 'broadcast', components: [ + name: isMedia?'broadcast_notext':'broadcast', components: [ { type: "header", parameters: [