Compare commits

...
9 Commits
Author SHA1 Message Date
shanmite a4215f1881 docs: 更新CHANGELOG
Build and push Docker images / docker (push) Has been cancelled
Mirror and run GitLab CI / build (push) Has been cancelled
Publishing to NPM / publish (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
2024-11-18 13:55:38 +08:00
shanmite 2f5990f277 fix: 动态ID字符串长度超过18 2024-11-18 13:55:05 +08:00
shanmite 6b1c2310ca docs: 更新CHANGELOG
Build and push Docker images / docker (push) Has been cancelled
Mirror and run GitLab CI / build (push) Has been cancelled
Publishing to NPM / publish (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
2024-11-09 13:51:13 +08:00
shanmite 1d4e8eaaca fix: 专栏获取为空 (#425)
Fixed #425
2024-11-09 13:50:13 +08:00
shanmite 890c86c3af docs: 更新CHANGELOG 2024-11-08 10:41:03 +08:00
shanmite 4134190927 fix: 分区移动失败继续运行 (#423)
Fixed #423
2024-11-08 10:37:35 +08:00
shanmite 66fa06f1f0 fix: 源动态禁止转发 2024-11-08 10:28:44 +08:00
shanmite b1de122c75 fix: 验证码识别失败无限重试
Build and push Docker images / docker (push) Has been cancelled
Mirror and run GitLab CI / build (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
2024-09-19 11:10:42 +08:00
巴拉巴拉嘿andGitHub d3475a5032 feat(notify.js): QYWX推送变为图文消息 (#416)
Build and push Docker images / docker (push) Has been cancelled
Mirror and run GitLab CI / build (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Has been cancelled
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
2024-09-13 20:51:43 +08:00
11 changed files with 135 additions and 88 deletions
+18
View File
@@ -1,5 +1,23 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.9.4)
* 2f5990f fix: 动态ID字符串长度超过18
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.9.3)
* 1d4e8ea fix: 专栏获取为空 (#425)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.9.2)
* 4134190 fix: 分区移动失败继续运行 (#423)
* 66fa06f fix: 源动态禁止转发
* b1de122 fix: 验证码识别失败无限重试
* d3475a5 feat(notify.js): QYWX推送变为图文消息 (#416)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.9.1)
* 9b0f9bf fix: 仅屏蔽自动回复 (#401)
* 74337ca fix: 账号转发动态途中被系统强制登出,任务直接终止 (#392)
+3 -4
View File
@@ -65,9 +65,6 @@ class Monitor extends Searcher {
case 2001:
event_bus.emit('Turn_off_the_Monitor', '关注出错');
break;
case 3001:
event_bus.emit('Turn_off_the_Monitor', '分区移动出错 可于设置处关闭移动分区');
break;
case 2004:
case 4005:
log.warn(`账号异常${status}`, `UID(${global_var.get('myUID')})异常号只会对部分UP出现异常`);
@@ -200,6 +197,7 @@ class Monitor extends Searcher {
case 1011:
case 2002:
case 2003:
case 3001:
case 4001:
case 4002:
case 4003:
@@ -207,6 +205,7 @@ class Monitor extends Searcher {
case 5002:
case 5003:
case 5004:
case 5005:
status = 0;
break;
case 2004:
@@ -222,7 +221,6 @@ class Monitor extends Searcher {
case 1010:
case 1004:
case 2001:
case 3001:
case 5001:
is_shutdown = true;
break;
@@ -572,6 +570,7 @@ class Monitor extends Searcher {
* - 转发 该动态不能转发分享 5002
* - 转发 请求数据发生错误,请刷新或稍后重试 5003
* - 转发 操作太频繁了,请稍后重试 5004
* - 转发 源动态禁止转发 5005
*/
async go(option) {
log.debug('正在转发的动态信息', option);
+42 -49
View File
@@ -582,7 +582,7 @@ class Searcher {
}
const
content = (await bili.getOneArticleByCv(id) || '').split('推荐文章')[0],
dyids = content.match(/[0-9]{18}/g) || [],
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)),
@@ -599,38 +599,34 @@ class Searcher {
/**遍历某专栏中的dyids */
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);
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`);
const card = await bili.getOneDynamicByDyid(dyid);
if (card) {
await utils.delay(get_dynamic_detail_wait);
if (card) {
await utils.delay(get_dynamic_detail_wait);
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`);
_weight += 1;
}
if (_weight >= weight && !not_check_article) {
log.warn('获取动态', '1/2动态曾经转过,该专栏或已查看,故中止');
_dyinfos = [];
break;
}
_dyinfos.push(parsed_card);
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`);
_weight += 1;
}
if (_weight >= weight && !not_check_article) {
log.warn('获取动态', '1/2动态曾经转过,该专栏或已查看,故中止');
_dyinfos = [];
break;
}
_dyinfos.push(parsed_card);
} else {
log.warn('获取动态', `动态(${dyid})无效 (${length--})`);
log.warn('获取动态', `动态细节获取失败(${dyid})`);
}
}
dyinfos.push(..._dyinfos);
@@ -751,33 +747,30 @@ class Searcher {
dyinfos = [];
for (const dyid of dyids) {
if (typeof dyid === 'string'
&& dyid.length === utils.dyid_length) {
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`);
const card = await bili.getOneDynamicByDyid(dyid);
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`);
const card = await bili.getOneDynamicByDyid(dyid);
if (card) {
await utils.delay(get_dynamic_detail_wait);
if (card) {
await utils.delay(get_dynamic_detail_wait);
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`);
continue;
}
dyinfos.push(parsed_card);
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`);
continue;
}
dyinfos.push(parsed_card);
} else {
log.warn('获取动态', `动态(${dyid})无效 (${length--})`);
log.warn('获取动态', `动态细节获取失败(${dyid})`);
}
}
const fomatdata = dyinfos.map(o => {
return {
+30 -22
View File
@@ -1,4 +1,4 @@
const { log, readDyidFile, writeDyidFile, dyid_length } = require('../utils');
const { log, readDyidFile, writeDyidFile } = require('../utils');
const d_storage = {
/**
@@ -6,24 +6,35 @@ const d_storage = {
* @param {string} dyid
* @returns {Promise<boolean>}
*/
searchDyid: (dyid) => {
return new Promise((resolve) => {
const Rdyid = new RegExp(dyid);
const rs = readDyidFile(Number(process.env.NUMBER));
let status = false;
rs.on('data', chunk => {
if (Rdyid.test(chunk)) {
status = true;
}
});
rs.on('end', () => {
resolve(status);
});
rs.on('error', err => {
log.error('搜索dyid', err);
resolve(status);
});
});
searchDyid: async (dyid) => {
let buffer = '';
let found = false;
const stream = readDyidFile(Number(process.env.NUMBER));
for await (const chunk of stream) {
buffer += chunk;
while ((buffer.indexOf(dyid)) !== -1) {
found = true;
stream.destroy();
return found;
}
const lastCommaIdx = buffer.lastIndexOf(',');
if (lastCommaIdx !== -1) {
buffer = buffer.slice(lastCommaIdx);
}
}
if (!found && buffer.length > 0) {
if (buffer.includes(dyid)) {
found = true;
}
}
stream.destroy();
return found;
},
/**
* 更新dyid
@@ -31,9 +42,6 @@ const d_storage = {
*/
updateDyid: (dyid) => {
log.info('更新dyid', `写入${dyid}`);
if (dyid.length !== dyid_length) {
log.error('更新dyid', `dyid(${dyid})长度不为18 若出现此问题请即时通知开发者`);
}
return new Promise((resolve) => {
const ws = writeDyidFile(Number(process.env.NUMBER));
ws.write(dyid + ',', () => {
+10 -3
View File
@@ -619,6 +619,7 @@ function ddBotNotify(text, desp) {
function qywxAmNotify(text, desp) {
return new Promise(resolve => {
desp=desp.replace(/\n/g, '<br>');
if (QYWX_AM) {
const QYWX_AM_AY = QYWX_AM.split(',');
send({
@@ -646,9 +647,15 @@ function qywxAmNotify(text, desp) {
touser: `${QYWX_AM_AY[2]}`,
agentid: `${QYWX_AM_AY[3]}`,
safe: '0',
msgtype: 'text',
text: {
content: `${text}\n\n${desp}`,
msgtype: 'mpnews',
mpnews : {
articles:[
{
title: `${text}`,
thumb_media_id: `${QYWX_AM_AY[4]}`,
content: `${desp}`,
}
]
},
},
config: {
+13 -3
View File
@@ -407,7 +407,7 @@ const bili_client = {
redirect: false,
}
}).then(a => {
const dyid = (a.match(/[0-9]{18}/) || [])[0];
const dyid = (a.match(/[0-9]{18,}/) || [])[0];
log.info('短连接转换', `${short_id} -> ${dyid}`);
return dyid;
});
@@ -568,7 +568,10 @@ const bili_client = {
*/
getOneArticleByCv(cv) {
return get({
url: API.READ_CV.replace('{{cv}}', cv)
url: API.READ_CV.replace('{{cv}}', cv),
config: {
redirect: true
}
});
},
/**
@@ -751,7 +754,7 @@ const bili_client = {
log.info('移动分区', 'up主分区移动成功');
return 0;
} else {
log.error('移动分区', `up主分区移动失败\n${responseText}`);
log.error('移动分区', `up主分区移动失败分区 可于设置处关闭移动分区\n${responseText}`);
return 1;
}
},
@@ -841,6 +844,7 @@ const bili_client = {
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
* - 源动态禁止转发 5
*/
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
const len = msg.length;
@@ -875,6 +879,9 @@ const bili_client = {
case 1101008:
log.warn('转发动态', '操作太频繁了,请稍后重试');
return 4;
case 4126117:
log.warn('转发动态', '源动态禁止转发');
return 5;
default:
log.error('转发动态', `未知错误\n${responseText}`);
return 1;
@@ -1159,6 +1166,9 @@ const bili_client = {
} else {
need_captcha = false;
}
} else {
log.error('验证码识别', '失败');
break;
}
} else {
url = await bili_client.sendChat(
+2 -4
View File
@@ -19,8 +19,6 @@ const utils = {
lottery_info_dir: path.join(process.cwd(), 'lottery_info'),
/**本地抽奖信息存放目录 */
lottery_dyids: path.join(process.cwd(), 'lottery_dyids'),
/**dyid长度 */
dyid_length: 18,
/**
* 将版本号转为数字
* @example
@@ -296,7 +294,7 @@ const utils = {
resolve(res.body);
},
failure: () => {
resolve();
resolve(null);
}
});
});
@@ -402,7 +400,7 @@ const utils = {
*/
readDyidFile(num) {
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
return fs.createReadStream(fpath, { encoding: 'utf8', highWaterMark: (utils.dyid_length + 1) * 1000 });
return fs.createReadStream(fpath, { encoding: 'utf8' });
},
/**
* 追加dyid
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.9.1",
"version": "2.9.4",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -6,7 +6,7 @@ const { parseDynamicCard } = require('../lib/core/searcher');
(async () => {
assert.notEqual(await bili_client.getMyinfo(), null);
await util.par_run([0, 3], [
await util.par_run([], [
// 0
async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10);
+14
View File
@@ -0,0 +1,14 @@
const assert = require('assert');
const util = require('./util');
const d_storage = require('../lib/helper/d_storage');
(async () => {
await util.par_run([0], [
// 0
async () => {
assert(await d_storage.searchDyid('1234567901234568'));
assert(!await d_storage.searchDyid('1234567901234569'));
},
]);
console.log('dyidSearch.test ... ok!');
})();
+1 -1
View File
@@ -4,7 +4,7 @@ const searcher = require('../lib/core/searcher');
const util = require('./util');
(async () => {
await util.par_run([0, 1, 2, 3, 4, 5, 6, 7, 8], [
await util.par_run([], [
// 0
async () => {
let info = await bili_client.getOneDynamicByDyid('728424890210713624');