Skip to content

Commit

Permalink
feat: 每组显示动态转发数(shanmiteko#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanmiteko committed Dec 23, 2021
1 parent 0cbacd6 commit ef969bb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/core/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ class Monitor extends Searcher {

if (len) {
let
status = 0,
is_exception = 0,
is_outof_maxfollow = 0;
is_outof_maxfollow = 0,
relayed_nums = 0;
for (const [index, lottery] of shuffle(allLottery).entries()) {
let status = 0;

let is_shutdown = false;
if (
is_outof_maxfollow
&& lottery.uid.length
Expand All @@ -121,7 +122,8 @@ class Monitor extends Searcher {
let { ts } = await bili.getLotteryNotice(lottery.dyid);
const ts_10 = Date.now() / 1000;
if (ts < 0) {
return 6001
status = 6001
break;
}
if (ts < ts_10) {
log.info('过滤', '已过开奖时间')
Expand All @@ -140,7 +142,8 @@ class Monitor extends Searcher {
if (minfollower > 0) {
const followerNum = await bili.getUserInfo(lottery.uid[0]);
if (followerNum < 0) {
return 7001
status = 7001
break;
}
if (followerNum < minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
Expand All @@ -165,6 +168,8 @@ class Monitor extends Searcher {
status = await this.go(lottery)
switch (status) {
case 0:
relayed_nums += 1
break;
case 1002:
case 1003:
case 1004:
Expand All @@ -190,17 +195,20 @@ class Monitor extends Searcher {
case 2001:
case 3001:
case 5001:
return status
is_shutdown = true
break;
}

if (is_shutdown) break

d_storage.updateDyid(lottery.dyid)

await delay(wait * (Math.random() + 0.5));
}
log.info('抽奖', '开始转发下一组动态');
log.info('抽奖', `本轮共转发${relayed_nums}条`);
return is_exception
|| is_outof_maxfollow
|| 0
|| status
} else {
log.info('抽奖', '无未转发抽奖');
return 0
Expand Down

0 comments on commit ef969bb

Please sign in to comment.