fix: 获取关注数和开奖时间出错时值设为-1

This commit is contained in:
shanmite 2021-04-17 12:17:50 +08:00
parent 76aff69347
commit 8b4284e944
2 changed files with 7 additions and 8 deletions

View File

@ -271,7 +271,7 @@ const BiliAPI = {
/**
* 获取关注数
* @param {number} uid
* @returns {Promise<number | 0>}
* @returns {Promise<number | -1>}
*/
getUserInfo: uid => {
return new Promise((resolve) => {
@ -289,7 +289,7 @@ const BiliAPI = {
resolve(res.data.follower);
} else {
tooltip.log('获取关注数出错,可能是访问过频繁');
resolve(0);
resolve(-1);
}
}
});
@ -301,7 +301,7 @@ const BiliAPI = {
* 动态id
* @returns {
Promise<{
ts:number|0;
ts:number|-1;
text:string|'获取开奖信息失败';
item:string|'null';
isMe:string|'未知';
@ -341,7 +341,7 @@ const BiliAPI = {
} else {
tooltip.log(`获取开奖信息失败\n${responseText}`);
resolve({
ts: 0,
ts: -1,
text: '获取开奖信息失败',
item: 'null',
isMe: '未知'

View File

@ -114,16 +114,15 @@ class Monitor extends Public {
const haslottery = /[抽奖]/.test(description);
const hasGuanZhuan = /[转关].*[转关]/.test(description);
if (hasOfficialLottery && model[0] === '1') {
const oneLNotice = await BiliAPI.getLotteryNotice(dyid);
ts = oneLNotice.ts;
if (!ts) { alllotteryinfo = null; break }
ts = await BiliAPI.getLotteryNotice(dyid).ts;
if (ts < 0) { alllotteryinfo = null; break }
isLottery = ts > now_ts_10 && ts < now_ts_10 + maxday;
isSendChat = chatmodel[0] === '1';
} else if (!hasOfficialLottery && model[1] === '1' && haslottery && hasGuanZhuan && !isTwoLevelRelay) {
ts = Base.getLotteryNotice(description).ts;
if (!official_verify) {
const followerNum = await BiliAPI.getUserInfo(uid);
if (!followerNum) { alllotteryinfo = null; break }
if (followerNum < 0) { alllotteryinfo = null; break }
if (followerNum < Number(minfollower)) continue;
isLottery = !befilter && (ts === 0 || (ts > now_ts_10 && ts < now_ts_10 + maxday));
} else {