pref: 对将要转发的动态洗牌乱序

防止被看出是抽奖号
This commit is contained in:
shanmite 2021-07-29 22:38:32 +08:00
parent 53ae976caf
commit fdee933ca4
3 changed files with 20 additions and 2 deletions

View File

@ -89,7 +89,7 @@ class Monitor extends Public {
log.info('筛选动态', `筛选完毕(${len})`);
if (len) {
for (const Lottery of allLottery) {
for (const Lottery of Util.shuffle(allLottery)) {
let status = 0;
if (Lottery.isOfficialLottery) {
let { ts } = await BiliAPI.getLotteryNotice(Lottery.dyid);

View File

@ -115,6 +115,24 @@ const Util = {
}
return RandomOne
},
/**
* FisherYates shuffle洗牌
* @template T
* @param {Array<T>} array
* @return {Array<T>}
*/
shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
},
/**
* 是否有指定环境变量
* @param {string} env_name
* @returns
*/
hasEnv(env_name) {
return process.env[env_name] ? true : false;
},

View File

@ -10,7 +10,7 @@ const metainfo = [
` __/ | | | `,
` |___/ |_| `,
` `,
` v1.9.9 by shanmite`,
` v2.0.0 by shanmite`,
]
/**多账号存储 */
let multiple_account = [];