Compare commits

...
18 Commits
Author SHA1 Message Date
shanmite e543c63404 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
2025-05-19 09:39:54 +08:00
shanmite bcf87a9d00 feat: 新增日志等级Notice (#454)
Fixed #454
2025-05-19 09:08:03 +08:00
shanmite 737feae41e 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
2025-05-16 09:53:33 +08:00
f261e915f0 fix: API.X_POLYMER_WEB_DYNAMIC_V1_DETAIL 缺少参数 (#452)
* 完善api

* 小修

---------

Co-authored-by: kaban <[email protected]>
2025-05-13 17:21:43 +08:00
OPPO9008andGitHub 533606839f fix: 修复通过uid监视转发抽奖动态 (#449)
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
Fixed #447

* fix:oldparseDynamicCard已经无法获取是否抽奖

使用新版api

* 当 offset 为 '0'(初始页)时,传入 offset 会报错

* 小修
2025-05-12 21:00:19 +08:00
shanmite 5447c9ae69 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
2025-05-06 15:04:19 +08:00
OPPO9008andGitHub f5f63bcc91 fix: 官方抽奖判断未获取到内容 (#445)
Fixed #445

增加ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes 判断
2025-05-06 14:58:31 +08:00
amadeus5201andGitHub 1832f6d52b feat: 增加多账号的代理 (#433)
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
* feat=>增加多账号的代理

* feat=>增加多账号的代理

* fix=>变量声明
2025-01-16 08:04:30 +08:00
shanmite 717d8cf281 fix: 换源gitlab
Mirror and run GitLab CI / build (push) Has been cancelled
2024-12-02 17:11:50 +08:00
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
18 changed files with 327 additions and 157 deletions
+36
View File
@@ -1,5 +1,41 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.9.7)
* bcf87a9 feat: 新增日志等级Notice (#454)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.9.6)
* f261e91 fix: API.X_POLYMER_WEB_DYNAMIC_V1_DETAIL 缺少参数 (#452)
* 5336068 fix: 修复通过uid监视转发抽奖动态 (#449)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.9.5)
* f5f63bc fix: 官方抽奖判断未获取到内容 (#445)
* 1832f6d feat: 增加多账号的代理 (#433)
* 717d8cf fix: 换源gitlab
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(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)
+1 -1
View File
@@ -1,7 +1,7 @@
1.初始化
```bash
curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo bash
curl -fsSL https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/script/docker/init.sh | sudo bash
```
进入`lottery`文件夹
+6 -2
View File
@@ -12,7 +12,7 @@ module.exports = Object.freeze({
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
* ## 调试相关
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Info<Debug 1<2<3<4
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Notice<Info<Debug 0<1<2<3<4
* - `NOT_GO_LOTTERY` 关闭抽奖行为
*
* ## 多账号
@@ -64,7 +64,11 @@ module.exports = Object.freeze({
NUMBER: 1,
CLEAR: true,
WAIT: 60 * 1000,
ACCOUNT_UA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
ACCOUNT_UA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
PROXY_HOST:'',//代理ip
PROXY_PORT:'',//代理ip端口
PROXY_USER:'',//代理ip账号
PROXY_PASS:'',//代理ip密码
}
],
+2 -2
View File
@@ -92,10 +92,10 @@ async function isMe(num) {
log.info('中奖检测', '--> OK');
}
if (desp) {
log.info('可能中奖了', desp);
log.notice('可能中奖了', desp);
await sendNotify(`帐号${num}可能中奖了`, desp);
} else {
log.info('中奖检测', '暂未中奖');
log.notice('中奖检测', '暂未中奖');
}
return;
}
+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);
+117 -86
View File
@@ -62,6 +62,12 @@ function parseDynamicCard(data) {
if (data?.card?.desc?.uid) {
return oldParseDynamicCard(data?.card);
}
// 如果是多个 items,返回一个数组
if (Array.isArray(data?.items)) {
return data.items.map(item => parseDynamicCard({ item }));
}
let ditem = data?.item;
/**临时储存单个动态中的信息 */
let obj = {};
@@ -103,22 +109,41 @@ function parseDynamicCard(data) {
/* 转发描述 */
obj.description = '';
let _total_len = 0;
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
if (Array.isArray(ditem?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
} else {
ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
}
/* 预约抽奖信息 */
obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
@@ -166,13 +191,23 @@ function parseDynamicCard(data) {
obj.origin_hasOfficialLottery = false;
/* 转发描述 */
obj.origin_description = '';
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
if (Array.isArray(ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
} else {
ditem?.orig.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
}
}
} catch (e) {
log.error('动态卡片解析', e);
@@ -323,16 +358,18 @@ function oldParseDynamicCard(dynamic_detail_card) {
function modifyDynamicRes(res) {
let
{ data, code } = utils.strToJson(res),
{ cards, has_more, offset } = data || {};
{ items, has_more, offset } = data || {};
if (code !== 0) {
log.error('处理动态数据', '获取动态数据出错,可能是访问太频繁 \n' + res);
return null;
}
if (cards == null || !cards || !cards.length) {
/**
* !cards已经能涵盖cards == null,你在想什么?
*/
if (!items || !items.length) {
log.warn('处理动态数据', '未找到任何动态信息');
cards = [];
items = [];
}
if (typeof has_more === 'undefined'
@@ -347,18 +384,16 @@ function modifyDynamicRes(res) {
*/
next = {
has_more,
next_offset: typeof offset === 'string'
? offset
: /(?<=next_offset":)[0-9]+/.exec(res)[0]
next_offset: offset
},
/**
* 储存获取到的一组动态中的信息
*/
array = next.has_more === 0
? []
: cards.map(oldParseDynamicCard);
: items.map(item => parseDynamicCard({ item }));
log.info('处理动态数据', `动态数据读取完毕(${cards.length})(${next.has_more})`);
log.info('处理动态数据', `动态数据读取完毕(${items.length})(${next.has_more})`);
return {
modifyDynamicResArray: array,
@@ -379,7 +414,7 @@ class Searcher {
* @param {string} [offset] 默认'0'
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
*/
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
static async checkAllDynamic(host_mid, pages, time = 0, offset = '0') {
log.info('检查所有动态', `准备读取${pages}页动态`);
const { getOneDynamicInfoByUID } = bili,
@@ -390,7 +425,7 @@ class Searcher {
/**
* 储存了特定UID的请求函数
*/
hadUidGetOneDynamicInfoByUID = curriedGetOneDynamicInfoByUID(hostuid);
hadUidGetOneDynamicInfoByUID = curriedGetOneDynamicInfoByUID(host_mid);
/**
* 储存所有经过整理后信息
@@ -401,9 +436,12 @@ class Searcher {
for (let i = 0; i < pages; i++) {
log.info('检查所有动态', `正在读取其中第${i + 1}页动态`);
const
OneDynamicInfo = await hadUidGetOneDynamicInfoByUID(offset),
mDRdata = modifyDynamicRes(OneDynamicInfo);
// 当 offset 为 '0'(初始页)时,传入 offset 会报错
const OneDynamicInfo = offset === '0'
? await hadUidGetOneDynamicInfoByUID()
: await hadUidGetOneDynamicInfoByUID(offset);
const mDRdata = modifyDynamicRes(OneDynamicInfo);
if (mDRdata === null) {
return null;
@@ -582,7 +620,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 +637,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 +785,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: {
+1 -1
View File
@@ -7,7 +7,6 @@ module.exports = Object.freeze({
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_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',
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
@@ -39,4 +38,5 @@ module.exports = Object.freeze({
WEB_INTERFACE_NAV_STAT: 'https://api.bilibili.com/x/web-interface/nav/stat',
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
X_POLYMER_WEB_DYNAMIC_V1_DETAIL: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/detail',
X_POLYMER_WEB_DYNAMIC_V1_FEED_SPACE: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space',
});
+20 -9
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;
});
@@ -419,7 +419,8 @@ const bili_client = {
url: API.X_POLYMER_WEB_DYNAMIC_V1_DETAIL,
config: { retry: false },
query: {
id
id,
features: 'itemOpusStyle'
}
}),
(dynamic_id) => get({
@@ -455,14 +456,14 @@ const bili_client = {
* @param {string} offset_dynamic_id 此动态偏移量 初始为 0
* @returns {Promise<string>}
*/
getOneDynamicInfoByUID(host_uid, offset_dynamic_id) {
getOneDynamicInfoByUID(host_mid, offset) {
/* 鉴别工作交由modifyDynamicRes完成 */
/* 新版似乎没有 visitor_uid */
return get({
url: API.DYNAMIC_SVR_SPACE_HISTORY,
url: API.X_POLYMER_WEB_DYNAMIC_V1_FEED_SPACE,
query: {
visitor_uid: GlobalVar.get('myUID'),
host_uid,
offset_dynamic_id,
host_mid,
offset,
},
config: {
retry: false
@@ -568,7 +569,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 +755,7 @@ const bili_client = {
log.info('移动分区', 'up主分区移动成功');
return 0;
} else {
log.error('移动分区', `up主分区移动失败\n${responseText}`);
log.error('移动分区', `up主分区移动失败分区 可于设置处关闭移动分区\n${responseText}`);
return 1;
}
},
@@ -841,6 +845,7 @@ const bili_client = {
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
* - 源动态禁止转发 5
*/
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
const len = msg.length;
@@ -875,6 +880,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 +1167,9 @@ const bili_client = {
} else {
need_captcha = false;
}
} else {
log.error('验证码识别', '失败');
break;
}
} else {
url = await bili_client.sendChat(
+1 -1
View File
@@ -83,7 +83,7 @@ async function update(isDdownload) {
log.info('自动下载', '成功下载到当前目录');
log.info('检查更新', '请手动解压替换可执行文件');
}
log.info('更新说明', '\n' + text + '\n');
log.notice('更新说明', '\n' + text + '\n');
} else {
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`;
}
+49 -18
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
@@ -100,6 +98,7 @@ const utils = {
return _c(restNum - 1, argsList.concat(x));
};
}
return _c(func.length, []);
},
/**
@@ -123,7 +122,9 @@ const utils = {
let c = {
i: 0,
next: () => c.i++,
clear: () => { c.i = 0; },
clear: () => {
c.i = 0;
},
value: () => c.i
};
return c;
@@ -132,7 +133,7 @@ const utils = {
* 无限序列
* `[0..]`
*/
*infiniteNumber() {
* infiniteNumber() {
for (let index = 0; ; index++) {
yield index;
}
@@ -180,7 +181,7 @@ const utils = {
/**
* 是否有指定环境变量
* @param {string} env_name
* @returns
* @returns
*/
hasEnv(env_name) {
return process.env[env_name] ? true : false;
@@ -190,7 +191,7 @@ const utils = {
_level: 3,
_colors: [
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BFFF00'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
],
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
_cache: [],
@@ -230,7 +231,7 @@ const utils = {
process.stdout.write(status_bar);
},
debug(context, msg) {
if (this._level > 3) {
if (this._level >= 4) {
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
@@ -242,7 +243,7 @@ const utils = {
}
},
info(context, msg) {
if (this._level > 2) {
if (this._level >= 3) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], '[Info]'],
@@ -253,25 +254,37 @@ const utils = {
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
}
},
notice(context, msg) {
if (this._level >= 2) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], '[Notice]'],
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
[this._colors[5], `[${msg}]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
}
},
warn(context, msg) {
if (this._level > 1) {
if (this._level >= 1) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], '[Warn]'],
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
[this._colors[5], `[\n${msg}\n]`],
[this._colors[6], `[\n${msg}\n]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
}
},
error(context, msg) {
if (this._level > 0) {
if (this._level >= 0) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], '[Error]'],
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
[this._colors[6], `[\n${msg}\n]`],
[this._colors[7], `[\n${msg}\n]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
@@ -280,7 +293,7 @@ const utils = {
},
/**
* 验证码识别
* @param {string} url
* @param {string} url
* @returns {Promise<string>}
*/
ocr(url) {
@@ -296,7 +309,7 @@ const utils = {
resolve(res.body);
},
failure: () => {
resolve();
resolve(null);
}
});
});
@@ -342,7 +355,7 @@ const utils = {
/**
* 是否存在文件或目录
* @param {string} path
* @returns
* @returns
*/
hasFileOrDir(path) {
try {
@@ -402,7 +415,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
@@ -416,7 +429,7 @@ const utils = {
/**
* 追加lotteryinfo
* @param {string} from
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
* @param {import('./core/searcher').LotteryInfo[]} lottery_info
* @return {Promise<void>}
*/
async appendLotteryInfoFile(from, lottery_info) {
@@ -437,7 +450,7 @@ const utils = {
/**
* 读取lottery_info
* @param {string} filename
* @return {Promise<import("./core/searcher").LotteryInfo[]>}
* @return {Promise<import('./core/searcher').LotteryInfo[]>}
*/
readLotteryInfoFile(filename) {
return new Promise((resolve) => {
@@ -473,6 +486,24 @@ const utils = {
}
});
});
},
getIpInfo() {
return new Promise((resolve) => {
send({
url: 'https://myip.qq.com/',
method: 'GET',
success: res => resolve(res.body),
failure: err => resolve(err)
});
});
},
printIpInfo(beforeProxy) {
const printMessage = beforeProxy ? '当前IP----->' : '代理后IP=======>';
utils.getIpInfo().then(res => {
console.log(printMessage + res);
}).catch((err) => {
console.error('获取' + printMessage + '地址失败', err);
});
}
};
+33 -4
View File
@@ -1,5 +1,15 @@
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require('./lib/utils');
const {
version: ve,
env_file,
config_file,
log,
hasEnv,
delay,
hasFileOrDir,
clearLotteryInfo, printIpInfo
} = require('./lib/utils');
const { HttpsProxyAgent } = require('https-proxy-agent');
const request = require('https');
const metainfo = [
' _ _ _ _____ _ _ ',
' | | | | | | / ____| (_) | | ',
@@ -31,6 +41,7 @@ async function main() {
: JSON.parse(MULTIPLE_ACCOUNT_PARM);
process.env.ENABLE_MULTIPLE_ACCOUNT = '';
let localhost = request.globalAgent;
for (const acco of muti_acco) {
process.env.COOKIE = acco.COOKIE;
@@ -38,6 +49,19 @@ async function main() {
process.env.CLEAR = acco.CLEAR;
process.env.NOTE = acco.NOTE;
process.env.ACCOUNT_UA = acco.ACCOUNT_UA;
if (acco.PROXY_HOST) {
printIpInfo(true);
//http://ip:port
//http://user:pwd@ip:port'
const proxyUrl = acco.PROXY_USER
? 'http://' + acco.PROXY_USER + ':' + acco.PROXY_PASS + '@' + acco.PROXY_HOST + ':' + acco.PROXY_PORT
: 'http://' + acco.PROXY_HOST + ':' + acco.PROXY_PORT;
request.globalAgent = new HttpsProxyAgent(proxyUrl);
printIpInfo(false);
}else {
//未设置还原
request.globalAgent = localhost;
}
const err_msg = await main();
if (err_msg) {
return err_msg;
@@ -48,8 +72,8 @@ async function main() {
await delay(3 * 1000);
}
}
request.globalAgent = localhost;
}
/**多账号状态还原 */
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
} else if (COOKIE) {
@@ -65,7 +89,12 @@ async function main() {
const mode = process.env.lottery_mode;
const help_msg = '用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息';
if (await checkCookie(NUMBER)) {
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require('./lib/data/config');
const {
lottery_loop_wait,
check_loop_wait,
clear_loop_wait,
save_lottery_info_to_file
} = require('./lib/data/config');
ck_flag = 1;
switch (mode) {
case 'start':
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.9.1",
"version": "2.9.7",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -37,7 +37,7 @@ CONFIG_FILE=my_config.js
# docker仓库
DOCKER_REPO=shanmite/lottery_auto_docker
# cdn
CDN=https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main
CDN=https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main
# env.example.js文件
ENV_EXAMPLE="$CDN/env.example.js"
# my_config.example.js文件
+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');