feat: 抽奖顺序可调LotteryOrder(#176)

Fixed #176
This commit is contained in:
shanmite 2022-08-15 12:25:57 +08:00
parent f6aa0d0544
commit 3491888f88
3 changed files with 52 additions and 21 deletions

View File

@ -6,16 +6,16 @@ const config = {
*/
UIDs: [],
/**
* 监视的tag
*/
TAGs: [],
/**
* 监视的专栏关键词
*/
Articles: [],
/**
* 监视的tag
*/
TAGs: [],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
@ -40,6 +40,18 @@ const config = {
*/
APIs: [],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* @example
* [3,2,1,0]
* [1,2,1,2,1]
*/
LotteryOrder: [2, 0, 1, 3],
/**
* API发送数据类型 {LotteryInfo[]}
* 上传抽奖信息的链接字符串

View File

@ -1,8 +1,6 @@
const { getRemoteConfig, createDir, createFile } = require("../utils");
const config = require("../data/config");
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
let global_var = {
inner: {},
get(key) {
@ -19,6 +17,16 @@ let global_var = {
*/
async init(cookie, num) {
if (cookie) {
const
key_map = new Map([
['DedeUserID', 'myUID'],
['bili_jct', 'csrf']]),
LotteryOrderMap = new Map([
[0, "UIDs"],
[1, "TAGs"],
[2, "Articles"],
[3, "APIs"]]);
config.updata(num);
this.set('cookie', cookie);
@ -29,13 +37,12 @@ let global_var = {
this.set(key_map.get(_item[0]), _item[1]);
});
const { UIDs = [], TAGs = [], Articles = [], APIs = [] } = config;
this.set('Lottery', [
...UIDs.map(it => ['UIDs', it]),
...TAGs.map(it => ['TAGs', it]),
...Articles.map(it => ['Articles', it]),
...APIs.map(it => ['APIs', it])
]);
const { LotteryOrder } = config;
this.set('Lottery',
LotteryOrder
.map(it => LotteryOrderMap.get(it))
.filter(it => typeof it === "string")
.map(lottery_option => [lottery_option, config[lottery_option]]));
this.set('remoteconfig', await getRemoteConfig());
}
await createDir('dyids');

View File

@ -11,13 +11,6 @@ module.exports = Object.freeze({
241675899
],
/**
* 监视的专栏关键词
*/
Articles: [
'抽奖合集'
],
/**
* 监视的tag
*/
@ -28,6 +21,13 @@ module.exports = Object.freeze({
'抽奖',
],
/**
* 监视的专栏关键词
*/
Articles: [
'抽奖合集'
],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
@ -54,6 +54,18 @@ module.exports = Object.freeze({
*/
APIs: [],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* @example
* [3,2,1,0]
* [1,2,1,2,1]
*/
LotteryOrder: [2, 0, 1, 3],
/**
* API发送数据类型 {LotteryInfo[]}
* 上传抽奖信息的链接字符串