mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2d9e192aa | ||
|
|
db7ba49ca1 | ||
|
|
b51882819a | ||
|
|
e0a8ce5b20 | ||
|
|
2b2613386d | ||
|
|
92f700384e | ||
|
|
8e77afadc3 | ||
|
|
bfc8fb6a14 | ||
|
|
f8dbe5ea5a | ||
|
|
47e09a1263 | ||
|
|
b91a4f979d | ||
|
|
d9cecbe163 | ||
|
|
989f836ba2 | ||
|
|
98948ad7f0 | ||
|
|
a363b4ee34 | ||
|
|
c220ff5d27 | ||
|
|
2b6cc8d602 | ||
|
|
856dd79ee9 | ||
|
|
468300227d |
@@ -1,20 +1,24 @@
|
||||
name: Mirror and run GitLab CI
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Mirror + trigger CI
|
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
|
||||
with:
|
||||
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
||||
env:
|
||||
FORCE_PUSH: "true"
|
||||
GITLAB_HOSTNAME: "gitlab.com"
|
||||
GITLAB_USERNAME: "shanmiteko"
|
||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
||||
GITLAB_PROJECT_ID: "36365601"
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
- uses: actions/checkout@v1
|
||||
- name: Mirror + trigger CI
|
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
|
||||
with:
|
||||
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
||||
env:
|
||||
FORCE_PUSH: "true"
|
||||
GITLAB_HOSTNAME: "gitlab.com"
|
||||
GITLAB_USERNAME: "shanmiteko"
|
||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
||||
GITLAB_PROJECT_ID: "36365601"
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
@@ -37,7 +37,6 @@ jobs:
|
||||
node-version: "*"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm install
|
||||
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
@@ -55,14 +54,19 @@ jobs:
|
||||
overwrite: true
|
||||
arm64:
|
||||
runs-on: ubuntu-latest
|
||||
name: arm64
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
- platform: linuxstatic
|
||||
- platform: alpine
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
npm run pkg arm
|
||||
npm run pkg "${{ matrix.platform }}-arm64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
||||
@@ -2,9 +2,11 @@ node_modules/
|
||||
.vscode/
|
||||
tests/
|
||||
dyids/
|
||||
lottery_info/
|
||||
dist/
|
||||
.env
|
||||
*.log
|
||||
*.zip
|
||||
package-lock.json
|
||||
env.js
|
||||
my_config.js
|
||||
@@ -1,5 +1,36 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.6.7)
|
||||
* db7ba49 style: 修改通知格式
|
||||
* b518828 feat: 新增企业微信应用推送 (#217)
|
||||
* e0a8ce5 doc: update image
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.6)
|
||||
* 92f7003 perf: monochrome
|
||||
* 8e77afa fix: `fs.uninkSync` returns before remove finish
|
||||
* bfc8fb6 ci: gitlab mirror `workflow_dispatch`
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.5)
|
||||
* 47e09a1 ci: arm64 added, and optimized
|
||||
* b91a4f9 fix: `fs.rm` node12
|
||||
* d9cecbe ci: push shanmite/pkg-arm64
|
||||
* 989f836 ci: 修改github release镜像源
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.4)
|
||||
* a363b4e ci: 关闭`arm64`自动打包
|
||||
* c220ff5 feat(多账号优化): 抽奖信息本地保存 (#209)
|
||||
* 2b6cc8d feat: 每条运行结果后面加上当前账号序列号 (#206)
|
||||
* 856dd79 fix: 增加获取关注上限(#207)
|
||||
* 4683002 fix: 青龙执行脚本时出错(#202)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.3)
|
||||
* ca1acd2 fix: 转发随机动态视频新的错误码(#201)
|
||||
* dabf8f9 fix: 关注出错(#199)
|
||||
|
||||
+16
-15
@@ -1,22 +1,23 @@
|
||||
FROM arm64v8/node
|
||||
FROM arm64v8/node:lts-alpine
|
||||
|
||||
WORKDIR /root/lottery
|
||||
|
||||
COPY . .
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
|
||||
apk add --no-cache curl
|
||||
|
||||
RUN npm config set registry https://registry.npm.taobao.org && npm i
|
||||
|
||||
ENV DOWNLOAD_HOST=https://download.fastgit.org \
|
||||
RELEASE_TAG=v3.4 \
|
||||
NODEV=18.5.0 \
|
||||
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||
PKG_IGNORE_TAG=true
|
||||
ENV DOWNLOAD_HOST=https://ghproxy.com/https://github.com \
|
||||
RELEASE_TAG=v3.4 \
|
||||
NODEV=18.5.0 \
|
||||
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||
PKG_IGNORE_TAG=true
|
||||
|
||||
RUN mkdir -p "${PKG_CACHE_PATH}" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-alpine-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-alpine-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
|
||||
|
||||
CMD ["bash", "-c", "npx pkg -t node$NODEV-linuxstatic-arm64 -o dist/lottery-auto-script-node$NODEV-linuxstatic-arm64 . && \
|
||||
npx pkg -t node$NODEV-linux-arm64 -o dist/lottery-auto-script-node$NODEV-linux-arm64 ."]
|
||||
ENTRYPOINT ["npx", "pkg"]
|
||||
CMD [""]
|
||||
|
||||
@@ -186,7 +186,8 @@ Chrome浏览器:
|
||||
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
||||
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
||||
| `QYWX_AM` | 企业微信应用 | 第一个值是企业id,第二个值是secret,第三个值@all(或者成员id),第四个值是AgentID (逗号分割) 可查看此[教程](http://note.youdao.com/s/HMiudGkb) [官方文档](https://developer.work.weixin.qq.com/document/path/90236) |
|
||||
| `QYWX_KEY` | 企业微信Bot推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
||||
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
||||
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
|
||||
| `QMSG_KEY` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | [Qmsg注册](https://qmsg.zendee.cn/login.html) |
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 221 KiB |
+16
-6
@@ -32,12 +32,21 @@ module.exports = Object.freeze({
|
||||
|
||||
/**
|
||||
* 为防止环境变量过长, 请将多账号填在此处
|
||||
* 以大括号内容为模板依次复制(包含大括号),逗号分割
|
||||
* ```
|
||||
* ...
|
||||
* NUMBER: 1
|
||||
* ...
|
||||
* NUMBER: 2
|
||||
* 以 **大括号内容** 为模板依次复制(包含大括号),逗号分割
|
||||
*
|
||||
* ```txt
|
||||
* [
|
||||
* {
|
||||
* ...
|
||||
* NUMBER: 1
|
||||
* ...
|
||||
* },
|
||||
* {
|
||||
* ...
|
||||
* NUMBER: 2
|
||||
* ...
|
||||
* }
|
||||
* ]
|
||||
* ```
|
||||
*/
|
||||
multiple_account_parm: [
|
||||
@@ -66,6 +75,7 @@ module.exports = Object.freeze({
|
||||
TG_PROXY_PORT: "",
|
||||
DD_BOT_TOKEN: "",
|
||||
DD_BOT_SECRET: "",
|
||||
QYWX_AM: "",
|
||||
QYWX_KEY: "",
|
||||
IGOT_PUSH_KEY: "",
|
||||
PUSH_PLUS_TOKEN: "",
|
||||
|
||||
+6
-6
@@ -23,13 +23,13 @@ async function isMe(num, note = "无") {
|
||||
.slice(0, unread_at_num)
|
||||
.forEach(({ at_time, up_uname, business, source_content, url }) => {
|
||||
desp += '## [at]检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${up_uname}\n\n`
|
||||
desp += `在${business}中@了你(https://space.bilibili.com/${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
@@ -41,12 +41,12 @@ async function isMe(num, note = "无") {
|
||||
.forEach(({ nickname, uri, source, timestamp }) => {
|
||||
if (judge(source, notice_key_words)) {
|
||||
desp += '## 回复检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${nickname}\n\n`
|
||||
desp += `回复你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
|
||||
desp += `[直达链接](${uri})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
})
|
||||
log.info('中奖检测', '--> OK');
|
||||
@@ -64,12 +64,12 @@ async function isMe(num, note = "无") {
|
||||
const content = await bili.fetch_session_msgs(talker_id, unread_count);
|
||||
if (judge(content, notice_key_words)) {
|
||||
desp += '## 私信检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${sender_uid}\n\n`
|
||||
desp += `私信你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${content}\n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
await bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(update_session_wait);
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ async function getFollowList() {
|
||||
log.info('获取关注列表', '未能成功获取关注分区id');
|
||||
return rmup
|
||||
}
|
||||
for (let index = 1; index < 42; index++) {
|
||||
for (let index = 1; index < 100; index++) {
|
||||
const uids = await bili.getPartitionUID(tagid, index);
|
||||
await delay(get_partition_wait);
|
||||
if (!uids.length) break;
|
||||
@@ -126,4 +126,4 @@ async function clear() {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { clear }
|
||||
module.exports = { clear }
|
||||
|
||||
+8
-3
@@ -1,4 +1,4 @@
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn } = require('../utils');
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn, appendLotteryInfoFile } = require('../utils');
|
||||
const { send } = require('../net/http');
|
||||
const bili = require('../net/bili');
|
||||
const { sendNotify } = require('../helper/notify');
|
||||
@@ -256,7 +256,7 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ check_if_duplicated, set_lottery_info_url, disable_reserve_lottery, reserve_lottery_wait, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
{ check_if_duplicated, save_lottery_info_to_file, set_lottery_info_url, disable_reserve_lottery, reserve_lottery_wait, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**
|
||||
@@ -287,8 +287,13 @@ class Monitor extends Searcher {
|
||||
log.info('筛选动态', `并发查询本地dyid完毕`);
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && save_lottery_info_to_file && protoLotteryInfo.length) {
|
||||
log.info("保存抽奖信息", "保存开始")
|
||||
await appendLotteryInfoFile(lottery_param[1].toString(), protoLotteryInfo)
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
|
||||
log.info("上传抽奖信息", "开始")
|
||||
log.info("上传抽奖信息", "上传开始")
|
||||
await new Promise((resolve) => {
|
||||
send({
|
||||
url: set_lottery_info_url,
|
||||
|
||||
+48
-44
@@ -478,64 +478,68 @@ class Searcher {
|
||||
if (api) {
|
||||
const { strToJson } = utils;
|
||||
log.info('获取动态', `开始获取链接(${api})中的抽奖信息`)
|
||||
send({
|
||||
url: api,
|
||||
config: {
|
||||
redirect: true
|
||||
},
|
||||
method: 'GET',
|
||||
success: ({ body }) => {
|
||||
if (body.err_msg) {
|
||||
log.error("从API响应数据中获取抽奖信息", body.err_msg)
|
||||
resolve(null)
|
||||
} else {
|
||||
const raw_lottery_info = strToJson(body).lottery_info;
|
||||
if (api.startsWith("file://")) {
|
||||
utils.readLotteryInfoFile(api.substring(7)).then(resolve)
|
||||
} else {
|
||||
send({
|
||||
url: api,
|
||||
config: {
|
||||
redirect: true
|
||||
},
|
||||
method: 'GET',
|
||||
success: ({ body }) => {
|
||||
if (body.err_msg) {
|
||||
log.error("从API响应数据中获取抽奖信息", body.err_msg)
|
||||
resolve(null)
|
||||
} else {
|
||||
const raw_lottery_info = strToJson(body).lottery_info;
|
||||
|
||||
if (raw_lottery_info) {
|
||||
let { length } = raw_lottery_info;
|
||||
if (length) {
|
||||
const lottery_info = raw_lottery_info
|
||||
.reduce(async (pre, cur) => {
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
if (raw_lottery_info) {
|
||||
let { length } = raw_lottery_info;
|
||||
if (length) {
|
||||
const lottery_info = raw_lottery_info
|
||||
.reduce(async (pre, cur) => {
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
results.push(cur)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
results.push(cur)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
results.push(cur)
|
||||
}
|
||||
} else {
|
||||
results.push(cur)
|
||||
}
|
||||
|
||||
return results
|
||||
return results
|
||||
|
||||
}, Promise.resolve([]))
|
||||
}, Promise.resolve([]))
|
||||
|
||||
resolve(lottery_info)
|
||||
return
|
||||
resolve(lottery_info)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
|
||||
resolve(null)
|
||||
}
|
||||
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
|
||||
},
|
||||
failure: err => {
|
||||
log.error("从API响应数据中获取抽奖信息", err)
|
||||
resolve(null)
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error("从API响应数据中获取抽奖信息", err)
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `链接为空`)
|
||||
resolve(null)
|
||||
|
||||
+15
-3
@@ -17,7 +17,6 @@ const config = {
|
||||
Articles: [],
|
||||
|
||||
/**
|
||||
* 从API接口中获取抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {string} lottery_info_type
|
||||
* @property {number} create_time
|
||||
@@ -32,11 +31,19 @@ const config = {
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
* @typedef RespondBody
|
||||
* @typedef {object} RespondBody
|
||||
* @property {string} err_msg 错误信息
|
||||
* @property {LotteryInfo[]} lottery_info
|
||||
* API传回数据类型 {RespondBody}
|
||||
*
|
||||
* - 从API接口中获取抽奖信息
|
||||
* 获取抽奖信息的链接字符串
|
||||
* @example
|
||||
* ["https://github.com/spiritLHL/sync_lottery"]
|
||||
*
|
||||
* - 从当前路径下符合要求的文件中获取
|
||||
* 文件名
|
||||
* @example
|
||||
* ["file://lottery_info_1.json"]
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
@@ -52,6 +59,11 @@ const config = {
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* 保存抽奖信息至文件
|
||||
*/
|
||||
save_lottery_info_to_file: false,
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { getRemoteConfig, createDir, createFile } = require("../utils");
|
||||
const { getRemoteConfig, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
let global_var = {
|
||||
@@ -47,7 +47,7 @@ let global_var = {
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
await createFile(num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
|
||||
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+88
-1
@@ -43,6 +43,12 @@ let DD_BOT_TOKEN = '';
|
||||
//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串
|
||||
let DD_BOT_SECRET = '';
|
||||
|
||||
// ================================企业微信应用通知设置区域====================================
|
||||
// 此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)
|
||||
// 环境变量名 QYWX_AM 依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型)
|
||||
// 注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
|
||||
let QYWX_AM = '';
|
||||
|
||||
// =======================================企业微信机器人通知设置区域===========================================
|
||||
//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
|
||||
//注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_KEY)
|
||||
@@ -125,6 +131,10 @@ if (process.env.DD_BOT_TOKEN) {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.QYWX_AM) {
|
||||
QYWX_AM = process.env.QYWX_AM;
|
||||
}
|
||||
|
||||
if (process.env.QYWX_KEY) {
|
||||
QYWX_KEY = process.env.QYWX_KEY;
|
||||
}
|
||||
@@ -169,7 +179,7 @@ if (process.env.SMTP_TO_USER) {
|
||||
|
||||
|
||||
async function sendNotify(text, desp, params = {}) {
|
||||
//提供10种通知方式
|
||||
//提供多种通知方式
|
||||
await Promise.all([
|
||||
//微信server酱
|
||||
serverNotify(text, desp),
|
||||
@@ -183,6 +193,8 @@ async function sendNotify(text, desp, params = {}) {
|
||||
tgBotNotify(text, desp),
|
||||
//钉钉机器人
|
||||
ddBotNotify(text, desp),
|
||||
//企业微信应用
|
||||
qywxAmNotify(text, desp),
|
||||
//企业微信机器人
|
||||
qywxBotNotify(text, desp),
|
||||
//iGot
|
||||
@@ -529,6 +541,81 @@ function ddBotNotify(text, desp) {
|
||||
})
|
||||
}
|
||||
|
||||
function qywxAmNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QYWX_AM) {
|
||||
const QYWX_AM_AY = QYWX_AM.split(',');
|
||||
send({
|
||||
method: 'POST',
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
||||
contents: {
|
||||
corpid: `${QYWX_AM_AY[0]}`,
|
||||
corpsecret: `${QYWX_AM_AY[1]}`,
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
let accesstoken = data.access_token;
|
||||
send({
|
||||
method: 'POST',
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
|
||||
contents: {
|
||||
touser: `${QYWX_AM_AY[2]}`,
|
||||
agentid: `${QYWX_AM_AY[3]}`,
|
||||
safe: '0',
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: `${text}\n\n${desp}`,
|
||||
},
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errcode === 0) {
|
||||
log.info('发送通知', '企业微信应用发送通知消息完成。');
|
||||
} else {
|
||||
log.error('发送通知', `${data.errmsg}`);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function qywxBotNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QYWX_KEY) {
|
||||
|
||||
+7
-8
@@ -65,17 +65,16 @@ async function update() {
|
||||
.filter(({ name }) => checkPlatform(name))
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (download_url.length) {
|
||||
const proxy_host = ['download.fastgit.org']
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = new URL(url)
|
||||
proxy_url.host = proxy_host[0]
|
||||
log.warn('自动下载', `切换代理${proxy_host[0]}`)
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
let proxy_url = "https://ghproxy.com/";
|
||||
proxy_url += url
|
||||
log.warn('自动下载', `切换代理${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
.catch(async err => {
|
||||
log.error('自动下载', err)
|
||||
proxy_url.host = 'github.com'
|
||||
log.warn('自动下载', `使用原始链接github.com`)
|
||||
await download(proxy_url.href, `latest_version${i}.zip`)
|
||||
proxy_url = url
|
||||
log.warn('自动下载', `使用原始链接${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
})
|
||||
return false
|
||||
})
|
||||
|
||||
+56
-11
@@ -15,6 +15,8 @@ const utils = {
|
||||
config_file: path.join(process.cwd(), "my_config.js"),
|
||||
/**dyids存放目录 */
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**lottery_info存放目录 */
|
||||
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
@@ -211,10 +213,7 @@ const utils = {
|
||||
* @returns
|
||||
*/
|
||||
rainbow(msg) {
|
||||
const
|
||||
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
|
||||
colorsCount = colors.length;
|
||||
this.proPrint(msg.map(it => it.split('').map((l, i) => chalk[colors[i % colorsCount]](l)).join('')), '\n')
|
||||
this.proPrint(msg.map(it => it.split('').map(l => chalk.hex("#89cff0")(l)).join('')), '\n')
|
||||
},
|
||||
/**
|
||||
* @param {number} done
|
||||
@@ -230,20 +229,20 @@ const utils = {
|
||||
debug(context, msg) {
|
||||
if (this._level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Debug]"), this._colors[2](`[${context}]`), this._colors[3](`[\n${msg}\n]`)])
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Debug]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[3](`[\n${msg}\n]`)])
|
||||
}
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this._level > 2)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Info]"), this._colors[2](`[${context}]`), this._colors[4](`[${msg}]`)])
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Info]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[4](`[${msg}]`)])
|
||||
},
|
||||
warn(context, msg) {
|
||||
if (this._level > 1)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Warn]"), this._colors[2](`[${context}]`), this._colors[5](`[\n${msg}\n]`)])
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Warn]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[5](`[\n${msg}\n]`)])
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this._level > 0)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Error]"), this._colors[2](`[${context}]`), this._colors[6](`[\n${msg}\n]`)])
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Error]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[6](`[\n${msg}\n]`)])
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -343,13 +342,14 @@ const utils = {
|
||||
},
|
||||
/**
|
||||
* CreateFile
|
||||
* @param {string} filepath 相对于dyids的文件路径
|
||||
* @param {string} basename
|
||||
* @param {string} filename
|
||||
* @param {string} [defaultValue] 写入默认值
|
||||
* @param {string} flag
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createFile(filepath, defaultValue, flag) {
|
||||
const fpath = path.join(utils.dyids_dir, filepath);
|
||||
createFile(basename, filename, defaultValue, flag) {
|
||||
const fpath = path.join(basename, filename);
|
||||
const buffer = Buffer.from(defaultValue);
|
||||
return new Promise((resolve, rejects) => {
|
||||
fs.open(fpath, flag, (err, fd) => {
|
||||
@@ -384,6 +384,51 @@ const utils = {
|
||||
writeDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createWriteStream(fpath, { flags: 'a' })
|
||||
},
|
||||
/**
|
||||
* 追加lotteryinfo
|
||||
* @param {string} from
|
||||
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async appendLotteryInfoFile(from, lottery_info) {
|
||||
let all_lottery_info = {};
|
||||
try {
|
||||
all_lottery_info = utils.strToJson(fs.readFileSync(path.join(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`)).toString())
|
||||
} catch (_) {
|
||||
all_lottery_info = {}
|
||||
}
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
if (all_lottery_info[from] instanceof Array) {
|
||||
all_lottery_info[from].push(...lottery_info)
|
||||
} else {
|
||||
all_lottery_info[from] = lottery_info
|
||||
}
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, JSON.stringify(all_lottery_info), "w")
|
||||
},
|
||||
/**
|
||||
* 读取lottery_info
|
||||
* @param {string} filename
|
||||
* @return {Promise<import("./core/searcher").LotteryInfo[]>}
|
||||
*/
|
||||
readLotteryInfoFile(filename) {
|
||||
return new Promise((resolve) => {
|
||||
fs.readFile(path.join(utils.lottery_info_dir, filename), (err, data) => {
|
||||
if (err) {
|
||||
resolve([])
|
||||
} else {
|
||||
let all_lottery_info = utils.strToJson(data.toString('utf8'));
|
||||
resolve(Object.values(all_lottery_info).flat())
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 清空lottery_info file
|
||||
*/
|
||||
async clearLotteryInfo() {
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require("./lib/utils");
|
||||
|
||||
const metainfo = [
|
||||
` _ _ _ _____ _ _ `,
|
||||
@@ -56,11 +56,14 @@ async function main() {
|
||||
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 { lottery_loop_wait, check_loop_wait, clear_loop_wait } = require("./lib/data/config");
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
log.info('抽奖', '开始运行');
|
||||
loop_wait = lottery_loop_wait;
|
||||
if (save_lottery_info_to_file) {
|
||||
await clearLotteryInfo()
|
||||
}
|
||||
await start(NUMBER);
|
||||
break;
|
||||
case 'check':
|
||||
|
||||
+40
-19
@@ -6,30 +6,19 @@ module.exports = Object.freeze({
|
||||
/**
|
||||
* 监视更转的用户uid
|
||||
*/
|
||||
UIDs: [
|
||||
689277291,
|
||||
241675899
|
||||
],
|
||||
UIDs: [],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
TAGs: [
|
||||
'互动抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
'抽奖',
|
||||
],
|
||||
TAGs: [],
|
||||
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
Articles: [],
|
||||
|
||||
/**
|
||||
* 从API接口中获取抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {string} lottery_info_type
|
||||
* @property {number} create_time
|
||||
@@ -44,15 +33,21 @@ module.exports = Object.freeze({
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
* @typedef RespondBody
|
||||
* @typedef {object} RespondBody
|
||||
* @property {string} err_msg 错误信息
|
||||
* @property {LotteryInfo[]} lottery_info
|
||||
* API传回数据类型 {RespondBody}
|
||||
*
|
||||
* - 从API接口中获取抽奖信息
|
||||
* 获取抽奖信息的链接字符串
|
||||
* @example
|
||||
* "https://github.com/spiritLHL/sync_lottery"
|
||||
* ["https://github.com/spiritLHL/sync_lottery"]
|
||||
*
|
||||
* - 从当前路径下符合要求的文件中获取
|
||||
* 文件名
|
||||
* @example
|
||||
* ["file://lottery_info_1.json"]
|
||||
*/
|
||||
APIs: [],
|
||||
APIs: ["file://lottery_info_1.json"],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
@@ -66,6 +61,11 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* 保存抽奖信息至文件
|
||||
*/
|
||||
save_lottery_info_to_file: false,
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
@@ -434,7 +434,28 @@ module.exports = Object.freeze({
|
||||
* 针对某一账号的特别设置
|
||||
* config_[数字] 依次类推
|
||||
*/
|
||||
config_1: {},
|
||||
config_1: {
|
||||
/**
|
||||
* 手动添加抽奖号UID
|
||||
* - 抽奖动态下的二级小号
|
||||
*/
|
||||
UIDs: [],
|
||||
|
||||
TAGs: [
|
||||
'互动抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
'抽奖',
|
||||
],
|
||||
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
|
||||
APIs: [],
|
||||
|
||||
save_lottery_info_to_file: true,
|
||||
},
|
||||
config_2: {},
|
||||
config_3: {}
|
||||
})
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.6.3",
|
||||
"version": "2.6.7",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+8
-3
@@ -24,13 +24,18 @@ if [[ -z "$1" ]]; then
|
||||
fi
|
||||
|
||||
mkdir -p $TARGET_DIR
|
||||
npm install
|
||||
|
||||
if [[ "$1" == *"arm"* ]]; then
|
||||
podman build -f Dockerfile.pkg-arm64 -t pkg-arm64
|
||||
podman run -it --rm -v ${PWD}/dist:/root/lottery/dist pkg-arm64
|
||||
OUTFILE="$TARGET_DIR/lottery-auto-script-node18-$1"
|
||||
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
podman run -it \
|
||||
--rm \
|
||||
-v ${PWD}:/root/lottery \
|
||||
shanmite/pkg-arm64 -t "node18.5.0-$1" -o "$OUTFILE" .
|
||||
elif [[ "$1" == *"x64"* ]]; then
|
||||
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
|
||||
npx pkg -t "$1" -o $OUTFILE .
|
||||
npx pkg -t "$1" -o "$OUTFILE" .
|
||||
fi
|
||||
|
||||
for file in "$TARGET_DIR/"*; do
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
set -e
|
||||
|
||||
NAME=LotteryAutoScript
|
||||
|
||||
# 视网络情况选择链接
|
||||
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
|
||||
# GIT_REPO=https://ghproxy.com/https://github.com/shanmiteko/${NAME}.git
|
||||
|
||||
@@ -14,11 +16,13 @@ else
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/my_config.js" ]; then
|
||||
echo 'my_config 已存在'
|
||||
else
|
||||
cp $NAME/my_config.example.js $NAME/my_config.js
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/env.js" ]; then
|
||||
echo 'env.js 已存在'
|
||||
else
|
||||
cp $NAME/env.example.js $NAME/env.js
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user