mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 15:54:03 +00:00
fix(bot): silence topic processor failure messages unless explicitly mentioned
Previously, the bot would reply with a 'Zzz...' message to every message in a topic if the topic processor failed or was missing. This change ensures the bot remains silent unless it is explicitly mentioned by the user.
This commit is contained in:
@@ -635,18 +635,22 @@ export function registerConfiguredPaymentTopicIngestion(
|
|||||||
engagementAssessment: conversationContext.engagement
|
engagementAssessment: conversationContext.engagement
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle processor failure
|
// Handle processor failure - only if explicitly mentioned
|
||||||
if (!processorResult) {
|
if (!processorResult) {
|
||||||
const { botSleepsMessage } = await import('./topic-processor')
|
if (conversationContext.explicitMention) {
|
||||||
await replyToPaymentMessage(
|
const { botSleepsMessage } = await import('./topic-processor')
|
||||||
ctx,
|
await replyToPaymentMessage(
|
||||||
botSleepsMessage(locale === 'ru' ? 'ru' : 'en'),
|
ctx,
|
||||||
undefined,
|
botSleepsMessage(locale === 'ru' ? 'ru' : 'en'),
|
||||||
{
|
undefined,
|
||||||
repository: options.historyRepository,
|
{
|
||||||
record
|
repository: options.historyRepository,
|
||||||
}
|
record
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await next()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,12 +860,21 @@ export function registerConfiguredPaymentTopicIngestion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No topic processor available - bot sleeps
|
// No topic processor available
|
||||||
const { botSleepsMessage } = await import('./topic-processor')
|
if (stripExplicitBotMention(ctx) !== null) {
|
||||||
await replyToPaymentMessage(ctx, botSleepsMessage(locale === 'ru' ? 'ru' : 'en'), undefined, {
|
const { botSleepsMessage } = await import('./topic-processor')
|
||||||
repository: options.historyRepository,
|
await replyToPaymentMessage(
|
||||||
record
|
ctx,
|
||||||
})
|
botSleepsMessage(locale === 'ru' ? 'ru' : 'en'),
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
repository: options.historyRepository,
|
||||||
|
record
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await next()
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
options.logger?.error(
|
options.logger?.error(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2476,18 +2476,22 @@ export function registerConfiguredPurchaseTopicIngestion(
|
|||||||
engagementAssessment: conversationContext.engagement
|
engagementAssessment: conversationContext.engagement
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle processor failure - fun "bot sleeps" message
|
// Handle processor failure - fun "bot sleeps" message only if explicitly mentioned
|
||||||
if (!processorResult) {
|
if (!processorResult) {
|
||||||
const { botSleepsMessage } = await import('./topic-processor')
|
if (conversationContext.explicitMention) {
|
||||||
await replyToPurchaseMessage(
|
const { botSleepsMessage } = await import('./topic-processor')
|
||||||
ctx,
|
await replyToPurchaseMessage(
|
||||||
botSleepsMessage(householdContext.locale === 'ru' ? 'ru' : 'en'),
|
ctx,
|
||||||
undefined,
|
botSleepsMessage(householdContext.locale === 'ru' ? 'ru' : 'en'),
|
||||||
{
|
undefined,
|
||||||
repository: options.historyRepository,
|
{
|
||||||
record
|
repository: options.historyRepository,
|
||||||
}
|
record
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await next()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2586,17 +2590,21 @@ export function registerConfiguredPurchaseTopicIngestion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No topic processor available - bot sleeps
|
// No topic processor available
|
||||||
const { botSleepsMessage } = await import('./topic-processor')
|
if (conversationContext.explicitMention) {
|
||||||
await replyToPurchaseMessage(
|
const { botSleepsMessage } = await import('./topic-processor')
|
||||||
ctx,
|
await replyToPurchaseMessage(
|
||||||
botSleepsMessage(householdContext.locale === 'ru' ? 'ru' : 'en'),
|
ctx,
|
||||||
undefined,
|
botSleepsMessage(householdContext.locale === 'ru' ? 'ru' : 'en'),
|
||||||
{
|
undefined,
|
||||||
repository: options.historyRepository,
|
{
|
||||||
record
|
repository: options.historyRepository,
|
||||||
}
|
record
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await next()
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
options.logger?.error(
|
options.logger?.error(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user