feat: 增加UIDs和TAGs自定义

This commit is contained in:
shanmite 2021-04-07 10:48:57 +08:00
parent a523361d3d
commit 16eb585bc3
5 changed files with 44 additions and 6 deletions

View File

@ -26,7 +26,6 @@ class Monitor extends Public {
*/
async init() {
if (config.model === '00') { Base.tooltip.log('已关闭所有转发行为'); return; }
if (GlobalVar.Lottery.length === 0) { Base.tooltip.log('抽奖信息为空'); return; }
this.tagid = await BiliAPI.checkMyPartition(); /* 检查关注分区 */
this.attentionList = await BiliAPI.getAttentionList(GlobalVar.myUID); /* 获取关注列表 */
await this.startLottery();

View File

@ -1,4 +1,4 @@
module.exports = {
const default_script = {
version: '|version: 3.8.2|in nodejs',
author: '@shanmite',
UIDs: [
@ -16,3 +16,36 @@ module.exports = {
'动态抽奖',
]
};
/**
* 自己修改过的设置
*/
const my_config = (() => {
let _my_config = {}
if (process.env.LOCALLAUNCH) {
try {
const { UIDs, TAGs } = require('../my_config.json');
if (UIDs) _my_config.UIDs = UIDs;
if (TAGs) _my_config.TAGs = TAGs;
} catch (_) {
console.log("无自定义设置");
}
} else {
try {
const { UIDs, TAGs } = JSON.parse(process.env.MY_CONFIG);
if (UIDs) _my_config.UIDs = UIDs;
if (TAGs) _my_config.TAGs = TAGs;
} catch (_) {
console.log("MY_CONFIG语法错误");
}
}
return _my_config;
})();
const script = {
...default_script,
...my_config
}
module.exports = script;

View File

@ -51,4 +51,5 @@ const config = {
...my_config
};
module.exports = config;
module.exports = config;

View File

@ -17,11 +17,11 @@ const MAX_TIME = 6 * 60 * 60 * 1000 - 6 * 60 * 1000;
function start() {
return new Promise(resolve => {
function createRandomDynamic() {
return new Promise((resolve) => {
return new Promise((_resolve) => {
if (config.create_dy === '1') {
Public.prototype.checkAllDynamic(GlobalVar.myUID, 1).then(Dynamic => {
if (Dynamic.allModifyDynamicResArray[0].type === 1) {
BiliAPI.createDynamic(Base.getRandomStr(config.dy_contents)).then(() => resolve())
BiliAPI.createDynamic(Base.getRandomStr(config.dy_contents)).then(() => _resolve())
}
})
}
@ -30,6 +30,11 @@ function start() {
let times = Base.counter();
/* 注册事件 */
eventBus.on('Turn_on_the_Monitor', async () => {
if (GlobalVar.Lottery.length) {
Base.tooltip.log('抽奖信息为空');
resolve();
return;
}
if (times.value() === GlobalVar.Lottery.length) {
await createRandomDynamic();
Base.tooltip.log('所有动态转发完毕');

View File

@ -31,6 +31,6 @@ const { NUMBER, CLEAR, COOKIE, PAT, LOCALLAUNCH } = process.env;
default:
break;
}
process.exit(0)
}
process.exit(0)
}))();