mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
Some checks failed
Build and push Docker images / docker (push) Failing after 2m16s
Mirror and run GitLab CI / build (push) Failing after 1m44s
Publishing to NPM / publish (push) Failing after 14s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Failing after 1m41s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Failing after 52s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Failing after 52s
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const config = require('../data/config');
|
|
const bili = require('../net/bili');
|
|
const utils = require('../utils');
|
|
|
|
/**
|
|
* 随机动态
|
|
* @param {number} num
|
|
* @returns
|
|
*/
|
|
async function randomDynamic(num) {
|
|
let dynamics = [];
|
|
const
|
|
{ create_dy_type, dy_contents, random_dynamic_wait } = config,
|
|
hasShareVideo = create_dy_type === -1 || create_dy_type === 1,
|
|
hasRandomCreate = create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined';
|
|
|
|
if (hasShareVideo) {
|
|
dynamics = await bili.getTopRcmd();
|
|
for (let index = 0; dynamics.length < num; index++) {
|
|
dynamics.push(...await bili.getTopRcmd());
|
|
}
|
|
}
|
|
|
|
if (hasRandomCreate) {
|
|
for (let index = 0; index < num; index++) {
|
|
dynamics.push(utils.getRandomOne(dy_contents));
|
|
}
|
|
}
|
|
|
|
await utils.try_for_each(
|
|
utils.shuffle(dynamics).slice(0, num),
|
|
async (dynamic) => {
|
|
await utils.delay(random_dynamic_wait);
|
|
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === 'number') {
|
|
await bili.shareVideo(...dynamic);
|
|
} else {
|
|
await bili.createDynamic(dynamic);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
module.exports = { randomDynamic }; |