mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ae391eee | ||
|
|
a1b055b9de | ||
|
|
d2d9d31ebf | ||
|
|
fdee933ca4 | ||
|
|
53ae976caf | ||
|
|
de88467c03 |
@@ -7,5 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### 清晰而简明地描述
|
||||
在此写下你的描述
|
||||
**清晰而简明地描述**
|
||||
- [x] 你确定提出的功能脚本的确没有
|
||||
|
||||
<!-- 在此写下你的描述 -->
|
||||
|
||||
@@ -1,33 +1,47 @@
|
||||
---
|
||||
name: Bug 反馈
|
||||
about: 提出你遇到的问题, 提问之前请检索问题是否重复
|
||||
about: 提出你遇到的问题
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### 在反馈bug之前,请确保你已经认真阅读了本项目的README和脚本的内置说明
|
||||
**描述bug**
|
||||
简要描述所遇到的bug
|
||||
**为避免无效问题和冗余问题,提问前请确认**
|
||||
|
||||
- [x] 你确定搜索引擎不能解决你的问题
|
||||
- [x] 你确定提供的Readme文档和Release说明不能解决你的问题
|
||||
- [x] 你确定已有的issue不能解决你的问题
|
||||
- [x] 你确定issue的title能简明的描述你的问题
|
||||
|
||||
**描述Bug**
|
||||
|
||||
<!-- 简要而清晰的描述你所遇到的bug -->
|
||||
|
||||
**重现Bug**
|
||||
|
||||
<!-- 说明您在进行了怎样的操作后出现了Bug -->
|
||||
|
||||
**重现bug**
|
||||
说明您在进行了怎样的操作后出现了bug
|
||||
1. xxx
|
||||
2. xxx
|
||||
|
||||
**预期行为**
|
||||
简要描述进行以上操作后预期的脚本行为
|
||||
**预期行为**
|
||||
|
||||
**截图**
|
||||
如果可以,请提供有关截图
|
||||
<!-- 简要描述进行以上操作后预期的脚本行为 -->
|
||||
|
||||
**运行日志**
|
||||
控制台日志。
|
||||
**截图**
|
||||
|
||||
**使用环境:**
|
||||
- Github Actions中
|
||||
- 本地运行
|
||||
<!-- 如果可以,请提供尽可能多的相关截图 -->
|
||||
|
||||
**其他**
|
||||
若您有其他想要补充的内容,请在此说明
|
||||
**运行日志**
|
||||
|
||||
<!-- 控制台日志 -->
|
||||
|
||||
**使用环境:**
|
||||
- 操作系统
|
||||
- NodeJs版本
|
||||
- 脚本版本
|
||||
|
||||
**其他**
|
||||
|
||||
<!-- 若您有其他想要补充的内容,请在此说明 -->
|
||||
|
||||
+17
-15
@@ -94,28 +94,25 @@ const BiliAPI = {
|
||||
* @property {string} session_ts
|
||||
* @property {string} content
|
||||
* @property {number} timestamp
|
||||
* @property {number} unread_count
|
||||
* @property {number} sender_uid
|
||||
* @property {number} talker_id
|
||||
* @property {number} msg_seqno
|
||||
*
|
||||
* @typedef SessionInfo
|
||||
* @property {number} has_more
|
||||
* @property {SessionData[]} data
|
||||
*
|
||||
* @param {number} session_type 1 已关注 2 未关注
|
||||
* @param {number} session_type 1 已关注 2 未关注 3 应援团
|
||||
* @param {string} [ts_16]
|
||||
* @returns {Promise<SessionInfo>}
|
||||
*/
|
||||
async getSessionInfo(session_type, ts_16 = '') {
|
||||
return new Promise((resolve) => {
|
||||
Ajax.post({
|
||||
Ajax.get({
|
||||
url: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions',
|
||||
data: {
|
||||
queryStringsObj: {
|
||||
session_type,
|
||||
group_fold: 1,
|
||||
unfollow_fold: 1,
|
||||
sort_rule: 2,
|
||||
build: 0,
|
||||
mobi_app: 'web',
|
||||
end_ts: ts_16,
|
||||
},
|
||||
success: responseText => {
|
||||
@@ -127,10 +124,13 @@ const BiliAPI = {
|
||||
const has_more = res.data.has_more;
|
||||
const data = sessions.map(session => {
|
||||
const { session_ts, last_msg = {}, unread_count, talker_id } = session;
|
||||
const { content = '', timestamp = 0, sender_uid = 0 } = last_msg;
|
||||
return { session_ts, content, timestamp, sender_uid, talker_id: unread_count ? talker_id : undefined }
|
||||
const { content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg;
|
||||
return { session_ts, content, timestamp, sender_uid, unread_count, talker_id, msg_seqno }
|
||||
})
|
||||
resolve({ has_more, data })
|
||||
} else if (res.code === 2) {
|
||||
log.error('获取私信', `API抽风...请再次尝试`);
|
||||
resolve({ has_more: 0, data: [] });
|
||||
} else {
|
||||
log.error('获取私信', `失败\n${responseText}`);
|
||||
resolve({ has_more: 0, data: [] });
|
||||
@@ -164,17 +164,19 @@ const BiliAPI = {
|
||||
/**
|
||||
* 私信已读
|
||||
* @param {number} talker_id
|
||||
* @param {number} session_type
|
||||
* @param {number} msg_seqno
|
||||
*/
|
||||
updateSessionStatus(talker_id) {
|
||||
updateSessionStatus(talker_id, session_type, msg_seqno) {
|
||||
Ajax.post({
|
||||
url: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
retry: false,
|
||||
data: {
|
||||
talker_id,
|
||||
session_type: 1,
|
||||
ack_seqno: 1,
|
||||
mobi_app: "web",
|
||||
csrf_token: GlobalVar.get("csrf")
|
||||
session_type,
|
||||
ack_seqno: msg_seqno,
|
||||
csrf_token: GlobalVar.get("csrf"),
|
||||
csrf: GlobalVar.get("csrf")
|
||||
},
|
||||
success: responseText => {
|
||||
let res = strToJson(responseText);
|
||||
|
||||
+8
-12
@@ -62,15 +62,12 @@ class Monitor extends Public {
|
||||
eventBus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 31:
|
||||
eventBus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 41:
|
||||
eventBus.emit('Turn_off_the_Monitor', '转发失败')
|
||||
break
|
||||
case 51:
|
||||
case 41:
|
||||
eventBus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
|
||||
break
|
||||
case 61:
|
||||
case 51:
|
||||
eventBus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
||||
break
|
||||
default:
|
||||
@@ -89,13 +86,13 @@ class Monitor extends Public {
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
for (const Lottery of allLottery) {
|
||||
for (const Lottery of Util.shuffle(allLottery)) {
|
||||
let status = 0;
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await BiliAPI.getLotteryNotice(Lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
if (ts < 0) {
|
||||
return 51
|
||||
return 41
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
@@ -110,7 +107,7 @@ class Monitor extends Public {
|
||||
} else if (Lottery.uid[0]) {
|
||||
const followerNum = await BiliAPI.getUserInfo(Lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 61
|
||||
return 51
|
||||
}
|
||||
if (followerNum < config.minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
@@ -314,8 +311,7 @@ class Monitor extends Public {
|
||||
* 11 - 评论错误
|
||||
* 21 - 关注错误
|
||||
* 22 - 关注异常
|
||||
* 31 - 点赞失败
|
||||
* 41 - 转发失败
|
||||
* 31 - 转发失败
|
||||
*/
|
||||
async go(option) {
|
||||
log.debug('正在转发的动态信息', option);
|
||||
@@ -356,10 +352,10 @@ class Monitor extends Public {
|
||||
}
|
||||
|
||||
/* 点赞 */
|
||||
if (await BiliAPI.autolike(dyid)) return 31;
|
||||
await BiliAPI.autolike(dyid)
|
||||
|
||||
/* 转发 */
|
||||
if (await BiliAPI.autoRelay(GlobalVar.get("myUID"), dyid, relay_chat, ctrl)) return 41;
|
||||
if (await BiliAPI.autoRelay(GlobalVar.get("myUID"), dyid, relay_chat, ctrl)) return 31;
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
+3
-4
@@ -303,17 +303,16 @@ class Public {
|
||||
/**判断此专栏是否查看过的权重 */
|
||||
weight = dyids_set.length / 2;
|
||||
|
||||
let { length } = dyids_set;
|
||||
|
||||
let { length } = dyids_set,
|
||||
_weight = 0;
|
||||
log.info('获取动态', `提取专栏(${cv})中提及的dyid(${length})`)
|
||||
for (const dyid of dyids_set) {
|
||||
let _weight = 0;
|
||||
const isRelayed = await MyStorage.searchDyid(dyid);
|
||||
if (isRelayed) {
|
||||
_weight += 1;
|
||||
}
|
||||
if (_weight >= weight) {
|
||||
log.info('获取动态', `1/2动态曾经转过,该专栏或已查看,故中止`)
|
||||
log.warn('获取动态', `1/2动态曾经转过,该专栏或已查看,故中止`)
|
||||
dyinfos = []
|
||||
break
|
||||
}
|
||||
|
||||
+18
@@ -115,6 +115,24 @@ const Util = {
|
||||
}
|
||||
return RandomOne
|
||||
},
|
||||
/**
|
||||
* Fisher–Yates shuffle洗牌
|
||||
* @template T
|
||||
* @param {Array<T>} array
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array;
|
||||
},
|
||||
/**
|
||||
* 是否有指定环境变量
|
||||
* @param {string} env_name
|
||||
* @returns
|
||||
*/
|
||||
hasEnv(env_name) {
|
||||
return process.env[env_name] ? true : false;
|
||||
},
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ async function getFollowList() {
|
||||
* 清理动态和关注
|
||||
*/
|
||||
async function clear() {
|
||||
const { clear_white_list, clear_max_day, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
|
||||
const { clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
|
||||
let success = true;
|
||||
const uid_list = await getFollowList();
|
||||
if (!uid_list.length) {
|
||||
@@ -38,7 +38,7 @@ async function clear() {
|
||||
} else {
|
||||
log.info('清理关注', `共有${uid_list.length}个关注`)
|
||||
}
|
||||
if (!clear_remove_dynamic && clear_remove_attention) {
|
||||
if (clear_quick_remove_attention) {
|
||||
log.info('清理关注', '进入只清理关注模式')
|
||||
/* 专清关注 */
|
||||
for (const [index, uid] of uid_list.entries()) {
|
||||
|
||||
@@ -78,7 +78,7 @@ async function isMe() {
|
||||
desp += `在${business}中@了你(${GlobalVar.get("myUID")}) \n\n`
|
||||
desp += `原内容为: ${source_content} \n\n`
|
||||
desp += `[直达链接](${url}) \n\n`
|
||||
desp += `\n\n\n\n`
|
||||
desp += `\n\n`
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
@@ -88,17 +88,17 @@ async function isMe() {
|
||||
let MySession = await BiliAPI.getSessionInfo(type)
|
||||
for (const index of Util.infiniteNumber()) {
|
||||
for (const Session of MySession.data) {
|
||||
const { content, sender_uid, session_ts, timestamp, talker_id } = Session;
|
||||
const { content, sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
session_t = session_ts;
|
||||
if (talker_id) {
|
||||
BiliAPI.updateSessionStatus(talker_id);
|
||||
if (unread_count) {
|
||||
BiliAPI.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await Util.delay(1000);
|
||||
if (/中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员/.test(content)) {
|
||||
if (config.notice_key_words.some(it => new RegExp(it).test(content))) {
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${sender_uid} \n\n`
|
||||
desp += `私信你(${GlobalVar.get("myUID")})说: ${content} \n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid}) \n\n`
|
||||
desp += `\n\n\n\n`
|
||||
desp += `\n\n`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,8 @@ async function isMe() {
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (desp) {
|
||||
log.info(desp);
|
||||
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
|
||||
log.info('可能中奖了', desp);
|
||||
await sendNotify('可能中奖了', desp);
|
||||
} else {
|
||||
log.info('中奖检测', "未中奖");
|
||||
|
||||
@@ -10,7 +10,7 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` v1.9.9 by shanmite`,
|
||||
` v2.0.2 by shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
let multiple_account = [];
|
||||
@@ -33,8 +33,12 @@ async function main() {
|
||||
process.env.COOKIE = acco.COOKIE;
|
||||
process.env.NUMBER = acco.NUMBER;
|
||||
process.env.CLEAR = acco.CLEAR;
|
||||
await main();
|
||||
await delay(acco.WAIT);
|
||||
const err_msg = await main();
|
||||
if (err_msg) {
|
||||
return err_msg
|
||||
} else {
|
||||
await delay(acco.WAIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**多账号状态还原 */
|
||||
|
||||
+15
-1
@@ -84,7 +84,7 @@ module.exports = {
|
||||
* - 循环等待时间(指所有操作完毕后的休眠时间)
|
||||
* - 单位毫秒
|
||||
*/
|
||||
lottery_loop_wait: 60 * 60 * 1000,
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
|
||||
@@ -177,6 +177,14 @@ module.exports = {
|
||||
*/
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 中奖通知关键词(满足一个就推送)
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
notice_key_words: [
|
||||
"中奖", "获得", "填写", "写上", "提供", "收货地址", "支付宝账号", "码", "大会员"
|
||||
],
|
||||
|
||||
/**
|
||||
* - 清理白名单uid或dyid
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
@@ -194,6 +202,12 @@ module.exports = {
|
||||
*/
|
||||
clear_max_day: 30,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 脚本根目录
|
||||
SCRIPT_FOLDER=lottery
|
||||
@@ -61,7 +62,7 @@ docker run \
|
||||
$DOCKER_REPO \
|
||||
start" \
|
||||
> start.sh
|
||||
chmod 777 start.sh
|
||||
chmod +x start.sh
|
||||
|
||||
echo "create check.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
@@ -72,7 +73,7 @@ docker run \
|
||||
$DOCKER_REPO \
|
||||
check" \
|
||||
> check.sh
|
||||
chmod 777 check.sh
|
||||
chmod +x check.sh
|
||||
|
||||
echo "create clear.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
@@ -83,4 +84,4 @@ docker run \
|
||||
$DOCKER_REPO \
|
||||
clear" \
|
||||
> clear.sh
|
||||
chmod 777 clear.sh
|
||||
chmod +x clear.sh
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run check
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run clear
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run start
|
||||
@@ -1,9 +0,0 @@
|
||||
chcp 65001
|
||||
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run check
|
||||
|
||||
# 暂停
|
||||
pause
|
||||
@@ -1,9 +0,0 @@
|
||||
chcp 65001
|
||||
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run clear
|
||||
|
||||
# 暂停
|
||||
pause
|
||||
@@ -1,9 +0,0 @@
|
||||
chcp 65001
|
||||
|
||||
cd ..
|
||||
cd ..
|
||||
npm i
|
||||
npm run start
|
||||
|
||||
# 暂停
|
||||
pause
|
||||
Reference in New Issue
Block a user