mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e845e3f7ef | ||
|
|
27eae63762 | ||
|
|
634f45a4c4 | ||
|
|
3c269b2f96 | ||
|
|
3851f51621 |
@@ -5,14 +5,7 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
- "package.json"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -29,11 +29,21 @@ jobs:
|
||||
run: |
|
||||
npm install
|
||||
npm run pkg_x64
|
||||
- name: "Upload to artifact"
|
||||
- name: "Upload to artifact(win)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: dist_x64
|
||||
path: dist/
|
||||
name: nlts-win-x64
|
||||
path: dist/nlts-win-x64/
|
||||
- name: "Upload to artifact(linux)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-linux-x64
|
||||
path: dist/nlts-linux-x64/
|
||||
- name: "Upload to artifact(macos)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-macos-x64
|
||||
path: dist/nlts-macos-x64/
|
||||
pkg_arm64:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
+5
-5
@@ -2,6 +2,7 @@ const utils = require('../utils');
|
||||
const bili = require('../net/bili');
|
||||
const { sendNotify } = require('../helper/notify');
|
||||
const event_bus = require('../helper/event_bus');
|
||||
const { randomDynamic } = require('../helper/randomDynamic')
|
||||
const { Searcher } = require('./searcher');
|
||||
const global_var = require("../data/global_var");
|
||||
const config = require("../data/config");
|
||||
@@ -119,11 +120,10 @@ class Monitor extends Searcher {
|
||||
if (create_dy
|
||||
&& create_dy_mode instanceof Array
|
||||
&& index > 0
|
||||
&& index % create_dy_mode[0] === 0) {
|
||||
for (let i = 0; i < create_dy_mode[1]; i++) {
|
||||
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
&& index % utils.getRandomOne(create_dy_mode[0]) === 0
|
||||
) {
|
||||
const number = utils.getRandomOne(create_dy_mode[1]) || 0;
|
||||
randomDynamic(number)
|
||||
}
|
||||
|
||||
status = await this.go(Lottery)
|
||||
|
||||
+22
-30
@@ -236,31 +236,29 @@ class Searcher {
|
||||
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})的细节 (${length--})`)
|
||||
|
||||
const res = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
, { code, data } = utils.strToJson(res)
|
||||
, { card } = data || {};
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取动态', '获取动态数据出错,可能是访问太频繁 \n' + res)
|
||||
return results
|
||||
if (card) {
|
||||
await utils.delay(2000)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
}
|
||||
|
||||
await utils.delay(2000)
|
||||
return results
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
}, Promise.resolve([]))
|
||||
|
||||
log.info('获取动态', `成功获取用户${UID}的动态信息`);
|
||||
@@ -352,18 +350,12 @@ class Searcher {
|
||||
for (const dyid of dyids_set) {
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid})的细节 (${length--})`)
|
||||
const res = await bili.getOneDynamicByDyid(dyid)
|
||||
, { code, data } = utils.strToJson(res)
|
||||
, { card } = data || {};
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取动态', '获取动态数据出错,可能是访问太频繁 \n' + res)
|
||||
break
|
||||
}
|
||||
|
||||
await utils.delay(2000)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(2000)
|
||||
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
const config = require("../data/config");
|
||||
const bili = require("../net/bili");
|
||||
const utils = require("../utils");
|
||||
|
||||
/**
|
||||
* 随机动态
|
||||
* @param {number} num
|
||||
* @returns
|
||||
*/
|
||||
async function randomDynamic(num) {
|
||||
const { create_dy_type, dy_contents } = config;
|
||||
|
||||
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
|
||||
for (let index = 0; index < num; index++) {
|
||||
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
if (create_dy_type === -1 || create_dy_type === 1) {
|
||||
let videos = await bili.getTopRcmd()
|
||||
for (let index = 0; videos.length < num; index++) {
|
||||
videos.push(...await bili.getTopRcmd())
|
||||
}
|
||||
|
||||
await utils.try_for_each(videos, async ([uid, aid]) => {
|
||||
if (num--) {
|
||||
await bili.shareVideo(uid, aid)
|
||||
await utils.delay(2000)
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { randomDynamic }
|
||||
+2
-6
@@ -1,10 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const bili = require('./net/bili');
|
||||
const event_bus = require('./helper/event_bus');
|
||||
const global_var = require('./data/global_var');
|
||||
const { Searcher } = require('./core/searcher');
|
||||
const { Monitor } = require('./core/monitor');
|
||||
const config = require('./data/config');
|
||||
const { randomDynamic } = require('./helper/randomDynamic');
|
||||
const { log } = utils;
|
||||
|
||||
async function createRandomDynamic(num) {
|
||||
@@ -12,10 +12,7 @@ async function createRandomDynamic(num) {
|
||||
log.info('随机动态', `准备创建${num}条随机动态`);
|
||||
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
|
||||
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
|
||||
for (let index = 0; index < num; index++) {
|
||||
await bili.createDynamic(utils.getRandomOne(config.dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
await randomDynamic(num)
|
||||
} else {
|
||||
log.info('随机动态', '已有非抽奖动态故无需创建');
|
||||
}
|
||||
@@ -39,7 +36,6 @@ function start() {
|
||||
return;
|
||||
}
|
||||
if (times.value() === lotterys.length) {
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
log.info('抽奖', '所有动态转发完毕');
|
||||
times.clear();
|
||||
event_bus.emit('Turn_off_the_Monitor', '目前无抽奖信息,过一会儿再来看看吧')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
|
||||
@@ -25,6 +26,7 @@ module.exports = Object.freeze({
|
||||
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
|
||||
TOPIC_SVR_TOPIC_HISTORY: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_history',
|
||||
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',
|
||||
|
||||
+63
-1
@@ -247,7 +247,7 @@ const bili_client = {
|
||||
/**
|
||||
* 获取一个动态的细节
|
||||
* @param {string} dynamic_id
|
||||
* @return {Promise<string>}
|
||||
* @return {Promise<JSON>} 失败返回undefined
|
||||
*/
|
||||
getOneDynamicByDyid(dynamic_id) {
|
||||
return get({
|
||||
@@ -255,6 +255,21 @@ const bili_client = {
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}).then(responseText => {
|
||||
const { code, data } = strToJson(responseText)
|
||||
, { card } = data || {};
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (!card) {
|
||||
log.warn('获取一个动态的细节', `动态(${dynamic_id})不存在`)
|
||||
return
|
||||
}
|
||||
|
||||
return card
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -701,6 +716,53 @@ const bili_client = {
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取推荐
|
||||
* @returns {Promise<Array<[number, number]>>}
|
||||
*/
|
||||
getTopRcmd() {
|
||||
return get(
|
||||
{
|
||||
url: API.TOP_RCMD,
|
||||
}
|
||||
).then(responseText => {
|
||||
const res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
log.info('获取推荐', `成功`);
|
||||
return res.data.item.map(it => {
|
||||
return [it.owner.mid, it.id]
|
||||
})
|
||||
} else {
|
||||
log.error('获取推荐', `获取推荐失败\n${responseText}`);
|
||||
return []
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 分享视频
|
||||
* @param {number} uid
|
||||
* @param {number} aid
|
||||
*/
|
||||
shareVideo(uid, aid) {
|
||||
return post({
|
||||
url: API.DYNAMIC_REPOST_SHARE,
|
||||
contents: {
|
||||
platform: "pc",
|
||||
uid,
|
||||
type: 8,
|
||||
content: "分享视频",
|
||||
repost_code: 20000,
|
||||
rid: aid,
|
||||
csrf_token: GlobalVar.get("csrf")
|
||||
}
|
||||
}).then(responseText => {
|
||||
if (/^{"code":0/.test(responseText)) {
|
||||
log.info('转发视频', `成功转发视频(av${aid})`);
|
||||
} else {
|
||||
log.error('转发视频', `转发失败\n${responseText}`);
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 移除动态
|
||||
* @param {string} dyid
|
||||
|
||||
+14
-6
@@ -122,17 +122,19 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
create_dy: false,
|
||||
|
||||
/**
|
||||
* 随机动态类型
|
||||
* - 0 自定义文字与图片
|
||||
* - 1 推荐视频
|
||||
* - -1 混合
|
||||
*/
|
||||
create_dy_type: 0,
|
||||
|
||||
/**
|
||||
* - 结束运行时发送随机动态的数量
|
||||
*/
|
||||
create_dy_num: 1,
|
||||
|
||||
/**
|
||||
* - 每转发x条抽奖动态就发送x条随机动态
|
||||
* - @example [6,1] 每转发6条抽奖动态就发送1条随机动态
|
||||
*/
|
||||
create_dy_mode: [0, 0],
|
||||
|
||||
/**
|
||||
* - 随机动态内容
|
||||
* - 类型 `content[]`
|
||||
@@ -144,6 +146,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
dy_contents: ['[doge]', '[doge][doge]'],
|
||||
|
||||
/**
|
||||
* - 每转发x条抽奖动态就发送x条随机动态
|
||||
* - @example [[10,11,9],[6,8,9]] 每转发9,10,11条抽奖动态就发送6,8,9条随机动态
|
||||
*/
|
||||
create_dy_mode: [[0], [0]],
|
||||
|
||||
/**
|
||||
* 转发时[at]的用户
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.2",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user