Commit 75c015d2 authored by mercury233's avatar mercury233

update deck post

parent 3b9fd134
...@@ -63,7 +63,8 @@ ...@@ -63,7 +63,8 @@
"enabled": false, "enabled": false,
"accesskey": "233", "accesskey": "233",
"local": "./deck_log/", "local": "./deck_log/",
"post": "https://mycard.moe/ygopro/analytics/deck/text" "post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "233"
}, },
"arena_mode": { "arena_mode": {
"enabled": false, "enabled": false,
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"enabled": true, "enabled": true,
"accesskey": "233", "accesskey": "233",
"local": false, "local": false,
"post": "https://mycard.moe/ygopro/analytics/deck/text" "post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "mycard"
}, },
"arena_mode": { "arena_mode": {
"enabled": true, "enabled": true,
......
...@@ -456,7 +456,7 @@ class Room ...@@ -456,7 +456,7 @@ class Room
userscoreB: score_array[1].score, userscoreB: score_array[1].score,
start: @start_time, start: @start_time,
end: moment().format(), end: moment().format(),
arena: settings.modules.arena_mode.mode arena: @arena
}}, (error, response, body)=> }}, (error, response, body)=>
if error if error
log.warn 'SCORE POST ERROR', error log.warn 'SCORE POST ERROR', error
...@@ -1379,20 +1379,31 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)-> ...@@ -1379,20 +1379,31 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
room.player_datas.push ip: player.ip, name: player.name room.player_datas.push ip: player.ip, name: player.name
if settings.modules.tips.enabled if settings.modules.tips.enabled
ygopro.stoc_send_random_tip(client) ygopro.stoc_send_random_tip(client)
if settings.modules.deck_log.enabled and client.main and client.main.length and not client.deck_saved and client.ip != '::ffff:127.0.0.1' if settings.modules.deck_log.enabled and client.main and client.main.length and not client.deck_saved and not room.windbot
deck_text = '#ygopro-server deck log\n#main\n' + client.main.join('\n') + '\n!side\n' + client.side.join('\n') + '\n' deck_text = '#ygopro-server deck log\n#main\n' + client.main.join('\n') + '\n!side\n' + client.side.join('\n') + '\n'
deck_arena = settings.modules.deck_log.arena + '-'
if room.arena
deck_arena = deck_arena + room.arena
else if room.hostinfo.mode == 2
deck_arena = deck_arena + 'tag'
else if room.random_type == 'S'
deck_arena = deck_arena + 'entertain'
else if room.random_type == 'M'
deck_arena = deck_arena + 'atheletic'
else
deck_arena = deck_arena + 'custom'
#log.info "DECK LOG START", client.name, room.arena #log.info "DECK LOG START", client.name, room.arena
if settings.modules.deck_log.local if settings.modules.deck_log.local
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_') deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_')
fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) -> fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) ->
if err if err
log.warn 'DECK SAVE ERROR', err log.warn 'DECK SAVE ERROR', err
if settings.modules.deck_log.post and (room.arena or not settings.modules.arena_mode.enabled) if settings.modules.deck_log.post
request.post { url : settings.modules.deck_log.post , form : { request.post { url : settings.modules.deck_log.post , form : {
accesskey: settings.modules.deck_log.accesskey, accesskey: settings.modules.deck_log.accesskey,
deck: deck_text, deck: deck_text,
playername: client.name, playername: client.name,
arena: settings.modules.arena_mode.mode arena: deck_arena
}}, (error, response, body)-> }}, (error, response, body)->
if error if error
log.warn 'DECK POST ERROR', error log.warn 'DECK POST ERROR', error
...@@ -1402,16 +1413,6 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)-> ...@@ -1402,16 +1413,6 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
#else #else
#log.info 'DECK POST OK', response.statusCode, client.name, body #log.info 'DECK POST OK', response.statusCode, client.name, body
return return
if settings.modules.deck_log.post # temp for analytics2
request.post { url : "https://mycard.moe/ygopro/analytics2/deck/text" , form : {
accesskey: settings.modules.deck_log.accesskey,
deck: deck_text,
playername: client.name,
arena: settings.modules.arena_mode.mode
}}, (error, response, body)->
if error
log.warn 'DECK POST ERROR', error
return
client.deck_saved = true client.deck_saved = true
return return
......
...@@ -619,7 +619,7 @@ ...@@ -619,7 +619,7 @@
userscoreB: score_array[1].score, userscoreB: score_array[1].score,
start: this.start_time, start: this.start_time,
end: moment().format(), end: moment().format(),
arena: settings.modules.arena_mode.mode arena: this.arena
} }
}, (function(_this) { }, (function(_this) {
return function(error, response, body) { return function(error, response, body) {
...@@ -1666,7 +1666,7 @@ ...@@ -1666,7 +1666,7 @@
} }
ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) { ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) {
var deck_name, deck_text, j, len, player, ref, room; var deck_arena, deck_name, deck_text, j, len, player, ref, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
...@@ -1695,8 +1695,20 @@ ...@@ -1695,8 +1695,20 @@
if (settings.modules.tips.enabled) { if (settings.modules.tips.enabled) {
ygopro.stoc_send_random_tip(client); ygopro.stoc_send_random_tip(client);
} }
if (settings.modules.deck_log.enabled && client.main && client.main.length && !client.deck_saved && client.ip !== '::ffff:127.0.0.1') { if (settings.modules.deck_log.enabled && client.main && client.main.length && !client.deck_saved && !room.windbot) {
deck_text = '#ygopro-server deck log\n#main\n' + client.main.join('\n') + '\n!side\n' + client.side.join('\n') + '\n'; deck_text = '#ygopro-server deck log\n#main\n' + client.main.join('\n') + '\n!side\n' + client.side.join('\n') + '\n';
deck_arena = settings.modules.deck_log.arena + '-';
if (room.arena) {
deck_arena = deck_arena + room.arena;
} else if (room.hostinfo.mode === 2) {
deck_arena = deck_arena + 'tag';
} else if (room.random_type === 'S') {
deck_arena = deck_arena + 'entertain';
} else if (room.random_type === 'M') {
deck_arena = deck_arena + 'atheletic';
} else {
deck_arena = deck_arena + 'custom';
}
if (settings.modules.deck_log.local) { if (settings.modules.deck_log.local) {
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_'); deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_');
fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) { fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) {
...@@ -1705,14 +1717,14 @@ ...@@ -1705,14 +1717,14 @@
} }
}); });
} }
if (settings.modules.deck_log.post && (room.arena || !settings.modules.arena_mode.enabled)) { if (settings.modules.deck_log.post) {
request.post({ request.post({
url: settings.modules.deck_log.post, url: settings.modules.deck_log.post,
form: { form: {
accesskey: settings.modules.deck_log.accesskey, accesskey: settings.modules.deck_log.accesskey,
deck: deck_text, deck: deck_text,
playername: client.name, playername: client.name,
arena: settings.modules.arena_mode.mode arena: deck_arena
} }
}, function(error, response, body) { }, function(error, response, body) {
if (error) { if (error) {
...@@ -1724,21 +1736,6 @@ ...@@ -1724,21 +1736,6 @@
} }
}); });
} }
if (settings.modules.deck_log.post) {
request.post({
url: "https://mycard.moe/ygopro/analytics2/deck/text",
form: {
accesskey: settings.modules.deck_log.accesskey,
deck: deck_text,
playername: client.name,
arena: settings.modules.arena_mode.mode
}
}, function(error, response, body) {
if (error) {
log.warn('DECK POST ERROR', error);
}
});
}
client.deck_saved = true; client.deck_saved = true;
} }
}); });
......
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