mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: 可间隔插入随机动态(#33)
This commit is contained in:
parent
88d3e97595
commit
d676a10e56
@ -81,14 +81,16 @@ class Monitor extends Searcher {
|
||||
*/
|
||||
async startLottery() {
|
||||
const allLottery = await this.filterLotteryInfo()
|
||||
, len = allLottery.length;
|
||||
, len = allLottery.length
|
||||
, { dy_contents, create_dy, create_dy_mode, wait } = config;
|
||||
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
let is_exception = false;
|
||||
for (const Lottery of utils.shuffle(allLottery)) {
|
||||
for (const [index, Lottery] of utils.shuffle(allLottery).entries()) {
|
||||
let status = 0;
|
||||
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
@ -113,6 +115,17 @@ class Monitor extends Searcher {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (create_dy
|
||||
&& create_dy_mode instanceof Array
|
||||
&& index > 0
|
||||
&& index % create_dy_mode[0] === 0) {
|
||||
for (let i = 0; i < create_dy_mode[1]; i++) {
|
||||
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
status = await this.go(Lottery)
|
||||
switch (status) {
|
||||
case 0:
|
||||
@ -124,7 +137,7 @@ class Monitor extends Searcher {
|
||||
return status
|
||||
}
|
||||
|
||||
await utils.delay(config.wait * (Math.random() + 0.5));
|
||||
await utils.delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
if (is_exception) {
|
||||
|
||||
@ -123,15 +123,19 @@ module.exports = Object.freeze({
|
||||
create_dy: false,
|
||||
|
||||
/**
|
||||
* - 发送随机动态的数量
|
||||
* - 结束运行时发送随机动态的数量
|
||||
*/
|
||||
create_dy_num: 1,
|
||||
|
||||
/**
|
||||
* - 每转发x条抽奖动态就发送x条随机动态
|
||||
* - @example [6,1] 每转发6条抽奖动态就发送1条随机动态
|
||||
*/
|
||||
create_dy_mode: [0, 0],
|
||||
|
||||
/**
|
||||
* - 随机动态内容
|
||||
* - 类型 `content[]`
|
||||
*/
|
||||
/**
|
||||
* @typedef Picture
|
||||
* @property {string} img_src 站内源
|
||||
* @property {number} img_width
|
||||
|
||||
Loading…
Reference in New Issue
Block a user