mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7bdf74d5c | ||
|
|
2426fe2384 | ||
|
|
d370fef899 | ||
|
|
00174b0fdc | ||
|
|
ea711ae048 | ||
|
|
881923ba54 | ||
|
|
097e2d61e7 | ||
|
|
82d285e841 | ||
|
|
bf4e8945c0 | ||
|
|
9c9bc18a44 |
@@ -1,5 +1,24 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.7.7)
|
||||
* 2426fe2 fix: 动态详情获取接口412频繁 (#279)
|
||||
* d370fef fix: 获取动态详情出现undefined (#271)
|
||||
* 00174b0 fix(monitor): L615
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.6)
|
||||
* 881923b fix: 开奖时间和粉丝数判断逻辑 (#253)
|
||||
* 097e2d6 fix: 筛选掉置顶的评论,与该动态UP的评论 (#252)
|
||||
* 82d285e fix: 充电专属动态 (#251)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.5)
|
||||
* 9c9bc18 fix: 查询评论报错 (#250)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.4)
|
||||
* 0630c89 feat: 新增设置抄热评屏蔽词 (#239)
|
||||
* 7b9d251 feat: 热评包含发送热评的人的昵称换成自己的昵称 (#239)
|
||||
|
||||
+16
-15
@@ -91,12 +91,6 @@ class Monitor extends Searcher {
|
||||
case 5001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '转发失败')
|
||||
break
|
||||
case 6001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
|
||||
break
|
||||
case 7001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
||||
break
|
||||
default:
|
||||
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
|
||||
break;
|
||||
@@ -135,9 +129,16 @@ class Monitor extends Searcher {
|
||||
if (lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
if (ts < 0) {
|
||||
status = 6001
|
||||
break;
|
||||
if (ts === -1) {
|
||||
log.warn('过滤', '无法判断开奖时间')
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts === -9999) {
|
||||
log.info('过滤', '已撤销抽奖')
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
@@ -155,9 +156,10 @@ class Monitor extends Searcher {
|
||||
const { minfollower } = config
|
||||
if (minfollower > 0) {
|
||||
const followerNum = await bili.getUserInfo(lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
status = 7001
|
||||
break;
|
||||
if (followerNum === -1) {
|
||||
log.warn('过滤', `粉丝数(${followerNum})获取失败`)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (followerNum < minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
@@ -601,17 +603,16 @@ class Monitor extends Searcher {
|
||||
const copy_chat = getRandomOne(
|
||||
(await bili.getChat(rid, chat_type))
|
||||
.filter(it => !(new RegExp(copy_blockword.join('|')).test(it[1])))
|
||||
);
|
||||
) || [";;;;;;;;;", chat || "!!!"];
|
||||
chat = copy_chat[1]
|
||||
.replace(
|
||||
new RegExp(copy_chat[0], 'g'),
|
||||
global_var.get("myUNAME") || '')
|
||||
|| "!!!"
|
||||
}
|
||||
|
||||
status = await retryfn(
|
||||
6,
|
||||
[4, 8, 9],
|
||||
[4],
|
||||
() => bili.sendChat(
|
||||
rid,
|
||||
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
|
||||
|
||||
@@ -110,8 +110,12 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description =
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|
||||
(item && ((item.content || '') + (item.description || '')))
|
||||
|| (
|
||||
(cardToJson.dynamic || '')
|
||||
+ (cardToJson.desc || '')
|
||||
+ (cardToJson.vest && cardToJson.vest.content || '')
|
||||
)
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
|
||||
+6
-1
@@ -5,7 +5,12 @@ module.exports = Object.freeze({
|
||||
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2: 'https://api.vc.bilibili.com/dynamic_svr/v2/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V3: 'https://api.vc.bilibili.com/dynamic_svr/v3/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V4: 'https://api.vc.bilibili.com/dynamic_svr/v4/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V5: 'https://api.vc.bilibili.com/dynamic_svr/v5/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V6: 'https://api.vc.bilibili.com/dynamic_svr/v6/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V7: 'https://api.vc.bilibili.com/dynamic_svr/v7/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
|
||||
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
|
||||
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
|
||||
|
||||
+83
-31
@@ -378,31 +378,74 @@ const bili_client = {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
_getOneDynamicByDyid: new Line('获取一个动态的细节', [
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V3,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V4,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V5,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V6,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V7,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
], responseText => {
|
||||
const
|
||||
res = strToJson(responseText),
|
||||
{ code, data } = res,
|
||||
{ card } = data || {};
|
||||
switch (code) {
|
||||
case 0:
|
||||
if (card) {
|
||||
return [false, card, `ok`];
|
||||
} else {
|
||||
return [false, undefined, `动态不存在`];
|
||||
}
|
||||
case 500207:
|
||||
return [false, undefined, `该动态为包月充电专属可以给UP主充电后观看`];
|
||||
default:
|
||||
return [true, undefined, `获取动态数据出错:\n${responseText}`]
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* 获取一个动态的细节
|
||||
* @param {string} dynamic_id
|
||||
* @return {Promise<JSON>} 失败返回undefined
|
||||
*/
|
||||
async getOneDynamicByDyid(dynamic_id) {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL,
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}),
|
||||
{ code, data } = strToJson(responseText),
|
||||
{ card } = data || {};
|
||||
if (code !== 0) {
|
||||
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`);
|
||||
return;
|
||||
}
|
||||
if (!card) {
|
||||
log.warn('获取一个动态的细节', `动态(${dynamic_id})不存在`);
|
||||
return;
|
||||
}
|
||||
log.info('获取一个动态的细节', `动态id(${dynamic_id})`);
|
||||
return card;
|
||||
return this._getOneDynamicByDyid.run(dynamic_id)
|
||||
},
|
||||
/**
|
||||
* 获取一组动态的信息
|
||||
@@ -572,7 +615,7 @@ const bili_client = {
|
||||
if (res.code === 0) {
|
||||
return [false, res.data.follower, 'ok'];
|
||||
} else {
|
||||
return [true, 1, `出错 可能是访问过频繁\n${responseText}`]
|
||||
return [true, -1, `出错 可能是访问过频繁\n${responseText}`]
|
||||
}
|
||||
}),
|
||||
/**
|
||||
@@ -588,7 +631,7 @@ const bili_client = {
|
||||
* @param {string} dyid
|
||||
* 动态id
|
||||
* @typedef LotteryNotice
|
||||
* @property {number | -1} ts
|
||||
* @property {number} ts
|
||||
* @returns {Promise<LotteryNotice>} 开奖时间
|
||||
*/
|
||||
async getLotteryNotice(dyid) {
|
||||
@@ -600,15 +643,21 @@ const bili_client = {
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
return {
|
||||
ts: res.data.lottery_time
|
||||
};
|
||||
} else {
|
||||
log.error('获取开奖信息', `失败\n${responseText}`);
|
||||
return {
|
||||
ts: -1
|
||||
};
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
return {
|
||||
ts: res.data.lottery_time
|
||||
};
|
||||
case -9999:
|
||||
log.warn('获取开奖信息', `${dyid}已撤销抽奖`);
|
||||
return {
|
||||
ts: -9999
|
||||
};
|
||||
default:
|
||||
log.error('获取开奖信息', `${dyid}失败\n${responseText}`);
|
||||
return {
|
||||
ts: -1
|
||||
};
|
||||
}
|
||||
},
|
||||
_autoAttention: new Line('自动关注', [
|
||||
@@ -1073,7 +1122,10 @@ const bili_client = {
|
||||
case 0:
|
||||
log.info('查询评论', `成功`);
|
||||
try {
|
||||
return res.data.replies.map(it => [it.member.uname, it.content.message]);
|
||||
const upmid = res.data.upper.mid;
|
||||
return res.data.replies
|
||||
.filter(it => it.mid !== upmid)
|
||||
.map(it => [it.member.uname, it.content.message]);
|
||||
} catch (_) {
|
||||
return []
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.7.4",
|
||||
"version": "2.7.7",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
@@ -13,7 +14,7 @@ const util = require('./util');
|
||||
// 1
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
|
||||
parseDynamicCard(await bili_client.getOneDynamicByDyid("692193323569381399")).rid_str,
|
||||
"test",
|
||||
11),
|
||||
7
|
||||
@@ -22,7 +23,7 @@ const util = require('./util');
|
||||
// 2
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
|
||||
parseDynamicCard(await bili_client.getOneDynamicByDyid("11229466874154064")).rid_str,
|
||||
"test",
|
||||
1),
|
||||
3
|
||||
@@ -43,7 +44,7 @@ const util = require('./util');
|
||||
// 6
|
||||
async () => {
|
||||
assert.equal(await bili_client.autolike("761391835139538967"), 4)
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
console.log("api.test ... ok!");
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneArticleByCv(22112353);
|
||||
console.log(info);
|
||||
},
|
||||
])
|
||||
|
||||
console.log("article.test ... ok!");
|
||||
})()
|
||||
@@ -4,7 +4,7 @@ const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0, 1, 2, 3], [
|
||||
await util.par_run([0, 1, 2, 3, 4, 5, 6], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
@@ -29,10 +29,28 @@ const util = require('./util');
|
||||
assert(card.chat_type == 17)
|
||||
assert(card.origin_chat_type == 11)
|
||||
},
|
||||
// 4
|
||||
async () => {
|
||||
assert.equal(await bili_client.getOneDynamicByDyid("111111111111111111"), undefined);
|
||||
assert.notEqual(await bili_client.getOneDynamicByDyid("746824225190314008"), undefined);
|
||||
assert.equal(await bili_client.getOneDynamicByDyid("761475750233636886"), undefined);
|
||||
},
|
||||
// 5
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("762591475338838053"));
|
||||
let chats = await bili_client.getChat(card.rid_str, card.chat_type)
|
||||
assert.equal(chats.length, 19)
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("762502724122050647"));
|
||||
chats = await bili_client.getChat(card.rid_str, card.chat_type)
|
||||
assert.equal(chats.filter(it => it[0] === '六的月').length, 0)
|
||||
},
|
||||
// 6
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("774973685666676768");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.notEqual(card.description + "", undefined + "");
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
})()
|
||||
+1
-1
@@ -3,7 +3,7 @@ const global_var = require("../lib/data/global_var");
|
||||
const { log } = require('../lib/utils');
|
||||
const fs = require('fs');
|
||||
|
||||
log._level = 1
|
||||
log._level = 2
|
||||
env.init()
|
||||
global_var.init(process.env["COOKIE"], 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user