Skip to content

Commit

Permalink
optimize: task's banWords
Browse files Browse the repository at this point in the history
  • Loading branch information
snowtafir committed Dec 26, 2024
1 parent a9a70ef commit 487df94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/models/bilibili/bilibili.main.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ export class BiliTask {
return 'return'; // 如果动态消息构建失败,则直接返回
}

if (biliConfigData.banWords.length > 0) {
const banWords = new RegExp(biliConfigData.banWords.join('|'), 'g'); // 构建屏蔽关键字正则表达式
const getBanWords: string[] | null = biliConfigData?.banWords;
if (getBanWords && Array.isArray(getBanWords) && getBanWords.length > 0) {
const banWords = new RegExp(getBanWords.join('|'), 'g'); // 构建屏蔽关键字正则表达式
if (banWords.test(dynamicMsg.msg.join(''))) {
return 'return'; // 如果动态消息包含屏蔽关键字,则直接返回
}
Expand Down
5 changes: 3 additions & 2 deletions src/models/weibo/weibo.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ export class WeiboTask {
return 'return'; // 如果动态消息构建失败或内部资源获取失败,则直接返回
}

if (weiboConfigData.banWords.length > 0) {
const banWords = new RegExp(weiboConfigData.banWords.join('|'), 'g'); // 构建屏蔽关键字正则表达式
const getBanWords: string[] | null = weiboConfigData?.banWords;
if (getBanWords && Array.isArray(getBanWords) && getBanWords.length > 0) {
const banWords = new RegExp(getBanWords.join('|'), 'g'); // 构建屏蔽关键字正则表达式
if (banWords.test(dynamicMsg.msg.join(''))) {
return 'return'; // 如果动态消息包含屏蔽关键字,则直接返回
}
Expand Down

0 comments on commit 487df94

Please sign in to comment.