mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b568208990 | ||
|
|
62768ddc71 | ||
|
|
101df0a7a6 | ||
|
|
f8829b5d4b | ||
|
|
be6552a321 | ||
|
|
83e19d44e3 | ||
|
|
c238c27d7d | ||
|
|
8addc9078d | ||
|
|
288851b491 | ||
|
|
ddcfceecef | ||
|
|
49ef4070ca | ||
|
|
0024b19cbf | ||
|
|
04c25a88fc | ||
|
|
9ab605a186 | ||
|
|
a83c5ab91a |
@@ -3,6 +3,7 @@ node_modules/
|
||||
tests/
|
||||
dyids/
|
||||
lottery_info/
|
||||
lottery_dyids/
|
||||
dist/
|
||||
.env
|
||||
*.log
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.8.7)
|
||||
* 62768dd fix: 修改win脚本
|
||||
* 101df0a fix: login等待时间过长
|
||||
* f8829b5 fix: 清理动态检索动态延时
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.6)
|
||||
* 83e19d4 docs: 扫码登陆使用说明
|
||||
* c238c27 fix:多账号login添加时延进行间隔
|
||||
* 8addc90 fix:登录跳过执行正常状态的账号
|
||||
* 288851b feat: 扫码登录获取移动端的CK更新账号,带sid可减小掉号频率
|
||||
* ddcfcee fix: 移除公共黑名单设置
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.5)
|
||||
* 0024b19 feat: 移除远程设置启用自动更新
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.4)
|
||||
* 9ab605a feat: 新增本地dyids抽奖新信息获取方式 (#311)(#287)
|
||||
* a83c5ab fix: extend_json undefined
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.3)
|
||||
* 2f2eaab fix: 预约抽奖包月抽奖识别异常 (#288)
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
- [AutoScript](#autoscript)
|
||||
- [操作步骤](#操作步骤)
|
||||
- [获取COOKIE](#获取cookie)
|
||||
- [扫码登陆](#扫码登陆)
|
||||
- [手动获取](#手动获取)
|
||||
- [本地运行](#本地运行)
|
||||
- [可执行文件](#可执行文件)
|
||||
- [以源码方式运行](#以源码方式运行)
|
||||
@@ -54,6 +56,14 @@
|
||||
|
||||
### 获取COOKIE
|
||||
|
||||
#### 扫码登陆
|
||||
|
||||
在`env.js`文件填`COOKIE`的对应位置写入`"DedeUserID=你的UID"`即可使用`lottery login`扫码自动获取Cookie
|
||||
|
||||
`COOKIE`中包含`DedeUserID=你的UID`的都会被自动替换
|
||||
|
||||
#### 手动获取
|
||||
|
||||
进入[B站主页](https://www.bilibili.com/)获取Cookie用于登录
|
||||
|
||||
Chrome浏览器:
|
||||
@@ -122,6 +132,7 @@ buvid3亦可不填 使用随机生成值
|
||||
acount 查看帐号信息
|
||||
clear 清理动态和关注
|
||||
update 检查更新
|
||||
login 扫码登录更新CK
|
||||
help 帮助信息
|
||||
```
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ async function clear() {
|
||||
log.error("清理失败", "出现错误")
|
||||
break
|
||||
}
|
||||
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
} else {
|
||||
@@ -124,6 +125,8 @@ async function clear() {
|
||||
log.info('清理动态', `此动态类型为${type} != 要清理的动态类型${clear_dynamic_type}`)
|
||||
}
|
||||
}
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
log.info('清理动态', `第${page + 1}页(${allModifyDynamicResArray.length})中的转发动态与关注全部处理成功`)
|
||||
if (next_offset === '0' || !success) break;
|
||||
}
|
||||
|
||||
+6
-20
@@ -26,7 +26,8 @@ class Monitor extends Searcher {
|
||||
['UIDs', this.getLotteryInfoByUID.bind(this)],
|
||||
['TAGs', this.getLotteryInfoByTag.bind(this)],
|
||||
['Articles', this.getLotteryInfoByArticle.bind(this)],
|
||||
['APIs', this.getLotteryInfoByAPI.bind(this)]
|
||||
['APIs', this.getLotteryInfoByAPI.bind(this)],
|
||||
['TxT', this.getLotteryInfoByTxT.bind(this)]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
@@ -62,7 +63,7 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_off_the_Monitor', '关注出错')
|
||||
break;
|
||||
case 3001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区移动出错 可于设置处关闭移动分区')
|
||||
break;
|
||||
case 2004:
|
||||
case 4005:
|
||||
@@ -280,7 +281,6 @@ class Monitor extends Searcher {
|
||||
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;
|
||||
|
||||
@@ -398,25 +398,12 @@ class Monitor extends Searcher {
|
||||
isSendChat =
|
||||
(hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1'),
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/**
|
||||
* 获取黑名单并去重合并
|
||||
* @type {string[]}
|
||||
*/
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
]
|
||||
: blacklist.split(','),
|
||||
keys = [dyid, m_uid, ori_uid];
|
||||
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
|
||||
if (
|
||||
new_blacklist.some(id => keys.some(key => {
|
||||
blacklist.split(',').some(id => keys.some(key => {
|
||||
if (key + '' === id) {
|
||||
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
|
||||
return true
|
||||
@@ -471,7 +458,6 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
if (isLottery) {
|
||||
const { uname_map = {} } = global_var.get("remoteconfig")
|
||||
let onelotteryinfo = {};
|
||||
|
||||
onelotteryinfo.isOfficialLottery = hasOfficialLottery;
|
||||
@@ -488,7 +474,7 @@ class Monitor extends Searcher {
|
||||
let
|
||||
/**转发评语 */
|
||||
RandomStr = (getRandomOne(relays) || "!!!")
|
||||
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
|
||||
.replace(/\$\{uname\}/g, uname),
|
||||
/**控制字段 */
|
||||
new_ctrl = [];
|
||||
|
||||
@@ -541,7 +527,7 @@ class Monitor extends Searcher {
|
||||
if (isSendChat) {
|
||||
onelotteryinfo.rid = rid
|
||||
onelotteryinfo.chat = (getRandomOne(chats) || "!!!")
|
||||
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname)
|
||||
.replace(/\$\{uname\}/g, uname)
|
||||
}
|
||||
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
|
||||
+67
-2
@@ -62,7 +62,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
const { desc, card, extension, extend_json, display = {} } = dynamic_detail_card
|
||||
const { desc, card, extension, extend_json = "{}", display = {} } = dynamic_detail_card
|
||||
, { is_liked = 1, user_profile = {} } = desc
|
||||
, { info = {} } = user_profile
|
||||
, cardToJson = strToJson(card)
|
||||
@@ -127,7 +127,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin, origin_extend_json } = cardToJson
|
||||
const { origin_extension, origin, origin_extend_json = "{}" } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { add_on_card_info = [] } = display.origin || {}
|
||||
, originExtendjsonToJson = strToJson(origin_extend_json)
|
||||
@@ -605,6 +605,71 @@ class Searcher {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从本地文件中获取抽奖信息
|
||||
* @param {string} txt
|
||||
* @returns {Promise<LotteryInfo[] | null>}
|
||||
*/
|
||||
async getLotteryInfoByTxT(txt) {
|
||||
log.info('获取动态', `开始获取${utils.lottery_dyids}`);
|
||||
const dyids = await utils.getLocalLotteryTxt(txt);
|
||||
let
|
||||
length = dyids.length,
|
||||
dyinfos = [];
|
||||
|
||||
for (const dyid of dyids) {
|
||||
if (typeof dyid === "string"
|
||||
&& dyid.length === utils.dyid_length) {
|
||||
|
||||
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated >= 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated >= 1)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
continue
|
||||
}
|
||||
|
||||
dyinfos.push(parsed_card);
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `动态(${dyid})无效 (${length--})`)
|
||||
}
|
||||
}
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'txt',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
};
|
||||
})
|
||||
log.info('获取动态', `成功获取txt信息`);
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { Searcher, parseDynamicCard };
|
||||
|
||||
+7
-6
@@ -47,12 +47,19 @@ const config = {
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids
|
||||
*/
|
||||
TxT: [],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
@@ -298,12 +305,6 @@ const config = {
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { getRemoteConfig, getRandomOne, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const { getRandomOne, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
let global_var = {
|
||||
@@ -25,7 +25,9 @@ let global_var = {
|
||||
[0, "UIDs"],
|
||||
[1, "TAGs"],
|
||||
[2, "Articles"],
|
||||
[3, "APIs"]]);
|
||||
[3, "APIs"],
|
||||
[4, "TxT"],
|
||||
]);
|
||||
|
||||
config.updata(num);
|
||||
|
||||
@@ -60,7 +62,6 @@ let global_var = {
|
||||
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
|
||||
.flat()
|
||||
);
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
const { login } = require('./login');
|
||||
const { isMe } = require('./check');
|
||||
const { clear } = require('./clear');
|
||||
const { start } = require('./lottery');
|
||||
@@ -24,4 +25,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, checkCookie, account }
|
||||
module.exports = { login, start, isMe, clear, checkCookie, account }
|
||||
@@ -0,0 +1,58 @@
|
||||
const { readFileSync, writeFileSync } = require('fs');
|
||||
const { log, env_file } = require("./utils");
|
||||
|
||||
/**
|
||||
* 扫码登陆
|
||||
* @param {string} num
|
||||
*/
|
||||
async function login(num) {
|
||||
try {
|
||||
const { pcLogin } = require('@catlair/blogin');
|
||||
const loginInfo = await pcLogin();
|
||||
if (!loginInfo) {
|
||||
log.error("扫码登陆", "失败/取消");
|
||||
return;
|
||||
}
|
||||
log.info("扫码登陆", "登录成功");
|
||||
JSON.stringify(loginInfo, null, 2);
|
||||
const uid = `${loginInfo.mid}`;
|
||||
const cookie = `${loginInfo.cookie}`;
|
||||
log.info("账号UID", uid);
|
||||
log.info("Cookie", cookie);
|
||||
if (replaceCookie(env_file, uid, cookie)) {
|
||||
log.info("扫码登陆", `账号${num}已进行cookie自动更新,如未能生效请手动复制在env.js内替换。路径:${env_file}`);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则检索uid更新cookie
|
||||
* @param {string} filePath
|
||||
* @param {string} uid
|
||||
* @param {string} oldCK
|
||||
*/
|
||||
function replaceCookie(filePath, uid, oldCK) {
|
||||
try {
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
const DedeUserID = `DedeUserID=${uid}`;
|
||||
const reg = new RegExp(`['"]?COOKIE['"]?:\\s?['"](.*${DedeUserID}.*)['"]`, 'g');
|
||||
const newCK = content.replaceAll(reg, substring => {
|
||||
let quote = substring.at(0) || '';
|
||||
/['"]/.test(quote) || (quote = '');
|
||||
const quote2 = oldCK.includes("'")
|
||||
? '"'
|
||||
: substring.match(/^['"]?COOKIE['"]?:\s?(['"])/)?.[1] || '"';
|
||||
return `${quote}COOKIE${quote}: ${quote2}${oldCK}${quote2}`;
|
||||
});
|
||||
if (content === newCK) return false;
|
||||
writeFileSync(filePath, newCK);
|
||||
return true;
|
||||
} catch (error) {
|
||||
log.error("扫码登陆", error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = { login }
|
||||
+20
-16
@@ -56,8 +56,9 @@ function checkPlatform(releases) {
|
||||
|
||||
/**
|
||||
* 半自动更新
|
||||
* @param {boolean} isDdownload
|
||||
*/
|
||||
async function update() {
|
||||
async function update(isDdownload) {
|
||||
try {
|
||||
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript')
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
@@ -65,20 +66,23 @@ async function update() {
|
||||
.filter(({ name }) => checkPlatform(name))
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (download_url.length) {
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
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 = url
|
||||
log.warn('自动下载', `使用原始链接${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
})
|
||||
return false
|
||||
})
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
if (isDdownload) {
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
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 = url
|
||||
log.warn('自动下载', `使用原始链接${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
})
|
||||
return false
|
||||
})
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('检查更新', '请手动解压替换可执行文件');
|
||||
}
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
} else {
|
||||
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`
|
||||
@@ -87,7 +91,7 @@ async function update() {
|
||||
throw '当前已是最新版本'
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('更新脚本', error)
|
||||
log.warn('更新脚本', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-29
@@ -17,6 +17,8 @@ const utils = {
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**lottery_info存放目录 */
|
||||
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
|
||||
/**本地抽奖信息存放目录 */
|
||||
lottery_dyids: path.join(process.cwd(), "lottery_dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
@@ -336,35 +338,6 @@ const utils = {
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取远程设置
|
||||
* @returns {Promise<JSON>}
|
||||
*/
|
||||
getRemoteConfig() {
|
||||
return new Promise((resolve) => {
|
||||
send({
|
||||
method: 'GET',
|
||||
url: 'https://gitee.com/shanmite/lottery-notice/raw/master/notice.json',
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const body = JSON.parse(Buffer.from(res.body, "base64").toString());
|
||||
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
|
||||
resolve(body.config)
|
||||
} catch (error) {
|
||||
utils.log.error('获取远程设置', '获取远程设置错误: ' + error);
|
||||
resolve({})
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
|
||||
resolve({})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 是否存在文件或目录
|
||||
* @param {string} path
|
||||
@@ -482,6 +455,22 @@ const utils = {
|
||||
async clearLotteryInfo() {
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
|
||||
},
|
||||
/**
|
||||
* 获取含抽奖dyids
|
||||
* @param {string} filename
|
||||
* @returns {Promise<Array<String>>}
|
||||
*/
|
||||
getLocalLotteryTxt(filename) {
|
||||
return new Promise((resolve) => {
|
||||
fs.readFile(path.join(utils.lottery_dyids, filename), (err, data) => {
|
||||
if (err) {
|
||||
resolve([])
|
||||
} else {
|
||||
resolve(data.toString("utf8").split(/[^0123456789]+/))
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ const metainfo = [
|
||||
let multiple_account = [];
|
||||
/**循环等待时间 */
|
||||
let loop_wait = 0;
|
||||
/**账号状态标记 1正常 -1失效 */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let ck_flag = 0
|
||||
|
||||
/**
|
||||
* @returns {Promise<string>} 错误信息
|
||||
@@ -38,7 +41,11 @@ async function main() {
|
||||
if (err_msg) {
|
||||
return err_msg
|
||||
} else {
|
||||
await delay(acco.WAIT);
|
||||
if (ck_flag === 1) {
|
||||
await delay(acco.WAIT);
|
||||
} else {
|
||||
await delay(3 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +56,16 @@ async function main() {
|
||||
await global_var.init(COOKIE, NUMBER);
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, account, checkCookie } = require("./lib/index");
|
||||
const { start, isMe, clear, account, checkCookie, login } = require("./lib/index");
|
||||
|
||||
log.info('main', '当前为第' + NUMBER + '个账号');
|
||||
log._cache.length = 0
|
||||
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
if (await checkCookie(NUMBER)) {
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
|
||||
ck_flag = 1;
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
log.info('抽奖', '开始运行');
|
||||
@@ -79,6 +87,9 @@ async function main() {
|
||||
await clear();
|
||||
}
|
||||
break;
|
||||
case 'login':
|
||||
log.info('登录状态', '正常,跳过扫码');
|
||||
break;
|
||||
case 'help':
|
||||
return help_msg
|
||||
case 'account':
|
||||
@@ -92,7 +103,12 @@ async function main() {
|
||||
}
|
||||
} else {
|
||||
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
|
||||
return
|
||||
ck_flag = -1;
|
||||
if (mode === "login") {
|
||||
log.info('登陆', '开始扫码');
|
||||
await login(NUMBER);
|
||||
await delay(1000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return '请查看README文件, 在env.js指定位置填入cookie'
|
||||
@@ -153,11 +169,13 @@ function initConfig() {
|
||||
/**OPTIONS */
|
||||
process.env.lottery_mode = process.argv[2]
|
||||
|
||||
log.info('检查更新', '开始')
|
||||
|
||||
if (process.env.lottery_mode === "update") {
|
||||
log.info('检查更新', '开始')
|
||||
await require("./lib/update").update()
|
||||
log.info('检查更新', '请手动解压替换可执行文件')
|
||||
await require("./lib/update").update(true)
|
||||
return
|
||||
} else {
|
||||
await require("./lib/update").update(false)
|
||||
}
|
||||
|
||||
const err_msg = await main();
|
||||
@@ -172,7 +190,7 @@ function initConfig() {
|
||||
if (initEnv() || initConfig()) return;
|
||||
await main()
|
||||
}
|
||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||
log.info('结束运行', '未在my_config.js中设置休眠时间')
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
|
||||
@@ -51,12 +51,19 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
APIs: ["file://lottery_info_1.json"],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids(非数字字符分割即可)
|
||||
*/
|
||||
TxT: ["dyids.txt"],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
@@ -303,12 +310,6 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
|
||||
+4
-2
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.8.3",
|
||||
"version": "2.8.7",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"login": "node main.js login",
|
||||
"start": "node main.js start",
|
||||
"test": "node test/index.js",
|
||||
"clear": "node main.js clear",
|
||||
@@ -46,6 +47,7 @@
|
||||
"chalk": "^4.1.2",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.0",
|
||||
"nodemailer": "^6.7.0"
|
||||
"nodemailer": "^6.7.0",
|
||||
"@catlair/blogin": "^0.0.8"
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -12,7 +12,8 @@ TARGET_DIR="dist"
|
||||
BIN_NAME="lottery"
|
||||
|
||||
create_win_bat() {
|
||||
echo "@echo off && lottery $1 && pause"
|
||||
echo "set NODE_SKIP_PLATFORM_CHECK=1" >>$2
|
||||
echo "lottery $1 & pause" >>$2
|
||||
}
|
||||
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
@@ -49,9 +50,9 @@ for file in "$TARGET_DIR/"*; do
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
|
||||
if [ "$(echo $file | grep '.exe')" ]; then
|
||||
BATS=("start" "check" "clear" "account" "update")
|
||||
BATS=("start" "check" "clear" "account" "update" "login")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||
create_win_bat "${item}" "$TMPDIR.d/$item.bat"
|
||||
done
|
||||
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
|
||||
else
|
||||
|
||||
@@ -188,3 +188,25 @@ docker image rm -f shanmite/lottery_auto_docker
|
||||
echo "see you next time!"
|
||||
EOF
|
||||
chmod +x remove_all.sh
|
||||
|
||||
echo "create login.sh"
|
||||
cat >login.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-login
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
login
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "login \$NAME"
|
||||
docker login \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x login.sh
|
||||
@@ -40,6 +40,7 @@ create start
|
||||
create check
|
||||
create clear
|
||||
create account
|
||||
create login
|
||||
|
||||
cd $NAME
|
||||
npm i
|
||||
|
||||
@@ -45,6 +45,10 @@ const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
async () => {
|
||||
assert.equal(await bili_client.autolike("761391835139538967"), 4)
|
||||
},
|
||||
// 7
|
||||
async () => {
|
||||
assert(await bili_client.rmDynamic("835102428771647513"))
|
||||
},
|
||||
])
|
||||
|
||||
console.log("api.test ... ok!");
|
||||
|
||||
Reference in New Issue
Block a user