新增抽奖关键词过滤功能

This commit is contained in:
Hex
2023-04-16 15:05:24 +08:00
parent 7868a0110c
commit a988274333
2 changed files with 22 additions and 5 deletions

View File

@@ -881,7 +881,23 @@ class SmzdmTaskBot extends SmzdmBot {
};
}
const crowd = this.getOneByRandom(crowds);
let crowd;
if (price > 0 && process.env.SMZDM_CROWD_KEYWORD) {
crowd = crowds.find((item) => {
const match = item.match(/data-title="([^"]+)"/i);
return (match && match[1].indexOf(process.env.SMZDM_CROWD_KEYWORD) >= 0);
});
if (!crowd) {
$.log('未找到符合关键词的抽奖,执行随机选取');
crowd = this.getOneByRandom(crowds);
}
}
else {
crowd = this.getOneByRandom(crowds);
}
const matchCrowd = crowd.match(/data-crowd_id="(\d+)"/i);