mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
parent
097e2d61e7
commit
881923ba54
@ -91,12 +91,6 @@ class Monitor extends Searcher {
|
|||||||
case 5001:
|
case 5001:
|
||||||
event_bus.emit('Turn_off_the_Monitor', '转发失败')
|
event_bus.emit('Turn_off_the_Monitor', '转发失败')
|
||||||
break
|
break
|
||||||
case 6001:
|
|
||||||
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
|
|
||||||
break
|
|
||||||
case 7001:
|
|
||||||
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
|
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
|
||||||
break;
|
break;
|
||||||
@ -135,9 +129,16 @@ class Monitor extends Searcher {
|
|||||||
if (lottery.isOfficialLottery) {
|
if (lottery.isOfficialLottery) {
|
||||||
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 === -1) {
|
||||||
status = 6001
|
log.warn('过滤', '无法判断开奖时间')
|
||||||
break;
|
await delay(filter_wait)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ts === -9999) {
|
||||||
|
log.info('过滤', '已撤销抽奖')
|
||||||
|
d_storage.updateDyid(lottery.dyid)
|
||||||
|
await delay(filter_wait)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if (ts < ts_10) {
|
if (ts < ts_10) {
|
||||||
log.info('过滤', '已过开奖时间')
|
log.info('过滤', '已过开奖时间')
|
||||||
@ -155,9 +156,10 @@ class Monitor extends Searcher {
|
|||||||
const { minfollower } = config
|
const { minfollower } = config
|
||||||
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 === -1) {
|
||||||
status = 7001
|
log.warn('过滤', `粉丝数(${followerNum})获取失败`)
|
||||||
break;
|
await delay(filter_wait)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if (followerNum < minfollower) {
|
if (followerNum < minfollower) {
|
||||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||||
|
|||||||
@ -578,7 +578,7 @@ const bili_client = {
|
|||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
return [false, res.data.follower, 'ok'];
|
return [false, res.data.follower, 'ok'];
|
||||||
} else {
|
} else {
|
||||||
return [true, 1, `出错 可能是访问过频繁\n${responseText}`]
|
return [true, -1, `出错 可能是访问过频繁\n${responseText}`]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
/**
|
/**
|
||||||
@ -594,7 +594,7 @@ const bili_client = {
|
|||||||
* @param {string} dyid
|
* @param {string} dyid
|
||||||
* 动态id
|
* 动态id
|
||||||
* @typedef LotteryNotice
|
* @typedef LotteryNotice
|
||||||
* @property {number | -1} ts
|
* @property {number} ts
|
||||||
* @returns {Promise<LotteryNotice>} 开奖时间
|
* @returns {Promise<LotteryNotice>} 开奖时间
|
||||||
*/
|
*/
|
||||||
async getLotteryNotice(dyid) {
|
async getLotteryNotice(dyid) {
|
||||||
@ -606,12 +606,18 @@ const bili_client = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
res = strToJson(responseText);
|
res = strToJson(responseText);
|
||||||
if (res.code === 0) {
|
switch (res.code) {
|
||||||
|
case 0:
|
||||||
return {
|
return {
|
||||||
ts: res.data.lottery_time
|
ts: res.data.lottery_time
|
||||||
};
|
};
|
||||||
} else {
|
case -9999:
|
||||||
log.error('获取开奖信息', `失败\n${responseText}`);
|
log.warn('获取开奖信息', `${dyid}已撤销抽奖`);
|
||||||
|
return {
|
||||||
|
ts: -9999
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
log.error('获取开奖信息', `${dyid}失败\n${responseText}`);
|
||||||
return {
|
return {
|
||||||
ts: -1
|
ts: -1
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const bili_client = require("../lib/net/bili");
|
const bili_client = require("../lib/net/bili");
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
|
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
assert(await bili_client.getMyinfo());
|
assert(await bili_client.getMyinfo());
|
||||||
@ -13,7 +14,7 @@ const util = require('./util');
|
|||||||
// 1
|
// 1
|
||||||
async () => {
|
async () => {
|
||||||
assert.equal(await bili_client.sendChat(
|
assert.equal(await bili_client.sendChat(
|
||||||
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
|
parseDynamicCard(await bili_client.getOneDynamicByDyid("692193323569381399")).rid_str,
|
||||||
"test",
|
"test",
|
||||||
11),
|
11),
|
||||||
7
|
7
|
||||||
@ -22,7 +23,7 @@ const util = require('./util');
|
|||||||
// 2
|
// 2
|
||||||
async () => {
|
async () => {
|
||||||
assert.equal(await bili_client.sendChat(
|
assert.equal(await bili_client.sendChat(
|
||||||
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
|
parseDynamicCard(await bili_client.getOneDynamicByDyid("11229466874154064")).rid_str,
|
||||||
"test",
|
"test",
|
||||||
1),
|
1),
|
||||||
3
|
3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user