mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 07:04:50 -06:00
Merge pull request #1599 from splusoficial/develop
fix: ajuste na validacao dos bots e pausar sessao
This commit is contained in:
commit
07cccb7c7f
@ -880,6 +880,12 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip if session exists and status is paused
|
||||||
|
if (session && session.status === 'paused') {
|
||||||
|
this.logger.warn(`Session for ${remoteJid} is paused, skipping message processing`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Merged settings
|
// Merged settings
|
||||||
const mergedSettings = {
|
const mergedSettings = {
|
||||||
...settings,
|
...settings,
|
||||||
|
@ -194,13 +194,13 @@ export class ChatbotController {
|
|||||||
instance: InstanceDto,
|
instance: InstanceDto,
|
||||||
session?: IntegrationSession,
|
session?: IntegrationSession,
|
||||||
) {
|
) {
|
||||||
let findBot: null;
|
let findBot: any = null;
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
findBot = await findBotByTrigger(botRepository, content, instance.instanceId);
|
findBot = await findBotByTrigger(botRepository, content, instance.instanceId);
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
findBot = await botRepository.findFirst({
|
findBot = await botRepository.findFirst({
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { advancedOperatorsSearch } from './advancedOperatorsSearch';
|
import { advancedOperatorsSearch } from './advancedOperatorsSearch';
|
||||||
|
|
||||||
export const findBotByTrigger = async (botRepository: any, content: string, instanceId: string) => {
|
export const findBotByTrigger = async (botRepository: any, content: string, instanceId: string) => {
|
||||||
// Check for triggerType 'all'
|
// Check for triggerType 'all' or 'none' (both should match any message)
|
||||||
const findTriggerAll = await botRepository.findFirst({
|
const findTriggerAllOrNone = await botRepository.findFirst({
|
||||||
where: {
|
where: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
triggerType: 'all',
|
triggerType: {
|
||||||
|
in: ['all', 'none'],
|
||||||
|
},
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findTriggerAll) return findTriggerAll;
|
if (findTriggerAllOrNone) {
|
||||||
|
return findTriggerAllOrNone;
|
||||||
|
}
|
||||||
|
|
||||||
const findTriggerAdvanced = await botRepository.findMany({
|
const findTriggerAdvanced = await botRepository.findMany({
|
||||||
where: {
|
where: {
|
||||||
@ -36,7 +40,9 @@ export const findBotByTrigger = async (botRepository: any, content: string, inst
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findTriggerEquals) return findTriggerEquals;
|
if (findTriggerEquals) {
|
||||||
|
return findTriggerEquals;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for regex match
|
// Check for regex match
|
||||||
const findRegex = await botRepository.findMany({
|
const findRegex = await botRepository.findMany({
|
||||||
|
Loading…
Reference in New Issue
Block a user