mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a28ec20b12 | ||
|
|
35cb1c24c2 | ||
|
|
4f961250be | ||
|
|
dce1ff61fd | ||
|
|
ab6bc97f50 | ||
|
|
da8903944a | ||
|
|
08f4375c21 | ||
|
|
ec0c5da092 |
Vendored
-123
@@ -1,123 +0,0 @@
|
||||
{
|
||||
"HttpRequest-get": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "hrget",
|
||||
"body": [
|
||||
"HttpRequest({",
|
||||
" method: 'GET',",
|
||||
" url: '$1',",
|
||||
" query: {",
|
||||
" $2",
|
||||
" },",
|
||||
" headers: {",
|
||||
" accept: 'application/json, text/plain, */*',",
|
||||
" cookie: '$3',",
|
||||
" },",
|
||||
" success: res => {",
|
||||
" $4",
|
||||
" },",
|
||||
" failure: err => {",
|
||||
" $5",
|
||||
" }",
|
||||
"})$6"
|
||||
],
|
||||
"description": "简化http-get请求"
|
||||
},
|
||||
"HttpRequest-post": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "hrpost",
|
||||
"body": [
|
||||
"HttpRequest({",
|
||||
" method: 'POST',",
|
||||
" url: '$1',",
|
||||
" contents: {",
|
||||
" $2",
|
||||
" },",
|
||||
" headers: {",
|
||||
" accept: 'application/json, text/plain, */*',",
|
||||
" 'content-type': 'application/x-www-form-urlencoded; charset=utf-8',",
|
||||
" cookie: '$3',",
|
||||
" },",
|
||||
" success: res => {",
|
||||
" $4",
|
||||
" },",
|
||||
" failure: err => {",
|
||||
" $5",
|
||||
" }",
|
||||
"})$6"
|
||||
],
|
||||
"description": "简化http-post请求"
|
||||
},
|
||||
"CORSajax-get": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "corsget",
|
||||
"body": [
|
||||
"CORSajax.get({",
|
||||
" proxy_link: '$1',",
|
||||
" proxy_querystring: {",
|
||||
" $2",
|
||||
" },",
|
||||
" proxy_headers: {",
|
||||
" Cookie: '$3'",
|
||||
" },",
|
||||
"},chunk => {",
|
||||
" $4",
|
||||
"})$5"
|
||||
],
|
||||
"description": "简化跨域Ajax本地nodejsのget代理"
|
||||
},
|
||||
"CORSajax-post": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "corspost",
|
||||
"body": [
|
||||
"CORSajax.post({",
|
||||
" proxy_link: '$1',",
|
||||
" proxy_headers: {",
|
||||
" 'content-type': 'application/x-www-form-urlencoded; charset=utf-8',",
|
||||
" cookie: '$2'",
|
||||
" },",
|
||||
" proxy_body: {",
|
||||
" $3",
|
||||
" },",
|
||||
"},chunk => {",
|
||||
" $4",
|
||||
"})$5"
|
||||
],
|
||||
"description": "简化跨域Ajax本地nodejsのpost代理"
|
||||
},
|
||||
"Ajax-get": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "myget",
|
||||
"body": [
|
||||
"Ajax.get({",
|
||||
" url: '$1',",
|
||||
" queryStringsObj: {",
|
||||
" $2",
|
||||
" },",
|
||||
" hasCookies: true,",
|
||||
" success: responseText => {",
|
||||
" $3",
|
||||
" }",
|
||||
"})",
|
||||
],
|
||||
"description": "简化AjaxのGet请求"
|
||||
},
|
||||
"Ajax-post": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "mypost",
|
||||
"body": [
|
||||
"Ajax.post({",
|
||||
" url: '$1',",
|
||||
" hasCookies: true,",
|
||||
" dataType: 'application/x-www-form-urlencoded',",
|
||||
" data: {",
|
||||
" $2",
|
||||
" },",
|
||||
" success: responseText => {",
|
||||
" $3",
|
||||
" }",
|
||||
"})",
|
||||
],
|
||||
"description": "简化Ajaxのpost请求"
|
||||
},
|
||||
}
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "启动程序",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${file}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -17,12 +17,19 @@
|
||||
|
||||
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
|
||||
|
||||
已实现功能:
|
||||
> 点赞 评论 转发 @好友 带话题 随机动态 检测开奖 清理
|
||||
已实现功能:
|
||||
- 监控用户转发
|
||||
- 监控话题页面
|
||||
- 监控专栏合集
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 检测是否中奖
|
||||
- 清理动态关注
|
||||
- 检查更新
|
||||
- 更多功能设置请参考配置文件
|
||||
|
||||
声明: 此脚本仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!
|
||||
**声明**: 此脚本仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!
|
||||
|
||||
----------------------------------------
|
||||
---------------------------------
|
||||
|
||||
## 操作步骤
|
||||
|
||||
@@ -70,11 +77,17 @@ Chrome浏览器:
|
||||
### 本地运行
|
||||
|
||||
#### 可执行文件
|
||||
1. [[下载](https://github.com/shanmiteko/LotteryAutoScript/releases)|[cnpmjs镜像下载](https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript/releases)|[Fastgit镜像下载](https://hub.fastgit.org/shanmiteko/LotteryAutoScript/releases)]压缩包并解压后有三个文件
|
||||
1. [[下载](https://github.com/shanmiteko/LotteryAutoScript/releases)|[cnpmjs镜像下载](https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript/releases)|[Fastgit镜像下载](https://hub.fastgit.org/shanmiteko/LotteryAutoScript/releases)]压缩包并解压后
|
||||
```
|
||||
env.js 便捷设置环境变量和多账号参数
|
||||
lottery.exe 可执行文件
|
||||
my_config.js 自定义设置文件
|
||||
~/nlts-linux-x64
|
||||
=> tree
|
||||
.
|
||||
├── dyids (自动生成的dyid存储)
|
||||
│ └── dyid.txt
|
||||
├── env.js (便捷设置环境变量和多账号参数)
|
||||
├── lottery (可执行文件)
|
||||
├── my_config.js (自定义设置文件) (!使用前必读)
|
||||
└── README.md (说明文件)
|
||||
```
|
||||
2. 用记事本或其他编辑器修改`env.js`和`my_config.js`文件(右键选择用记事本打开)
|
||||
3. 在`env.js`中填入`COOKIE`和推送参数
|
||||
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
const { log, delay, infiniteNumber } = require('./utils')
|
||||
const { log, delay, infiniteNumber, judge } = require('./utils')
|
||||
const { sendNotify } = require('./helper/notify')
|
||||
const config = require('./data/config')
|
||||
const global_var = require('./data/global_var')
|
||||
const bili_client = require('./net/bili')
|
||||
const bili = require('./net/bili')
|
||||
|
||||
/**
|
||||
* 是否中奖
|
||||
*/
|
||||
async function isMe() {
|
||||
let desp = '';
|
||||
const UnreadAtNum = await bili_client.getUnreadAtNum();
|
||||
const UnreadSessionNum = await bili_client.getUnreadSessionNum();
|
||||
const UnreadAtNum = await bili.getUnreadAtNum();
|
||||
const UnreadSessionNum = await bili.getUnreadSessionNum();
|
||||
const { follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
|
||||
if (UnreadAtNum > 0) {
|
||||
log.info('中奖检测', '<-- 正在检查at');
|
||||
const MyAtInfo = await bili_client.getMyAtInfo();
|
||||
const MyAtInfo = await bili.getMyAtInfo();
|
||||
MyAtInfo.forEach(async AtInfo => {
|
||||
const { at_time, up_uname, business, source_content, url } = AtInfo
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()} \n\n`
|
||||
@@ -29,15 +29,15 @@ async function isMe() {
|
||||
if (follow_unread + unfollow_unread > 0) {
|
||||
const check = async (type) => {
|
||||
let session_t = '';
|
||||
let MySession = await bili_client.getSessionInfo(type)
|
||||
let MySession = await bili.getSessionInfo(type)
|
||||
for (const index of infiniteNumber()) {
|
||||
for (const Session of MySession.data) {
|
||||
const { content, sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
session_t = session_ts;
|
||||
if (unread_count) {
|
||||
bili_client.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(1000);
|
||||
if (config.notice_key_words.some(it => new RegExp(it).test(content))) {
|
||||
if (judge(content, config.notice_key_words)) {
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${sender_uid} \n\n`
|
||||
desp += `私信你(${global_var.get("myUID")})说: ${content} \n\n`
|
||||
@@ -48,7 +48,7 @@ async function isMe() {
|
||||
}
|
||||
if (MySession.has_more && index < 16) {
|
||||
await delay(3e3);
|
||||
MySession = await bili_client.getSessionInfo(type, session_t)
|
||||
MySession = await bili.getSessionInfo(type, session_t)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
+4
-1
@@ -195,7 +195,7 @@ class Monitor extends Searcher {
|
||||
, isFollowed = (new RegExp(uid)).test(attentionList)
|
||||
, description = typeof des === 'string' ? des : ''
|
||||
, needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description)
|
||||
, needTopic = [...(new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#/ig) || []))].join(' ')
|
||||
, 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))
|
||||
@@ -326,6 +326,9 @@ class Monitor extends Searcher {
|
||||
const max_retry_times = 5;
|
||||
for (let times = 0; times < max_retry_times; times++) {
|
||||
status = await bili.sendChat(rid, utils.getRandomOne(config.chat), chat_type)
|
||||
if (status === -1) {
|
||||
return 0
|
||||
}
|
||||
if (!status) {
|
||||
break
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
const { isMe } = require('./check');
|
||||
const { clear } = require('./clear');
|
||||
const { start } = require('./lottery');
|
||||
const { update } = require('./update');
|
||||
const global_var = require('./data/global_var')
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
const { sendNotify } = require('./helper/notify')
|
||||
const { sendNotify } = require('./helper/notify');
|
||||
|
||||
/**
|
||||
* 检查cookie是否有效
|
||||
@@ -23,4 +24,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, checkCookie }
|
||||
module.exports = { start, isMe, clear, update, checkCookie }
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
module.exports = Object.freeze({
|
||||
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
|
||||
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
@@ -29,4 +29,4 @@ module.exports = {
|
||||
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
}
|
||||
})
|
||||
+7
-3
@@ -218,7 +218,7 @@ const bili_client = {
|
||||
if (res.code === 0) {
|
||||
log.info('私信已读', `成功 -> talker_id: ${talker_id}`);
|
||||
} else {
|
||||
log.error('私信已读', `失败 -> talker_id: ${talker_id}`);
|
||||
log.error('私信已读', `失败 -> talker_id: ${talker_id}\n${responseText}`);
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -724,8 +724,9 @@ const bili_client = {
|
||||
* 11(有图)
|
||||
* 17(无图)
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 1 - 失败
|
||||
* - 成功 0
|
||||
* - 失败 1
|
||||
* - 黑名单 -1
|
||||
*/
|
||||
sendChat(rid, msg, type, show = true) {
|
||||
return post({
|
||||
@@ -750,6 +751,9 @@ const bili_client = {
|
||||
} else if (res.code === 12015) {
|
||||
show && log.error('自动评论', '需要输入验证码');
|
||||
return 1
|
||||
} else if (res.code === 12053) {
|
||||
show && log.error('自动评论', '黑名单用户无法互动');
|
||||
return -1
|
||||
} else {
|
||||
show && log.error('自动评论', `评论失败\n${responseText}`);
|
||||
return 1
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
const { send } = require('./net/http')
|
||||
const { strToJson, download } = require('./utils')
|
||||
const { version, checkVersion, log } = require('./utils')
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {Promise<{ download_url: string, text: string }>}
|
||||
*/
|
||||
function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/releases/latest`,
|
||||
headers: {
|
||||
"accept": 'application/vnd.github.v3+json'
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
success: ({ body }) => {
|
||||
const { tag_name, assets, body: text } = strToJson(body)
|
||||
if (tag_name) {
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const platform = new Map([
|
||||
['win32', 'win'],
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos']
|
||||
]).get(process.platform)
|
||||
if (platform) {
|
||||
try {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => name.includes(platform))
|
||||
.map(({ browser_download_url }) => browser_download_url)[0]
|
||||
resolve({ download_url, text })
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
} else {
|
||||
reject(`未找到能在此平台(${process.platform})上运行的版本`)
|
||||
}
|
||||
} else {
|
||||
reject('当前已是最新版本')
|
||||
}
|
||||
} else {
|
||||
reject(body)
|
||||
}
|
||||
},
|
||||
failure: error => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 半自动更新
|
||||
*/
|
||||
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')
|
||||
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
} catch (error) {
|
||||
log.error('更新脚本', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { update }
|
||||
+70
-7
@@ -2,11 +2,13 @@ const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { send } = require("./net/http");
|
||||
const { version } = require('../package.json');
|
||||
|
||||
/**
|
||||
* 基础工具
|
||||
*/
|
||||
const utils = {
|
||||
version,
|
||||
/**环境变量设置文件 */
|
||||
env_file: path.join(process.cwd(), "env.js"),
|
||||
/**配置文件 */
|
||||
@@ -15,6 +17,16 @@ const utils = {
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
* 将版本号转为数字
|
||||
* @example
|
||||
* 1.2.3 => 1.0203
|
||||
* @param {string} version
|
||||
* @returns {Number}
|
||||
*/
|
||||
checkVersion(version) {
|
||||
return (version.match(/\d.*/)[0]).split('.').reduce((a, v, i) => a + (0.01 ** i) * Number(v), 0)
|
||||
},
|
||||
/**
|
||||
* 安全的将JSON字符串转为对象
|
||||
* 超出精度的数转为字符串
|
||||
@@ -130,6 +142,20 @@ const utils = {
|
||||
}
|
||||
return array;
|
||||
},
|
||||
/**
|
||||
* 关键词判断
|
||||
* @param {string} text
|
||||
* @param {string[]} key_words startwith '~' 表示黑名单
|
||||
* @return {boolean}
|
||||
*/
|
||||
judge(text, key_words) {
|
||||
return key_words.reduce((acc, word) => {
|
||||
word.startsWith('~')
|
||||
? RegExp(word.slice(1)).test(text) && (acc = false)
|
||||
: RegExp(word).test(text) && (acc = true)
|
||||
return acc
|
||||
}, false)
|
||||
},
|
||||
/**
|
||||
* 是否有指定环境变量
|
||||
* @param {string} env_name
|
||||
@@ -140,7 +166,7 @@ const utils = {
|
||||
},
|
||||
/**日志 */
|
||||
log: {
|
||||
level: 0,
|
||||
level: 3,
|
||||
/**
|
||||
* 初始化默认level为3
|
||||
*/
|
||||
@@ -158,22 +184,59 @@ const utils = {
|
||||
debug(context, msg) {
|
||||
if (this.level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
|
||||
}
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this.level > 2)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
|
||||
},
|
||||
warn(context, msg) {
|
||||
if (this.level > 1)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[${msg}]`)])
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this.level > 0)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date().toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[${msg}]`)])
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 下载文件
|
||||
* @param {string} url
|
||||
* @param {string} file_name
|
||||
* @returns {Promise<void | string>}
|
||||
*/
|
||||
download(url, file_name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url,
|
||||
stream: true,
|
||||
config: {
|
||||
redirect: true,
|
||||
retry: false
|
||||
},
|
||||
success: ({ resStream }) => {
|
||||
let recv_length = 0;
|
||||
const wtbs = fs.createWriteStream(file_name);
|
||||
resStream.on('data', chuck => {
|
||||
recv_length += chuck.length
|
||||
utils.log.proPrint(`已收到:${recv_length} Bytes`)
|
||||
})
|
||||
resStream.pipe(wtbs)
|
||||
wtbs.on('finish', () => {
|
||||
utils.log.proPrint('下载完成')
|
||||
resolve()
|
||||
}).on('error', error => {
|
||||
wtbs.destroy()
|
||||
resolve(error)
|
||||
})
|
||||
},
|
||||
failure: error => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取远程设置
|
||||
* @returns {Promise<JSON>}
|
||||
@@ -191,14 +254,14 @@ const utils = {
|
||||
success: res => {
|
||||
try {
|
||||
const body = JSON.parse(res.body);
|
||||
if (body.node_msg) this.log.info('公告', '\n' + body.node_msg + '\n');
|
||||
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
|
||||
resolve(body.config)
|
||||
} catch (error) {
|
||||
resolve(JSON.parse('{}'))
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
this.log.error('获取远程设置', '获取远程设置错误: ' + err);
|
||||
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
|
||||
resolve(JSON.parse('{}'));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { env_file, config_file, log, delay, hasFileOrDir } = require("./lib/utils");
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
|
||||
|
||||
const metainfo = [
|
||||
` _ _ _ _____ _ _ `,
|
||||
@@ -10,8 +10,8 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` Verison: v2.0.3`,
|
||||
` Written by shanmite`,
|
||||
` Verison: v${ve}`,
|
||||
` Written By shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
let multiple_account = [];
|
||||
@@ -44,21 +44,19 @@ async function main() {
|
||||
|
||||
/**多账号状态还原 */
|
||||
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
|
||||
} else {
|
||||
if (!COOKIE) {
|
||||
return '请查看README文件, 在env.js指定位置填入cookie'
|
||||
}
|
||||
} else if (COOKIE) {
|
||||
const global_var = require("./lib/data/global_var");
|
||||
await global_var.init(COOKIE, Number(NUMBER));
|
||||
|
||||
const { start, isMe, clear, checkCookie } = require("./lib/index");
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
|
||||
|
||||
log.info('main', '当前为第' + NUMBER + '个账号');
|
||||
|
||||
if (await checkCookie(NUMBER)) {
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tclear 清理动态和关注\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait } = require("./lib/data/config");
|
||||
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, update_loop_wait } = require("./lib/data/config");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
log.info('抽奖', '开始运行');
|
||||
@@ -77,6 +75,11 @@ async function main() {
|
||||
await clear();
|
||||
}
|
||||
break;
|
||||
case 'update':
|
||||
log.info('检查更新', '开始')
|
||||
loop_wait = update_loop_wait;
|
||||
await update()
|
||||
break;
|
||||
case 'help':
|
||||
return help_msg
|
||||
case undefined:
|
||||
@@ -84,7 +87,11 @@ async function main() {
|
||||
default:
|
||||
return `提供了错误的[OPTIONS] -> ${mode}\n\n` + help_msg
|
||||
}
|
||||
} else {
|
||||
return 'Cookie已失效, 切换账号时不要点击退出账号而应直接删除Cookie退出'
|
||||
}
|
||||
} else {
|
||||
return '请查看README文件, 在env.js指定位置填入cookie'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +106,12 @@ async function main() {
|
||||
initEnv();
|
||||
log.init();
|
||||
log.info('环境变量初始化', '成功加载env.js文件');
|
||||
} else if (hasEnv('COOKIE') || hasEnv('MULTIPLE_ACCOUNT_PARM')) {
|
||||
log.init();
|
||||
log.info('环境变量初始化', '成功从环境变量中读取COOKIE设置');
|
||||
} else {
|
||||
log.init();
|
||||
log.warn('环境变量初始化', '未在当前目录下找到env.js文件 也可在环境变量中设置所需参数');
|
||||
log.error('环境变量初始化', '未在当前目录下找到env.js文件或者在环境变量中设置所需参数');
|
||||
return
|
||||
}
|
||||
|
||||
@@ -127,7 +137,7 @@ async function main() {
|
||||
await delay(loop_wait)
|
||||
await main()
|
||||
}
|
||||
log.info('结束运行', '未设置休眠时间')
|
||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
|
||||
@@ -87,6 +87,7 @@ module.exports = {
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
update_loop_wait: 0,
|
||||
|
||||
/**
|
||||
* - 转发间隔时间
|
||||
@@ -140,7 +141,7 @@ module.exports = {
|
||||
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
|
||||
|
||||
/**
|
||||
* - 同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
@@ -178,11 +179,13 @@ module.exports = {
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 中奖通知关键词(满足一个就推送)
|
||||
* 符合js正则表达式的字符串
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
* - 若以 ~ 开头则表示为黑名单规则
|
||||
*/
|
||||
notice_key_words: [
|
||||
"中奖", "获得", "填写", "写上", "提供", "收货地址", "支付宝账号", "码", "大会员"
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~有奖预约通知"
|
||||
],
|
||||
|
||||
/**
|
||||
|
||||
+5
-4
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "lottery-in-bili",
|
||||
"version": "3.0.0",
|
||||
"description": "自动抽奖",
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.0.6",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "node main.js start",
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"pkg_x86": "npx pkg . && PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"update": "node main.js update",
|
||||
"pkg_x64": "npx pkg . && PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"pkg_clean_dist": "PowerShell -Command \"& {Remove-Item -Path .\\dist\\ -Recurse}\"",
|
||||
"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"
|
||||
|
||||
+6
-3
@@ -7,10 +7,12 @@ $ENV_FILE = "env.js"
|
||||
|
||||
$TARGET_DIR = ".\dist"
|
||||
|
||||
$NAME = 'lottery-auto-script'
|
||||
|
||||
$TRIARR = @(
|
||||
@("lottery-in-bili-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("lottery-in-bili-linux", "lottery", "nlts-linux-x64"),
|
||||
@("lottery-in-bili-macos", "lottery", "nlts-macos-x64")
|
||||
@("$NAME-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("$NAME-linux", "lottery", "nlts-linux-x64"),
|
||||
@("$NAME-macos", "lottery", "nlts-macos-x64")
|
||||
)
|
||||
|
||||
Copy-Item -Path $TEMPLATE_ENV_FILE -Destination $TARGET_DIR -Force
|
||||
@@ -38,6 +40,7 @@ foreach ($TRI in $TRIARR) {
|
||||
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)-$(Get-Date -Format "yyyyMMd")" -Force
|
||||
|
||||
Reference in New Issue
Block a user