Commit 937769bf authored by nanahira's avatar nanahira

merge config

parents 78caea33 cfa53219
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
......@@ -6,6 +6,8 @@ coffeelint.json
password.json
config.*.json
/bak
/config
/ygopro
/windbot
/decks/
......@@ -29,4 +31,6 @@ Desktop.ini
$RECYCLE.BIN/
.DS_Store
*.csv
\ No newline at end of file
*.csv
config.user.bak
\ No newline at end of file
......@@ -21,19 +21,16 @@
### 使用方法
* 可参考[wiki](https://github.com/mercury233/ygopro-server/wiki)安装
* 手动安装:
* 安装修改后的YGOPro服务端:https://github.com/moecube/ygopro/tree/server
* `git clone https://github.com/moecube/srvpro.git`
* `cd srvpro`
* `npm install`
*`config.json`复制为`config.user.json`并进行修改
* `port`为你想要的端口
* ~~更多选项参见wiki~~
* 安装修改后的YGOPro服务端:https://github.com/moecube/ygopro/tree/server
* `node ygopro-server.js`即可运行
* 简易的控制台在 http://mercury233.me/ygosrv233/dashboard.html
* 简易的控制台在 http://srvpro.ygo233.com/dashboard.html
### 高级功能
* 待补充说明
* 简易的先行卡更新控制台在 http://mercury233.me/ygosrv233/pre-dashboard.html
* 简易的先行卡更新控制台在 http://srvpro.ygo233.com/pre-dashboard.html
### 开发计划
* 重做CTOS和STOC部分
......@@ -64,7 +61,7 @@
### License
SRVPro
Copyright (C) 2013-2017 MoeCube Team
Copyright (C) 2013-2018 MoeCube Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
......
{
"file": "./config/config.json",
"port": 7210,
"version": 4924,
"version": 4930,
"hostinfo": {
"lflist": 0,
"rule": 0,
......@@ -39,7 +40,7 @@
"get": "http://mercury233.me/ygosrv233/dialogues.json"
},
"words": {
"enabled": true,
"enabled": false,
"get": false
},
"music": {
......@@ -69,10 +70,10 @@
"auth_key": "233333"
},
"deck_log": {
"enabled": true,
"enabled": false,
"accesskey": "233",
"local": "./decks_save/",
"post": false,
"local": "./deck_log/",
"post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "233"
},
"big_brother": {
......@@ -121,7 +122,9 @@
"cdn": {
"enabled": false,
"exe": "upx",
"params": ["sync"],
"params": [
"sync"
],
"local": "./ygosrv233",
"remote": "/ygosrv233",
"pics_remote": "/ygopro/"
......@@ -130,22 +133,55 @@
"only_show_dbs": {
"news.cdb": true,
"pre-release.cdb": true
},
"html_gits": [
{
"name": "GitHub",
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": [
"push",
"coding",
"master:master"
]
}
]
},
"update_util": {
"enabled": false,
"port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/",
"changelog_filename": "changelog.json",
"html_gits": [
{
"name": "GitHub",
"push": ["push", "origin"]
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": ["push", "coding", "master:master"]
"push": [
"push",
"coding",
"master:master"
]
}
]
},
"command": {
"enabled": true,
"identity": {
"Nanahira": "Halozy"
"username1": "password1",
"username1": "password2"
},
"command_list": {
"ygopro": {
......@@ -235,31 +271,12 @@
"ban": {
"banned_user": [],
"banned_ip": [],
"badword_level0": ["滚", "衮", "操", "草", "艹", "狗", "日", "曰", "妈", "娘", "逼"],
"badword_level1": ["傻逼", "鸡巴"],
"badword_level2": ["死妈", "草你妈"],
"badword_level3": ["迷奸", "仿真枪"],
"illegal_id": ["^Lv\\.-*\\d+\\s*(.*)", "^VIP\\.\\d+\\s*(.*)"],
"spam_word": ["——"]
},
"tips": [
"欢迎来到本服务器",
"本服务器使用萌卡代码搭建"
],
"words": {
"test1": [
"test_word_1"
],
"test2": [
"test_word_2"
]
},
"dialogues": {
"46986414": [
"出来吧,我最强的仆人,黑魔导!"
"illegal_id": [
"^Lv\\.-*\\d+\\s*(.*)",
"^VIP\\.\\d+\\s*(.*)"
],
"58481572": [
"我们来做朋友吧!"
"spam_word": [
"——"
]
}
}
\ No newline at end of file
{
"file": "./config/config.json",
"port": 7911,
"version": 4924,
"version": 4930,
"hostinfo": {
"lflist": 0,
"rule": 0,
......@@ -121,7 +122,9 @@
"cdn": {
"enabled": false,
"exe": "upx",
"params": ["sync"],
"params": [
"sync"
],
"local": "./ygosrv233",
"remote": "/ygosrv233",
"pics_remote": "/ygopro/"
......@@ -130,15 +133,47 @@
"only_show_dbs": {
"news.cdb": true,
"pre-release.cdb": true
},
"html_gits": [
{
"name": "GitHub",
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": [
"push",
"coding",
"master:master"
]
}
]
},
"update_util": {
"enabled": false,
"port": 7955,
"password": "123456",
"git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/",
"changelog_filename": "changelog.json",
"html_gits": [
{
"name": "GitHub",
"push": ["push", "origin"]
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": ["push", "coding", "master:master"]
"push": [
"push",
"coding",
"master:master"
]
}
]
},
......@@ -236,31 +271,12 @@
"ban": {
"banned_user": [],
"banned_ip": [],
"badword_level0": ["滚", "衮", "操", "草", "艹", "狗", "日", "曰", "妈", "娘", "逼"],
"badword_level1": ["傻逼", "鸡巴"],
"badword_level2": ["死妈", "草你妈"],
"badword_level3": ["迷奸", "仿真枪"],
"illegal_id": ["^Lv\\.-*\\d+\\s*(.*)", "^VIP\\.\\d+\\s*(.*)"],
"spam_word": ["——"]
},
"tips": [
"欢迎来到本服务器",
"本服务器使用萌卡代码搭建"
],
"words": {
"test1": [
"test_word_1"
],
"test2": [
"test_word_2"
]
},
"dialogues": {
"46986414": [
"出来吧,我最强的仆人,黑魔导!"
"illegal_id": [
"^Lv\\.-*\\d+\\s*(.*)",
"^VIP\\.\\d+\\s*(.*)"
],
"58481572": [
"我们来做朋友吧!"
"spam_word": [
"——"
]
}
}
\ No newline at end of file
{
"badwords": {
"file": "./config/badwords.json",
"level0": ["滚", "衮", "操", "草", "艹", "狗", "日", "曰", "妈", "娘", "逼"],
"level1": ["傻逼", "鸡巴"],
"level2": ["死妈", "草你妈"],
"level3": ["迷奸", "仿真枪"]
},
"tips": {
"file": "./config/tips.json",
"tips": [
"欢迎来到本服务器",
"本服务器使用萌卡代码搭建"
]
},
"words": {
"test1": [
"test_word_1"
],
"test2": [
"test_word_2"
]
},
"dialogues": {
"file": "./config/dialogues.json",
"dialogues": {
"46986414": [
"出来吧,我最强的仆人,黑魔导!"
],
"58481572": [
"我们来做朋友吧!"
]
}
}
}
\ No newline at end of file
{
"port": 7911,
"modules": {
"welcome": "MyCard YGOPro Server",
"update": "请更新游戏版本,可在社区(https://ygobbs.com)手动下载更新包",
"tips": {
"enabled": true,
"get": "http://mycard.moe/tips.json"
},
"dialogues": {
"enabled": true,
"get": "http://mercury233.me/ygosrv233/dialogues.json"
},
"mycard": {
"enabled": true,
"auth_base_url": "https://ygobbs.com",
"auth_database": "postgres://233@233.mycard.moe/233",
"auth_key": "233333"
},
"deck_log": {
"enabled": true,
"accesskey": "233",
"local": false,
"post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "mycard"
},
"arena_mode": {
"enabled": true,
"mode": "entertain",
"comment": "mode: athletic / entertain",
"accesskey": "233",
"post_score": "https://mycard.moe/ygopro/api/score",
"get_score": "https://mycard.moe/ygopro/api/user?username="
},
"windbot": {
"enabled": true,
"botlist": "./windbot/bots.json",
"spawn": false,
"port": 2399
},
"http": {
"port": 7922,
"password": "123456",
"websocket_roomlist": true,
"ssl": {
"enabled": true,
"port": 7923,
"cert": "ssl/fullchain.pem",
"key": "ssl/privkey.pem"
}
}
}
}
......@@ -11,8 +11,8 @@
"author": "zh99998 <zh99998@gmail.com>, mercury233 <me@mercury233.me>",
"dependencies": {
"bunyan": "latest",
"deepmerge": "latest",
"moment": "latest",
"nconf": "latest",
"redis": "latest",
"formidable": "latest",
"request": "latest",
......
......@@ -8,8 +8,8 @@
*/
var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var config = require('./config.deckstats.json'); //{ "deckpath": "../decks", "dbfile": "cards.cdb" }
var constants = require('./constants.json');
var config = require('./config/deckstats.json'); //{ "deckpath": "../decks", "dbfile": "cards.cdb" }
var constants = require('./data/constants.json');
var ALL_MAIN_CARDS={};
var ALL_SIDE_CARDS={};
......
......@@ -16,13 +16,9 @@ var url = require('url');
var moment = require('moment');
moment.locale('zh-cn');
var constants = require('./constants.json');
var constants = require('./data/constants.json');
var nconf = require('nconf');
nconf.file('./config.user.json');
var defaultconfig = require('./config.json');
nconf.defaults(defaultconfig);
var settings = nconf.get();
var settings = require('./config/config.json');
config=settings.modules.pre_util;
//全卡HTML列表
......
This diff is collapsed.
This diff is collapsed.
......@@ -15,11 +15,7 @@ var _ = require('underscore');
_.str = require('underscore.string');
_.mixin(_.str.exports());
var nconf = require('nconf');
nconf.file('./config.user.json');
var defaultconfig = require('./config.json');
nconf.defaults(defaultconfig);
var settings = nconf.get();
var settings = require('./config/config.json');
config=settings.modules.tournament_mode;
//http长连接
......
/*
ygopro-update.js
ygopro update util (not fully implymented)
Author: mercury233
License: MIT
不带参数运行时,会建立一个服务器,调用API执行对应操作
TODO:带参数运行时执行对应操作后退出
*/
var http = require('http');
var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var execSync = require('child_process').execSync;
var spawn = require('child_process').spawn;
var spawnSync = require('child_process').spawnSync;
var url = require('url');
var moment = require('moment');
moment.locale('zh-cn');
var constants = require('./data/constants.json');
var settings = require('./config/config.json');
config=settings.modules.update_util;
//全卡名称列表
var cardNames={};
//
var changelog=[];
//http长连接
var responder;
//输出反馈信息,如有http长连接则输出到http,否则输出到控制台
var sendResponse = function(text) {
text=""+text;
if (responder) {
text=text.replace(/\n/g,"<br>");
responder.write("data: " + text + "\n\n");
}
else {
console.log(text);
}
}
//读取数据库内内容到cardNames,异步
var loadDb = function(db_file) {
var db = new sqlite3.Database(db_file);
db.each("select id,name from texts", function (err,result) {
if (err) {
sendResponse(db_file + ":" + err);
return;
}
else {
cardNames[result.id] = result.name;
}
}, function(err, num) {
if(err) {
sendResponse(db_file + ":" + err);
}
else {
sendResponse("已加载数据库"+db_file+",共"+num+"张卡。");
}
});
}
var loadChangelog = function(json_file) {
changelog = JSON.parse(fs.readFileSync(json_file, 'utf8')).changelog;
sendResponse("已加载更新记录"+json_file+",共"+changelog.length+"条,最后更新于"+changelog[0].date+"");
}
var makeChangelogs = function(dir, since) {
var lastcommit;
var addedCards=[];
var changedCards=[];
var prc_git_log = spawnSync("git", [ "log", "--pretty=%H,%ai", since ], { "cwd" : dir });
if (prc_git_log.stdout) {
var logs = prc_git_log.stdout.toString().split(/\n/g);
for (var i in logs) {
var log = logs[i].split(",");
var date = log[1];
if (date) {
var prc_git_diff = spawnSync("git", [ "diff-tree", "--no-commit-id", "--name-only" ,"--diff-filter=A" , "-r", log[0] ], { "cwd" : dir });
if (prc_git_diff.stdout) {
var lines = prc_git_diff.stdout.toString().split(/\n/g);
for (var j in lines) {
var line = lines[j].match(/c(\d+)\.lua/);
if (line) {
var name = cardNames[line[1]] || line[1];
addedCards.push(name);
sendResponse("<span class='add'>" + date + " + " + name + "</span>");
}
}
}
}
}
for (var i in logs) {
var log = logs[i].split(",");
var date = log[1];
if (date) {
var prc_git_diff = spawnSync("git", [ "diff-tree", "--no-commit-id", "--name-only" ,"--diff-filter=ad" , "-r", log[0] ], { "cwd" : dir });
if (prc_git_diff.stdout) {
var lines = prc_git_diff.stdout.toString().split(/\n/g);
for (var j in lines) {
var line = lines[j].match(/c(\d+)\.lua/);
if (line) {
var name = cardNames[line[1]] || line[1];
sendResponse("<span class='change'>" + date + " * " + name + "</span>");
if (!addedCards.includes(name) && !changedCards.includes(name)) {
changedCards.push(name);
}
}
}
}
}
}
sendResponse("新增卡片:");
for (var i in addedCards) {
sendResponse("-&nbsp;&nbsp;&nbsp;" + addedCards[i]);
}
if (addedCards.length == 0) {
sendResponse("-&nbsp;&nbsp;&nbsp;无");
}
sendResponse("\n");
sendResponse("卡片更改:");
for (var i in changedCards) {
sendResponse("-&nbsp;&nbsp;&nbsp;" + changedCards[i]);
}
if (changedCards.length == 0) {
sendResponse("-&nbsp;&nbsp;&nbsp;无");
}
} else {
sendResponse("获取更新记录失败:" + prc_git_log.stderr.toString());
}
}
//从远程更新数据库,异步
var fetchDatas = function() {
var proc = spawn("git", ["pull", "origin", "master"], { cwd: config.git_db_path, env: process.env });
proc.stdout.setEncoding('utf8');
proc.stdout.on('data', function(data) {
sendResponse("git pull: "+data);
});
proc.stderr.setEncoding('utf8');
proc.stderr.on('data', function(data) {
sendResponse("git pull: "+data);
});
proc.on('close', function (code) {
sendResponse("数据更新完成。");
});
var proc2 = spawn("git", ["pull", "origin", "master"], { cwd: config.git_html_path, env: process.env });
proc2.stdout.setEncoding('utf8');
proc2.stdout.on('data', function(data) {
sendResponse("git pull: "+data);
});
proc2.stderr.setEncoding('utf8');
proc2.stderr.on('data', function(data) {
sendResponse("git pull: "+data);
});
proc2.on('close', function (code) {
sendResponse("网页同步完成。");
});
}
//建立一个http服务器,接收API操作
http.createServer(function (req, res) {
var u = url.parse(req.url, true);
if (u.query.password !== config.password) {
res.writeHead(403);
res.end("Auth Failed.");
return;
}
if (u.pathname === '/api/msg') {
res.writeHead(200, {
"Access-Control-Allow-origin": "*",
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
"Connection": "keep-alive"
});
res.on("close", function(){
responder = null;
});
responder = res;
sendResponse("已连接。");
}
else if (u.pathname === '/api/load_db') {
res.writeHead(200);
res.end(u.query.callback+'({"message":"开始加载数据库。"});');
loadDb("./ygopro/cards.cdb");
loadChangelog(config.html_path + config.changelog_filename);
}
else if (u.pathname === '/api/make_changelog') {
res.writeHead(200);
var date = moment(changelog[0].date).add(1,'days').format("YYYY-MM-DD");
res.end(u.query.callback+'({"message":"开始生成'+ date +'以来的更新记录:"});');
makeChangelogs("./ygopro/script", "--since="+date);
}
else if (u.pathname === '/api/make_more_changelog') {
res.writeHead(200);
res.end(u.query.callback+'({"message":"开始生成最近20次的更新记录:"});');
makeChangelogs("./ygopro/script", "-20");
}
else if (u.pathname === '/api/push_datas') {
res.writeHead(200);
res.end(u.query.callback+'({"message":"开始上传到网页。"});');
pushDatas();
}
else if (u.pathname === '/api/write_to_file') {
res.writeHead(200);
res.end(u.query.callback+'({"message":"开始写列表页。"});');
writeToFile(u.query.message);
}
else {
res.writeHead(400);
res.end("400");
}
}).listen(config.port);
......@@ -4,13 +4,13 @@ _.mixin(_.str.exports())
Struct = require('./struct.js').Struct
i18ns = require './i18n.json'
i18ns = require './data/i18n.json'
#常量/类型声明
structs_declaration = require './structs.json' #结构体声明
typedefs = require './typedefs.json' #类型声明
@proto_structs = require './proto_structs.json' #消息与结构体的对应,未完成,对着duelclient.cpp加
@constants = require './constants.json' #network.h里定义的常量
structs_declaration = require './data/structs.json' #结构体声明
typedefs = require './data/typedefs.json' #类型声明
@proto_structs = require './data/proto_structs.json' #消息与结构体的对应,未完成,对着duelclient.cpp加
@constants = require './data/constants.json' #network.h里定义的常量
#结构体定义
@structs = {}
......
......@@ -10,15 +10,15 @@
Struct = require('./struct.js').Struct;
i18ns = require('./i18n.json');
i18ns = require('./data/i18n.json');
structs_declaration = require('./structs.json');
structs_declaration = require('./data/structs.json');
typedefs = require('./typedefs.json');
typedefs = require('./data/typedefs.json');
this.proto_structs = require('./proto_structs.json');
this.proto_structs = require('./data/proto_structs.json');
this.constants = require('./constants.json');
this.constants = require('./data/constants.json');
this.structs = {};
......
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