mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: api线路切换具有记忆功能
perf: 重构部分代码 fix: 清理动态时关注列表获取失败
This commit is contained in:
parent
b5fdb2d247
commit
1458c800b8
@ -6,7 +6,7 @@
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
- 监控专栏合集
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 检测是否中奖
|
||||
- 已读@
|
||||
- 已读私信
|
||||
- 清理动态关注
|
||||
- 检查更新
|
||||
- 更多功能设置请参考配置文件
|
||||
|
||||
@ -10,11 +10,11 @@ const config = require("./data/config");
|
||||
*/
|
||||
async function getFollowList() {
|
||||
const tagid = await bili.checkMyPartition(config.clear_partition);
|
||||
let rmup = [];
|
||||
if (typeof tagid === 'undefined') {
|
||||
log.info('获取关注列表', '未能成功获取关注分区id');
|
||||
return
|
||||
return rmup
|
||||
}
|
||||
let rmup = [];
|
||||
for (let index = 1; index < 42; index++) {
|
||||
const uids = await bili.getPartitionUID(tagid, index);
|
||||
await delay(2e3);
|
||||
|
||||
@ -83,7 +83,7 @@ class Monitor extends Searcher {
|
||||
async startLottery() {
|
||||
const allLottery = await this.filterLotteryInfo()
|
||||
, len = allLottery.length
|
||||
, { dy_contents, create_dy, create_dy_mode, wait } = config;
|
||||
, { create_dy, create_dy_mode, wait } = config;
|
||||
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
@ -332,53 +332,51 @@ class Monitor extends Searcher {
|
||||
log.info('NOT_GO_LOTTERY', 'ON');
|
||||
return 0
|
||||
}
|
||||
|
||||
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
|
||||
|
||||
/* 评论 */
|
||||
if (rid && chat_type) {
|
||||
let status = 0;
|
||||
const max_retry_times = 5;
|
||||
for (let times = 0; times < max_retry_times; times++) {
|
||||
status = await bili.sendChat(rid, utils.getRandomOne(config.chat), chat_type)
|
||||
if (status === -1) {
|
||||
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 0
|
||||
let status = 0
|
||||
const
|
||||
{ chat } = config,
|
||||
retry = [...new Array(5).keys()],
|
||||
max_retry_times = retry.length;
|
||||
await utils.try_for_each(retry, async (times) => {
|
||||
status = await bili.sendChat(rid, utils.getRandomOne(chat), chat_type)
|
||||
switch (status) {
|
||||
case 0:
|
||||
return true
|
||||
case -1:
|
||||
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return true
|
||||
default:
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
return false
|
||||
}
|
||||
if (!status) {
|
||||
break
|
||||
}
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
}
|
||||
if (status) return 11;
|
||||
})
|
||||
if (status) return 10 + status;
|
||||
}
|
||||
|
||||
/* 关注 */
|
||||
const [u1, u2] = uid
|
||||
if (u1) {
|
||||
let status = await bili.autoAttention(u1)
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
status = await bili.movePartition(u1, this.tagid)
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
if (u2) {
|
||||
utils.delay(5000)
|
||||
status = await bili.autoAttention(u2)
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
status = await bili.movePartition(u2, this.tagid)
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
}
|
||||
if (uid.length) {
|
||||
let status = 0
|
||||
await utils.try_for_each(uid, async (u) => {
|
||||
status = await bili.autoAttention(u)
|
||||
switch (status) {
|
||||
case 0:
|
||||
return false
|
||||
case -1:
|
||||
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
return true
|
||||
default:
|
||||
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (status) return 20 + status
|
||||
}
|
||||
|
||||
/* 点赞 */
|
||||
|
||||
1082
lib/net/bili.js
1082
lib/net/bili.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user