diff --git a/src/client/utils/i18n/i18n.js b/src/client/utils/i18n/i18n.js index 50ecb10d2..ed2866a16 100644 --- a/src/client/utils/i18n/i18n.js +++ b/src/client/utils/i18n/i18n.js @@ -588,6 +588,14 @@ export default { 'Спамни аниқлаш учун Тенсент Слоуд махфий идентификатори. Тенсент Слоуд ва Акисмет бир вақтнинг ўзида ўрнатилганда, фақат Тенсент Слоуд кучга киради. Рўйхатдан ўтиш: https://twikoo.js.org/cms.html', 'Tencent CloudのシークレットID、スパムコメントの検出に使用されます。同時にTencent CloudとAkismetを設定した場合、Tencent Cloudのみが有効になります。登録:https://twikoo.js.org/cms.html' ], + [S.ACI + '_QCLOUD_CMS_BIZTYPE']: [ + '腾讯云内容安全 Biztype 名称,用于垃圾评论策略。可以自定义垃圾拦截规则', + '騰訊雲內容安全 Biztype 名稱,用於垃圾評論策略。可以自定義垃圾攔截規則', + '騰訊雲內容安全 Biztype 名稱,用於垃圾評論策略。可以自定義垃圾攔截規則', // 「騰訊雲」是一家網路服務提供商,不改為「騰訊雲端」。 + 'Tencent Cloud Content Security Biztype name for spam comment policy. Spam blocking rules can be customized', + 'Tencent Cloud Content Security Biztype име, използвано за спам политика. Може да персонализира правилата за блокиране на спам', + 'Tencent Cloud Content Security Biztype name スパムコメントポリシー。スパムブロックルールはカスタマイズ可能' + ], [S.ACI + '_QCLOUD_SECRET_KEY']: [ '腾讯云 secret key', '騰訊雲 secret key', diff --git a/src/client/view/components/TkAdminConfig.vue b/src/client/view/components/TkAdminConfig.vue index 037792b98..9ee8a8dc9 100644 --- a/src/client/view/components/TkAdminConfig.vue +++ b/src/client/view/components/TkAdminConfig.vue @@ -93,6 +93,7 @@ export default { { key: 'AKISMET_KEY', desc: t('ADMIN_CONFIG_ITEM_AKISMET_KEY'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}8651783edxxx`, value: '' }, { key: 'QCLOUD_SECRET_ID', desc: t('ADMIN_CONFIG_ITEM_QCLOUD_SECRET_ID'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}AKIDBgZDdnbTw9D4ey9qPkrkwtb2Do9EwIHw`, value: '' }, { key: 'QCLOUD_SECRET_KEY', desc: t('ADMIN_CONFIG_ITEM_QCLOUD_SECRET_KEY'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}XrkOnvKWS7WeXbP1QZT76rPgtpWx73D7`, value: '', secret: true }, + { key: 'QCLOUD_CMS_BIZTYPE', desc: t('ADMIN_CONFIG_ITEM_QCLOUD_CMS_BIZTYPE'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}1787728329856520192`, value: '', secret: true }, { key: 'LIMIT_PER_MINUTE', desc: t('ADMIN_CONFIG_ITEM_LIMIT_PER_MINUTE'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}5`, value: '' }, { key: 'LIMIT_PER_MINUTE_ALL', desc: t('ADMIN_CONFIG_ITEM_LIMIT_PER_MINUTE_ALL'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}5`, value: '' }, { key: 'LIMIT_LENGTH', desc: t('ADMIN_CONFIG_ITEM_LIMIT_LENGTH'), ph: `${t('ADMIN_CONFIG_EXAMPLE')}100`, value: '' }, diff --git a/src/server/function/twikoo/utils/index.js b/src/server/function/twikoo/utils/index.js index 63ed8a187..df22458e8 100644 --- a/src/server/function/twikoo/utils/index.js +++ b/src/server/function/twikoo/utils/index.js @@ -334,6 +334,11 @@ const fn = { throw new Error(`参数"${requiredParam}"不合法`) } } + }, + // 移除表情内容,用于内容安全检测 + removeEmotionImages (content) { + const regex = /]*class="tk-owo-emotion"[^>]*>/g + return content.replace(regex, '') } } diff --git a/src/server/function/twikoo/utils/spam.js b/src/server/function/twikoo/utils/spam.js index 13d870595..239eaa0eb 100644 --- a/src/server/function/twikoo/utils/spam.js +++ b/src/server/function/twikoo/utils/spam.js @@ -3,6 +3,10 @@ const { getCryptoJS, getTencentcloud } = require('./lib') +const { + equalsMail, + removeEmotionImages +} = require('.') const AkismetClient = getAkismetClient() const CryptoJS = getCryptoJS() @@ -29,17 +33,23 @@ const fn = { if (comment.isSpam) { // 预检测没过的,就不再检测了 isSpam = true + } else if (equalsMail(config.BLOGGER_EMAIL, comment.mail)) { + // 博主本人评论,不再检测了 + isSpam = false } else if (config.QCLOUD_SECRET_ID && config.QCLOUD_SECRET_KEY) { // 腾讯云内容安全 - const client = new (getTencentCloud().tms.v20200713.Client)({ + const client = new (getTencentCloud().tms.v20201229.Client)({ credential: { secretId: config.QCLOUD_SECRET_ID, secretKey: config.QCLOUD_SECRET_KEY }, region: 'ap-shanghai', profile: { httpProfile: { endpoint: 'tms.tencentcloudapi.com' } } }) + const cleanContent = removeEmotionImages(comment.comment) const checkResult = await client.TextModeration({ - Content: CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(comment.comment)), + Content: CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(cleanContent)), Device: { IP: comment.ip }, - User: { Nickname: comment.nick } + BizType: { BizType: config.QCLOUD_SECRET_ID }, + User: { Nickname: comment.nick }, + DataId: { DataId: comment.id } }) logger.log('腾讯云返回结果:', checkResult) isSpam = checkResult.EvilFlag !== 0