fix: 关注失败时只转发已关注

This commit is contained in:
shanmite 2021-01-31 12:33:01 +08:00
parent 382caa04f4
commit 65e636de7c

View File

@ -20,6 +20,7 @@ class Monitor extends Public {
this.tagid = 0; /* tagid初始化为默认分组 */
this.attentionList = ''; /* 转为字符串的所有关注的up主uid */
this.AllMyLotteryInfo = ''; /* 转发过的动态信息 */
this.isAttentionErr = false;
}
/**
* 初始化
@ -126,6 +127,7 @@ class Monitor extends Public {
if (isLottery) {
/* 判断是否关注过 */
const isFollowed = (new RegExp(uid)).test(self.attentionList);
if (this.isAttentionErr && !isFollowed) continue;
/* 判断是否转发过 */
const isRelay = (new RegExp(dyid)).test(self.AllMyLotteryInfo);
/* 获取黑名单并去重合并 */
@ -180,16 +182,25 @@ class Monitor extends Public {
async go(option) {
const { uid, dyid, type, rid, relay_chat, ctrl } = option;
if (typeof dyid === 'string') {
if (!this.isAttentionErr) {
uid.forEach(async (one_uid) => {
if (typeof one_uid === 'number') {
if (await BiliAPI.autoAttention(uid) === 0) {
this.isAttentionErr = true;
return
}
await Base.delay(5000);
if (await BiliAPI.movePartition(uid, this.tagid) === 0) {
this.isAttentionErr = true;
return
}
}
})
}
if (this.isAttentionErr && uid.length !== 0) return 0;
if (typeof rid === 'string' && type !== 0) {
if (await BiliAPI.sendChat(rid, Base.getRandomStr(config.chat), type) === 0) return 0;
}
uid.forEach(async (one_uid) => {
if (typeof one_uid === 'number') {
if (await BiliAPI.autoAttention(uid) === 0) return 0;
await Base.delay(5000);
if (await BiliAPI.movePartition(uid, this.tagid) === 0) return 0;
}
})
if (await BiliAPI.autoRelay(GlobalVar.myUID, dyid, relay_chat, ctrl) === 0) return 0;
if (await MyStorage.updateDyid((Array.from(new Set([dyid, ...this.AllMyLotteryInfo.split(',')]))).toString()) === -1) return 0;
if (await BiliAPI.autolike(dyid) === 0) return 0;