feat: Now you can register several typebots with triggers

This commit is contained in:
Davidson Gomes
2024-06-08 19:04:57 -03:00
parent 56df0caab0
commit fe9803b828
19 changed files with 1023 additions and 282 deletions

View File

@@ -502,7 +502,6 @@ export class BaileysStartupService extends ChannelStartupService {
this.loadWebsocket();
this.loadRabbitmq();
this.loadSqs();
this.loadTypebot();
this.loadProxy();
this.instance.authState = await this.defineAuthState();
@@ -1182,19 +1181,13 @@ export class BaileysStartupService extends ChannelStartupService {
}
if (this.configService.get<Typebot>('TYPEBOT').ENABLED) {
const typebotSessionRemoteJid = this.localTypebot.sessions?.find(
(session) => session.remoteJid === received.key.remoteJid,
);
if ((this.localTypebot.enabled && type === 'notify') || typebotSessionRemoteJid) {
if (!(this.localTypebot.listeningFromMe === false && messageRaw.key.fromMe === true)) {
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
if (type === 'notify') {
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name, instanceId: this.instanceId },
messageRaw.key.remoteJid,
messageRaw,
);
}
}

View File

@@ -133,7 +133,6 @@ export class BusinessStartupService extends ChannelStartupService {
this.loadWebsocket();
this.loadRabbitmq();
this.loadSqs();
this.loadTypebot();
this.eventHandler(content);
@@ -399,20 +398,12 @@ export class BusinessStartupService extends ChannelStartupService {
}
if (this.configService.get<Typebot>('TYPEBOT').ENABLED) {
const typebotSessionRemoteJid = this.localTypebot.sessions?.find(
(session) => session.remoteJid === key.remoteJid,
);
if (this.localTypebot.enabled || typebotSessionRemoteJid) {
if (!(this.localTypebot.listeningFromMe === false && key.fromMe === true)) {
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name },
messageRaw.key.remoteJid,
messageRaw,
);
}
}
if (messageRaw.messageType !== 'reactionMessage')
await this.typebotService.sendTypebot(
{ instanceName: this.instance.name },
messageRaw.key.remoteJid,
messageRaw,
);
}
await this.prismaRepository.message.create({