From 6130f01565069c8427f940f4e9ede9413221664b Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Mon, 6 May 2024 17:52:08 -0300 Subject: [PATCH] new(whatsapp.gblib): New WhatsApp provider: Meta. --- packages/basic.gblib/services/DialogKeywords.ts | 13 +++++++++++++ .../basic.gblib/services/KeywordsExpressions.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index b70b6a36..c9e31657 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -612,6 +612,19 @@ export class DialogKeywords { return await this.internalSendFile({ pid, mobile, channel: proc.channel, filename, caption }); } + /** + * Sends a template to a given mobile. + * + * @example SEND TEMPLATE TO "+199988887777","image.jpg" + * + */ + public async sendTemplateTo({ pid, mobile, filename: text}) { + const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); + GBLogEx.info(min, `BASIC: SEND TEMPLATE TO '${mobile}',filename '${text}'.`); + const service = new GBConversationalService(min.core); + return await service.fillAndBroadcastTemplate(min, mobile, text); + } + /** * Sends a file to the current user. * diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 0f9d405e..4d6c0a4d 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1028,7 +1028,7 @@ export class KeywordsExpressions { /^\s*(send template to)(\s*)(.*)/gim, ($0, $1, $2, $3) => { const params = this.getParams($3, ['mobile', 'text']); - return `await dk.fillAndBroadcastTemplate({pid: pid, ${params}})`; + return `await dk.sendTemplateTo({pid: pid, ${params}})`; } ];