Commit c34e95c8 authored by nanahira's avatar nanahira

format

parent 702cc4a8
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
"websocket_roomlist": true, "websocket_roomlist": true,
"public_roomlist": false, "public_roomlist": false,
"show_ip": true, "show_ip": true,
"show_info": true,
"ssl": { "ssl": {
"enabled": false, "enabled": false,
"port": 7923, "port": 7923,
......
...@@ -221,6 +221,7 @@ ...@@ -221,6 +221,7 @@
"websocket_roomlist": false, "websocket_roomlist": false,
"public_roomlist": false, "public_roomlist": false,
"show_ip": false, "show_ip": false,
"show_info": false,
"ssl": { "ssl": {
"enabled": false, "enabled": false,
"port": 7923, "port": 7923,
......
...@@ -25,9 +25,9 @@ function add_to_deck(deck,id) { ...@@ -25,9 +25,9 @@ function add_to_deck(deck,id) {
} }
function add_to_all_list(LIST,id,use) { function add_to_all_list(LIST,id,use) {
if (!ALL_CARD_DATAS[id]) { if (!ALL_CARD_DATAS[id]) {
return; return;
} }
if (ALL_CARD_DATAS[id].alias) { if (ALL_CARD_DATAS[id].alias) {
id=ALL_CARD_DATAS[id].alias; id=ALL_CARD_DATAS[id].alias;
} }
...@@ -166,9 +166,9 @@ function output_csv(list,filename) { ...@@ -166,9 +166,9 @@ function output_csv(list,filename) {
var file=fs.openSync(filename,"w"); var file=fs.openSync(filename,"w");
for (var i in list) { for (var i in list) {
var card=ALL_CARD_DATAS[i]; var card=ALL_CARD_DATAS[i];
if (!card) { if (!card) {
continue; continue;
} }
var card_usage=list[i]; var card_usage=list[i];
console.log("writing "+card.name); console.log("writing "+card.name);
......
...@@ -98,34 +98,34 @@ ...@@ -98,34 +98,34 @@
settings.lflist = (function() { settings.lflist = (function() {
var j, len, ref, ref_custom, results; var j, len, ref, ref_custom, results;
results = []; results = [];
try { try {
ref_custom = fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g); ref_custom = fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g);
for (j = 0, len = ref_custom.length; j < len; j++) { for (j = 0, len = ref_custom.length; j < len; j++) {
list = ref_custom[j]; list = ref_custom[j];
date = list.match(/!([\d\.]+)/); date = list.match(/!([\d\.]+)/);
if (!date) { if (!date) {
continue; continue;
} }
results.push({ results.push({
date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"),
tcg: list.indexOf('TCG') !== -1 tcg: list.indexOf('TCG') !== -1
}); });
} }
} catch (error1) {} } catch (error1) {}
try { try {
ref = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g); ref = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g);
for (j = 0, len = ref.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
list = ref[j]; list = ref[j];
date = list.match(/!([\d\.]+)/); date = list.match(/!([\d\.]+)/);
if (!date) { if (!date) {
continue; continue;
} }
results.push({ results.push({
date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"),
tcg: list.indexOf('TCG') !== -1 tcg: list.indexOf('TCG') !== -1
}); });
} }
} catch (error1) {} } catch (error1) {}
return results; return results;
})(); })();
...@@ -1401,13 +1401,13 @@ ...@@ -1401,13 +1401,13 @@
if (!room) { if (!room) {
return; return;
} }
if (settings.modules.words.enabled && settings.words[client.name]) { if (settings.modules.words.enabled && settings.words[client.name]) {
var player_words = _.lines(settings.words[client.name][Math.floor(Math.random() * settings.words[client.name].length)]); var player_words = _.lines(settings.words[client.name][Math.floor(Math.random() * settings.words[client.name].length)]);
for (j = 0, len = player_words.length; j < len; j++) { for (j = 0, len = player_words.length; j < len; j++) {
line = player_words[j]; line = player_words[j];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
if (settings.modules.welcome) { if (settings.modules.welcome) {
ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN); ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN);
} }
...@@ -1600,11 +1600,11 @@ ...@@ -1600,11 +1600,11 @@
} }
if (settings.modules.music.enabled) { if (settings.modules.music.enabled) {
if (ygopro.constants.MSG[msg] === 'HINT') { if (ygopro.constants.MSG[msg] === 'HINT') {
var hint_type = buffer.readUInt8(1); var hint_type = buffer.readUInt8(1);
pos = buffer.readUInt8(2); pos = buffer.readUInt8(2);
var music_id = buffer.readUInt32LE(3); var music_id = buffer.readUInt32LE(3);
if (hint_type === 11 && music_list_rev[music_id]) { if (hint_type === 11 && music_list_rev[music_id]) {
ygopro.stoc_send_chat(client, "${play_music}"+music_list_rev[music_id], ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat(client, "${play_music}"+music_list_rev[music_id], ygopro.constants.COLORS.PINK);
} }
} }
} }
...@@ -1841,27 +1841,27 @@ ...@@ -1841,27 +1841,27 @@
var music_count = 0; var music_count = 0;
if (settings.modules.music.enabled) { if (settings.modules.music.enabled) {
var sqlite3 = require('sqlite3').verbose(); var sqlite3 = require('sqlite3').verbose();
var db=new sqlite3.Database("./ygopro/" + settings.modules.music.dbpath); var db=new sqlite3.Database("./ygopro/" + settings.modules.music.dbpath);
db.each("select * from datas,texts where datas.id=texts.id", function (err,result) { db.each("select * from datas,texts where datas.id=texts.id", function (err,result) {
if (err) { if (err) {
log.info("music load errored", err); log.info("music load errored", err);
return; return;
} else { } else {
for (i = 1, len = 16; i <= len; i++) { for (i = 1, len = 16; i <= len; i++) {
var song_name = result["str"+i]; var song_name = result["str"+i];
if (song_name) { if (song_name) {
var music_id = result.id * 16 + i - 1; var music_id = result.id * 16 + i - 1;
music_list_rev[music_id] = song_name; music_list_rev[music_id] = song_name;
if (!music_list[song_name]) { if (!music_list[song_name]) {
music_list[song_name] = music_id; music_list[song_name] = music_id;
music_count++; music_count++;
} }
} }
} }
} }
}, function() { }, function() {
log.info("music loaded", music_count); log.info("music loaded", music_count);
}); });
} }
ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) { ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) {
...@@ -2054,46 +2054,46 @@ ...@@ -2054,46 +2054,46 @@
break; break;
case '/command': case '/command':
if (settings.modules.command.enabled && (!settings.modules.command.identity || (settings.modules.command.identity[client.name] && settings.modules.command.identity[client.name] === room.name))) { if (settings.modules.command.enabled && (!settings.modules.command.identity || (settings.modules.command.identity[client.name] && settings.modules.command.identity[client.name] === room.name))) {
var cname = cmd[1]; var cname = cmd[1];
if (!cname) { if (!cname) {
ygopro.stoc_send_chat(client, "Please enter the command.", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "Please enter the command.", ygopro.constants.COLORS.RED);
break; break;
} }
var command_info = settings.modules.command.command_list[cname]; var command_info = settings.modules.command.command_list[cname];
if (!command_info) { if (!command_info) {
ygopro.stoc_send_chat(client, "Command '"+cname+"' not found.", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "Command '"+cname+"' not found.", ygopro.constants.COLORS.RED);
break; break;
} }
ygopro.stoc_send_chat(client, "Started running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "Started running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE);
try { try {
var proc = spawn(command_info.command, command_info.args, { cwd: command_info.path, env: process.env }); var proc = spawn(command_info.command, command_info.args, { cwd: command_info.path, env: process.env });
proc.stdout.setEncoding('utf8'); proc.stdout.setEncoding('utf8');
proc.stdout.on('data', function(data) { proc.stdout.on('data', function(data) {
ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.LIGHTBLUE); ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.LIGHTBLUE);
}); });
proc.stderr.setEncoding('utf8'); proc.stderr.setEncoding('utf8');
proc.stderr.on('data', function(data) { proc.stderr.on('data', function(data) {
ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.RED);
}); });
proc.on('close', function (code) { proc.on('close', function (code) {
ygopro.stoc_send_chat(client, "Finished running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "Finished running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE);
}); });
} catch (e) {} } catch (e) {}
} }
break; break;
/* /*
case '/music': case '/music':
var music = msg.slice(7); var music = msg.slice(7);
if (settings.modules.music.enabled) { if (settings.modules.music.enabled) {
if (!music || music.length <= 0) { if (!music || music.length <= 0) {
ygopro.stoc_send_hint_music(client, 0, 11); ygopro.stoc_send_hint_music(client, 0, 11);
ygopro.stoc_send_chat(client, "${stop_music}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${stop_music}", ygopro.constants.COLORS.BABYBLUE);
break; break;
} }
var music_id = music_list[music]; var music_id = music_list[music];
if (music_id) { if (music_id) {
ygopro.stoc_send_hint_music(client, music_id, 11); ygopro.stoc_send_hint_music(client, music_id, 11);
ygopro.stoc_send_chat(client, "${play_music}"+music, ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${play_music}"+music, ygopro.constants.COLORS.BABYBLUE);
} else { } else {
ygopro.stoc_send_chat(client, "${music_not_found_1}"+music+"${music_not_found_2}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${music_not_found_1}"+music+"${music_not_found_2}", ygopro.constants.COLORS.RED);
} }
...@@ -2518,7 +2518,7 @@ ...@@ -2518,7 +2518,7 @@
var cname = player.name; var cname = player.name;
if (settings.modules.http.show_ip && pass_validated) { if (settings.modules.http.show_ip && pass_validated) {
cname = player.name + " (" + player.ip + ")"; cname = player.name + " (" + player.ip + ")";
} }
if (player.pos != null) { if (player.pos != null) {
results1.push({ results1.push({
id: (-1).toString(), id: (-1).toString(),
...@@ -2577,24 +2577,24 @@ ...@@ -2577,24 +2577,24 @@
} }
if (u.query.shout) { if (u.query.shout) {
/* /*
if (u.query.shout.slice(0, 7) === "/music " && settings.modules.music.enabled) { if (u.query.shout.slice(0, 7) === "/music " && settings.modules.music.enabled) {
var music = u.query.shout.slice(7); var music = u.query.shout.slice(7);
var music_id = music_list[music]; var music_id = music_list[music];
if (music_id) { if (music_id) {
for (j = 0, len = ROOM_all.length; j < len; j++) { for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j]; room = ROOM_all[j];
if (room && room.established) { if (room && room.established) {
ygopro.stoc_send_hint_music_to_room(room, music_id, 11); ygopro.stoc_send_hint_music_to_room(room, music_id, 11);
ygopro.stoc_send_chat_to_room(room, "${play_music}"+music, ygopro.constants.COLORS.YELLOW); ygopro.stoc_send_chat_to_room(room, "${play_music}"+music, ygopro.constants.COLORS.YELLOW);
} }
} }
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['music ok', '" + u.query.shout + "']")); response.end(addCallback(u.query.callback, "['music ok', '" + u.query.shout + "']"));
} else { } else {
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['music not found', '" + u.query.shout + "']")); response.end(addCallback(u.query.callback, "['music not found', '" + u.query.shout + "']"));
} }
} else { } else {
*/ */
for (j = 0, len = ROOM_all.length; j < len; j++) { for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j]; room = ROOM_all[j];
...@@ -2604,8 +2604,8 @@ ...@@ -2604,8 +2604,8 @@
} }
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['shout ok', '" + u.query.shout + "']")); response.end(addCallback(u.query.callback, "['shout ok', '" + u.query.shout + "']"));
// } // }
} else if (u.query.stop) { } else if (u.query.stop) {
if (u.query.stop === 'false') { if (u.query.stop === 'false') {
u.query.stop = false; u.query.stop = false;
......
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