Compare commits

...
20 Commits
Author SHA1 Message Date
jkluio78andshanmiteko 8bf47698ad feat: 新增设置not_check_article(#25) 2021-09-14 17:00:01 +08:00
shanmite c0bc4878e3 fix: 漏了逗号导致无法更新 2021-09-11 07:33:05 +00:00
shanmiteandGitHub e9b7965a76 doc: 增加徽标 2021-09-09 22:08:20 +08:00
shanmiteandGitHub 0a54cd20db fix(action): no match for platform in manifest 2021-09-09 22:02:34 +08:00
shanmite a2591f260a fix: 黑名单处理(#22) 2021-09-09 13:57:04 +00:00
shanmiteandGitHub e6dc9d7abb Merge pull request #21 from licncnn/main
修改了Linux 定时使用的操作文档
2021-09-09 14:24:00 +08:00
shanmite 179f4d0d41 fix: 错误码变更(#20) 2021-09-09 04:37:27 +00:00
licncnnandGitHub 5a625dbd12 Update linux_schedule.md 2021-09-09 11:43:12 +08:00
licncnnandGitHub 65fd4b3112 Update linux_schedule.md 2021-09-09 11:39:03 +08:00
licncnnandGitHub 14067ca923 Update linux_schedule.md 2021-09-09 11:38:28 +08:00
shanmite 33e55721f6 chore: 修改打包文件名 2021-08-26 15:25:09 +08:00
shanmite aa1aad7ddd fix: copy my_config.js 2021-08-26 15:02:32 +08:00
shanmite 0c0d112aaf feat: arm平台可更新 2021-08-26 14:55:09 +08:00
shanmite b4ec45a48d fix: node16-linuxstatic-armv7 2021-08-26 14:30:31 +08:00
shanmite 1ce8e966e8 fix: 调整arm目标 2021-08-26 14:23:58 +08:00
shanmite f252365809 chore: arm64,armv7 2021-08-26 14:13:45 +08:00
shanmite 30fee87485 chore: 自动打包 2021-08-26 13:53:37 +08:00
shanmite 214abd449f feat: 改变账号异常应对策略 2021-08-26 13:25:18 +08:00
shanmiteandGitHub 79b348d37e Merge pull request #17 from Adamcrg/main
fix: 修改dingtalk签名base64问题
2021-08-26 12:13:17 +08:00
ruigangChen 965734c2f2 修改dingtalk签名base64问题 2021-08-26 11:54:52 +08:00
13 changed files with 199 additions and 67 deletions
+40
View File
@@ -0,0 +1,40 @@
name: "Build and push Docker images"
on:
push:
branches:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
workflow_dispatch:
jobs:
path-context:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: shanmite/lottery_auto_docker:latest
+72
View File
@@ -0,0 +1,72 @@
name: "Package Node.js project into an executable"
on:
push:
branches:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
workflow_dispatch:
branches:
- main
jobs:
pkg_x64:
runs-on: windows-latest
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
- name: "Use Node.js"
uses: actions/setup-node@v1
with:
node-version: "16"
- name: "Pkg this"
run: |
npm install
npm run pkg_x64
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
with:
name: dist_x64
path: dist/
pkg_arm64:
runs-on: ubuntu-latest
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
- name: "Use Node.js"
uses: actions/setup-node@v1
with:
node-version: "16"
- name: "Pkg this"
run: |
npm install
npm run pkg_arm64
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
with:
name: nlts-linux-arm64
path: dist/
pkg_armv7:
runs-on: ubuntu-latest
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
- name: "Use Node.js"
uses: actions/setup-node@v1
with:
node-version: "16"
- name: "Pkg this"
run: |
npm install
npm run pkg_armv7
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
with:
name: nlts-linux-armv7
path: dist/
-27
View File
@@ -1,27 +0,0 @@
name: 'Automatic sync'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
watch:
types: started
repository_dispatch:
types: repo-sync
jobs:
repo-sync:
env:
PAT: ${{ github.event.client_payload.PAT || secrets.PAT }}
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: 开始自动同步
uses: repo-sync/github-sync@v2
if: env.PAT
with:
source_repo: "https://github.com/shanmite/LotteryAutoScript.git"
source_branch: "main"
destination_branch: "main"
github_token: ${{ github.event.client_payload.PAT || secrets.PAT }}
+11 -4
View File
@@ -1,5 +1,4 @@
# AutoScript
- [AutoScript](#autoscript)
- [操作步骤](#操作步骤)
- [获取COOKIE](#获取cookie)
@@ -17,6 +16,9 @@
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
[![Package Node.js project into an executable](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)<br>
[![Build and push Docker images](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)
已实现功能:
- 监控用户转发
- 监控话题页面
@@ -33,6 +35,8 @@
## 操作步骤
**使用前务必阅读此教程和配置文件内注释**
右上角<kbd>★ Star</kbd>
↓↓
@@ -93,8 +97,11 @@ Chrome浏览器:
3. 在`env.js`中填入`COOKIE`和推送参数
4. 在`my_config.js`中自定义设置
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
6. 键入`lottery start`启动抽奖|`lottery check`检测中奖|`lottery clear`清理动态
> 或者新建文本文档写入`lottery start`然后更改扩展名为.bat点击运行
- `lottery start` 启动抽奖
- `lottery check` 检测中奖
- `lottery clear` 清理动态
或者 新建文本文档写入`lottery start`然后更改扩展名为.bat点击运行(已自带start.bat可直接点击)
7. 运行截图
![lottery_start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/lottery_start.png)
@@ -255,4 +262,4 @@ rm -rf lottery/
## 设置说明
详见[env.example.js](./env.example.js)文件内部注释
详见[my_config.example.js](./my_config.example.js)文件内部注释
详见[my_config.example.js](./my_config.example.js)文件内部注释
+13 -14
View File
@@ -10,15 +10,14 @@
2.下载脚本到本地
```sh
git clone https://github.com/shanmite/LotteryAutoScript.git
git clone https://github.com/shanmiteko/LotteryAutoScript.git
```
![image_download](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/image_download.png)
**注意**: github访问下载速度可能很慢, 如果卡住了可以通过Github镜像网站下载
```sh
git clone https://github.com.cnpmjs.org/shanmite/LotteryAutoScript.git
git clone https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript.git
```
@@ -26,6 +25,7 @@ git clone https://github.com.cnpmjs.org/shanmite/LotteryAutoScript.git
```sh
mv env.example.js env.js
mv my_config.example.js my_config.js
```
@@ -38,11 +38,10 @@ vim env.js
# 此处可查阅Vim的使用手册
```
![image-envjs](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/image-envjs.png)
详见[env.example.js](https://github.com/shanmiteko/LotteryAutoScript/blob/main/env.example.js)文件内部注释
说明: `"CLEAR"`项设置为`true`, 才可以开启自动清理动态功能
`"PAT"``"GITHUB_REPOSITORY"`不填也行
[my_config.example.js](https://github.com/shanmiteko/LotteryAutoScript/blob/main/my_config.example.js)同理
~~5.设置定时工作~~
@@ -54,14 +53,14 @@ vim env.js
```sh
crontab -e
```
cd 后的路径修改为你的脚本路径
```sh
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin/:/usr/bin
![crontab](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/crontab.png)
`SHELL``PATH`照着填
`MAILTO`不填也行
注意`HOME`后面跟脚本所在的目录, 这样才能到那个目录下去执行命令
1 */3 * * * cd /root/LotteryAutoScript && npm i && npm run check
1 */3 * * * cd /root/LotteryAutoScript && npm i && npm run start
```
6.手动运行一波
@@ -83,4 +82,4 @@ crontab -e
```sh
git pull
```
```
+34 -10
View File
@@ -55,10 +55,9 @@ class Monitor extends Searcher {
event_bus.emit('Turn_on_the_Monitor')
break
case 22:
config.only_followed = true;
log.warn('账号异常', `UID(${global_var.get('myUID')})临时进入只转已关注模式(异常号只会对部分UP出现关注异常)`)
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
if (!config.is_exception) {
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n临时进入只转已关注模式(异常号只会对部分UP出现关注异常)\n\n可在设置中令is_exception为true关闭此推送`)
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
}
config.is_exception = true;
event_bus.emit('Turn_on_the_Monitor')
@@ -88,6 +87,7 @@ class Monitor extends Searcher {
log.info('筛选动态', `筛选完毕(${len})`);
if (len) {
let is_exception = false;
for (const Lottery of utils.shuffle(allLottery)) {
let status = 0;
if (Lottery.isOfficialLottery) {
@@ -118,14 +118,24 @@ class Monitor extends Searcher {
}
}
status = await this.go(Lottery)
if (status) {
return status
switch (status) {
case 0:
break;
case 22:
is_exception = true
break;
default:
return status
}
d_storage.updateDyid(Lottery.dyid)
await utils.delay(config.wait * (Math.random() + 0.5));
}
log.info('抽奖', '开始转发下一组动态');
return 0
if (is_exception) {
return 22
} else {
return 0
}
} else {
log.info('抽奖', '无未转发抽奖');
return 0
@@ -329,11 +339,13 @@ class Monitor extends Searcher {
for (let times = 0; times < max_retry_times; times++) {
status = await bili.sendChat(rid, utils.getRandomOne(config.chat), chat_type)
if (status === -1) {
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return 0
}
if (!status) {
break
}
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
await utils.delay(60 * 1000 * (times + 1))
}
@@ -344,15 +356,27 @@ class Monitor extends Searcher {
const [u1, u2] = uid
if (u1) {
let status = await bili.autoAttention(u1)
if (status) return 20 + status;
if (status) {
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return 20 + status
};
status = await bili.movePartition(u1, this.tagid)
if (status) return 20 + status;
if (status) {
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return 20 + status
};
if (u2) {
utils.delay(5000)
status = await bili.autoAttention(u2)
if (status) return 20 + status;
if (status) {
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return 20 + status
};
status = await bili.movePartition(u2, this.tagid)
if (status) return 20 + status;
if (status) {
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return 20 + status
};
}
}
+2 -2
View File
@@ -317,7 +317,7 @@ class Searcher {
if (isRelayed) {
_weight += 1;
}
if (_weight >= weight) {
if (_weight >= weight && !config.not_check_article) {
log.warn('获取动态', `1/2动态曾经转过,该专栏或已查看,故中止`)
_dyinfos = []
break
@@ -368,4 +368,4 @@ class Searcher {
}
module.exports = { Searcher };
module.exports = { Searcher };
+1 -1
View File
@@ -430,7 +430,7 @@ function ddBotNotify(text, desp) {
const dateNow = Date.now();
const hmac = crypto.createHmac('sha256', DD_BOT_SECRET);
hmac.update(`${dateNow}\n${DD_BOT_SECRET}`);
const result = encodeURIComponent(hmac.digest('Util64'));
const result = encodeURIComponent(hmac.digest().toString('base64'));
send({
method: 'POST',
url: `https://oapi.dingtalk.com/robot/send`,
+3
View File
@@ -763,6 +763,9 @@ const bili_client = {
} else if (res.code === 12015) {
show && log.error('自动评论', '需要输入验证码');
return 1
} else if (res.code === 12035) {
show && log.error('自动评论', `已被对方拉入黑名单`);
return -1
} else if (res.code === 12053) {
show && log.error('自动评论', '黑名单用户无法互动');
return -1
+11 -3
View File
@@ -27,17 +27,25 @@ function getLatestReleaseDownloadUrl(owner, repo) {
['linux', 'linux'],
['darwin', 'macos']
]).get(process.platform)
if (platform) {
const arch = new Map([
['x64', 'x64'],
['arm', 'armv7'],
['arm64', 'arm64']
]).get(process.arch)
if (platform && arch) {
try {
const download_url = assets
.filter(({ name }) => name.includes(platform))
.filter(({ name }) => name.includes(platform) && name.includes(arch))
.map(({ browser_download_url }) => browser_download_url)[0]
if (!download_url) {
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
}
resolve({ download_url, text })
} catch (err) {
reject(err)
}
} else {
reject(`未找到能在此平台(${process.platform})上运行的版本`)
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
}
} else {
reject('当前已是最新版本')
+7 -1
View File
@@ -73,6 +73,12 @@ module.exports = {
* - 获取专栏数量
*/
article_scan_page: 3,
/**
* - 不检查专栏是否看过,若选择检查可以提高检测效率
* - 默认false(检查)
*/
not_check_article: false,
/**
* - 开奖时间距离现在的最大天数
@@ -249,4 +255,4 @@ module.exports = {
config_1: {},
config_2: {},
config_3: {}
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.1.1",
"version": "2.1.6",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
@@ -9,8 +9,8 @@
"check": "node main.js check",
"update": "node main.js update",
"pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1",
"pkg_arm64": "npx pkg -t linux-arm64 -o dist/lottery main.js && cp my_config.example.js my_config.js && cp env.example.js dist/env.js",
"pkg_armv7": "npx pkg -t linux-armv7 -o dist/lottery main.js && cp my_config.example.js my_config.js && cp env.example.js dist/env.js"
"pkg_arm64": "npx pkg -t node16-linux-arm64 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js",
"pkg_armv7": "npx pkg -t node16-linuxstatic-armv7 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js"
},
"files": [
"lib",
@@ -52,4 +52,4 @@
"chalk": "^4.1.1",
"nodemailer": "^6.5.0"
}
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ foreach ($TRI in $TRIARR) {
New-Item -Path $DIR -Name "update.bat" -ItemType File -Value "@echo off && lottery update && pause" -Force
}
Compress-Archive -Path $DIR -DestinationPath "$($DIR)-$(Get-Date -Format "yyyyMMd")" -Force
Compress-Archive -Path $DIR -DestinationPath $DIR -Force
}
Remove-Item -Path $ENV_FILE