mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04c25a88fc | ||
|
|
9ab605a186 | ||
|
|
a83c5ab91a | ||
|
|
092bd843e1 | ||
|
|
2f2eaabc57 | ||
|
|
da8d460dc6 | ||
|
|
3825be45df | ||
|
|
248c78d669 | ||
|
|
3d90e11b96 | ||
|
|
d44981b7eb | ||
|
|
3bfc93fd4e | ||
|
|
ef8366be66 | ||
|
|
a7e31b484e | ||
|
|
f4f45c5107 | ||
|
|
c8876a7fd1 | ||
|
|
2f935bbebb | ||
|
|
eec22ffd76 | ||
|
|
909fb83f79 | ||
|
|
41b036966e | ||
|
|
c282d8492d | ||
|
|
5a3c16d20d | ||
|
|
75383e8faa | ||
|
|
29645bc4e7 | ||
|
|
d950a59b4d | ||
|
|
d3e3436075 | ||
|
|
3828a0f054 | ||
|
|
67313f4a23 | ||
|
|
fd2921cb07 | ||
|
|
ad6af9705f | ||
|
|
b6c56c5061 | ||
|
|
c7bdf74d5c | ||
|
|
2426fe2384 | ||
|
|
d370fef899 |
@@ -26,8 +26,8 @@ jobs:
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 12
|
||||
# - platform: win
|
||||
# nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v3
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,7 @@ node_modules/
|
||||
tests/
|
||||
dyids/
|
||||
lottery_info/
|
||||
lottery_dyids/
|
||||
dist/
|
||||
.env
|
||||
*.log
|
||||
|
||||
@@ -1,5 +1,69 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.8.4)
|
||||
* 9ab605a feat: 新增本地dyids抽奖新信息获取方式 (#311)(#287)
|
||||
* a83c5ab fix: extend_json undefined
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.3)
|
||||
* 2f2eaab fix: 预约抽奖包月抽奖识别异常 (#288)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.2)
|
||||
* 3825be4 feat: 查看帐号信息
|
||||
* 248c78d feat: 快速移除关注模式新增粉丝数限制 (#305)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.1)
|
||||
* d44981b fix: 随机cookie参数buvid3
|
||||
* 3bfc93f fix: 目前回复无法正常推送 (#302)
|
||||
* ef8366b fix: tg推送代理设置出错 (#298)
|
||||
* a7e31b4 docs: update
|
||||
* f4f45c5 fix: cookie参数buvid3错误导致专栏获取滞后
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.0)
|
||||
* 2f935bb chore: update env.js
|
||||
* eec22ff feat: 验证码自动识别
|
||||
* 909fb83 chore: update qinglong script
|
||||
* 41b0369 ci: fix pkg.yml
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(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)
|
||||
* 00174b0 fix(monitor): L615
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.6)
|
||||
* 881923b fix: 开奖时间和粉丝数判断逻辑 (#253)
|
||||
* 097e2d6 fix: 筛选掉置顶的评论,与该动态UP的评论 (#252)
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
- [以源码方式运行](#以源码方式运行)
|
||||
- [Docker](#docker)
|
||||
- [青龙面板](#青龙面板)
|
||||
- [防重复转发(可选)](#防重复转发可选)
|
||||
- [检测中奖](#检测中奖)
|
||||
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
|
||||
- [中奖推送(可选)](#中奖推送可选)
|
||||
- [中奖推送](#中奖推送)
|
||||
- [设置说明](#设置说明)
|
||||
- [评论验证码识别](#评论验证码识别)
|
||||
- [其他](#其他)
|
||||
- [Awesome](#awesome)
|
||||
|
||||
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
|
||||
@@ -73,7 +74,7 @@ Chrome浏览器:
|
||||
.cookie
|
||||
.split(/\s*;\s*/)
|
||||
.map(it => it.split('='))
|
||||
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA'].indexOf(it[0]) > -1)
|
||||
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA', 'buvid3'].indexOf(it[0]) > -1)
|
||||
.map(it => it.join('='))
|
||||
.join('; ')
|
||||
.split()
|
||||
@@ -82,7 +83,9 @@ Chrome浏览器:
|
||||
|
||||
也可以采用**其他方式获取**所需的Cookie
|
||||
|
||||
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...` 三项即可
|
||||
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...;buvid3=...` 即可
|
||||
|
||||
buvid3亦可不填 使用随机生成值
|
||||
|
||||
(分号分割, 不要换行, 顺序随意)
|
||||
|
||||
@@ -109,22 +112,20 @@ Chrome浏览器:
|
||||
4. 在`my_config.js`中自定义设置
|
||||
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
|
||||
- windows 可直接点击对应的`*.bat`文件
|
||||
- unix-like
|
||||
```sh
|
||||
## 进入脚本所在目录
|
||||
## 授予执行权限
|
||||
$ chmod u+x lottery
|
||||
## 启动脚本
|
||||
$ ./lottery start
|
||||
## 检测中奖
|
||||
$ ./lottery check
|
||||
## 清理关注动态
|
||||
$ ./lottery clear
|
||||
## 下载最新版本
|
||||
$ ./lottery update
|
||||
|
||||
```
|
||||
用法: lottery [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
start 启动抽奖
|
||||
check 中奖检查
|
||||
acount 查看帐号信息
|
||||
clear 清理动态和关注
|
||||
update 检查更新
|
||||
help 帮助信息
|
||||
```
|
||||
|
||||
7. 运行截图
|
||||
1. 运行截图
|
||||

|
||||
|
||||
#### 以源码方式运行
|
||||
@@ -145,14 +146,6 @@ Chrome浏览器:
|
||||
|
||||
----------------------------------------
|
||||
|
||||
## 防重复转发(可选)
|
||||
|
||||
- 脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
|
||||
|
||||
- 是否点赞
|
||||
|
||||
----------------------------------------
|
||||
|
||||
## 检测中奖
|
||||
|
||||
### 检测未读信息, 已读未读信息
|
||||
@@ -165,7 +158,7 @@ Chrome浏览器:
|
||||
|
||||
关键词有限 可能会有**漏掉**的或**误报**
|
||||
|
||||
### 中奖推送(可选)
|
||||
### 中奖推送
|
||||
|
||||
> 填写在env.js内
|
||||
|
||||
@@ -204,6 +197,12 @@ Chrome浏览器:
|
||||
|
||||
## 设置说明
|
||||
|
||||
### 评论验证码识别
|
||||
|
||||
[点击跳转](doc/chat_captcha_orc.md)
|
||||
|
||||
### 其他
|
||||
|
||||
详见[env.example.js](./env.example.js)文件内部注释
|
||||
|
||||
详见[my_config.example.js](./my_config.example.js)文件内部注释
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
使用此功能前需启动OCR服务
|
||||
|
||||
## 拉取镜像
|
||||
```
|
||||
docker pull shanmite/ocr_api_server
|
||||
```
|
||||
## 启动容器
|
||||
```
|
||||
docker run -p 9898:9898 -d ocr_api_server
|
||||
```
|
||||
|
||||
### 非docker启动方式
|
||||
|
||||

|
||||
|
||||
[ocr_api_server](https://github.com/shanmiteko/ocr_api_server)
|
||||
|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 328 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 292 KiB |
+5
-1
@@ -5,11 +5,14 @@ module.exports = Object.freeze({
|
||||
* - `NOTE` 帐号备注
|
||||
* - `NUMBER` 表示是第几个账号
|
||||
* - `CLEAR` 是否启用清理功能
|
||||
* ## 高级功能
|
||||
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
|
||||
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
|
||||
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式)
|
||||
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
|
||||
* ## 调试相关
|
||||
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Info<Debug 1<2<3<4
|
||||
* - `NOT_GO_LOTTERY` 关闭抽奖行为
|
||||
*
|
||||
* ## 多账号
|
||||
* 1. 将 ENABLE_MULTIPLE_ACCOUNT 的值改为true
|
||||
* 2. 将账号信息依次填写于 multiple_account_parm 中, 参考例子类推
|
||||
@@ -23,6 +26,7 @@ module.exports = Object.freeze({
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
|
||||
ENABLE_CHAT_CAPTCHA_OCR: "",
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
|
||||
MULTIPLE_ACCOUNT_PARM: "",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
|
||||
async function account() {
|
||||
const my_info = await bili.getMyinfo();
|
||||
const stat = await bili.getStat();
|
||||
if (my_info && stat) {
|
||||
log.info("帐号信息", `${my_info.name} Lv${my_info.level} ${my_info.silence ? "已封禁" : "未封禁"} 升级还需${my_info.level_exp.next_exp - my_info.level_exp.current_exp}经验`)
|
||||
log.info("帐号信息", `当前关注数:${stat.following} 粉丝数:${stat.follower} 动态数量:${stat.dynamic_count}`)
|
||||
} else {
|
||||
log.error("帐号信息", "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { account }
|
||||
+17
-12
@@ -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_quick_remove_attention_fans_number_smallest, 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 {
|
||||
@@ -44,13 +45,17 @@ async function clear() {
|
||||
log.info('清理关注', '进入只清理关注模式')
|
||||
/* 专清关注 */
|
||||
for (const [index, uid] of uid_list.entries()) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
const fannumber = await bili.getUserInfo(uid);
|
||||
log.info('清理关注', `粉丝数${fannumber}`)
|
||||
if (fannumber !== -1 && fannumber < clear_quick_remove_attention_fans_number_smallest) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
}
|
||||
}
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
|
||||
+7
-7
@@ -26,7 +26,8 @@ class Monitor extends Searcher {
|
||||
['UIDs', this.getLotteryInfoByUID.bind(this)],
|
||||
['TAGs', this.getLotteryInfoByTag.bind(this)],
|
||||
['Articles', this.getLotteryInfoByArticle.bind(this)],
|
||||
['APIs', this.getLotteryInfoByAPI.bind(this)]
|
||||
['APIs', this.getLotteryInfoByAPI.bind(this)],
|
||||
['TxT', this.getLotteryInfoByTxT.bind(this)]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
@@ -396,8 +397,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 +488,7 @@ class Monitor extends Searcher {
|
||||
|
||||
let
|
||||
/**转发评语 */
|
||||
RandomStr = getRandomOne(relays)
|
||||
RandomStr = (getRandomOne(relays) || "!!!")
|
||||
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
|
||||
/**控制字段 */
|
||||
new_ctrl = [];
|
||||
@@ -541,7 +541,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)
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ class Monitor extends Searcher {
|
||||
status = await retryfn(
|
||||
6,
|
||||
[4],
|
||||
() => bili.sendChat(
|
||||
() => bili.sendChatWithOcr(
|
||||
rid,
|
||||
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
|
||||
chat_type
|
||||
@@ -622,7 +622,7 @@ class Monitor extends Searcher {
|
||||
|
||||
if (status === 8 ||
|
||||
status === 9) {
|
||||
status = await bili.sendChat(
|
||||
status = await bili.sendChatWithOcr(
|
||||
rid,
|
||||
"[doge][doge][doge][doge][doge]",
|
||||
chat_type
|
||||
|
||||
+111
-14
@@ -62,7 +62,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
const { desc, card, extension, extend_json, display = {} } = dynamic_detail_card
|
||||
const { desc, card, extension, extend_json = "{}", display = {} } = dynamic_detail_card
|
||||
, { is_liked = 1, user_profile = {} } = desc
|
||||
, { info = {} } = user_profile
|
||||
, cardToJson = strToJson(card)
|
||||
@@ -103,21 +103,34 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
if (extendjsonToJson[""]) {
|
||||
let r = extendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.reserve_id = reserve_id + "";
|
||||
obj.reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (extend_json.match(/"":\{"lottery/)) {
|
||||
obj.is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
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) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
const { origin_extension, origin, origin_extend_json = "{}" } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { add_on_card_info = [] } = display.origin || {}
|
||||
, originExtendjsonToJson = strToJson(origin_extend_json)
|
||||
, { user, item } = originToJson;
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
@@ -146,7 +159,15 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
if (originExtendjsonToJson[""]) {
|
||||
let r = originExtendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.origin_reserve_id = reserve_id + "";
|
||||
obj.origin_reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (origin_extend_json.match(/"":\{"lottery/)) {
|
||||
obj.origin_is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
@@ -182,6 +203,12 @@ function modifyDynamicRes(res) {
|
||||
log.warn('处理动态数据', '未找到任何动态信息')
|
||||
}
|
||||
|
||||
if (typeof has_more === "undefined"
|
||||
&& typeof offset === "undefined") {
|
||||
log.error('处理动态数据', '该功能已失效');
|
||||
return null;
|
||||
}
|
||||
|
||||
const
|
||||
/**
|
||||
* 字符串offset防止损失精度
|
||||
@@ -349,6 +376,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),
|
||||
@@ -356,7 +385,6 @@ class Searcher {
|
||||
|
||||
if (modDR === null) return null;
|
||||
|
||||
log.info('获取动态', `开始获取带话题#${tag_name}#的动态信息`);
|
||||
log.info('获取动态', '成功获取热门动态');
|
||||
|
||||
/**
|
||||
@@ -421,13 +449,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 */
|
||||
@@ -435,8 +466,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)
|
||||
@@ -573,6 +605,71 @@ class Searcher {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从本地文件中获取抽奖信息
|
||||
* @param {string} txt
|
||||
* @returns {Promise<LotteryInfo[] | null>}
|
||||
*/
|
||||
async getLotteryInfoByTxT(txt) {
|
||||
log.info('获取动态', `开始获取${utils.lottery_dyids}`);
|
||||
const dyids = await utils.getLocalLotteryTxt(txt);
|
||||
let
|
||||
length = dyids.length,
|
||||
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)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `动态(${dyid})无效 (${length--})`)
|
||||
}
|
||||
}
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'txt',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
};
|
||||
})
|
||||
log.info('获取动态', `成功获取txt信息`);
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { Searcher, parseDynamicCard };
|
||||
|
||||
+15
-1
@@ -47,12 +47,19 @@ const config = {
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids
|
||||
*/
|
||||
TxT: [],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
@@ -408,6 +415,13 @@ const config = {
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
@@ -419,7 +433,7 @@ const config = {
|
||||
clear_remove_attention: true,
|
||||
|
||||
/**
|
||||
* 清除动态延时(毫秒)
|
||||
* 清除延时(毫秒)
|
||||
*/
|
||||
clear_remove_delay: 8000,
|
||||
|
||||
|
||||
+21
-4
@@ -1,4 +1,4 @@
|
||||
const { getRemoteConfig, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const { getRemoteConfig, getRandomOne, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
let global_var = {
|
||||
@@ -25,11 +25,28 @@ let global_var = {
|
||||
[0, "UIDs"],
|
||||
[1, "TAGs"],
|
||||
[2, "Articles"],
|
||||
[3, "APIs"]]);
|
||||
[3, "APIs"],
|
||||
[4, "TxT"],
|
||||
]);
|
||||
|
||||
config.updata(num);
|
||||
|
||||
this.set('cookie', cookie + ';buvid3=AAAAAAAA-BBBB-CCCC-DDDD-DDDDDDDDDDDDDDDDDinfoc');
|
||||
if (!/buvid3/.test(cookie)) {
|
||||
const charset = "0123456789ABCDEF".split("");
|
||||
const buvid3 = "x".repeat(8).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(17).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "infoc";
|
||||
this.set('cookie', cookie + ";" + buvid3);
|
||||
} else {
|
||||
this.set('cookie', cookie);
|
||||
}
|
||||
|
||||
cookie.split(/\s*;\s*/).forEach(item => {
|
||||
const _item = item.split('=');
|
||||
@@ -53,4 +70,4 @@ let global_var = {
|
||||
};
|
||||
|
||||
|
||||
module.exports = global_var;
|
||||
module.exports = global_var;
|
||||
|
||||
@@ -495,8 +495,8 @@ function tgBotNotify(text, desp) {
|
||||
}
|
||||
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
||||
options.proxy = {
|
||||
hostname: TG_PROXY_HOST,
|
||||
port: TG_PROXY_PORT * 1
|
||||
url: "http://" + TG_PROXY_HOST + ":" + TG_PROXY_PORT,
|
||||
auth_headers: []
|
||||
}
|
||||
}
|
||||
send(options)
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
const { isMe } = require('./check');
|
||||
const { clear } = require('./clear');
|
||||
const { start } = require('./lottery');
|
||||
const { account } = require("./account");
|
||||
const global_var = require('./data/global_var')
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
@@ -23,4 +24,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, checkCookie }
|
||||
module.exports = { start, isMe, clear, checkCookie, account }
|
||||
+8
-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',
|
||||
@@ -27,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",
|
||||
@@ -35,5 +41,6 @@ module.exports = Object.freeze({
|
||||
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
|
||||
V2_REPLAY: "https://api.bilibili.com/x/v2/reply",
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
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',
|
||||
})
|
||||
+179
-39
@@ -1,5 +1,5 @@
|
||||
const GlobalVar = require('../data/global_var');
|
||||
const { strToJson, log } = require('../utils');
|
||||
const { strToJson, log, ocr, hasEnv } = require('../utils');
|
||||
const { send } = require('./http');
|
||||
const API = require('./api.bili');
|
||||
|
||||
@@ -117,7 +117,7 @@ function post({ url, config, contents, query }) {
|
||||
config,
|
||||
headers: {
|
||||
"accept": 'application/json, text/plain, */*',
|
||||
"content-type": 'application/x-www-form-urlencoded; charset=utf-8',
|
||||
"content-type": 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
"cookie": GlobalVar.get("cookie")
|
||||
},
|
||||
query,
|
||||
@@ -134,7 +134,7 @@ function post({ url, config, contents, query }) {
|
||||
const bili_client = {
|
||||
/**
|
||||
* 判断是否成功登录
|
||||
* @returns {Promise<boolean>}
|
||||
* @returns {Promise<Object?>}
|
||||
*/
|
||||
async getMyinfo() {
|
||||
const
|
||||
@@ -144,9 +144,25 @@ const bili_client = {
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
GlobalVar.set("myUNAME", res.data.name)
|
||||
return true;
|
||||
return res.data;
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 帐号统计
|
||||
* @returns {Promise<Object?>}
|
||||
*/
|
||||
async getStat() {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.WEB_INTERFACE_NAV_STAT
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -218,7 +234,9 @@ const bili_client = {
|
||||
items = data.items || [];
|
||||
log.info('获取一页回复', `成功(${items.length})`);
|
||||
return items
|
||||
.filter(it => it.item.type === 'reply')
|
||||
.filter(it => it.item !== undefined
|
||||
&& it.user !== undefined
|
||||
&& it.reply_time !== undefined)
|
||||
.map(it => {
|
||||
return {
|
||||
nickname: it.user.nickname,
|
||||
@@ -378,37 +396,90 @@ 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,
|
||||
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 || {};
|
||||
switch (code) {
|
||||
case 0:
|
||||
if (card) {
|
||||
log.info('获取一个动态的细节', `动态id(${dynamic_id})`);
|
||||
return card;
|
||||
} else {
|
||||
log.warn('获取一个动态的细节', `动态id(${dynamic_id})不存在`);
|
||||
return;
|
||||
}
|
||||
case 500207:
|
||||
log.warn('获取一个动态的细节', `动态id(${dynamic_id})该动态为包月充电专属可以给UP主充电后观看`);
|
||||
return;
|
||||
default:
|
||||
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`);
|
||||
return;
|
||||
}
|
||||
return this._getOneDynamicByDyid.run(dynamic_id)
|
||||
},
|
||||
/**
|
||||
* 获取一组动态的信息
|
||||
@@ -840,7 +911,7 @@ const bili_client = {
|
||||
},
|
||||
/**
|
||||
* 预约抽奖
|
||||
* @param {number} reserve_id
|
||||
* @param {string} reserve_id
|
||||
* @returns
|
||||
*/
|
||||
async reserve_lottery(reserve_id) {
|
||||
@@ -997,15 +1068,16 @@ const bili_client = {
|
||||
* cid_str
|
||||
* @param {string} msg
|
||||
* @param {number} type
|
||||
* @param {string} code
|
||||
* 1(视频)
|
||||
* 11(有图)
|
||||
* 17(无图)
|
||||
* @returns {Promise<number>}
|
||||
* @returns {Promise<number|string>}
|
||||
* - 成功 0
|
||||
* - 未知错误 1
|
||||
* - 原动态已删除 2
|
||||
* - 评论区已关闭 3
|
||||
* - 需要输入验证码 4
|
||||
* - 需要输入验证码 4 -> url
|
||||
* - 已被对方拉入黑名单 5
|
||||
* - 黑名单用户无法互动 6
|
||||
* - UP主已关闭评论区 7
|
||||
@@ -1013,8 +1085,9 @@ const bili_client = {
|
||||
* - 重复评论 9
|
||||
* - 帐号未登录 10
|
||||
* - 关注UP主7天以上的人可发评论 11
|
||||
* - 验证码错误 12
|
||||
*/
|
||||
async sendChat(rid, msg, type) {
|
||||
async sendChat(rid, msg, type, code) {
|
||||
const
|
||||
responseText = await post({
|
||||
url: API.REPLY_ADD,
|
||||
@@ -1022,6 +1095,7 @@ const bili_client = {
|
||||
oid: rid,
|
||||
type: type,
|
||||
message: msg,
|
||||
code,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}),
|
||||
@@ -1038,7 +1112,7 @@ const bili_client = {
|
||||
return 3;
|
||||
case 12015:
|
||||
log.error('自动评论', '需要输入验证码');
|
||||
return 4;
|
||||
return res.data.url;
|
||||
case 12035:
|
||||
log.error('自动评论', `已被对方拉入黑名单`);
|
||||
return 5;
|
||||
@@ -1060,11 +1134,77 @@ const bili_client = {
|
||||
case 12078:
|
||||
log.error('自动评论', '关注UP主7天以上的人可发评论');
|
||||
return 11;
|
||||
case 12073:
|
||||
log.error('自动评论', '验证码错误');
|
||||
return 12;
|
||||
default:
|
||||
log.error('自动评论', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 发送评论 自动识别验证码
|
||||
* @param {string} rid
|
||||
* cid_str
|
||||
* @param {string} msg
|
||||
* @param {number} type
|
||||
* 1(视频)
|
||||
* 11(有图)
|
||||
* 17(无图)
|
||||
* @returns {Promise<number>}
|
||||
* - 成功 0
|
||||
* - 未知错误 1
|
||||
* - 原动态已删除 2
|
||||
* - 评论区已关闭 3
|
||||
* - 需要输入验证码 4 -> url
|
||||
* - 已被对方拉入黑名单 5
|
||||
* - 黑名单用户无法互动 6
|
||||
* - UP主已关闭评论区 7
|
||||
* - 评论内容包含敏感信息 8
|
||||
* - 重复评论 9
|
||||
* - 帐号未登录 10
|
||||
* - 关注UP主7天以上的人可发评论 11
|
||||
* - 验证码错误 12
|
||||
*/
|
||||
async sendChatWithOcr(rid, msg, type) {
|
||||
let need_captcha = false;
|
||||
let url = "";
|
||||
let status = 0;
|
||||
do {
|
||||
if (need_captcha) {
|
||||
const code = await ocr(url);
|
||||
if (code) {
|
||||
log.info("验证码识别", `${url} -> ${code}`);
|
||||
status = await bili_client.sendChat(
|
||||
rid,
|
||||
msg,
|
||||
type,
|
||||
code
|
||||
);
|
||||
if (status === 0) {
|
||||
need_captcha = false
|
||||
} else if (status === 12) {
|
||||
need_captcha = true
|
||||
} else {
|
||||
need_captcha = false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
url = await bili_client.sendChat(
|
||||
rid,
|
||||
msg,
|
||||
type
|
||||
)
|
||||
if (typeof url === "string"
|
||||
&& hasEnv("ENABLE_CHAT_CAPTCHA_OCR")) {
|
||||
need_captcha = true
|
||||
} else {
|
||||
status = url
|
||||
}
|
||||
}
|
||||
} while (need_captcha);
|
||||
return status;
|
||||
},
|
||||
/**
|
||||
* 查询评论
|
||||
* @param {*} rid
|
||||
@@ -1115,7 +1255,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}`);
|
||||
@@ -1182,10 +1322,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;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-5
@@ -20,12 +20,16 @@
|
||||
* @property {boolean} [redirect] 是否重定向
|
||||
* @property {number} [retry_times] 重试次数
|
||||
*
|
||||
* @typedef ProxyConfig
|
||||
* @property {string} url https?://{IP}:{PORT}
|
||||
* @property {[[string, string]]} auth_headers [[k,v],[k,v]]
|
||||
*
|
||||
* @typedef {object} RequestOptions Http请求选项
|
||||
* @property {string} [method] 请求方法
|
||||
* @property {string} url 完整链接
|
||||
* @property {boolean} [stream] 是否流式数据
|
||||
* @property {RequestConfig} [config] 设置
|
||||
* @property {string} [proxy] HTTP代理 IP:PORT
|
||||
* @property {ProxyConfig} [proxy] HTTP代理 IP:PORT
|
||||
* @property {Object.<string, string|number>} [query] 查询选项
|
||||
* @property {Object.<string, string|number> | string} [contents] 内容
|
||||
* @property {HttpHeaders} [headers] 请求头
|
||||
@@ -34,7 +38,9 @@
|
||||
*/
|
||||
|
||||
const { request: http_request } = require('http');
|
||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||
const { request: https_request } = require('https');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { stringify } = require('querystring');
|
||||
|
||||
/**默认编码 */
|
||||
@@ -64,7 +70,10 @@ function send(detail) {
|
||||
const { timeout, wait, retry, redirect, retry_times } = config;
|
||||
const thisURL = new URL(url)
|
||||
, content = formatContents(headers["content-type"], contents)
|
||||
, request = (thisURL.protocol === 'https:') && !proxy ? https_request : http_request;
|
||||
, request = (thisURL.protocol === 'https:') ? https_request : http_request;
|
||||
/**
|
||||
* @type {import("https").RequestOptions}
|
||||
*/
|
||||
let options = {
|
||||
timeout,
|
||||
method: method.toUpperCase(),
|
||||
@@ -80,9 +89,13 @@ function send(detail) {
|
||||
options.headers['content-length'] = Buffer.byteLength(content, 'utf-8').toString();
|
||||
}
|
||||
if (proxy) {
|
||||
options.headers.host = thisURL.host;
|
||||
options.path = thisURL.href;
|
||||
[options.host, options.port] = proxy.split(':');
|
||||
options.agent = (thisURL.protocol === 'https:')
|
||||
? new HttpsProxyAgent(proxy.url)
|
||||
: new HttpProxyAgent(proxy.url);
|
||||
for (const ah of proxy.auth_headers) {
|
||||
options.headers[ah[0]] = ah[1]
|
||||
}
|
||||
options.rejectUnauthorized = false
|
||||
}
|
||||
const req = request(options, res => {
|
||||
let protodata = '';
|
||||
|
||||
@@ -17,6 +17,8 @@ const utils = {
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**lottery_info存放目录 */
|
||||
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
|
||||
/**本地抽奖信息存放目录 */
|
||||
lottery_dyids: path.join(process.cwd(), "lottery_dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
@@ -275,6 +277,29 @@ const utils = {
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 验证码识别
|
||||
* @param {string} url
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
ocr(url) {
|
||||
return new Promise((resolve) => {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'http://127.0.0.1:9898/ocr/url/text',
|
||||
headers: {
|
||||
"content-type": 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
contents: { url },
|
||||
success: res => {
|
||||
resolve(res.body)
|
||||
},
|
||||
failure: () => {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 下载文件
|
||||
* @param {string} url
|
||||
@@ -459,6 +484,22 @@ const utils = {
|
||||
async clearLotteryInfo() {
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
|
||||
},
|
||||
/**
|
||||
* 获取含抽奖dyids
|
||||
* @param {string} filename
|
||||
* @returns {Promise<Array<String>>}
|
||||
*/
|
||||
getLocalLotteryTxt(filename) {
|
||||
return new Promise((resolve) => {
|
||||
fs.readFile(path.join(utils.lottery_dyids, filename), (err, data) => {
|
||||
if (err) {
|
||||
resolve([])
|
||||
} else {
|
||||
resolve(data.toString("utf8").split(/[^0123456789]+/))
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ async function main() {
|
||||
await global_var.init(COOKIE, NUMBER);
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, checkCookie } = require("./lib/index");
|
||||
const { start, isMe, clear, account, checkCookie } = require("./lib/index");
|
||||
|
||||
log.info('main', '当前为第' + NUMBER + '个账号');
|
||||
log._cache.length = 0
|
||||
|
||||
if (await checkCookie(NUMBER)) {
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
@@ -81,6 +81,10 @@ async function main() {
|
||||
break;
|
||||
case 'help':
|
||||
return help_msg
|
||||
case 'account':
|
||||
log.info('检查帐号信息', '开始运行');
|
||||
await account();
|
||||
break;
|
||||
case undefined:
|
||||
return "未提供以下参数\n\t[OPTIONS]\n\n" + help_msg
|
||||
default:
|
||||
|
||||
+16
-1
@@ -51,12 +51,19 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
APIs: ["file://lottery_info_1.json"],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids(非数字字符分割即可)
|
||||
*/
|
||||
TxT: ["dyids.txt"],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
@@ -403,6 +410,7 @@ module.exports = Object.freeze({
|
||||
/**
|
||||
* - 取关分区
|
||||
* - 默认为: 此处存放因抽奖临时关注的up
|
||||
* - 可用逗号分割以取关多分区
|
||||
*/
|
||||
clear_partition: '',
|
||||
|
||||
@@ -417,6 +425,13 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
@@ -428,7 +443,7 @@ module.exports = Object.freeze({
|
||||
clear_remove_attention: true,
|
||||
|
||||
/**
|
||||
* 清除动态延时(毫秒)
|
||||
* 清除延时(毫秒)
|
||||
*/
|
||||
clear_remove_delay: 8000,
|
||||
|
||||
|
||||
+5
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.7.6",
|
||||
"version": "2.8.4",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
@@ -9,6 +9,8 @@
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"update": "node main.js update",
|
||||
"account": "node main.js account",
|
||||
"help": "node main.js help",
|
||||
"pkg": "bash script/build/pkg.sh",
|
||||
"changelog": "bash script/build/changelog.sh"
|
||||
},
|
||||
@@ -42,6 +44,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.0",
|
||||
"nodemailer": "^6.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ for file in "$TARGET_DIR/"*; do
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
|
||||
if [ "$(echo $file | grep '.exe')" ]; then
|
||||
BATS=("start" "check" "clear" "update")
|
||||
BATS=("start" "check" "clear" "account" "update")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||
done
|
||||
|
||||
+32
-6
@@ -8,7 +8,7 @@ PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
@@ -19,12 +19,12 @@ for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
done
|
||||
if ! systemctl is-active docker >/dev/null 2>&1; then
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -82,6 +82,7 @@ if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
start
|
||||
@@ -103,6 +104,7 @@ if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
check
|
||||
@@ -116,6 +118,28 @@ fi
|
||||
EOF
|
||||
chmod +x check.sh
|
||||
|
||||
echo "create account.sh"
|
||||
cat >account.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-account
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
account
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x account.sh
|
||||
|
||||
echo "create clear.sh"
|
||||
cat >clear.sh <<EOF
|
||||
#!$(which env) bash
|
||||
@@ -124,6 +148,7 @@ if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
clear
|
||||
@@ -144,6 +169,7 @@ NAME=shanmite-lottery-debug
|
||||
echo "create temporary debug container"
|
||||
docker run \\
|
||||
-it \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
--entrypoint /bin/bash \\
|
||||
$DOCKER_REPO -c bash
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
set -e
|
||||
|
||||
NAME=LotteryAutoScript
|
||||
BRABCH=main
|
||||
|
||||
# 视网络情况选择链接
|
||||
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
|
||||
@@ -12,7 +13,7 @@ if [ -d "$NAME" ]; then
|
||||
git pull
|
||||
cd ..
|
||||
else
|
||||
git clone $GIT_REPO $NAME --depth=1
|
||||
git clone -b $BRABCH $GIT_REPO $NAME
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/my_config.js" ]; then
|
||||
@@ -38,6 +39,7 @@ EOF
|
||||
create start
|
||||
create check
|
||||
create clear
|
||||
create account
|
||||
|
||||
cd $NAME
|
||||
npm i
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
await util.par_run([0, 1, 2, 3, 4, 6], [
|
||||
await util.par_run([0, 3], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.equal((await bili_client.getTopRcmd()).length, 10)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneArticleByCv(22112353);
|
||||
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!");
|
||||
})()
|
||||
@@ -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], [
|
||||
await util.par_run([0, 1, 2, 3, 4, 5, 6, 7, 8], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
@@ -12,7 +12,7 @@ const util = require('./util');
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728455586333589522");
|
||||
let info = await bili_client.getOneDynamicByDyid("768874900850999300");
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
},
|
||||
// 2
|
||||
@@ -44,6 +44,24 @@ const util = require('./util');
|
||||
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 + "");
|
||||
},
|
||||
// 7
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832208853440397352");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.reserve_id, "3106984");
|
||||
},
|
||||
// 8
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832966468497834066");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.origin_reserve_id, "3106984");
|
||||
},
|
||||
])
|
||||
|
||||
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 = 2
|
||||
log._level = 4
|
||||
env.init()
|
||||
global_var.init(process.env["COOKIE"], 1)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
const rid = parseDynamicCard(await bili_client.getOneDynamicByDyid("551416252543796684")).rid_str;
|
||||
|
||||
for (let index = 0; index < 100; index++) {
|
||||
console.log(index);
|
||||
await bili_client.sendChatWithOcr(
|
||||
rid,
|
||||
Date.now().toString(),
|
||||
17,
|
||||
)
|
||||
}
|
||||
},]);
|
||||
})()
|
||||
Reference in New Issue
Block a user