new(whatsapp.gblib): Native provider works in groups now.
This commit is contained in:
parent
9e84298ab0
commit
64d77b4b43
2 changed files with 29 additions and 16 deletions
|
|
@ -991,7 +991,10 @@ export class GBConversationalService {
|
||||||
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
|
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
|
||||||
|
|
||||||
if (!isNaN(member.id) && !member.id.startsWith('1000')) {
|
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 {
|
} else {
|
||||||
await step.context.sendActivity(text);
|
await step.context.sendActivity(text);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
message = req;
|
message = req;
|
||||||
text = message.body;
|
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;
|
fromName = message._data.notifyName;
|
||||||
|
|
||||||
if (message.hasMedia) {
|
if (message.hasMedia) {
|
||||||
|
|
@ -727,7 +728,16 @@ export class WhatsappDirectLine extends GBService {
|
||||||
switch (this.provider) {
|
switch (this.provider) {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
const attachment = await MessageMedia.fromUrl(url);
|
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;
|
break;
|
||||||
|
|
||||||
case 'chatapi':
|
case 'chatapi':
|
||||||
|
|
@ -859,15 +869,15 @@ export class WhatsappDirectLine extends GBService {
|
||||||
switch (this.provider) {
|
switch (this.provider) {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
|
|
||||||
if (to.length == 18)
|
if (to.indexOf('@') == -1) {
|
||||||
{
|
if (to.length == 18) {
|
||||||
to = to + '@g.us';
|
to = to + '@g.us';
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
to = to + '@c.us';
|
to = to + '@c.us';
|
||||||
}
|
}
|
||||||
this.customClient.sendMessage(to, msg);
|
}
|
||||||
|
await this.customClient.sendMessage(to, msg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue