feat: 每组显示动态转发数(#97)

This commit is contained in:
shanmite 2021-12-23 15:19:07 +08:00
parent 0cbacd6ddf
commit ef969bb2c2

View File

@ -103,11 +103,12 @@ class Monitor extends Searcher {
if (len) { if (len) {
let let
status = 0,
is_exception = 0, is_exception = 0,
is_outof_maxfollow = 0; is_outof_maxfollow = 0,
relayed_nums = 0;
for (const [index, lottery] of shuffle(allLottery).entries()) { for (const [index, lottery] of shuffle(allLottery).entries()) {
let status = 0; let is_shutdown = false;
if ( if (
is_outof_maxfollow is_outof_maxfollow
&& lottery.uid.length && lottery.uid.length
@ -121,7 +122,8 @@ class Monitor extends Searcher {
let { ts } = await bili.getLotteryNotice(lottery.dyid); let { ts } = await bili.getLotteryNotice(lottery.dyid);
const ts_10 = Date.now() / 1000; const ts_10 = Date.now() / 1000;
if (ts < 0) { if (ts < 0) {
return 6001 status = 6001
break;
} }
if (ts < ts_10) { if (ts < ts_10) {
log.info('过滤', '已过开奖时间') log.info('过滤', '已过开奖时间')
@ -140,7 +142,8 @@ class Monitor extends Searcher {
if (minfollower > 0) { if (minfollower > 0) {
const followerNum = await bili.getUserInfo(lottery.uid[0]); const followerNum = await bili.getUserInfo(lottery.uid[0]);
if (followerNum < 0) { if (followerNum < 0) {
return 7001 status = 7001
break;
} }
if (followerNum < minfollower) { if (followerNum < minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`) log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
@ -165,6 +168,8 @@ class Monitor extends Searcher {
status = await this.go(lottery) status = await this.go(lottery)
switch (status) { switch (status) {
case 0: case 0:
relayed_nums += 1
break;
case 1002: case 1002:
case 1003: case 1003:
case 1004: case 1004:
@ -190,17 +195,20 @@ class Monitor extends Searcher {
case 2001: case 2001:
case 3001: case 3001:
case 5001: case 5001:
return status is_shutdown = true
break;
} }
if (is_shutdown) break
d_storage.updateDyid(lottery.dyid) d_storage.updateDyid(lottery.dyid)
await delay(wait * (Math.random() + 0.5)); await delay(wait * (Math.random() + 0.5));
} }
log.info('抽奖', '开始转发下一组动态'); log.info('抽奖', `本轮共转发${relayed_nums}`);
return is_exception return is_exception
|| is_outof_maxfollow || is_outof_maxfollow
|| 0 || status
} else { } else {
log.info('抽奖', '无未转发抽奖'); log.info('抽奖', '无未转发抽奖');
return 0 return 0