new(whatsapp.gblib): Native provider works in groups now.

This commit is contained in:
rodrigorodriguez 2022-10-12 02:05:26 -03:00
parent 9e84298ab0
commit 64d77b4b43
2 changed files with 29 additions and 16 deletions

View file

@ -991,7 +991,10 @@ export class GBConversationalService {
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
if (!isNaN(member.id) && !member.id.startsWith('1000')) {
await min.whatsAppDirectLine.sendToDevice(member.id, text, step.context.activity.conversation.id);
const to = step.context.activity.group? step.context.activity.group : member.id;
await min.whatsAppDirectLine.sendToDevice(to, text, step.context.activity.conversation.id);
} else {
await step.context.sendActivity(text);
}

View file

@ -344,7 +344,8 @@ export class WhatsappDirectLine extends GBService {
case 'GeneralBots':
message = req;
text = message.body;
from = message.from.split('@')[0];
from = message.from.endsWith('@g.us') ?
message.author.split('@')[0] : message.from.split('@')[0];
fromName = message._data.notifyName;
if (message.hasMedia) {
@ -727,7 +728,16 @@ export class WhatsappDirectLine extends GBService {
switch (this.provider) {
case 'GeneralBots':
const attachment = await MessageMedia.fromUrl(url);
await this.customClient.sendMessage(to + '@c.us', attachment, { caption: caption });
if (to.indexOf('@') == -1) {
if (to.length == 18) {
to = to + '@g.us';
}
else {
to = to + '@c.us';
}
}
await this.customClient.sendMessage(to, attachment, { caption: caption });
break;
case 'chatapi':
@ -859,15 +869,15 @@ export class WhatsappDirectLine extends GBService {
switch (this.provider) {
case 'GeneralBots':
if (to.length == 18)
{
if (to.indexOf('@') == -1) {
if (to.length == 18) {
to = to + '@g.us';
}
else
{
else {
to = to + '@c.us';
}
this.customClient.sendMessage(to, msg);
}
await this.customClient.sendMessage(to, msg);
break;