mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-12 21:03:13 +08:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
const config = require("../data/config");
|
|
const bili = require("../net/bili");
|
|
const utils = require("../utils");
|
|
|
|
/**
|
|
* 随机动态
|
|
* @param {number} num
|
|
* @returns
|
|
*/
|
|
async function randomDynamic(num) {
|
|
const { create_dy_type, dy_contents, random_dynamic_wait } = config;
|
|
|
|
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
|
|
for (let index = 0; index < num; index++) {
|
|
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
|
await utils.delay(random_dynamic_wait);
|
|
}
|
|
}
|
|
|
|
if (create_dy_type === -1 || create_dy_type === 1) {
|
|
let videos = await bili.getTopRcmd()
|
|
for (let index = 0; videos.length < num; index++) {
|
|
videos.push(...await bili.getTopRcmd())
|
|
}
|
|
|
|
await utils.try_for_each(videos, async ([uid, aid]) => {
|
|
if (num--) {
|
|
await bili.shareVideo(uid, aid)
|
|
await utils.delay(random_dynamic_wait)
|
|
return false
|
|
} else {
|
|
return true
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = { randomDynamic } |