mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: settings on dify, flowise and openai
This commit is contained in:
parent
726b0dcbb2
commit
ffac87835b
@ -736,17 +736,25 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
|||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let expire = findBot?.expire;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let keywordFinish = findBot?.keywordFinish;
|
||||||
let debounceTime = findBot.debounceTime;
|
let delayMessage = findBot?.delayMessage;
|
||||||
|
let unknownMessage = findBot?.unknownMessage;
|
||||||
|
let listeningFromMe = findBot?.listeningFromMe;
|
||||||
|
let stopBotFromMe = findBot?.stopBotFromMe;
|
||||||
|
let keepOpen = findBot?.keepOpen;
|
||||||
|
let debounceTime = findBot?.debounceTime;
|
||||||
|
let ignoreJids = findBot?.ignoreJids;
|
||||||
|
|
||||||
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
if (!expire) expire = settings.expire;
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
||||||
|
if (!delayMessage) delayMessage = settings.delayMessage;
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
||||||
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
}
|
if (!keepOpen) keepOpen = settings.keepOpen;
|
||||||
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
|
if (!ignoreJids) ignoreJids = settings.ignoreJids;
|
||||||
|
|
||||||
const key = msg.key as {
|
const key = msg.key as {
|
||||||
id: string;
|
id: string;
|
||||||
@ -782,7 +790,18 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
debouncedContent,
|
debouncedContent,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
@ -793,7 +812,18 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
content,
|
content,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { InstanceDto } from '@api/dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import { PrismaRepository } from '@api/repository/repository.service';
|
import { PrismaRepository } from '@api/repository/repository.service';
|
||||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||||
@ -14,7 +15,7 @@ export class DifyService {
|
|||||||
private readonly waMonitor: WAMonitoringService,
|
private readonly waMonitor: WAMonitoringService,
|
||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly prismaRepository: PrismaRepository,
|
private readonly prismaRepository: PrismaRepository,
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
private readonly logger = new Logger('DifyService');
|
private readonly logger = new Logger('DifyService');
|
||||||
|
|
||||||
@ -349,12 +350,7 @@ export class DifyService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sendMessageWhatsApp(
|
private async sendMessageWhatsApp(instance: any, remoteJid: string, message: string, settings: DifySetting) {
|
||||||
instance: any,
|
|
||||||
remoteJid: string,
|
|
||||||
message: string,
|
|
||||||
settings: DifySetting
|
|
||||||
) {
|
|
||||||
const linkRegex = /(!?)\[(.*?)\]\((.*?)\)/g;
|
const linkRegex = /(!?)\[(.*?)\]\((.*?)\)/g;
|
||||||
|
|
||||||
let textBuffer = '';
|
let textBuffer = '';
|
||||||
@ -393,20 +389,18 @@ export class DifyService {
|
|||||||
delay: settings?.delayMessage || 1000,
|
delay: settings?.delayMessage || 1000,
|
||||||
text: textBuffer.trim(),
|
text: textBuffer.trim(),
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
textBuffer = '';
|
textBuffer = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaType === 'audio') {
|
if (mediaType === 'audio') {
|
||||||
await instance.audioWhatsapp(
|
await instance.audioWhatsapp({
|
||||||
{
|
number: remoteJid.split('@')[0],
|
||||||
number: remoteJid.split('@')[0],
|
delay: settings?.delayMessage || 1000,
|
||||||
delay: settings?.delayMessage || 1000,
|
audio: url,
|
||||||
audio: url,
|
caption: altText,
|
||||||
caption: altText,
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
await instance.mediaMessage(
|
await instance.mediaMessage(
|
||||||
{
|
{
|
||||||
@ -416,7 +410,7 @@ export class DifyService {
|
|||||||
media: url,
|
media: url,
|
||||||
caption: altText,
|
caption: altText,
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -440,7 +434,7 @@ export class DifyService {
|
|||||||
delay: settings?.delayMessage || 1000,
|
delay: settings?.delayMessage || 1000,
|
||||||
text: textBuffer.trim(),
|
text: textBuffer.trim(),
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,17 +708,25 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
|||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let expire = findBot?.expire;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let keywordFinish = findBot?.keywordFinish;
|
||||||
let debounceTime = findBot.debounceTime;
|
let delayMessage = findBot?.delayMessage;
|
||||||
|
let unknownMessage = findBot?.unknownMessage;
|
||||||
|
let listeningFromMe = findBot?.listeningFromMe;
|
||||||
|
let stopBotFromMe = findBot?.stopBotFromMe;
|
||||||
|
let keepOpen = findBot?.keepOpen;
|
||||||
|
let debounceTime = findBot?.debounceTime;
|
||||||
|
let ignoreJids = findBot?.ignoreJids;
|
||||||
|
|
||||||
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
if (!expire) expire = settings.expire;
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
||||||
|
if (!delayMessage) delayMessage = settings.delayMessage;
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
||||||
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
}
|
if (!keepOpen) keepOpen = settings.keepOpen;
|
||||||
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
|
if (!ignoreJids) ignoreJids = settings.ignoreJids;
|
||||||
|
|
||||||
const key = msg.key as {
|
const key = msg.key as {
|
||||||
id: string;
|
id: string;
|
||||||
@ -754,7 +762,18 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
debouncedContent,
|
debouncedContent,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
@ -765,7 +784,18 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
content,
|
content,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
|
@ -708,17 +708,25 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let expire = findBot?.expire;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let keywordFinish = findBot?.keywordFinish;
|
||||||
let debounceTime = findBot.debounceTime;
|
let delayMessage = findBot?.delayMessage;
|
||||||
|
let unknownMessage = findBot?.unknownMessage;
|
||||||
|
let listeningFromMe = findBot?.listeningFromMe;
|
||||||
|
let stopBotFromMe = findBot?.stopBotFromMe;
|
||||||
|
let keepOpen = findBot?.keepOpen;
|
||||||
|
let debounceTime = findBot?.debounceTime;
|
||||||
|
let ignoreJids = findBot?.ignoreJids;
|
||||||
|
|
||||||
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
if (!expire) expire = settings.expire;
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
||||||
|
if (!delayMessage) delayMessage = settings.delayMessage;
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
||||||
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
}
|
if (!keepOpen) keepOpen = settings.keepOpen;
|
||||||
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
|
if (!ignoreJids) ignoreJids = settings.ignoreJids;
|
||||||
|
|
||||||
const key = msg.key as {
|
const key = msg.key as {
|
||||||
id: string;
|
id: string;
|
||||||
@ -754,7 +762,18 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
debouncedContent,
|
debouncedContent,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
@ -765,7 +784,18 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
|||||||
remoteJid,
|
remoteJid,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
content,
|
content,
|
||||||
msg?.pushName,
|
msg?.pushName,
|
||||||
);
|
);
|
||||||
|
@ -945,18 +945,25 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
|||||||
|
|
||||||
if (!findBot) return;
|
if (!findBot) return;
|
||||||
|
|
||||||
// verify default settings
|
let expire = findBot?.expire;
|
||||||
let listeningFromMe = findBot.listeningFromMe;
|
let keywordFinish = findBot?.keywordFinish;
|
||||||
let stopBotFromMe = findBot.stopBotFromMe;
|
let delayMessage = findBot?.delayMessage;
|
||||||
let debounceTime = findBot.debounceTime;
|
let unknownMessage = findBot?.unknownMessage;
|
||||||
|
let listeningFromMe = findBot?.listeningFromMe;
|
||||||
|
let stopBotFromMe = findBot?.stopBotFromMe;
|
||||||
|
let keepOpen = findBot?.keepOpen;
|
||||||
|
let debounceTime = findBot?.debounceTime;
|
||||||
|
let ignoreJids = findBot?.ignoreJids;
|
||||||
|
|
||||||
if (!listeningFromMe || !stopBotFromMe || !debounceTime) {
|
if (!expire) expire = settings.expire;
|
||||||
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
if (!keywordFinish) keywordFinish = settings.keywordFinish;
|
||||||
|
if (!delayMessage) delayMessage = settings.delayMessage;
|
||||||
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
if (!unknownMessage) unknownMessage = settings.unknownMessage;
|
||||||
|
if (!listeningFromMe) listeningFromMe = settings.listeningFromMe;
|
||||||
if (!debounceTime) debounceTime = settings.debounceTime;
|
if (!stopBotFromMe) stopBotFromMe = settings.stopBotFromMe;
|
||||||
}
|
if (!keepOpen) keepOpen = settings.keepOpen;
|
||||||
|
if (!debounceTime) debounceTime = settings.debounceTime;
|
||||||
|
if (!ignoreJids) ignoreJids = settings.ignoreJids;
|
||||||
|
|
||||||
const key = msg.key as {
|
const key = msg.key as {
|
||||||
id: string;
|
id: string;
|
||||||
@ -994,7 +1001,18 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
|||||||
key.fromMe,
|
key.fromMe,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
debouncedContent,
|
debouncedContent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1006,7 +1024,18 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
|||||||
pushName,
|
pushName,
|
||||||
findBot,
|
findBot,
|
||||||
session,
|
session,
|
||||||
settings,
|
{
|
||||||
|
...settings,
|
||||||
|
expire,
|
||||||
|
keywordFinish,
|
||||||
|
delayMessage,
|
||||||
|
unknownMessage,
|
||||||
|
listeningFromMe,
|
||||||
|
stopBotFromMe,
|
||||||
|
keepOpen,
|
||||||
|
debounceTime,
|
||||||
|
ignoreJids,
|
||||||
|
},
|
||||||
debouncedContent,
|
debouncedContent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user