mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
136379a3aa | ||
|
|
313942adb7 | ||
|
|
66efd62d56 | ||
|
|
d7cf7422f4 | ||
|
|
094e019063 | ||
|
|
8de74537f7 | ||
|
|
70c10f247b | ||
|
|
2f26a393ca | ||
|
|
a19739d2d8 | ||
|
|
50e18e2772 | ||
|
|
b9c73bda96 | ||
|
|
608b1fb83e | ||
|
|
07ef8dfb2e | ||
|
|
6b09e26cbf | ||
|
|
7babd5780b | ||
|
|
8b57a85476 | ||
|
|
c85ea6bc77 | ||
|
|
eae72dbdd7 | ||
|
|
111602f248 | ||
|
|
d366e252e9 | ||
|
|
40dcc5f879 | ||
|
|
8c0d96afc6 | ||
|
|
09b6db4f8b | ||
|
|
24e16ed8bc | ||
|
|
fabe9f7d6e | ||
|
|
1962d97bc1 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
**/**
|
||||
!lib/
|
||||
!package*
|
||||
!package.json
|
||||
!main.js
|
||||
@@ -60,9 +60,11 @@ body:
|
||||
attributes:
|
||||
label: "运行日志"
|
||||
description: |
|
||||
控制台日志。
|
||||
控制台日志,请用md代码格式上传,日志内容过多时请上传文件
|
||||
placeholder: |
|
||||
```
|
||||
请在此黏贴运行日志。
|
||||
```
|
||||
|
||||
- id: system
|
||||
type: input
|
||||
|
||||
@@ -6,35 +6,23 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
path-context:
|
||||
docker:
|
||||
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:
|
||||
- name: Build and push
|
||||
env:
|
||||
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
|
||||
repo: ${{ secrets.DOCKERHUB_REPO }}
|
||||
run: |
|
||||
curl -fsSL https://get.docker.com | bash -s docker
|
||||
docker build -t $repo .
|
||||
docker login -p $password -u $username
|
||||
docker push $repo
|
||||
|
||||
+19
-60
@@ -1,23 +1,18 @@
|
||||
name: "Package Node.js project into an executable"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
pkg_x64:
|
||||
runs-on: windows-latest
|
||||
build_all:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
@@ -27,56 +22,20 @@ jobs:
|
||||
node-version: "16"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
sudo apt install zip unzip
|
||||
npm install
|
||||
npm run pkg_x64
|
||||
- name: "Upload to artifact(win)"
|
||||
npm run build_all
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-win-x64
|
||||
path: dist/nlts-win-x64/
|
||||
- name: "Upload to artifact(linux)"
|
||||
uses: actions/upload-artifact@v2
|
||||
name: all_platform
|
||||
path: dist/
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
with:
|
||||
name: nlts-linux-x64
|
||||
path: dist/nlts-linux-x64/
|
||||
- name: "Upload to artifact(macos)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-macos-x64
|
||||
path: dist/nlts-macos-x64/
|
||||
# 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/
|
||||
file: "dist/*.zip"
|
||||
delete_file: "dist/*.zip"
|
||||
tag_name: "v*.*.*"
|
||||
overwrite: true
|
||||
|
||||
@@ -3,6 +3,7 @@ node_modules/
|
||||
tests/
|
||||
dyids/
|
||||
dist/
|
||||
*.log
|
||||
package-lock.json
|
||||
env.js
|
||||
my_config.js
|
||||
@@ -1,5 +1,66 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.3.8)
|
||||
* 313942a ci: pkg.yml tag_name
|
||||
* 66efd62 feat: 新增设置`use_public_blacklist`
|
||||
* d7cf742 feat: 增加粉丝数查询第三方接口
|
||||
* 094e019 fix: 二级转发带有效抽奖
|
||||
* 8de7453 fix: description获取不到
|
||||
* 70c10f2 fix: 更改默认设置`key_words` `blockword`
|
||||
* 2f26a39 feat: 源uid参与筛选判断
|
||||
## 较上一版本变化
|
||||
* 变更可执行文件
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.7...v2.3.8
|
||||
|
||||
## 主要变化(2.3.7)
|
||||
* 50e18e2 feat: 下载更新时有多个版本
|
||||
* b9c73bd chore: change docker auto build
|
||||
* 608b1fb pref: 增加筛选时日志输出(#79)
|
||||
* 07ef8df chore: 移植并完善自动化构建脚本
|
||||
* 6b09e26 chore: update docker init.sh
|
||||
* 7babd57 docs: about docker
|
||||
* 8b57a85 chore: pkg build
|
||||
## 较上一版本变化
|
||||
* 变更可执行文件
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.6...v2.3.7
|
||||
|
||||
## 主要变化(2.3.6)
|
||||
* eae72db feat: minfollower填0可关闭本地粉丝数筛选
|
||||
* 111602f perf: 日志显示是否转发过
|
||||
* d366e25 fix: 转发动态时非限制性错误码(#72)
|
||||
## 较上一版本变化
|
||||
* 变更可执行文件
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.5...v2.3.6
|
||||
|
||||
## 主要变化(2.3.5)
|
||||
* 8c0d96a refactor: 检测是否已经发送过随机动态(#71)
|
||||
* 09b6db4 feat: 新增设置`check_session_pages`(#66)
|
||||
## 较上一版本变化
|
||||
* 变更可执行文件
|
||||
* [my_config.js](my_config.example.js)增加
|
||||
- `check_session_pages` - 检查私信页数
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.4...v2.3.5
|
||||
|
||||
## 主要变化(2.3.4)
|
||||
* 1962d97 fix: 过滤专栏时间失效(#67)
|
||||
## 较上一版本变化
|
||||
只变更可执行文件
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.2...v2.3.4
|
||||
|
||||
## 主要变化(2.3.3)
|
||||
* 11625b3 feat: 检索专栏时能够根据发布时间进行过滤(#65)
|
||||
|
||||
+2
-5
@@ -1,13 +1,10 @@
|
||||
# Latest Nodejs + Alpine Linux
|
||||
FROM node:lts-alpine
|
||||
|
||||
MAINTAINER [email protected]
|
||||
|
||||
LABEL version="1.0" description="自动参与B站动态抽奖"
|
||||
LABEL author="shanmite" version="1.1" description="自动参与B站动态抽奖"
|
||||
|
||||
WORKDIR /lottery
|
||||
|
||||
COPY ["package.json", "package*.json", "./"]
|
||||
COPY ["package.json", "./"]
|
||||
|
||||
RUN npm install
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ npm i && npm run clear
|
||||
1.初始化
|
||||
|
||||
```bash
|
||||
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sh
|
||||
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
|
||||
```
|
||||
|
||||
进入`lottery`文件夹
|
||||
@@ -215,30 +215,27 @@ cd lottery
|
||||
- env.js 设置必要环境变量
|
||||
- my_config.js 你的设置
|
||||
|
||||
执行相应的脚本
|
||||
> start,check,clear
|
||||
|
||||
例如:
|
||||
|
||||
```bash
|
||||
./start.sh
|
||||
2.执行相应的脚本
|
||||
```
|
||||
$ tree
|
||||
.
|
||||
├── check.sh
|
||||
├── clear.sh
|
||||
├── debug.sh 进入临时容器查看内容
|
||||
├── env.js
|
||||
├── my_config.js
|
||||
├── new_env.js
|
||||
├── new_my_config.js
|
||||
├── remove_all.sh 移除对应docker镜像和所有相关容器
|
||||
└── start.sh
|
||||
```
|
||||
|
||||
2.更新
|
||||
3.更新
|
||||
|
||||
进入lottery上一级目录
|
||||
|
||||
使用与初始化相同的命令
|
||||
|
||||
3.卸载
|
||||
|
||||
进入lottery上一级目录
|
||||
|
||||
```bash
|
||||
docker image rm -f shanmite/lottery_auto_docker
|
||||
rm -rf lottery/
|
||||
```
|
||||
|
||||
----------------------------------------
|
||||
|
||||
## 防重复转发
|
||||
|
||||
+3
-2
@@ -10,7 +10,7 @@ const bili = require('./net/bili')
|
||||
async function isMe() {
|
||||
let desp = '';
|
||||
const
|
||||
{ notice_key_words, update_session_wait, get_session_wait } = config,
|
||||
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
|
||||
UnreadAtNum = await bili.getUnreadAtNum(),
|
||||
UnreadSessionNum = await bili.getUnreadSessionNum(),
|
||||
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
|
||||
@@ -34,6 +34,7 @@ async function isMe() {
|
||||
const check = async (type) => {
|
||||
let session_t = '';
|
||||
let MySession = await bili.getSessionInfo(type)
|
||||
log.info("准备检查私信", check_session_pages + "页")
|
||||
for (const index of infiniteNumber()) {
|
||||
for (const Session of MySession.data) {
|
||||
const { sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
@@ -53,7 +54,7 @@ async function isMe() {
|
||||
await delay(update_session_wait);
|
||||
}
|
||||
}
|
||||
if (MySession.has_more && index < 16) {
|
||||
if (MySession.has_more && index < check_session_pages) {
|
||||
await delay(get_session_wait);
|
||||
MySession = await bili.getSessionInfo(type, session_t)
|
||||
} else {
|
||||
|
||||
+77
-38
@@ -110,14 +110,19 @@ class Monitor extends Searcher {
|
||||
continue
|
||||
}
|
||||
} else if (Lottery.uid[0]) {
|
||||
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 51
|
||||
}
|
||||
if (followerNum < config.minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
const { minfollower } = config
|
||||
if (minfollower > 0) {
|
||||
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 51
|
||||
}
|
||||
if (followerNum < minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
log.info('过滤', "不过滤粉丝数")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +188,10 @@ class Monitor extends Searcher {
|
||||
|
||||
log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`);
|
||||
|
||||
log.debug('未进行筛选的动态信息', protoLotteryInfo);
|
||||
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist } = config,
|
||||
{ set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**
|
||||
@@ -205,6 +208,8 @@ class Monitor extends Searcher {
|
||||
return true
|
||||
});
|
||||
|
||||
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
|
||||
|
||||
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
|
||||
log.info("上传抽奖信息", "开始")
|
||||
await new Promise((resolve) => {
|
||||
@@ -228,50 +233,81 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
/* 检查动态是否满足要求 */
|
||||
await try_for_each(protoLotteryInfo, async function ({
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, create_time,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
}) {
|
||||
await try_for_each(protoLotteryInfo, async function (lottery_info) {
|
||||
const {
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, create_time,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
|
||||
log.debug('正在筛选的动态信息', lottery_info);
|
||||
|
||||
/* 遇到转发过就退出 */
|
||||
if (is_liked) return false;
|
||||
if (is_liked) {
|
||||
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
/* 超过指定时间退出 */
|
||||
if (now_ts - create_time > max_create_time * 86400) return false;
|
||||
if (now_ts - create_time > max_create_time * 86400) {
|
||||
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
const
|
||||
/**判断是转发源动态还是现动态 */
|
||||
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
|
||||
isFollowed = (new RegExp(uid)).test(attentionList),
|
||||
description = typeof des === 'string' ? des : '',
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = m_uid && (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = ori_uid && (new RegExp(ori_uid)).test(attentionList),
|
||||
/**判断是转发源动态还是现动态 实际发奖人*/
|
||||
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
|
||||
? [ori_uid, oriIsFollowed]
|
||||
: [m_uid, mIsFollowed],
|
||||
description = des.split(/\/\/@.*?:/)[0],
|
||||
needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description),
|
||||
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
|
||||
isRelayDynamic = type === 1,
|
||||
isTwoLevelDynamic = /\/\/@/.test(description),
|
||||
has_key_words = key_words.every(it => new RegExp(it).test(description)),
|
||||
isBlock = new RegExp(blockword.join('|')).test(description),
|
||||
isLottery =
|
||||
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|
||||
|| (hasOfficialLottery && model[0] === '1')
|
||||
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words),
|
||||
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
|
||||
isSendChat =
|
||||
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|
||||
|| (hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1');
|
||||
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
|
||||
/**屏蔽词 */
|
||||
if (isBlock) return false;
|
||||
if (isBlock) {
|
||||
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
if (only_followed && !isFollowed) return false;
|
||||
if (only_followed && !mIsFollowed && !oriIsFollowed) {
|
||||
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
/* 获取黑名单并去重合并 */
|
||||
const { blacklist: remote_blacklist } = global_var.get("remoteconfig")
|
||||
, new_blacklist = remote_blacklist
|
||||
? [...new Set([...blacklist.split(','), ...remote_blacklist.split(',')])].join()
|
||||
const
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/* 获取黑名单并去重合并 */
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
].join()
|
||||
: blacklist;
|
||||
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) return false;
|
||||
|
||||
if ((new RegExp(dyid + '|' + m_uid + '|' + ori_uid)).test(new_blacklist)) {
|
||||
log.info("筛选动态", `公共黑名单用户(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if (isLottery) {
|
||||
@@ -282,8 +318,8 @@ class Monitor extends Searcher {
|
||||
/**初始化待关注列表 */
|
||||
onelotteryinfo.uid = []
|
||||
|
||||
if (!isFollowed) {
|
||||
onelotteryinfo.uid.push(uid);
|
||||
if (!realIsFollowed) {
|
||||
onelotteryinfo.uid.push(real_uid);
|
||||
}
|
||||
|
||||
onelotteryinfo.dyid = dyid;
|
||||
@@ -313,12 +349,12 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
/* 是否是转发的动态 */
|
||||
if (isRelayDynamic) {
|
||||
if (isRelayDynamic && real_uid) {
|
||||
/* 转发内容长度+'//'+'@'+用户名+':'+源内容 */
|
||||
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
|
||||
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
|
||||
new_ctrl.push({
|
||||
data: String(uid),
|
||||
data: String(real_uid),
|
||||
location: RandomStr.length + 2,
|
||||
length: uname.length + 1,
|
||||
type: 1
|
||||
@@ -327,8 +363,9 @@ class Monitor extends Searcher {
|
||||
item.location += addlength;
|
||||
return item;
|
||||
}).forEach(it => new_ctrl.push(it))
|
||||
if (!(new RegExp(uids[1])).test(attentionList))
|
||||
onelotteryinfo.uid.push(uids[1]);
|
||||
if (!oriIsFollowed) {
|
||||
onelotteryinfo.uid.push(ori_uid);
|
||||
}
|
||||
} else {
|
||||
onelotteryinfo.relay_chat = RandomStr;
|
||||
}
|
||||
@@ -349,6 +386,8 @@ class Monitor extends Searcher {
|
||||
if (isSendChat) onelotteryinfo.rid = rid;
|
||||
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
} else {
|
||||
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
+36
-24
@@ -75,7 +75,10 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description = (item && (item.content || item.description || cardToJson.dynamic || cardToJson.desc)) || '';
|
||||
obj.description =
|
||||
(item && (item.content + item.description))
|
||||
|| (cardToJson.dynamic + cardToJson.desc)
|
||||
|| '';
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
@@ -93,7 +96,10 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
/* 被转发者的name */
|
||||
obj.origin_uname = (user && (user.name || user.uname)) || '';
|
||||
/* 被转发者的描述 */
|
||||
obj.origin_description = (item && (item.content || item.description || originToJson.dynamic || originToJson.desc)) || '';
|
||||
obj.origin_description =
|
||||
(item && (item.content + item.description))
|
||||
|| (originToJson.dynamic + originToJson.desc)
|
||||
|| '';
|
||||
}
|
||||
|
||||
return obj
|
||||
@@ -237,8 +243,6 @@ class Searcher {
|
||||
const results = await pre
|
||||
, { origin_dynamic_id } = cur;
|
||||
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
|
||||
if (card) {
|
||||
@@ -246,19 +250,24 @@ class Searcher {
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
create_time: cur.origin_create_time,
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${origin_dynamic_id})已转发过`)
|
||||
} else {
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
create_time: cur.origin_create_time,
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
@@ -337,7 +346,8 @@ class Searcher {
|
||||
let dyinfos = [];
|
||||
/**遍历专栏s */
|
||||
for (const { id, pub_time } of cvs) {
|
||||
if (pub_time / 86400 > article_create_time) {
|
||||
let now_time = Math.floor(Date.now() / 1000);
|
||||
if ((now_time - pub_time) / 86400 > article_create_time) {
|
||||
log.warn("获取动态", `该专栏(${id})创建时间大于设定天数(${article_create_time}天)`)
|
||||
continue
|
||||
}
|
||||
@@ -358,7 +368,6 @@ class Searcher {
|
||||
/**遍历某专栏中的dyids */
|
||||
for (const dyid of dyids_set) {
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid})是否点赞 (${length--})`)
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
@@ -368,6 +377,7 @@ class Searcher {
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
_weight += 1;
|
||||
@@ -438,8 +448,6 @@ class Searcher {
|
||||
const results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
@@ -447,9 +455,13 @@ class Searcher {
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
cur.is_liked = is_liked
|
||||
|
||||
return [...results, cur]
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
return [...results, cur]
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
+15
-4
@@ -49,8 +49,8 @@ const config = {
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖]",
|
||||
"[转关].*[转关]"
|
||||
"[抽奖送]",
|
||||
"[转关评]"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -221,15 +221,20 @@ const config = {
|
||||
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
@@ -269,6 +274,11 @@ const config = {
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
|
||||
],
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
check_session_pages: 16,
|
||||
|
||||
/**
|
||||
* - 清理白名单uid或dyid
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
@@ -340,6 +350,7 @@ const config = {
|
||||
* @param {string} n
|
||||
*/
|
||||
updata(n) {
|
||||
this.init()
|
||||
this.setObject(this.raw_config()[`config_${n}`])
|
||||
},
|
||||
|
||||
|
||||
+23
-19
@@ -8,32 +8,36 @@ const utils = require("../utils");
|
||||
* @returns
|
||||
*/
|
||||
async function randomDynamic(num) {
|
||||
const { create_dy_type, dy_contents, random_dynamic_wait } = config;
|
||||
let dynamics = []
|
||||
const
|
||||
{ create_dy_type, dy_contents, random_dynamic_wait } = config,
|
||||
hasShareVideo = create_dy_type === -1 || create_dy_type === 1,
|
||||
hasRandomCreate = create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined';
|
||||
|
||||
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
|
||||
if (hasShareVideo) {
|
||||
dynamics = await bili.getTopRcmd()
|
||||
for (let index = 0; dynamics.length < num; index++) {
|
||||
dynamics.push(...await bili.getTopRcmd())
|
||||
}
|
||||
}
|
||||
|
||||
if (hasRandomCreate) {
|
||||
for (let index = 0; index < num; index++) {
|
||||
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
||||
await utils.delay(random_dynamic_wait);
|
||||
dynamics.push(utils.getRandomOne(dy_contents))
|
||||
}
|
||||
}
|
||||
|
||||
if (create_dy_type === -1 || create_dy_type === 1) {
|
||||
let videos = await bili.getTopRcmd()
|
||||
for (let index = 0; videos.length < num; index++) {
|
||||
videos.push(...await bili.getTopRcmd())
|
||||
}
|
||||
|
||||
await utils.try_for_each(videos, async ([uid, aid]) => {
|
||||
if (num--) {
|
||||
await bili.shareVideo(uid, aid)
|
||||
await utils.delay(random_dynamic_wait)
|
||||
return false
|
||||
await utils.try_for_each(
|
||||
utils.shuffle(dynamics).slice(0, num),
|
||||
async (dynamic) => {
|
||||
await utils.delay(random_dynamic_wait)
|
||||
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === "number") {
|
||||
return await bili.shareVideo(...dynamic)
|
||||
} else {
|
||||
return true
|
||||
return await bili.createDynamic(dynamic)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
module.exports = { randomDynamic }
|
||||
+4
-2
@@ -10,8 +10,10 @@ const { log } = utils;
|
||||
async function createRandomDynamic(num) {
|
||||
if (config.create_dy) {
|
||||
log.info('随机动态', `准备创建${num}条随机动态`);
|
||||
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
|
||||
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
|
||||
const
|
||||
{ allModifyDynamicResArray } = await Searcher.checkAllDynamic(global_var.get("myUID"), 1),
|
||||
{ type, orig_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && orig_type !== 8) {
|
||||
await randomDynamic(num)
|
||||
} else {
|
||||
log.info('随机动态', '已有非抽奖动态故无需创建');
|
||||
|
||||
+20
-1
@@ -526,6 +526,17 @@ const bili_client = {
|
||||
query: {
|
||||
vmid: uid
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* 线路三
|
||||
* @param {number} uid
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
(uid) => get({
|
||||
url: "https://tenapi.cn/bilibilifo/",
|
||||
query: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
], responseText => {
|
||||
const res = strToJson(responseText);
|
||||
@@ -748,6 +759,9 @@ const bili_client = {
|
||||
} else if (res.code === 1101004) {
|
||||
log.warn('转发动态', '该动态不能转发分享');
|
||||
return 0;
|
||||
} else if (res.code === 2201116) {
|
||||
log.warn('转发动态', '请求数据发生错误,请刷新或稍后重试');
|
||||
return 0;
|
||||
} else {
|
||||
log.error('转发动态', `转发动态失败\n${responseText}`);
|
||||
return 1;
|
||||
@@ -760,7 +774,7 @@ const bili_client = {
|
||||
* @property {number} img_height
|
||||
* 发布一条动态
|
||||
* @param { string | Picture[] } content
|
||||
* @return {Promise<void>}
|
||||
* @return {Promise<boolean>} isError true
|
||||
*/
|
||||
async createDynamic(content) {
|
||||
let
|
||||
@@ -790,8 +804,10 @@ const bili_client = {
|
||||
});
|
||||
if (/^{"code":0/.test(responseText)) {
|
||||
log.info('发布动态', `成功创建一条随机内容的动态\n${JSON.stringify(content)}\n`);
|
||||
return false
|
||||
} else {
|
||||
log.error('发布动态', `发布动态失败\n${JSON.stringify(content)}\n${responseText}`);
|
||||
return true
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -820,6 +836,7 @@ const bili_client = {
|
||||
* 分享视频
|
||||
* @param {number} uid
|
||||
* @param {number} aid
|
||||
* @return {boolean} isError true
|
||||
*/
|
||||
async shareVideo(uid, aid) {
|
||||
const responseText = await post({
|
||||
@@ -836,8 +853,10 @@ const bili_client = {
|
||||
});
|
||||
if (/^{"code":0/.test(responseText)) {
|
||||
log.info('转发视频', `成功转发视频(av${aid})`);
|
||||
return false
|
||||
} else {
|
||||
log.error('转发视频', `转发失败\n${responseText}`);
|
||||
return true
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
+10
-9
@@ -1,12 +1,12 @@
|
||||
const { send } = require('./net/http')
|
||||
const { strToJson, download } = require('./utils')
|
||||
const { strToJson, download, try_for_each } = require('./utils')
|
||||
const { version, checkVersion, log } = require('./utils')
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {Promise<{ download_url: string, text: string }>}
|
||||
* @returns {Promise<{ download_url: string[], text: string }>}
|
||||
*/
|
||||
function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -36,8 +36,8 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
try {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => name.includes(platform) && name.includes(arch))
|
||||
.map(({ browser_download_url }) => browser_download_url)[0]
|
||||
if (!download_url) {
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (!download_url.length) {
|
||||
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
|
||||
}
|
||||
resolve({ download_url, text })
|
||||
@@ -67,11 +67,12 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
async function update() {
|
||||
try {
|
||||
const { download_url, text } = await getLatestReleaseDownloadUrl('shanmiteko', 'LotteryAutoScript')
|
||||
|
||||
let proxy_url = new URL(download_url)
|
||||
proxy_url.host = 'download.fastgit.org'
|
||||
|
||||
await download(proxy_url.href, 'latest_version.zip')
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = new URL(url)
|
||||
proxy_url.host = 'download.fastgit.org'
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
return false
|
||||
})
|
||||
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
|
||||
+14
-4
@@ -63,8 +63,8 @@ module.exports = Object.freeze({
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖]",
|
||||
"[转关].*[转关]"
|
||||
"[抽奖送]",
|
||||
"[转关评]"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -235,15 +235,20 @@ module.exports = Object.freeze({
|
||||
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
@@ -283,6 +288,11 @@ module.exports = Object.freeze({
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
|
||||
],
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
check_session_pages: 16,
|
||||
|
||||
/**
|
||||
* - 清理白名单uid或dyid
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
|
||||
+9
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.8",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
@@ -8,9 +8,7 @@
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"update": "node main.js update",
|
||||
"pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"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"
|
||||
"build_all": "bash script/build/pkg.sh"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
@@ -24,9 +22,12 @@
|
||||
"bin": "main.js",
|
||||
"pkg": {
|
||||
"targets": [
|
||||
"linux-x64",
|
||||
"win-x64",
|
||||
"macos-x64"
|
||||
"node12-win-x64",
|
||||
"node16-win-x64",
|
||||
"node16-linux-x64",
|
||||
"node16-macos-x64",
|
||||
"node16-linuxstatic-arm64",
|
||||
"node16-linuxstatic-armv7"
|
||||
],
|
||||
"outputPath": "dist"
|
||||
},
|
||||
@@ -52,4 +53,4 @@
|
||||
"chalk": "^4.1.2",
|
||||
"nodemailer": "^6.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ROOT=$PWD
|
||||
README="README.md"
|
||||
TEMPLATE_CONFIG_FILE="my_config.example.js"
|
||||
TEMPLATE_ENV_FILE="env.example.js"
|
||||
CONFIG_FILE="my_config.js"
|
||||
ENV_FILE="env.js"
|
||||
TARGET_DIR="./dist"
|
||||
BIN_NAME="lottery"
|
||||
|
||||
create_win_bat() {
|
||||
echo "@echo off && lottery $1 && pause"
|
||||
}
|
||||
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
npx pkg .
|
||||
|
||||
# Searching in the current directory
|
||||
for file in "$TARGET_DIR/"*; do
|
||||
TMPDIR="${file%.exe}"
|
||||
TMPDIR_NAME="${TMPDIR##*/}"
|
||||
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
|
||||
mv $file $REMANE_FILE
|
||||
mkdir -p "$TMPDIR/"
|
||||
mv $REMANE_FILE "$TMPDIR/"
|
||||
cp $README "$TMPDIR/"
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR/$ENV_FILE"
|
||||
if [ "$(echo $file | grep '.exe')" ]; then
|
||||
BATS=("start" "check" "clear" "update")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR/$item.bat"
|
||||
done
|
||||
else
|
||||
cat >"$TMPDIR/update.sh" <<-EOF
|
||||
#!/bin/bash
|
||||
./lottery update
|
||||
if [[ -r "latest_version.zip" ]]; then
|
||||
unzip latest_version.zip
|
||||
rm latest_version0.zip
|
||||
chmod u+x lottery
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
cd $TMPDIR
|
||||
zip -r "$TMPDIR_NAME.zip" .
|
||||
mv "$TMPDIR_NAME.zip" ../
|
||||
cd $ROOT
|
||||
done
|
||||
Regular → Executable
+86
-23
@@ -29,7 +29,9 @@ if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "create $ENV_FILE"
|
||||
curl -fsSL $ENV_EXAMPLE -o $ENV_FILE
|
||||
else
|
||||
echo "$ENV_FILE exists"
|
||||
echo "$ENV_FILE already existed"
|
||||
echo "create new_$ENV_FILE"
|
||||
curl -fsSL $ENV_EXAMPLE -o "new_$ENV_FILE"
|
||||
fi
|
||||
|
||||
# 新建配置文件
|
||||
@@ -37,38 +39,99 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "create $CONFIG_FILE"
|
||||
curl -fsSL $CONFIG_EXAMPLE -o $CONFIG_FILE
|
||||
else
|
||||
echo "$CONFIG_FILE exists"
|
||||
echo "$CONFIG_FILE already existed"
|
||||
echo "create new_$CONFIG_FILE"
|
||||
curl -fsSL $CONFIG_EXAMPLE -o "new_$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
echo "docker pull $DOCKER_REPO"
|
||||
docker -v && docker pull $DOCKER_REPO
|
||||
|
||||
echo "create start.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
$DOCKER_REPO \
|
||||
start" \
|
||||
> start.sh
|
||||
cat >start.sh <<EOF
|
||||
#!/bin/sh
|
||||
NAME=shanmite-lottery-start
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
start
|
||||
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 start.sh
|
||||
|
||||
echo "create check.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
$DOCKER_REPO \
|
||||
check" \
|
||||
> check.sh
|
||||
cat >check.sh <<EOF
|
||||
#!/bin/sh
|
||||
NAME=shanmite-lottery-check
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
check
|
||||
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 check.sh
|
||||
|
||||
echo "create clear.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
$DOCKER_REPO \
|
||||
clear" \
|
||||
> clear.sh
|
||||
cat >clear.sh <<EOF
|
||||
#!/bin/sh
|
||||
NAME=shanmite-lottery-clear
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
clear
|
||||
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 clear.sh
|
||||
|
||||
echo "create debug.sh"
|
||||
cat >debug.sh <<EOF
|
||||
#!/bin/sh
|
||||
NAME=shanmite-lottery-debug
|
||||
echo "create temporary debug container"
|
||||
docker run \\
|
||||
-it \\
|
||||
--name \$NAME \\
|
||||
--entrypoint /bin/sh \\
|
||||
$DOCKER_REPO -c sh
|
||||
echo "remove temporary debug container"
|
||||
docker rm -v \$NAME
|
||||
EOF
|
||||
chmod +x debug.sh
|
||||
|
||||
echo "create remove_all.sh"
|
||||
cat >remove_all.sh <<EOF
|
||||
#!/bin/sh
|
||||
echo "remove all containers about $DOCKER_REPO"
|
||||
docker rm -v \$(docker ps -a | awk '/shanmite\/lottery_auto_docker/ {print \$1}')
|
||||
echo "remove image $DOCKER_REPO"
|
||||
docker image rm -f shanmite/lottery_auto_docker
|
||||
echo "see you next time!"
|
||||
EOF
|
||||
chmod +x remove_all.sh
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
$README = "README.md"
|
||||
$TEMPLATE_CONFIG_FILE = "my_config.example.js"
|
||||
$TEMPLATE_ENV_FILE = "env.example.js"
|
||||
|
||||
$CONFIG_FILE = "my_config.js"
|
||||
$ENV_FILE = "env.js"
|
||||
|
||||
$TARGET_DIR = ".\dist"
|
||||
|
||||
$NAME = 'lottery-auto-script'
|
||||
|
||||
$TRIARR = @(
|
||||
@("$NAME-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("$NAME-linux", "lottery", "nlts-linux-x64"),
|
||||
@("$NAME-macos", "lottery", "nlts-macos-x64")
|
||||
)
|
||||
|
||||
if((Test-Path $TARGET_DIR) -eq "True") {
|
||||
Remove-Item -Path $TARGET_DIR -Recurse
|
||||
}
|
||||
|
||||
npx pkg .
|
||||
|
||||
Copy-Item -Path $TEMPLATE_ENV_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $TEMPLATE_CONFIG_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $README -Destination $TARGET_DIR -Force
|
||||
|
||||
Set-Location -Path $TARGET_DIR
|
||||
|
||||
Move-Item -Path $TEMPLATE_ENV_FILE -Destination $ENV_FILE -Force
|
||||
Move-Item -Path $TEMPLATE_CONFIG_FILE -Destination $CONFIG_FILE -Force
|
||||
|
||||
foreach ($TRI in $TRIARR) {
|
||||
$PROTO_BIN,$BIN,$DIR = $TRI
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $DIR
|
||||
|
||||
Move-Item -Path $PROTO_BIN -Destination $BIN -Force
|
||||
|
||||
Move-Item -Path $BIN -Destination $DIR -Force
|
||||
Copy-Item -Path $ENV_FILE -Destination $DIR -Force
|
||||
Copy-Item -Path $CONFIG_FILE -Destination $DIR -Force
|
||||
Copy-Item -Path $README -Destination $DIR -Force
|
||||
|
||||
if ($DIR -eq "nlts-win-x64") {
|
||||
New-Item -Path $DIR -Name "start.bat" -ItemType File -Value "@echo off && lottery start && pause" -Force
|
||||
New-Item -Path $DIR -Name "check.bat" -ItemType File -Value "@echo off && lottery check && pause" -Force
|
||||
New-Item -Path $DIR -Name "clear.bat" -ItemType File -Value "@echo off && lottery clear && pause" -Force
|
||||
New-Item -Path $DIR -Name "update.bat" -ItemType File -Value "@echo off && lottery update && pause" -Force
|
||||
}
|
||||
|
||||
Compress-Archive -Path $DIR -DestinationPath $DIR -Force
|
||||
}
|
||||
|
||||
Remove-Item -Path $ENV_FILE
|
||||
Remove-Item -Path $CONFIG_FILE
|
||||
Remove-Item -Path $README
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
./lottery update
|
||||
|
||||
if [[ -r "latest_version.zip" ]]; then
|
||||
unzip latest_version.zip
|
||||
rm latest_version.zip
|
||||
chmod u+x lottery
|
||||
fi
|
||||
Reference in New Issue
Block a user