feat(bots/discord): improve logs

This commit is contained in:
PalmDevs
2024-03-29 19:50:22 +07:00
parent faf1e5fc78
commit 6abb740994
2 changed files with 5 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ on('disconnect', (reason, msg) => {
// TODO: move to config // TODO: move to config
if (api.disconnectCount >= 3) { if (api.disconnectCount >= 3) {
console.error(new Error('Disconnected from bot API too many times')) console.error('Disconnected from bot API too many times')
// We don't want the process hanging // We don't want the process hanging
process.exit(1) process.exit(1)
} }

View File

@@ -54,6 +54,7 @@ export const getResponseFromContent = async (
// If none of the regexes match, we can search for labels immediately // If none of the regexes match, we can search for labels immediately
if (!response && !ocrMode) { if (!response && !ocrMode) {
logger.debug('No match from before regexes, doing NLP')
const scan = await api.client.parseText(content) const scan = await api.client.parseText(content)
if (scan.labels.length) { if (scan.labels.length) {
const matchedLabel = scan.labels[0]! const matchedLabel = scan.labels[0]!
@@ -82,7 +83,8 @@ export const getResponseFromContent = async (
} }
// If we still don't have a label, we can match all regexes after the initial label trigger // If we still don't have a label, we can match all regexes after the initial label trigger
if (!response) if (!response) {
logger.debug('No match from NLP, doing after regexes')
for (let i = 0; i < config.responses.length; i++) { for (let i = 0; i < config.responses.length; i++) {
const { triggers, response: resp } = config.responses[i]! const { triggers, response: resp } = config.responses[i]!
const firstLabelIndex = firstLabelIndexes[i] ?? -1 const firstLabelIndex = firstLabelIndexes[i] ?? -1
@@ -99,6 +101,7 @@ export const getResponseFromContent = async (
} }
} }
} }
}
return { return {
response, response,