Commit 1c8310b7 authored by nanahira's avatar nanahira

update config

parent b42b8997
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
}, },
"vip": { "vip": {
"enabled": false, "enabled": false,
"generate_count": 50 "generate_count": 1000
}, },
"random_duel": { "random_duel": {
"enabled": false, "enabled": false,
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
"180": [], "180": [],
"90": [], "90": [],
"30": [], "30": [],
"15": [],
"7": [], "7": [],
"3": [], "3": [],
"1": [] "1": []
......
...@@ -155,10 +155,11 @@ setting_change = (settings, path, val) -> ...@@ -155,10 +155,11 @@ setting_change = (settings, path, val) ->
VIP_generate_cdkeys = (key_type, count) -> VIP_generate_cdkeys = (key_type, count) ->
return false unless settings.modules.vip.enabled and vip_info.cdkeys[key_type] return false unless settings.modules.vip.enabled and vip_info.cdkeys[key_type]
for i in [1...count] for i in [0...count]
key = Math.floor(Math.random() * 10000000000000000).toString() key = Math.floor(Math.random() * 10000000000000000).toString()
vip_info.cdkeys[key_type].push(key) vip_info.cdkeys[key_type].push(key)
setting_save(vip_info) setting_save(vip_info)
log.info("keys generated", key_type, count, vip_info.cdkeys[key_type].length)
return true return true
CLIENT_use_cdkey = (client, pkey) -> CLIENT_use_cdkey = (client, pkey) ->
...@@ -280,8 +281,6 @@ try ...@@ -280,8 +281,6 @@ try
vip_info = loadJSON('./config/vip_info.json') vip_info = loadJSON('./config/vip_info.json')
catch catch
vip_info = default_data.vip_info vip_info = default_data.vip_info
for k,v of vip_info.cdkeys
VIP_generate_cdkeys(k, settings.modules.vip.generate_count)
setting_save(vip_info) setting_save(vip_info)
try try
...@@ -358,6 +357,10 @@ if settings.modules.challonge.enabled ...@@ -358,6 +357,10 @@ if settings.modules.challonge.enabled
apiKey: settings.modules.challonge.api_key apiKey: settings.modules.challonge.api_key
}) })
if settings.modules.vip.enabled
for k,v of vip_info.cdkeys when v.length == 0
VIP_generate_cdkeys(k, settings.modules.vip.generate_count)
# 获取可用内存 # 获取可用内存
memory_usage = 0 memory_usage = 0
get_memory_usage = ()-> get_memory_usage = ()->
......
...@@ -165,11 +165,12 @@ ...@@ -165,11 +165,12 @@
if (!(settings.modules.vip.enabled && vip_info.cdkeys[key_type])) { if (!(settings.modules.vip.enabled && vip_info.cdkeys[key_type])) {
return false; return false;
} }
for (i = j = 1, ref = count; 1 <= ref ? j < ref : j > ref; i = 1 <= ref ? ++j : --j) { for (i = j = 0, ref = count; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
key = Math.floor(Math.random() * 10000000000000000).toString(); key = Math.floor(Math.random() * 10000000000000000).toString();
vip_info.cdkeys[key_type].push(key); vip_info.cdkeys[key_type].push(key);
} }
setting_save(vip_info); setting_save(vip_info);
log.info("keys generated", key_type, count, vip_info.cdkeys[key_type].length);
return true; return true;
}; };
...@@ -343,11 +344,6 @@ ...@@ -343,11 +344,6 @@
vip_info = loadJSON('./config/vip_info.json'); vip_info = loadJSON('./config/vip_info.json');
} catch (error1) { } catch (error1) {
vip_info = default_data.vip_info; vip_info = default_data.vip_info;
ref = vip_info.cdkeys;
for (k in ref) {
v = ref[k];
VIP_generate_cdkeys(k, settings.modules.vip.generate_count);
}
setting_save(vip_info); setting_save(vip_info);
} }
...@@ -362,9 +358,9 @@ ...@@ -362,9 +358,9 @@
lflists = []; lflists = [];
try { try {
ref1 = fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g); ref = fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g);
for (j = 0, len = ref1.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
list = ref1[j]; list = ref[j];
date = list.match(/!([\d\.]+)/); date = list.match(/!([\d\.]+)/);
if (!date) { if (!date) {
continue; continue;
...@@ -379,9 +375,9 @@ ...@@ -379,9 +375,9 @@
} }
try { try {
ref2 = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g); ref1 = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g);
for (l = 0, len1 = ref2.length; l < len1; l++) { for (l = 0, len1 = ref1.length; l < len1; l++) {
list = ref2[l]; list = ref1[l];
date = list.match(/!([\d\.]+)/); date = list.match(/!([\d\.]+)/);
if (!date) { if (!date) {
continue; continue;
...@@ -454,6 +450,16 @@ ...@@ -454,6 +450,16 @@
}); });
} }
if (settings.modules.vip.enabled) {
ref2 = vip_info.cdkeys;
for (k in ref2) {
v = ref2[k];
if (v.length === 0) {
VIP_generate_cdkeys(k, settings.modules.vip.generate_count);
}
}
}
memory_usage = 0; memory_usage = 0;
get_memory_usage = function() { get_memory_usage = function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment