Compare commits

...
12 Commits
Author SHA1 Message Date
shanmite 41b036966e ci: fix pkg.yml 2023-06-29 08:01:24 +08:00
shanmite c282d8492d docs: 更新CHANGELOG 2023-06-28 16:06:23 +08:00
shanmite 5a3c16d20d fix: 专栏获取内容不正确,需要排除推荐内容 (#293)
Fixed #293
2023-06-28 15:28:27 +08:00
shanmite 75383e8faa docs: 更新CHANGELOG 2023-05-16 09:56:09 +08:00
shanmite 29645bc4e7 fixed: 话题搜索功能已失效 #285
Fixed #285
2023-05-16 09:55:08 +08:00
shanmite d950a59b4d fix: is_imitator导致错误评论 2023-05-15 11:24:09 +08:00
shanmite d3e3436075 docs: 更新CHANGELOG 2023-05-15 10:49:26 +08:00
shanmite 3828a0f054 fix: Cannot read properties of null (#284)
Fixed #284
2023-05-15 10:47:57 +08:00
shanmite 67313f4a23 feat: 专栏里的动态链接识别优化 (#283)
Fixed #283
2023-05-05 10:20:17 +08:00
shanmite fd2921cb07 docs: 更新CHANGELOG 2023-05-04 15:07:42 +08:00
shanmite ad6af9705f feat: 专栏短链接识别 (#263)
Fixed #263
2023-05-04 14:58:19 +08:00
shanmite b6c56c5061 feat: 取关分区支持设置多分区 (#281)
Fixed #281
2023-05-03 08:37:47 +08:00
10 changed files with 75 additions and 26 deletions
-2
View File
@@ -49,7 +49,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v2"
overwrite: true
arm64:
@@ -78,6 +77,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v2"
overwrite: true
+23
View File
@@ -1,5 +1,28 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.7.11)
* 5a3c16d fix: 专栏获取内容不正确,需要排除推荐内容 (#293)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.10)
* 29645bc fixed: 话题搜索功能已失效 #285
* d950a59 fix: is_imitator导致错误评论
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.9)
* 3828a0f fix: Cannot read properties of null (#284)
* 67313f4 feat: 专栏里的动态链接识别优化 (#283)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.8)
* ad6af97 feat: 专栏短链接识别 (#263)
* b6c56c5 feat: 取关分区支持设置多分区 (#281)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.7)
* 2426fe2 fix: 动态详情获取接口412频繁 (#279)
* d370fef fix: 获取动态详情出现undefined (#271)
+6 -5
View File
@@ -6,12 +6,13 @@ const config = require("./data/config");
/**
* 获取关注分区里的uid
* @param {string} partition
* @returns { Promise<number[]> }
*/
async function getFollowList() {
async function getFollowList(partition) {
const
{ clear_partition, clear_white_list, get_partition_wait } = config,
tagid = await bili.checkMyPartition(clear_partition);
{ clear_white_list, get_partition_wait } = config,
tagid = await bili.checkMyPartition(partition);
let rmup = [];
if (typeof tagid === 'undefined') {
log.info('获取关注列表', '未能成功获取关注分区id');
@@ -32,9 +33,9 @@ async function getFollowList() {
* 清理动态和关注
*/
async function clear() {
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config;
let success = true;
const uid_list = await getFollowList();
const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat();
if (!uid_list.length) {
log.info('清理关注', `关注为空`)
} else {
+3 -4
View File
@@ -396,8 +396,7 @@ class Monitor extends Searcher {
|| (hasOfficialLottery && model[0] === '1')
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
isSendChat =
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|| (hasOfficialLottery && chatmodel[0] === '1')
(hasOfficialLottery && chatmodel[0] === '1')
|| (!hasOfficialLottery && chatmodel[1] === '1'),
{ blacklist: remote_blacklist } = use_public_blacklist === false
? { blacklist: "" }
@@ -488,7 +487,7 @@ class Monitor extends Searcher {
let
/**转发评语 */
RandomStr = getRandomOne(relays)
RandomStr = (getRandomOne(relays) || "!!!")
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
/**控制字段 */
new_ctrl = [];
@@ -541,7 +540,7 @@ class Monitor extends Searcher {
/* 是否评论 */
if (isSendChat) {
onelotteryinfo.rid = rid
onelotteryinfo.chat = getRandomOne(chats)
onelotteryinfo.chat = (getRandomOne(chats) || "!!!")
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname)
}
+19 -8
View File
@@ -186,6 +186,12 @@ function modifyDynamicRes(res) {
log.warn('处理动态数据', '未找到任何动态信息')
}
if (typeof has_more === "undefined"
&& typeof offset === "undefined") {
log.error('处理动态数据', '该功能已失效');
return null;
}
const
/**
* 字符串offset防止损失精度
@@ -353,6 +359,8 @@ class Searcher {
* @returns {Promise<LotteryInfo[] | null>}
*/
async getLotteryInfoByTag(tag_name) {
log.info('获取动态', `开始获取带话题#${tag_name}#的动态信息`);
const
tag_id = await bili.getTagIDByTagName(tag_name),
hotdy = await bili.getHotDynamicInfoByTagID(tag_id),
@@ -360,7 +368,6 @@ class Searcher {
if (modDR === null) return null;
log.info('获取动态', `开始获取带话题#${tag_name}#的动态信息`);
log.info('获取动态', '成功获取热门动态');
/**
@@ -425,13 +432,16 @@ class Searcher {
continue
}
const
content = await bili.getOneArticleByCv(id),
dyids = content.match(/(?<=t.bilibili.com\/)[0-9]+/g) || [],
dyids_set = [...new Set(dyids)],
content = (await bili.getOneArticleByCv(id) || "").split("推荐文章")[0],
dyids = content.match(/[0-9]{18}/g) || [],
short_ids = content.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [],
short_id_set = [...new Set(short_ids)],
short_ids_to_dyids = await Promise.all(short_id_set.map(bili.shortDynamicIdToDyid)),
dyid_set = [...new Set([...dyids, ...short_ids_to_dyids])],
/**判断此专栏是否查看过的权重 */
weight = dyids_set.length / 2;
weight = dyid_set.length / 2;
let { length } = dyids_set,
let { length } = dyid_set,
/**初始权重 */
_weight = 0,
/**单个专栏中的dyid */
@@ -439,8 +449,9 @@ class Searcher {
log.info('获取动态', `提取专栏(${id})中提及的dyid(${length})`)
/**遍历某专栏中的dyids */
for (const dyid of dyids_set) {
if (dyid.length === utils.dyid_length) {
for (const dyid of dyid_set) {
if (typeof dyid === "string"
&& dyid.length === utils.dyid_length) {
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
+1
View File
@@ -32,6 +32,7 @@ module.exports = Object.freeze({
SESSION_SVR_GET_SESSIONS: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions',
SESSION_SVR_SINGLE_UNREAD: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread',
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
SHORTLINK: 'https://b23.tv/{{short_id}}',
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
+19 -3
View File
@@ -378,6 +378,22 @@ const bili_client = {
return null;
}
},
/**
* @param {string} short_id
* @returns {Promise<string>}
*/
async shortDynamicIdToDyid(short_id) {
return get({
url: API.SHORTLINK.replace('{{short_id}}', short_id),
config: {
redirect: false,
}
}).then(a => {
const dyid = (a.match(/[0-9]{18}/) || [])[0];
log.info("短连接转换", `${short_id} -> ${dyid}`)
return dyid
})
},
_getOneDynamicByDyid: new Line('获取一个动态的细节', [
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2,
@@ -1152,7 +1168,7 @@ const bili_client = {
if (res.code === 0) {
const data = res.data.filter((it) => it.name === name);
if (data.length) {
log.info('获取分区id', '成功');
log.info('获取分区id', `成功 ${name}`);
tagid = data[0].tagid;
} else {
log.warn('获取分区id', `失败 无指定分区名${name}`);
@@ -1219,10 +1235,10 @@ const bili_client = {
res.data.forEach(d => {
uids.push(d.mid);
});
log.info(`获取分组${tagid}`, `成功获取取关分区列表${n}`);
log.info(`获取分组id${tagid}`, `成功获取取关分区列表${n}`);
return uids;
} else {
log.error(`获取分组${tagid}`, `获取取关分区列表失败\n${responseText}`);
log.error(`获取分组id${tagid}`, `获取取关分区列表失败\n${responseText}`);
return uids;
}
}
+1
View File
@@ -403,6 +403,7 @@ module.exports = Object.freeze({
/**
* - 取关分区
* - 默认为: 此处存放因抽奖临时关注的up
* - 可用逗号分割以取关多分区
*/
clear_partition: '',
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.7.7",
"version": "2.7.11",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+2 -3
View File
@@ -1,6 +1,5 @@
const assert = require('assert');
const bili_client = require("../lib/net/bili");
const searcher = require("../lib/core/searcher");
const util = require('./util');
(async () => {
@@ -8,9 +7,9 @@ const util = require('./util');
// 0
async () => {
let info = await bili_client.getOneArticleByCv(22112353);
console.log(info);
let short_ids = [...new Set(info.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [])];
assert.equal((await Promise.all(short_ids.map(bili_client.shortDynamicIdToDyid)))[0], "767357823884460033");
},
])
console.log("article.test ... ok!");
})()