2
0
Files
bot/packages/radar/index.ts
2023-12-20 08:02:32 +01:00

27 lines
638 B
TypeScript

import { env } from '@typebot.io/env'
export const computeRiskLevel = (typebot: any) => {
const stringifiedTypebot = JSON.stringify(typebot)
if (
env.RADAR_HIGH_RISK_KEYWORDS?.some((keyword) =>
new RegExp(`(?<!https?://[^\\s"]*)\\b${keyword}\\b`, 'gi').test(
stringifiedTypebot
)
)
)
return 100
if (
env.RADAR_CUMULATIVE_KEYWORDS?.every((keyword) =>
stringifiedTypebot.toLowerCase().includes(keyword)
)
)
return 100
if (
env.RADAR_INTERMEDIATE_RISK_KEYWORDS?.some((keyword) =>
stringifiedTypebot.toLowerCase().includes(keyword)
)
)
return 50
return 0
}