Reupload
这个提交包含在:
312
AI.js
312
AI.js
@ -1,157 +1,157 @@
|
|||||||
const https = require('http');
|
const https = require('http');
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const md5 = crypto.createHash('md5');
|
const md5 = crypto.createHash('md5');
|
||||||
//const iconv = require('iconv-lite');
|
//const iconv = require('iconv-lite');
|
||||||
var ret = "";
|
var ret = "";
|
||||||
const R = "_";
|
const R = "_";
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetAITalk:function(user){
|
GetAITalk:function(user){
|
||||||
if(Core.frame.ReadSystemConfig("AITalk")[user] != true){
|
if(Core.frame.ReadSystemConfig("AITalk")[user] != true){
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
console.log(Core.HOOK);
|
console.log(Core.HOOK);
|
||||||
var message0 = new String(info["message"]);
|
var message0 = new String(info["message"]);
|
||||||
if(message0 == "智能聊天"){
|
if(message0 == "智能聊天"){
|
||||||
if(!exports.add.Interfaces.GetAITalk("Core")){
|
if(!exports.add.Interfaces.GetAITalk("Core")){
|
||||||
Core.frame.SendMsg(connect,info,"请联系AI管理员(发送\"AI管理员\"查看)开启智能聊天功能。")
|
Core.frame.SendMsg(connect,info,"请联系AI管理员(发送\"AI管理员\"查看)开启智能聊天功能。")
|
||||||
}
|
}
|
||||||
temp = Core.frame.ReadSystemConfig("AITalk");
|
temp = Core.frame.ReadSystemConfig("AITalk");
|
||||||
if(exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))){
|
if(exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},我们不是一直在聊吗?`)
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},我们不是一直在聊吗?`)
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},现在你已经开启智能聊天了。`)
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},现在你已经开启智能聊天了。`)
|
||||||
}
|
}
|
||||||
temp[Core.GetUser(info["user_id"])] = true;
|
temp[Core.GetUser(info["user_id"])] = true;
|
||||||
Core.frame.WriteSystemConfig("AITalk",temp);
|
Core.frame.WriteSystemConfig("AITalk",temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message0 == "停止聊天"){
|
if(message0 == "停止聊天"){
|
||||||
if(!exports.add.Interfaces.GetAITalk("Core")){
|
if(!exports.add.Interfaces.GetAITalk("Core")){
|
||||||
Core.frame.SendMsg(connect,info,"请联系AI管理员(发送\"AI管理员\"查看)开启智能聊天功能。")
|
Core.frame.SendMsg(connect,info,"请联系AI管理员(发送\"AI管理员\"查看)开启智能聊天功能。")
|
||||||
}
|
}
|
||||||
temp = Core.frame.ReadSystemConfig("AITalk");
|
temp = Core.frame.ReadSystemConfig("AITalk");
|
||||||
if(exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))){
|
if(exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},哼,不理你了。`)
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},哼,不理你了。`)
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},谁愿意和你聊啊!`)
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},谁愿意和你聊啊!`)
|
||||||
}
|
}
|
||||||
temp[Core.GetUser(info["user_id"])] = false;
|
temp[Core.GetUser(info["user_id"])] = false;
|
||||||
Core.frame.WriteSystemConfig("AITalk",temp);
|
Core.frame.WriteSystemConfig("AITalk",temp);
|
||||||
}
|
}
|
||||||
info["message"] = info["message"].replace("[CQ:at,qq=2142562417]","");
|
info["message"] = info["message"].replace("[CQ:at,qq=2142562417]","");
|
||||||
|
|
||||||
if(info["message"].indexOf("[CQ:at,qq=")!=-1){
|
if(info["message"].indexOf("[CQ:at,qq=")!=-1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Core.HOOK == true){
|
if(Core.HOOK == true){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))&&info["raw_message"].indexOf("[CQ:at,qq=2142562417]")==-1){
|
if(!exports.add.Interfaces.GetAITalk(Core.GetUser(info["user_id"]))&&info["raw_message"].indexOf("[CQ:at,qq=2142562417]")==-1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const https = require('http');
|
const https = require('http');
|
||||||
//const Core = require("./Core");
|
//const Core = require("./Core");
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const md5 = crypto.createHash('md5');
|
const md5 = crypto.createHash('md5');
|
||||||
var kee = new String(info["message"]);
|
var kee = new String(info["message"]);
|
||||||
|
|
||||||
for(;kee.indexOf("?")!=-1;){
|
for(;kee.indexOf("?")!=-1;){
|
||||||
kee = kee.replace("?","?");
|
kee = kee.replace("?","?");
|
||||||
}
|
}
|
||||||
for(;kee.indexOf("!")!=-1;){
|
for(;kee.indexOf("!")!=-1;){
|
||||||
kee = kee.replace("!","!");
|
kee = kee.replace("!","!");
|
||||||
}
|
}
|
||||||
for(;kee.indexOf(" ")!=-1;){
|
for(;kee.indexOf(" ")!=-1;){
|
||||||
kee = kee.replace(" "," ");
|
kee = kee.replace(" "," ");
|
||||||
}
|
}
|
||||||
var params = new Object({
|
var params = new Object({
|
||||||
app_id:"2125346185",
|
app_id:"2125346185",
|
||||||
time_stamp: Date.parse(new Date())/1000,
|
time_stamp: Date.parse(new Date())/1000,
|
||||||
"nonce\_str":new String("A"+Math.floor(Math.random() * 100000000)),
|
"nonce\_str":new String("A"+Math.floor(Math.random() * 100000000)),
|
||||||
session:Core.GetUser(info["user_id"]),
|
session:Core.GetUser(info["user_id"]),
|
||||||
question:kee
|
question:kee
|
||||||
});
|
});
|
||||||
var key = "T6zpC15OkWJ9jP0a";
|
var key = "T6zpC15OkWJ9jP0a";
|
||||||
var p2 = new Object();
|
var p2 = new Object();
|
||||||
var k = Object.keys(params).sort();
|
var k = Object.keys(params).sort();
|
||||||
for(var i = 0;i<k.length;i++){
|
for(var i = 0;i<k.length;i++){
|
||||||
p2[k[i]] = params[k[i]];
|
p2[k[i]] = params[k[i]];
|
||||||
}
|
}
|
||||||
var Str="";
|
var Str="";
|
||||||
for(var i = 0;i<k.length;i++){
|
for(var i = 0;i<k.length;i++){
|
||||||
Str=Str+Object.keys(p2)[i]+"="+encodeURI(Object.values(p2)[i])+"&";
|
Str=Str+Object.keys(p2)[i]+"="+encodeURI(Object.values(p2)[i])+"&";
|
||||||
}
|
}
|
||||||
Str = Str+"app_key="+key;
|
Str = Str+"app_key="+key;
|
||||||
sign = md5.update(Str).digest("hex").toUpperCase();
|
sign = md5.update(Str).digest("hex").toUpperCase();
|
||||||
params["sign"] = sign;
|
params["sign"] = sign;
|
||||||
|
|
||||||
(()=>{
|
(()=>{
|
||||||
request.get({
|
request.get({
|
||||||
url:`https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat?${Str}&sign=${sign}`,
|
url:`https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat?${Str}&sign=${sign}`,
|
||||||
encoding:'utf8'
|
encoding:'utf8'
|
||||||
},(err,req,body)=>{
|
},(err,req,body)=>{
|
||||||
if(req.statusCode==200){
|
if(req.statusCode==200){
|
||||||
console.log(body);
|
console.log(body);
|
||||||
var an = JSON.parse(body)["data"]["answer"];
|
var an = JSON.parse(body)["data"]["answer"];
|
||||||
an = an.replace(/呵/g,"").replace(/哈/g,"").replace(/吧/g,"").replace(/哦/g,"");
|
an = an.replace(/呵/g,"").replace(/哈/g,"").replace(/吧/g,"").replace(/哦/g,"");
|
||||||
Core.frame._SendMsg(connect,info,an);
|
Core.frame._SendMsg(connect,info,an);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
https.get(`http://api.qingyunke.com/api.php?key=free&appid=0&msg=${encodeURI(message0)}`,(resp) => {
|
https.get(`http://api.qingyunke.com/api.php?key=free&appid=0&msg=${encodeURI(message0)}`,(resp) => {
|
||||||
let data = '';
|
let data = '';
|
||||||
resp.on('data', (chunk) => {
|
resp.on('data', (chunk) => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
});
|
});
|
||||||
resp.on('end', () => {
|
resp.on('end', () => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if(data.substr(0,1)!="{"){
|
if(data.substr(0,1)!="{"){
|
||||||
Core.frame.SendMsg(connect,info,ret);
|
Core.frame.SendMsg(connect,info,ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ret = new String(JSON.parse(data).content);
|
var ret = new String(JSON.parse(data).content);
|
||||||
for(;ret.match("{br}")!=null;){
|
for(;ret.match("{br}")!=null;){
|
||||||
ret = ret.replace("{br}","\\r\\n");
|
ret = ret.replace("{br}","\\r\\n");
|
||||||
}
|
}
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
Core.frame.SendMsg(connect,info,ret)
|
Core.frame.SendMsg(connect,info,ret)
|
||||||
});
|
});
|
||||||
}).on("error", (err) => {
|
}).on("error", (err) => {
|
||||||
console.log("Error: " + err.message);
|
console.log("Error: " + err.message);
|
||||||
});
|
});
|
||||||
*///这个是未经测试的版本
|
*///这个是未经测试的版本
|
||||||
|
|
||||||
/*Yige.ai暂停运营
|
/*Yige.ai暂停运营
|
||||||
*request.post({
|
*request.post({
|
||||||
url:'http://www.yige.ai/v1/query',
|
url:'http://www.yige.ai/v1/query',
|
||||||
form:{
|
form:{
|
||||||
token:"ED1A14F0606567943CC354351A9E6B0E",
|
token:"ED1A14F0606567943CC354351A9E6B0E",
|
||||||
query:info["message"],
|
query:info["message"],
|
||||||
session_id:Core.GetUser(info["user_id"])
|
session_id:Core.GetUser(info["user_id"])
|
||||||
},
|
},
|
||||||
encoding:'utf8'
|
encoding:'utf8'
|
||||||
},function(error,response,body){
|
},function(error,response,body){
|
||||||
if(response.statusCode == 200){
|
if(response.statusCode == 200){
|
||||||
console.log(body);
|
console.log(body);
|
||||||
var ret = JSON.parse(body).answer;
|
var ret = JSON.parse(body).answer;
|
||||||
if(ret != "[ERROR]无回复"){
|
if(ret != "[ERROR]无回复"){
|
||||||
Core.frame._SendMsg(connect,info,ret);
|
Core.frame._SendMsg(connect,info,ret);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
});
|
});
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
62
API/Main.js
62
API/Main.js
@ -1,31 +1,31 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const 利刃 = __importStar(require("./Public"));
|
const 利刃 = __importStar(require("./Public"));
|
||||||
const Core = __importStar(require("./../Core"));
|
const Core = __importStar(require("./../Core"));
|
||||||
const Debug = require("./../Debug");
|
const Debug = require("./../Debug");
|
||||||
Core.AddListener((Connect, Info) => {
|
Core.AddListener((Connect, Info) => {
|
||||||
Info.Core = Core;
|
Info.Core = Core;
|
||||||
if (Info.message == "更新利刃" && Debug.add.Interfaces.IsAdmin(Info.user_id)) {
|
if (Info.message == "更新利刃" && Debug.add.Interfaces.IsAdmin(Info.user_id)) {
|
||||||
利刃.更新API();
|
利刃.更新API();
|
||||||
Core.frame.SendMsg(Connect, Info, "[利刃后端]更新成功!");
|
Core.frame.SendMsg(Connect, Info, "[利刃后端]更新成功!");
|
||||||
}
|
}
|
||||||
if (Info.message.substr(0, 4) == "利刃执行") {
|
if (Info.message.substr(0, 4) == "利刃执行") {
|
||||||
if (!(Debug.add.Interfaces.IsAdmin(Info.user_id))) {
|
if (!(Debug.add.Interfaces.IsAdmin(Info.user_id))) {
|
||||||
Core.frame.SendMsg(Connect, Info, "只有Ai管理员才有权使用本指令");
|
Core.frame.SendMsg(Connect, Info, "只有Ai管理员才有权使用本指令");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Command = Info.message.replace("利刃执行", "").replace(/[/g, "[").replace(/]/g, "]");
|
var Command = Info.message.replace("利刃执行", "").replace(/[/g, "[").replace(/]/g, "]");
|
||||||
Core.frame.SendMsg(Connect, Info, 利刃.解析(Command, Info));
|
Core.frame.SendMsg(Connect, Info, 利刃.解析(Command, Info));
|
||||||
}
|
}
|
||||||
var 利刃Ret = 利刃.核心(Info);
|
var 利刃Ret = 利刃.核心(Info);
|
||||||
if (利刃Ret != "") {
|
if (利刃Ret != "") {
|
||||||
Core.frame.SendMsg(Connect, Info, 利刃Ret);
|
Core.frame.SendMsg(Connect, Info, 利刃Ret);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
42
API/Main.ts
42
API/Main.ts
@ -1,22 +1,22 @@
|
|||||||
import * as 利刃 from "./Public";
|
import * as 利刃 from "./Public";
|
||||||
import * as Core from "./../Core";
|
import * as Core from "./../Core";
|
||||||
const Debug = require("./../Debug");
|
const Debug = require("./../Debug");
|
||||||
Core.AddListener((Connect,Info)=>{
|
Core.AddListener((Connect,Info)=>{
|
||||||
Info.Core = Core;
|
Info.Core = Core;
|
||||||
if(Info.message == "更新利刃" && Debug.add.Interfaces.IsAdmin(Info.user_id)){
|
if(Info.message == "更新利刃" && Debug.add.Interfaces.IsAdmin(Info.user_id)){
|
||||||
利刃.更新API();
|
利刃.更新API();
|
||||||
Core.frame.SendMsg(Connect,Info,"[利刃后端]更新成功!")
|
Core.frame.SendMsg(Connect,Info,"[利刃后端]更新成功!")
|
||||||
}
|
}
|
||||||
if(Info.message.substr(0,4) == "利刃执行"){
|
if(Info.message.substr(0,4) == "利刃执行"){
|
||||||
if(!(Debug.add.Interfaces.IsAdmin(Info.user_id))){
|
if(!(Debug.add.Interfaces.IsAdmin(Info.user_id))){
|
||||||
Core.frame.SendMsg(Connect,Info,"只有Ai管理员才有权使用本指令");
|
Core.frame.SendMsg(Connect,Info,"只有Ai管理员才有权使用本指令");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Command = Info.message.replace("利刃执行","").replace(/[/g,"[").replace(/]/g,"]");
|
var Command = Info.message.replace("利刃执行","").replace(/[/g,"[").replace(/]/g,"]");
|
||||||
Core.frame.SendMsg(Connect,Info,利刃.解析(Command,Info));
|
Core.frame.SendMsg(Connect,Info,利刃.解析(Command,Info));
|
||||||
}
|
}
|
||||||
var 利刃Ret = 利刃.核心(Info);
|
var 利刃Ret = 利刃.核心(Info);
|
||||||
if(利刃Ret != ""){
|
if(利刃Ret != ""){
|
||||||
Core.frame.SendMsg(Connect,Info,利刃Ret);
|
Core.frame.SendMsg(Connect,Info,利刃Ret);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
182
API/Public.js
182
API/Public.js
@ -1,91 +1,91 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
/**
|
/**
|
||||||
* <利刃后端>
|
* <利刃后端>
|
||||||
* 介绍:本后端提供了全新的中文编程方式,
|
* 介绍:本后端提供了全新的中文编程方式,
|
||||||
*/
|
*/
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
var APIs = [];
|
var APIs = [];
|
||||||
var API = {};
|
var API = {};
|
||||||
API.Base = {
|
API.Base = {
|
||||||
Const: {},
|
Const: {},
|
||||||
Function: {}
|
Function: {}
|
||||||
};
|
};
|
||||||
API.Config = {
|
API.Config = {
|
||||||
Name: "[USING NAMESPACE]",
|
Name: "[USING NAMESPACE]",
|
||||||
Author: "OnlineAi"
|
Author: "OnlineAi"
|
||||||
};
|
};
|
||||||
API.Using = {};
|
API.Using = {};
|
||||||
exports.更新API = (() => {
|
exports.更新API = (() => {
|
||||||
APIs = [];
|
APIs = [];
|
||||||
fs.readdir("./API/Using/", (err, files) => {
|
fs.readdir("./API/Using/", (err, files) => {
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
fs.readFile(`./API/Using/${files[i]}`, (err, data) => {
|
fs.readFile(`./API/Using/${files[i]}`, (err, data) => {
|
||||||
APIs[APIs.length] = JSON.parse(data.toString());
|
APIs[APIs.length] = JSON.parse(data.toString());
|
||||||
APIs.forEach((OAPI) => {
|
APIs.forEach((OAPI) => {
|
||||||
Object.keys(OAPI.Base.Const).forEach((Keys) => {
|
Object.keys(OAPI.Base.Const).forEach((Keys) => {
|
||||||
API.Base.Const[Keys] = OAPI.Base.Const[Keys];
|
API.Base.Const[Keys] = OAPI.Base.Const[Keys];
|
||||||
});
|
});
|
||||||
Object.keys(OAPI.Base.Function).forEach((Keys) => {
|
Object.keys(OAPI.Base.Function).forEach((Keys) => {
|
||||||
API.Base.Function[Keys] = OAPI.Base.Function[Keys];
|
API.Base.Function[Keys] = OAPI.Base.Function[Keys];
|
||||||
});
|
});
|
||||||
Object.keys(OAPI.Using).forEach((Keys) => {
|
Object.keys(OAPI.Using).forEach((Keys) => {
|
||||||
API.Using[Keys] = OAPI.Using[Keys];
|
API.Using[Keys] = OAPI.Using[Keys];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
exports.更新API();
|
exports.更新API();
|
||||||
exports.解析 = ((内容, 收到) => {
|
exports.解析 = ((内容, 收到) => {
|
||||||
var Core = 收到.Core;
|
var Core = 收到.Core;
|
||||||
var 返回 = 内容;
|
var 返回 = 内容;
|
||||||
var ConstKeys = Object.keys(API.Base.Const);
|
var ConstKeys = Object.keys(API.Base.Const);
|
||||||
ConstKeys.forEach((Key) => {
|
ConstKeys.forEach((Key) => {
|
||||||
返回 = 返回.replace(new RegExp(`\\[${Key}\\]`, "g"), eval(API.Base.Const[Key]));
|
返回 = 返回.replace(new RegExp(`\\[${Key}\\]`, "g"), eval(API.Base.Const[Key]));
|
||||||
});
|
});
|
||||||
var FunctionKeys = Object.keys(API.Base.Function);
|
var FunctionKeys = Object.keys(API.Base.Function);
|
||||||
// 函数预判
|
// 函数预判
|
||||||
FunctionKeys.forEach((Key) => {
|
FunctionKeys.forEach((Key) => {
|
||||||
返回 = 返回.replace(new RegExp(`\\[${Key} `, "g"), `{${Key} `);
|
返回 = 返回.replace(new RegExp(`\\[${Key} `, "g"), `{${Key} `);
|
||||||
});
|
});
|
||||||
if (返回.indexOf("[") != -1) {
|
if (返回.indexOf("[") != -1) {
|
||||||
return "[ERR]DISALLOW CALLING FUNCTIONS OR CONSTS WITHOUT DEFINIE";
|
return "[ERR]DISALLOW CALLING FUNCTIONS OR CONSTS WITHOUT DEFINIE";
|
||||||
}
|
}
|
||||||
返回 = 返回.replace(/\{/g, "[");
|
返回 = 返回.replace(/\{/g, "[");
|
||||||
FunctionKeys.forEach((Key) => {
|
FunctionKeys.forEach((Key) => {
|
||||||
var Function = new RegExp(`^\\[${Key} (.*?)\\]$`);
|
var Function = new RegExp(`^\\[${Key} (.*?)\\]$`);
|
||||||
if (Function.test(返回.valueOf())) {
|
if (Function.test(返回.valueOf())) {
|
||||||
Function.exec(返回.valueOf());
|
Function.exec(返回.valueOf());
|
||||||
var 处理 = RegExp.$1;
|
var 处理 = RegExp.$1;
|
||||||
if (处理.indexOf("[") != -1) {
|
if (处理.indexOf("[") != -1) {
|
||||||
处理 = exports.解析(处理, 收到);
|
处理 = exports.解析(处理, 收到);
|
||||||
}
|
}
|
||||||
返回 = 返回.replace(Function, eval(`${API.Base.Function[Key]}("${处理}",收到)`));
|
返回 = 返回.replace(Function, eval(`${API.Base.Function[Key]}("${处理}",收到)`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return 返回;
|
return 返回;
|
||||||
});
|
});
|
||||||
exports.核心 = ((收到) => {
|
exports.核心 = ((收到) => {
|
||||||
var Core = 收到.Core;
|
var Core = 收到.Core;
|
||||||
var 内容 = 收到.message;
|
var 内容 = 收到.message;
|
||||||
var 消息 = "";
|
var 消息 = "";
|
||||||
Object.keys(API.Using).forEach((value) => {
|
Object.keys(API.Using).forEach((value) => {
|
||||||
if (new RegExp(`^${value}$`).test(内容.valueOf())) {
|
if (new RegExp(`^${value}$`).test(内容.valueOf())) {
|
||||||
var 过程 = API.Using[value];
|
var 过程 = API.Using[value];
|
||||||
消息 = 过程.Content;
|
消息 = 过程.Content;
|
||||||
过程.Execute.forEach((v, i) => {
|
过程.Execute.forEach((v, i) => {
|
||||||
消息 = 消息.replace(new RegExp(`\\{${i}\\}`, "g"), exports.解析(v, 收到).valueOf());
|
消息 = 消息.replace(new RegExp(`\\{${i}\\}`, "g"), exports.解析(v, 收到).valueOf());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return 消息;
|
return 消息;
|
||||||
});
|
});
|
||||||
|
|||||||
166
API/Public.ts
166
API/Public.ts
@ -1,84 +1,84 @@
|
|||||||
/**
|
/**
|
||||||
* <利刃后端>
|
* <利刃后端>
|
||||||
* 介绍:本后端提供了全新的中文编程方式,
|
* 介绍:本后端提供了全新的中文编程方式,
|
||||||
*/
|
*/
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as Core from "./../Core"
|
import * as Core from "./../Core"
|
||||||
var APIs:Addons[] = [];
|
var APIs:Addons[] = [];
|
||||||
var API:Addons = {} as any;
|
var API:Addons = {} as any;
|
||||||
API.Base = {
|
API.Base = {
|
||||||
Const:{},
|
Const:{},
|
||||||
Function:{}
|
Function:{}
|
||||||
}
|
}
|
||||||
API.Config = {
|
API.Config = {
|
||||||
Name:"[USING NAMESPACE]",
|
Name:"[USING NAMESPACE]",
|
||||||
Author:"OnlineAi"
|
Author:"OnlineAi"
|
||||||
}
|
}
|
||||||
API.Using = {}
|
API.Using = {}
|
||||||
export var 更新API = (()=>{
|
export var 更新API = (()=>{
|
||||||
APIs = [];
|
APIs = [];
|
||||||
fs.readdir("./API/Using/",(err,files)=>{
|
fs.readdir("./API/Using/",(err,files)=>{
|
||||||
for(var i = 0;i < files.length ; i++){
|
for(var i = 0;i < files.length ; i++){
|
||||||
fs.readFile(`./API/Using/${files[i]}`,(err,data)=>{
|
fs.readFile(`./API/Using/${files[i]}`,(err,data)=>{
|
||||||
APIs[APIs.length] = JSON.parse(data.toString()) as Addons;
|
APIs[APIs.length] = JSON.parse(data.toString()) as Addons;
|
||||||
APIs.forEach((OAPI)=>{
|
APIs.forEach((OAPI)=>{
|
||||||
Object.keys(OAPI.Base.Const).forEach((Keys)=>{
|
Object.keys(OAPI.Base.Const).forEach((Keys)=>{
|
||||||
API.Base.Const[Keys] = OAPI.Base.Const[Keys];
|
API.Base.Const[Keys] = OAPI.Base.Const[Keys];
|
||||||
});
|
});
|
||||||
Object.keys(OAPI.Base.Function).forEach((Keys)=>{
|
Object.keys(OAPI.Base.Function).forEach((Keys)=>{
|
||||||
API.Base.Function[Keys] = OAPI.Base.Function[Keys];
|
API.Base.Function[Keys] = OAPI.Base.Function[Keys];
|
||||||
})
|
})
|
||||||
Object.keys(OAPI.Using).forEach((Keys)=>{
|
Object.keys(OAPI.Using).forEach((Keys)=>{
|
||||||
API.Using[Keys] = OAPI.Using[Keys];
|
API.Using[Keys] = OAPI.Using[Keys];
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
更新API();
|
更新API();
|
||||||
export var 解析:((内容:String,收到:Core.InfoType)=> String) = ((内容,收到)=>{
|
export var 解析:((内容:String,收到:Core.InfoType)=> String) = ((内容,收到)=>{
|
||||||
var Core = 收到.Core;
|
var Core = 收到.Core;
|
||||||
var 返回 = 内容;
|
var 返回 = 内容;
|
||||||
var ConstKeys = Object.keys(API.Base.Const);
|
var ConstKeys = Object.keys(API.Base.Const);
|
||||||
ConstKeys.forEach((Key)=>{
|
ConstKeys.forEach((Key)=>{
|
||||||
返回 = 返回.replace(new RegExp(`\\[${Key}\\]`,"g"),eval(API.Base.Const[Key]));
|
返回 = 返回.replace(new RegExp(`\\[${Key}\\]`,"g"),eval(API.Base.Const[Key]));
|
||||||
});
|
});
|
||||||
var FunctionKeys = Object.keys(API.Base.Function);
|
var FunctionKeys = Object.keys(API.Base.Function);
|
||||||
// 函数预判
|
// 函数预判
|
||||||
FunctionKeys.forEach((Key)=>{
|
FunctionKeys.forEach((Key)=>{
|
||||||
返回 = 返回.replace(new RegExp(`\\[${Key} `,"g"),`{${Key} `);
|
返回 = 返回.replace(new RegExp(`\\[${Key} `,"g"),`{${Key} `);
|
||||||
})
|
})
|
||||||
if(返回.indexOf("[")!=-1){
|
if(返回.indexOf("[")!=-1){
|
||||||
return "[ERR]DISALLOW CALLING FUNCTIONS OR CONSTS WITHOUT DEFINIE"
|
return "[ERR]DISALLOW CALLING FUNCTIONS OR CONSTS WITHOUT DEFINIE"
|
||||||
}
|
}
|
||||||
返回 = 返回.replace(/\{/g,"[");
|
返回 = 返回.replace(/\{/g,"[");
|
||||||
FunctionKeys.forEach((Key)=>{
|
FunctionKeys.forEach((Key)=>{
|
||||||
var Function = new RegExp(`^\\[${Key} (.*?)\\]$`);
|
var Function = new RegExp(`^\\[${Key} (.*?)\\]$`);
|
||||||
if(Function.test(返回.valueOf())){
|
if(Function.test(返回.valueOf())){
|
||||||
Function.exec(返回.valueOf());
|
Function.exec(返回.valueOf());
|
||||||
var 处理 = RegExp.$1 as String;
|
var 处理 = RegExp.$1 as String;
|
||||||
if(处理.indexOf("[") != -1){
|
if(处理.indexOf("[") != -1){
|
||||||
处理 = 解析(处理,收到);
|
处理 = 解析(处理,收到);
|
||||||
}
|
}
|
||||||
返回 = 返回.replace(Function,eval(`${API.Base.Function[Key]}("${处理}",收到)`));
|
返回 = 返回.replace(Function,eval(`${API.Base.Function[Key]}("${处理}",收到)`));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return 返回;
|
return 返回;
|
||||||
});
|
});
|
||||||
|
|
||||||
export var 核心:((收到:Core.InfoType)=>String) = ((收到:Core.InfoType)=>{
|
export var 核心:((收到:Core.InfoType)=>String) = ((收到:Core.InfoType)=>{
|
||||||
var Core = 收到.Core;
|
var Core = 收到.Core;
|
||||||
var 内容:String = 收到.message;
|
var 内容:String = 收到.message;
|
||||||
var 消息:String = "";
|
var 消息:String = "";
|
||||||
Object.keys(API.Using).forEach((value)=>{
|
Object.keys(API.Using).forEach((value)=>{
|
||||||
if(new RegExp(`^${value}$`).test(内容.valueOf())){
|
if(new RegExp(`^${value}$`).test(内容.valueOf())){
|
||||||
var 过程 = (API.Using[value] as AddonsUsing)
|
var 过程 = (API.Using[value] as AddonsUsing)
|
||||||
消息 = 过程.Content;
|
消息 = 过程.Content;
|
||||||
过程.Execute.forEach((v,i)=>{
|
过程.Execute.forEach((v,i)=>{
|
||||||
消息 = 消息.replace(new RegExp(`\\{${i}\\}`,"g"),解析(v,收到).valueOf());
|
消息 = 消息.replace(new RegExp(`\\{${i}\\}`,"g"),解析(v,收到).valueOf());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return 消息;
|
return 消息;
|
||||||
});
|
});
|
||||||
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var E = /^\[(.*?)\]$/g;
|
var E = /^\[(.*?)\]$/g;
|
||||||
var S = "[A[BC]]";
|
var S = "[A[BC]]";
|
||||||
E.exec(S);
|
E.exec(S);
|
||||||
console.log(RegExp.$1);
|
console.log(RegExp.$1);
|
||||||
console.log(RegExp.$2);
|
console.log(RegExp.$2);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var E = /^\[(.*?)\]$/g;
|
var E = /^\[(.*?)\]$/g;
|
||||||
var S = "[A[BC]]"
|
var S = "[A[BC]]"
|
||||||
E.exec(S);
|
E.exec(S);
|
||||||
console.log(RegExp.$1);
|
console.log(RegExp.$1);
|
||||||
console.log(RegExp.$2);
|
console.log(RegExp.$2);
|
||||||
32
API/lib.d.ts
vendored
32
API/lib.d.ts
vendored
@ -1,17 +1,17 @@
|
|||||||
declare interface Addons{
|
declare interface Addons{
|
||||||
Config:AddonsConfig,
|
Config:AddonsConfig,
|
||||||
Base:AddonsBase,
|
Base:AddonsBase,
|
||||||
Using:any;
|
Using:any;
|
||||||
}
|
}
|
||||||
declare interface AddonsConfig{
|
declare interface AddonsConfig{
|
||||||
Name:String,
|
Name:String,
|
||||||
Author:String
|
Author:String
|
||||||
}
|
}
|
||||||
declare interface AddonsBase{
|
declare interface AddonsBase{
|
||||||
Const:any,
|
Const:any,
|
||||||
Function:any;
|
Function:any;
|
||||||
}
|
}
|
||||||
declare interface AddonsUsing{
|
declare interface AddonsUsing{
|
||||||
Content:String,
|
Content:String,
|
||||||
Execute:Array<String>;
|
Execute:Array<String>;
|
||||||
}
|
}
|
||||||
76
AbleSend.js
76
AbleSend.js
@ -1,38 +1,38 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const CGI = require("./CGI");
|
const CGI = require("./CGI");
|
||||||
(() => {
|
(() => {
|
||||||
var SendAble = Core.frame.ReadSystemConfig("SendAble");
|
var SendAble = Core.frame.ReadSystemConfig("SendAble");
|
||||||
var Ks = 1;
|
var Ks = 1;
|
||||||
Core.AddListener((c, i) => {
|
Core.AddListener((c, i) => {
|
||||||
if (CGI.HOOK) {
|
if (CGI.HOOK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var delete_msg = ((msgid) => {
|
var delete_msg = ((msgid) => {
|
||||||
if (i.group_id != undefined) {
|
if (i.group_id != undefined) {
|
||||||
Core.frame.SendMsg(c, i, "[!][警告]有一个未备案消息被发送,请管理员自行验证此消息是否合理。");
|
Core.frame.SendMsg(c, i, "[!][警告]有一个未备案消息被发送,请管理员自行验证此消息是否合理。");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!(i.group_id != 588932037)) {
|
if (!(i.group_id != 588932037)) {
|
||||||
if (SendAble[Core.GetUser(i.user_id)] != true) {
|
if (SendAble[Core.GetUser(i.user_id)] != true) {
|
||||||
delete_msg(i.message_id);
|
delete_msg(i.message_id);
|
||||||
Core.frame.Ban(c, i, 5 * 60 * Ks);
|
Core.frame.Ban(c, i, 5 * 60 * Ks);
|
||||||
Ks = Ks + 1;
|
Ks = Ks + 1;
|
||||||
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你的消息属于未备案消息,请私信Ai发送"备案"来获取消息备案。`);
|
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你的消息属于未备案消息,请私信Ai发送"备案"来获取消息备案。`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i.group_id == undefined && i.message == "备案") {
|
if (i.group_id == undefined && i.message == "备案") {
|
||||||
SendAble[i.user_id.valueOf()] = true;
|
SendAble[i.user_id.valueOf()] = true;
|
||||||
Core.frame.WriteSystemConfig("SendAble", SendAble);
|
Core.frame.WriteSystemConfig("SendAble", SendAble);
|
||||||
Core.frame.SendMsg(c, i, "你已完成备案。现在你可以在主群中发表你的合理的、合法的、有建设性的意见或建议。");
|
Core.frame.SendMsg(c, i, "你已完成备案。现在你可以在主群中发表你的合理的、合法的、有建设性的意见或建议。");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
56
AbleSend.ts
56
AbleSend.ts
@ -1,29 +1,29 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
const CGI = require("./CGI");
|
const CGI = require("./CGI");
|
||||||
(()=>{
|
(()=>{
|
||||||
var SendAble = Core.frame.ReadSystemConfig("SendAble") as any;
|
var SendAble = Core.frame.ReadSystemConfig("SendAble") as any;
|
||||||
var Ks = 1;
|
var Ks = 1;
|
||||||
Core.AddListener((c,i)=>{
|
Core.AddListener((c,i)=>{
|
||||||
if(CGI.HOOK){
|
if(CGI.HOOK){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var delete_msg = ((msgid:Number)=>{
|
var delete_msg = ((msgid:Number)=>{
|
||||||
if(i.group_id != undefined){
|
if(i.group_id != undefined){
|
||||||
Core.frame.SendMsg(c,i,"[!][警告]有一个未备案消息被发送,请管理员自行验证此消息是否合理。");
|
Core.frame.SendMsg(c,i,"[!][警告]有一个未备案消息被发送,请管理员自行验证此消息是否合理。");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!(i.group_id != 588932037)){
|
if(!(i.group_id != 588932037)){
|
||||||
if(SendAble[Core.GetUser(i.user_id)] != true){
|
if(SendAble[Core.GetUser(i.user_id)] != true){
|
||||||
delete_msg(i.message_id);
|
delete_msg(i.message_id);
|
||||||
Core.frame.Ban(c,i,5*60*Ks);
|
Core.frame.Ban(c,i,5*60*Ks);
|
||||||
Ks = Ks + 1;
|
Ks = Ks + 1;
|
||||||
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你的消息属于未备案消息,请私信Ai发送"备案"来获取消息备案。`);
|
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你的消息属于未备案消息,请私信Ai发送"备案"来获取消息备案。`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i.group_id == undefined&&i.message == "备案"){
|
if(i.group_id == undefined&&i.message == "备案"){
|
||||||
SendAble[i.user_id.valueOf()] = true
|
SendAble[i.user_id.valueOf()] = true
|
||||||
Core.frame.WriteSystemConfig("SendAble",SendAble);
|
Core.frame.WriteSystemConfig("SendAble",SendAble);
|
||||||
Core.frame.SendMsg(c,i,"你已完成备案。现在你可以在主群中发表你的合理的、合法的、有建设性的意见或建议。");
|
Core.frame.SendMsg(c,i,"你已完成备案。现在你可以在主群中发表你的合理的、合法的、有建设性的意见或建议。");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})()
|
})()
|
||||||
70
AddOns.js
70
AddOns.js
@ -1,36 +1,36 @@
|
|||||||
//这是插件系统的支持库
|
//这是插件系统的支持库
|
||||||
//作者:蓝树叶
|
//作者:蓝树叶
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetAddons:function(message){
|
GetAddons:function(message){
|
||||||
var msg = new String(message);
|
var msg = new String(message);
|
||||||
if(!fs.existsSync("./Addons/List.json")){return ["void.js",""];};
|
if(!fs.existsSync("./Addons/List.json")){return ["void.js",""];};
|
||||||
var data = new Object(JSON.parse(fs.readFileSync("./Addons/List.json").toString()));
|
var data = new Object(JSON.parse(fs.readFileSync("./Addons/List.json").toString()));
|
||||||
var keys = Object.keys(data);
|
var keys = Object.keys(data);
|
||||||
for(var i=0;i<keys.length;i++){
|
for(var i=0;i<keys.length;i++){
|
||||||
if(msg.substr(0,keys[i].length) == keys[i]){
|
if(msg.substr(0,keys[i].length) == keys[i]){
|
||||||
Core.frame.SetHOOK(true);
|
Core.frame.SetHOOK(true);
|
||||||
return [new String(data[keys[i]]),msg.substr(keys[i].length,msg.length - keys[i].length)];
|
return [new String(data[keys[i]]),msg.substr(keys[i].length,msg.length - keys[i].length)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ["void.js",""];
|
return ["void.js",""];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
var s = exports.add.Interfaces.GetAddons(info["message"]);
|
var s = exports.add.Interfaces.GetAddons(info["message"]);
|
||||||
console.log(s);
|
console.log(s);
|
||||||
console.log(`./Addons/${s[0]}`);
|
console.log(`./Addons/${s[0]}`);
|
||||||
try{
|
try{
|
||||||
require(`./Addons/${s[0]}`).add.Control(connect,s[1],Core.GetUser(info["user_id"]),info);
|
require(`./Addons/${s[0]}`).add.Control(connect,s[1],Core.GetUser(info["user_id"]),info);
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
Core.frame.SendMsg(connect,info,err);
|
Core.frame.SendMsg(connect,info,err);
|
||||||
}
|
}
|
||||||
if(new String(info["message"]).substr(0,4)=="斗罗大陆"){
|
if(new String(info["message"]).substr(0,4)=="斗罗大陆"){
|
||||||
Core.frame.SetHOOK(true);
|
Core.frame.SetHOOK(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,304 +1,304 @@
|
|||||||
const Core = require("./../../Core");
|
const Core = require("./../../Core");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
/*GetPath:function(dir){
|
/*GetPath:function(dir){
|
||||||
return `./Addons/PVP/${dir}`;
|
return `./Addons/PVP/${dir}`;
|
||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
Control:function(connect,message,user,info){
|
Control:function(connect,message,user,info){
|
||||||
var msg = new String(message);
|
var msg = new String(message);
|
||||||
console.log("0");
|
console.log("0");
|
||||||
if(msg.substr(0,2)=="购买"){
|
if(msg.substr(0,2)=="购买"){
|
||||||
msg = msg.replace("购买","");
|
msg = msg.replace("购买","");
|
||||||
console.log("1");
|
console.log("1");
|
||||||
fs.readFile("./Addons/PVP/DataBase.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/DataBase.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString())
|
var data_obj = JSON.parse(data.toString())
|
||||||
if(data_obj["PVP"]["物品"][msg]==undefined){
|
if(data_obj["PVP"]["物品"][msg]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,"没有这样的物品。");
|
Core.frame.SendMsg(connect,info,"没有这样的物品。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err2,data2)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err2,data2)=>{
|
||||||
var data2_obj = JSON.parse(data2.toString());
|
var data2_obj = JSON.parse(data2.toString());
|
||||||
if(data2_obj[user]==undefined){
|
if(data2_obj[user]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,"没有你的账户,发送\\\"PVP注册\\\"注册账户!");
|
Core.frame.SendMsg(connect,info,"没有你的账户,发送\\\"PVP注册\\\"注册账户!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(var i=0;i<data2_obj[user]["仓库"].length;i++){
|
for(var i=0;i<data2_obj[user]["仓库"].length;i++){
|
||||||
if(data2_obj[user]["仓库"][i]==msg){
|
if(data2_obj[user]["仓库"][i]==msg){
|
||||||
Core.frame.SendMsg(connect,info,"你已经有这个物品了");
|
Core.frame.SendMsg(connect,info,"你已经有这个物品了");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data_obj["PVP"]["物品"][msg]["价格"]==null){
|
if(data_obj["PVP"]["物品"][msg]["价格"]==null){
|
||||||
Core.frame.SendMsg(connect,info,"这是非卖品");
|
Core.frame.SendMsg(connect,info,"这是非卖品");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(data2_obj[user]["余额"]<data_obj["PVP"]["物品"][msg]["价格"]){
|
if(data2_obj[user]["余额"]<data_obj["PVP"]["物品"][msg]["价格"]){
|
||||||
Core.frame.SendMsg(connect,info,"你的PVP代币不足");
|
Core.frame.SendMsg(connect,info,"你的PVP代币不足");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data2_obj[user]["余额"] = data2_obj[user]["余额"] - data_obj["PVP"]["物品"][msg]["价格"];
|
data2_obj[user]["余额"] = data2_obj[user]["余额"] - data_obj["PVP"]["物品"][msg]["价格"];
|
||||||
data2_obj[user]["仓库"][data2_obj[user]["仓库"].length] = msg;
|
data2_obj[user]["仓库"][data2_obj[user]["仓库"].length] = msg;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data2_obj),(err3)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data2_obj),(err3)=>{
|
||||||
Core.frame.SendMsg(connect,info,"购买成功");
|
Core.frame.SendMsg(connect,info,"购买成功");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg=="我的物品"){
|
if(msg=="我的物品"){
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = JSON.parse(data.toString());
|
data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj[user]==undefined){
|
if(data_obj[user]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,"没有你的账户,发送\\\"PVP注册\\\"注册账户!");
|
Core.frame.SendMsg(connect,info,"没有你的账户,发送\\\"PVP注册\\\"注册账户!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Str = `你的物品`;
|
var Str = `你的物品`;
|
||||||
for(var i=0;i<data_obj[user]["仓库"].length;i++){
|
for(var i=0;i<data_obj[user]["仓库"].length;i++){
|
||||||
Str = Str + "\\r\\n" + `${i+1}.`+ data_obj[user]["仓库"][i];
|
Str = Str + "\\r\\n" + `${i+1}.`+ data_obj[user]["仓库"][i];
|
||||||
};
|
};
|
||||||
Core.frame.SendMsg(connect,info,Str);
|
Core.frame.SendMsg(connect,info,Str);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.substr(0,2)=="装备"){
|
if(msg.substr(0,2)=="装备"){
|
||||||
var item = msg.replace("装备","");
|
var item = msg.replace("装备","");
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj[user]==undefined){
|
if(data_obj[user]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你暂未注册PVP插件,请发送"PVP注册"。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你暂未注册PVP插件,请发送"PVP注册"。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[user]["装备"]==item){
|
if(data_obj[user]["装备"]==item){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你已经装备此物品,请勿重复装备。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你已经装备此物品,请勿重复装备。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(var i=0;i<data_obj[user]["仓库"].length;i++){
|
for(var i=0;i<data_obj[user]["仓库"].length;i++){
|
||||||
if(item == data_obj[user]["仓库"][i]){
|
if(item == data_obj[user]["仓库"][i]){
|
||||||
data_obj[user]["装备"] = item;
|
data_obj[user]["装备"] = item;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},装备物品${item}成功!`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},装备物品${item}成功!`);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你没有物品${item}。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你没有物品${item}。`);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg=="注册"){
|
if(msg=="注册"){
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = new Object(JSON.parse(data.toString()));
|
data_obj = new Object(JSON.parse(data.toString()));
|
||||||
if(data_obj[user]!=undefined){
|
if(data_obj[user]!=undefined){
|
||||||
Core.frame.SendMsg(connect,info,"你已经注册了账户。");
|
Core.frame.SendMsg(connect,info,"你已经注册了账户。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data_obj[user]={"余额":1000,"装备":"木制剑","仓库":["木制剑"]}
|
data_obj[user]={"余额":1000,"装备":"木制剑","仓库":["木制剑"]}
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
||||||
Core.frame.SendMsg(connect,info,"注册成功,获得系统赠送1000枚PVP代币以及一把木制剑。");
|
Core.frame.SendMsg(connect,info,"注册成功,获得系统赠送1000枚PVP代币以及一把木制剑。");
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg.substr(0,4)=="查看物品"){
|
if(msg.substr(0,4)=="查看物品"){
|
||||||
msg = msg.replace("查看物品","");
|
msg = msg.replace("查看物品","");
|
||||||
msg = msg.replace("[CQ:at,qq=","");
|
msg = msg.replace("[CQ:at,qq=","");
|
||||||
msg = msg.replace(" ","");
|
msg = msg.replace(" ","");
|
||||||
msg = msg.replace("]","");
|
msg = msg.replace("]","");
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = new Object(JSON.parse(data.toString()));
|
data_obj = new Object(JSON.parse(data.toString()));
|
||||||
if(data_obj[msg]==undefined){
|
if(data_obj[msg]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}没有注册PVP。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}没有注册PVP。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Str = `${Core.frame.At(msg)}的物品`;
|
var Str = `${Core.frame.At(msg)}的物品`;
|
||||||
for(var i=0;i<data_obj[msg]["仓库"].length;i++){
|
for(var i=0;i<data_obj[msg]["仓库"].length;i++){
|
||||||
Str = Str + "\\r\\n" + `${i+1}.`+ data_obj[msg]["仓库"][i];
|
Str = Str + "\\r\\n" + `${i+1}.`+ data_obj[msg]["仓库"][i];
|
||||||
};
|
};
|
||||||
Core.frame.SendMsg(connect,info,Str);
|
Core.frame.SendMsg(connect,info,Str);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg.substr(0,2)=="对战"){
|
if(msg.substr(0,2)=="对战"){
|
||||||
msg = msg.replace("对战","");
|
msg = msg.replace("对战","");
|
||||||
msg = msg.replace("[CQ:at,qq=","");
|
msg = msg.replace("[CQ:at,qq=","");
|
||||||
msg = msg.replace(" ","");
|
msg = msg.replace(" ","");
|
||||||
msg = msg.replace("]","");
|
msg = msg.replace("]","");
|
||||||
if(user==msg){
|
if(user==msg){
|
||||||
Core.frame.SendMsg(connect,info,"不能和自己进行PVP!");
|
Core.frame.SendMsg(connect,info,"不能和自己进行PVP!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(msg=="2142562417"){
|
if(msg=="2142562417"){
|
||||||
Core.frame.SendMsg(connect,info,"萌萌还不会PVP呢");
|
Core.frame.SendMsg(connect,info,"萌萌还不会PVP呢");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = new Object(JSON.parse(data.toString()));
|
data_obj = new Object(JSON.parse(data.toString()));
|
||||||
if(data_obj[user]==undefined){
|
if(data_obj[user]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`你没有注册PVP。`);
|
Core.frame.SendMsg(connect,info,`你没有注册PVP。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[msg]==undefined){
|
if(data_obj[msg]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}没有注册PVP。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}没有注册PVP。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[user]["Playing"]!=undefined&&data_obj[user]["Playing"]!=-1){
|
if(data_obj[user]["Playing"]!=undefined&&data_obj[user]["Playing"]!=-1){
|
||||||
Core.frame.SendMsg(connect,info,`你正与其他人PVP中。`);
|
Core.frame.SendMsg(connect,info,`你正与其他人PVP中。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[msg]["Playing"]!=undefined&&data_obj[msg]["Playing"]!=-1){
|
if(data_obj[msg]["Playing"]!=undefined&&data_obj[msg]["Playing"]!=-1){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}正在与其他人PVP中。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}正在与其他人PVP中。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[user]["Saving"]==true){
|
if(data_obj[user]["Saving"]==true){
|
||||||
Core.frame.SendMsg(connect,info,`你在保护状态中,不可PVP,发送\\"PVP解除保护\\"来结束保护`);
|
Core.frame.SendMsg(connect,info,`你在保护状态中,不可PVP,发送\\"PVP解除保护\\"来结束保护`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[msg]["Saving"]==true){
|
if(data_obj[msg]["Saving"]==true){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}正处于保护状态中。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(msg)}正处于保护状态中。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data_obj["#PVPROOM"][data_obj["#PVPROOM"].length] = {"P1":{"ID":user.toString(),"HP":100,"Hold":"Attacked"},"P2":{"ID":msg.toString(),"HP":100,"Hold":"Attacked"}};
|
data_obj["#PVPROOM"][data_obj["#PVPROOM"].length] = {"P1":{"ID":user.toString(),"HP":100,"Hold":"Attacked"},"P2":{"ID":msg.toString(),"HP":100,"Hold":"Attacked"}};
|
||||||
data_obj[user]["Playing"] = data_obj["#PVPROOM"].length-1;
|
data_obj[user]["Playing"] = data_obj["#PVPROOM"].length-1;
|
||||||
data_obj[msg]["Playing"] = data_obj["#PVPROOM"].length-1;
|
data_obj[msg]["Playing"] = data_obj["#PVPROOM"].length-1;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
||||||
Core.frame.SendMsg(connect,info,"PVP设定完成,发送相关PVP指令来进行PVP吧。");
|
Core.frame.SendMsg(connect,info,"PVP设定完成,发送相关PVP指令来进行PVP吧。");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg=="攻击"){
|
if(msg=="攻击"){
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = new Object(JSON.parse(data.toString()));
|
data_obj = new Object(JSON.parse(data.toString()));
|
||||||
if(data_obj[user]["Playing"]!=undefined&&data_obj[user]["Playing"]!=-1){
|
if(data_obj[user]["Playing"]!=undefined&&data_obj[user]["Playing"]!=-1){
|
||||||
//DoNothing();
|
//DoNothing();
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你没有进行PVP!`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你没有进行PVP!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var room = data_obj["#PVPROOM"][data_obj[user]["Playing"]];
|
var room = data_obj["#PVPROOM"][data_obj[user]["Playing"]];
|
||||||
|
|
||||||
if(room["P1"]["ID"]==user){
|
if(room["P1"]["ID"]==user){
|
||||||
var thisPlayerID = "P1";
|
var thisPlayerID = "P1";
|
||||||
var OtherPlayerID = "P2";
|
var OtherPlayerID = "P2";
|
||||||
}
|
}
|
||||||
if(room["P2"]["ID"]==user){
|
if(room["P2"]["ID"]==user){
|
||||||
var OtherPlayerID = "P1";
|
var OtherPlayerID = "P1";
|
||||||
var thisPlayerID = "P2";
|
var thisPlayerID = "P2";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(room[thisPlayerID]["Hold"]!="Attacked"){
|
if(room[thisPlayerID]["Hold"]!="Attacked"){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你已经攻击过了;请等待其他玩家攻击。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},你已经攻击过了;请等待其他玩家攻击。`);
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
room[thisPlayerID]["Hold"]="DoAttacked";
|
room[thisPlayerID]["Hold"]="DoAttacked";
|
||||||
}
|
}
|
||||||
if(room[OtherPlayerID]["Hold"]!="Attacked"){
|
if(room[OtherPlayerID]["Hold"]!="Attacked"){
|
||||||
room[thisPlayerID]["Hold"]="Attacked";
|
room[thisPlayerID]["Hold"]="Attacked";
|
||||||
room[OtherPlayerID]["Hold"]="Attacked";
|
room[OtherPlayerID]["Hold"]="Attacked";
|
||||||
}
|
}
|
||||||
var thisPlayerWeapon = data_obj[user]["装备"];
|
var thisPlayerWeapon = data_obj[user]["装备"];
|
||||||
fs.readFile("./Addons/PVP/DataBase.json",(err,data2)=>{
|
fs.readFile("./Addons/PVP/DataBase.json",(err,data2)=>{
|
||||||
data2_obj = JSON.parse(data2.toString());
|
data2_obj = JSON.parse(data2.toString());
|
||||||
var WeaponInfo = data2_obj["PVP"]["物品"][thisPlayerWeapon];
|
var WeaponInfo = data2_obj["PVP"]["物品"][thisPlayerWeapon];
|
||||||
if(WeaponInfo["加成"]["我方"]==undefined){
|
if(WeaponInfo["加成"]["我方"]==undefined){
|
||||||
var 我方加成 = {"Att":0,"Def":0};
|
var 我方加成 = {"Att":0,"Def":0};
|
||||||
}else{
|
}else{
|
||||||
var 我方加成 = WeaponInfo["加成"]["我方"];
|
var 我方加成 = WeaponInfo["加成"]["我方"];
|
||||||
}
|
}
|
||||||
if(WeaponInfo["加成"]["敌方"]==undefined){
|
if(WeaponInfo["加成"]["敌方"]==undefined){
|
||||||
var 敌方加成 = {"Att":0,"Def":0};
|
var 敌方加成 = {"Att":0,"Def":0};
|
||||||
}else{
|
}else{
|
||||||
var 敌方加成 = WeaponInfo["加成"]["敌方"];
|
var 敌方加成 = WeaponInfo["加成"]["敌方"];
|
||||||
}
|
}
|
||||||
if(我方加成["Att"]==undefined){
|
if(我方加成["Att"]==undefined){
|
||||||
我方加成["Att"] = 0;
|
我方加成["Att"] = 0;
|
||||||
}
|
}
|
||||||
if(我方加成["Def"]==undefined){
|
if(我方加成["Def"]==undefined){
|
||||||
我方加成["Def"] = 0;
|
我方加成["Def"] = 0;
|
||||||
}
|
}
|
||||||
if(敌方加成["Att"]==undefined){
|
if(敌方加成["Att"]==undefined){
|
||||||
我方加成["Att"] = 0;
|
我方加成["Att"] = 0;
|
||||||
}
|
}
|
||||||
if(敌方加成["Def"]==undefined){
|
if(敌方加成["Def"]==undefined){
|
||||||
敌方加成["Def"] = 0;
|
敌方加成["Def"] = 0;
|
||||||
}
|
}
|
||||||
var 我方总攻击 =Math.floor( 20 * (1 + 0.01 * 我方加成["Att"]) * Math.random() - 5 * (1 + 0.01 * 敌方加成["Def"]) * Math.random() * 0.5);
|
var 我方总攻击 =Math.floor( 20 * (1 + 0.01 * 我方加成["Att"]) * Math.random() - 5 * (1 + 0.01 * 敌方加成["Def"]) * Math.random() * 0.5);
|
||||||
|
|
||||||
room[OtherPlayerID]["HP"] = new Number(room[OtherPlayerID]["HP"]) - 我方总攻击;
|
room[OtherPlayerID]["HP"] = new Number(room[OtherPlayerID]["HP"]) - 我方总攻击;
|
||||||
console.log("A");
|
console.log("A");
|
||||||
var Umsg = `${Core.frame.At(user)},你使用了${thisPlayerWeapon}对${Core.frame.At(room[OtherPlayerID]["ID"])}进行打击,扣除对方${我方总攻击}点血量,对方剩余${room[OtherPlayerID]["HP"]}`
|
var Umsg = `${Core.frame.At(user)},你使用了${thisPlayerWeapon}对${Core.frame.At(room[OtherPlayerID]["ID"])}进行打击,扣除对方${我方总攻击}点血量,对方剩余${room[OtherPlayerID]["HP"]}`
|
||||||
console.log("B");
|
console.log("B");
|
||||||
console.log("HPI");
|
console.log("HPI");
|
||||||
console.log(new Number(room[OtherPlayerID]["HP"]));
|
console.log(new Number(room[OtherPlayerID]["HP"]));
|
||||||
console.log(new Number(room[OtherPlayerID]["HP"]).valueOf()>0);
|
console.log(new Number(room[OtherPlayerID]["HP"]).valueOf()>0);
|
||||||
if(!(new Number(room[OtherPlayerID]["HP"]).valueOf()>0)){
|
if(!(new Number(room[OtherPlayerID]["HP"]).valueOf()>0)){
|
||||||
console.log("HPI");
|
console.log("HPI");
|
||||||
console.log(new Number(room[OtherPlayerID]["HP"]));
|
console.log(new Number(room[OtherPlayerID]["HP"]));
|
||||||
var temp = data_obj[user]["Playing"];
|
var temp = data_obj[user]["Playing"];
|
||||||
data_obj[user]["Playing"] = undefined;
|
data_obj[user]["Playing"] = undefined;
|
||||||
data_obj[room[OtherPlayerID]["ID"]]["Playing"] = undefined;
|
data_obj[room[OtherPlayerID]["ID"]]["Playing"] = undefined;
|
||||||
Umsg = `${Umsg}\\r\\n${Core.frame.At(user)},${Core.frame.At(room[OtherPlayerID]["ID"])}已战败。`;
|
Umsg = `${Umsg}\\r\\n${Core.frame.At(user)},${Core.frame.At(room[OtherPlayerID]["ID"])}已战败。`;
|
||||||
data_obj[room[OtherPlayerID]["ID"]]["Saving"] = true;
|
data_obj[room[OtherPlayerID]["ID"]]["Saving"] = true;
|
||||||
room = {};
|
room = {};
|
||||||
data_obj["#PVPROOM"][temp] = room;
|
data_obj["#PVPROOM"][temp] = room;
|
||||||
}
|
}
|
||||||
console.log("C");
|
console.log("C");
|
||||||
data_obj["#PVPROOM"][data_obj[user]["Playing"]] = room;
|
data_obj["#PVPROOM"][data_obj[user]["Playing"]] = room;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
||||||
Core.frame.SendMsg(connect,info,`${Umsg}\\r\\nPVP信息保存成功!\\r\\nPVP插件作者:蓝树叶`);
|
Core.frame.SendMsg(connect,info,`${Umsg}\\r\\nPVP信息保存成功!\\r\\nPVP插件作者:蓝树叶`);
|
||||||
console.log("E");
|
console.log("E");
|
||||||
});
|
});
|
||||||
console.log("D");
|
console.log("D");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg=="删档"){
|
if(msg=="删档"){
|
||||||
if(!require("./../../Debug.js").add.Interfaces.IsAdmin(user)){
|
if(!require("./../../Debug.js").add.Interfaces.IsAdmin(user)){
|
||||||
Core.frame.SendMsg(connect,info,"只有管理员才有权执行此命令。");
|
Core.frame.SendMsg(connect,info,"只有管理员才有权执行此命令。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
data_obj = JSON.parse(data.toString());
|
data_obj = JSON.parse(data.toString());
|
||||||
data_obj["#PVPROOM"] = [];
|
data_obj["#PVPROOM"] = [];
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err)=>{
|
||||||
Core.frame.SendMsg(connect,info,"删除临时数据完成!");
|
Core.frame.SendMsg(connect,info,"删除临时数据完成!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg=="投降"){
|
if(msg=="投降"){
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj[user]==undefined){
|
if(data_obj[user]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`你没有注册PVP。`);
|
Core.frame.SendMsg(connect,info,`你没有注册PVP。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(data_obj[user]["Playing"]==undefined){
|
if(data_obj[user]["Playing"]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`你没有进行PVP。`);
|
Core.frame.SendMsg(connect,info,`你没有进行PVP。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var P1 = data_obj["#PVPROOM"][data_obj[user]["Playing"]]["P1"];
|
var P1 = data_obj["#PVPROOM"][data_obj[user]["Playing"]]["P1"];
|
||||||
var P2 = data_obj["#PVPROOM"][data_obj[user]["Playing"]]["P2"];
|
var P2 = data_obj["#PVPROOM"][data_obj[user]["Playing"]]["P2"];
|
||||||
data_obj[P1["ID"]]["Playing"] = -1;
|
data_obj[P1["ID"]]["Playing"] = -1;
|
||||||
data_obj[P2["ID"]]["Playing"] = -1;
|
data_obj[P2["ID"]]["Playing"] = -1;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
||||||
Core.frame.SendMsg(connect,info,"投降成功!");
|
Core.frame.SendMsg(connect,info,"投降成功!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg=="解除保护"){
|
if(msg=="解除保护"){
|
||||||
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/UserData.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj[user]["Saving"]==true){
|
if(data_obj[user]["Saving"]==true){
|
||||||
data_obj[user]["Saving"] = false;
|
data_obj[user]["Saving"] = false;
|
||||||
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
fs.writeFile("./Addons/PVP/UserData.json",JSON.stringify(data_obj),(err2)=>{
|
||||||
Core.frame.SendMsg(connect,info,"解除保护成功,现在你可以PVP了!");
|
Core.frame.SendMsg(connect,info,"解除保护成功,现在你可以PVP了!");
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"你本来就没有被保护。");
|
Core.frame.SendMsg(connect,info,"你本来就没有被保护。");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Core.frame.SendMsg(connect,info,"PVP插件暂未开发。");
|
//Core.frame.SendMsg(connect,info,"PVP插件暂未开发。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,61 +1,61 @@
|
|||||||
const Core = require("./../../Core");
|
const Core = require("./../../Core");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
/*GetPath:function(dir){
|
/*GetPath:function(dir){
|
||||||
return `./Addons/PVP/${dir}`;
|
return `./Addons/PVP/${dir}`;
|
||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
Control:function(connect,message,user,info){
|
Control:function(connect,message,user,info){
|
||||||
var msg = new String(message);
|
var msg = new String(message);
|
||||||
if(msg=="创建队伍"){
|
if(msg=="创建队伍"){
|
||||||
fs.readFile("./Addons/PVP/MulBase.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/MulBase.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj["Player"][user]==undefined){
|
if(data_obj["Player"][user]==undefined){
|
||||||
data_obj["Player"][user]={"Team":-1};
|
data_obj["Player"][user]={"Team":-1};
|
||||||
}else{
|
}else{
|
||||||
if(data_obj["Player"][user]["Team"]!=-1){
|
if(data_obj["Player"][user]["Team"]!=-1){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(user))},你已经加入一个队伍了。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(user))},你已经加入一个队伍了。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var teams = new Array(data_obj["Team"]);
|
var teams = new Array(data_obj["Team"]);
|
||||||
data_obj["Player"][user]["Team"]=teams.length;
|
data_obj["Player"][user]["Team"]=teams.length;
|
||||||
data_obj["Player"][user]["ID"]=1;
|
data_obj["Player"][user]["ID"]=1;
|
||||||
teams[teams.length] = [{"Attacking":-1,"Owner":user},{"ID":user,"Attacked":false,"HP":100,"PP":100}];
|
teams[teams.length] = [{"Attacking":-1,"Owner":user},{"ID":user,"Attacked":false,"HP":100,"PP":100}];
|
||||||
data_obj["Team"]=teams;
|
data_obj["Team"]=teams;
|
||||||
fs.writeFile("./Addons/PVP/MulBase.json",JSON.stringify(data_obj),(err2)=>{
|
fs.writeFile("./Addons/PVP/MulBase.json",JSON.stringify(data_obj),(err2)=>{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},队伍创建成功,队伍ID为${data_obj["Player"][user]["Team"]}。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},队伍创建成功,队伍ID为${data_obj["Player"][user]["Team"]}。`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(msg.substr(0,4)=="加入队伍"){
|
if(msg.substr(0,4)=="加入队伍"){
|
||||||
var teamId = new Number(msg.replace("加入队伍",""));
|
var teamId = new Number(msg.replace("加入队伍",""));
|
||||||
fs.readFile("./Addons/PVP/MulBase.json",(err,data)=>{
|
fs.readFile("./Addons/PVP/MulBase.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj["Player"][user]==undefined){
|
if(data_obj["Player"][user]==undefined){
|
||||||
data_obj["Player"][user]={"Team":-1};
|
data_obj["Player"][user]={"Team":-1};
|
||||||
}else{
|
}else{
|
||||||
if(data_obj["Player"][user]["Team"]!=-1){
|
if(data_obj["Player"][user]["Team"]!=-1){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(user))},你已经加入一个队伍了。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(user))},你已经加入一个队伍了。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var teams = new Array(data_obj["Team"]);
|
var teams = new Array(data_obj["Team"]);
|
||||||
if(teams.length<new Number(teamId)){
|
if(teams.length<new Number(teamId)){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},没有这个Mul-PVP队伍。`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},没有这个Mul-PVP队伍。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var theTeam = new Array(teams[new Number(teamId)]);
|
var theTeam = new Array(teams[new Number(teamId)]);
|
||||||
theTeam[theTeam.length] = {"ID":user,"Attacked":false,"HP":100,"PP":100};
|
theTeam[theTeam.length] = {"ID":user,"Attacked":false,"HP":100,"PP":100};
|
||||||
data_obj["Player"][user]["Team"] = new Number(teamId);
|
data_obj["Player"][user]["Team"] = new Number(teamId);
|
||||||
data_obj["Player"][user]["ID"] = theTeam.length - 1;
|
data_obj["Player"][user]["ID"] = theTeam.length - 1;
|
||||||
teams[teamId] = theTeam;
|
teams[teamId] = theTeam;
|
||||||
data_obj["Team"] = teams;
|
data_obj["Team"] = teams;
|
||||||
fs.writeFile("./Addons/PVP/MulBase.json",JSON.stringify(data_obj),(err2)=>{
|
fs.writeFile("./Addons/PVP/MulBase.json",JSON.stringify(data_obj),(err2)=>{
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},加入队伍${teamId}成功!`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(user)},加入队伍${teamId}成功!`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,114 +1,114 @@
|
|||||||
const Core = require("./../../Core");
|
const Core = require("./../../Core");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const efs = function(dir,info,call){
|
const efs = function(dir,info,call){
|
||||||
console.log(`写入${info}到${dir}`);
|
console.log(`写入${info}到${dir}`);
|
||||||
fs.writeFile(dir,info,call);
|
fs.writeFile(dir,info,call);
|
||||||
}
|
}
|
||||||
var PVZStart = false;
|
var PVZStart = false;
|
||||||
var GameMain = function(connect,info){
|
var GameMain = function(connect,info){
|
||||||
var data_obj = JSON.parse(fs.readFileSync("./Addons/PVZ/GameData.json").toString());
|
var data_obj = JSON.parse(fs.readFileSync("./Addons/PVZ/GameData.json").toString());
|
||||||
for(var i=0;i<64;i++){
|
for(var i=0;i<64;i++){
|
||||||
if(data_obj["Area"][i]==undefined){
|
if(data_obj["Area"][i]==undefined){
|
||||||
data_obj["Area"][i] = {};
|
data_obj["Area"][i] = {};
|
||||||
}
|
}
|
||||||
var temp = data_obj["Area"][i]
|
var temp = data_obj["Area"][i]
|
||||||
if(temp!=undefined){
|
if(temp!=undefined){
|
||||||
if(temp["Plant"]!=undefined&&temp["Plant"]!="NoThing"){
|
if(temp["Plant"]!=undefined&&temp["Plant"]!="NoThing"){
|
||||||
for(var j=0;j<temp["Plant"]["Weapon"].length;j++){
|
for(var j=0;j<temp["Plant"]["Weapon"].length;j++){
|
||||||
if(temp["Plant"]["Weapon"][j]["LastTimer"]!=0&&temp["Plant"]["Weapon"][j]["LastTimer"]!=undefined){
|
if(temp["Plant"]["Weapon"][j]["LastTimer"]!=0&&temp["Plant"]["Weapon"][j]["LastTimer"]!=undefined){
|
||||||
temp["Plant"]["Weapon"][j]["LastTimer"] = temp["Plant"]["Weapon"][j]["LastTimer"] - 1;
|
temp["Plant"]["Weapon"][j]["LastTimer"] = temp["Plant"]["Weapon"][j]["LastTimer"] - 1;
|
||||||
}else{
|
}else{
|
||||||
temp["Plant"]["Weapon"][j]["LastTimer"] = temp["Plant"]["Weapon"][j]["Timer"];
|
temp["Plant"]["Weapon"][j]["LastTimer"] = temp["Plant"]["Weapon"][j]["Timer"];
|
||||||
if(temp["Plant"]["Weapon"][j]["Type"]=="Launcher"){
|
if(temp["Plant"]["Weapon"][j]["Type"]=="Launcher"){
|
||||||
var k= Math.floor(i/8);
|
var k= Math.floor(i/8);
|
||||||
for(var n=0;n<8;n++){
|
for(var n=0;n<8;n++){
|
||||||
if(data_obj["Area"][k*8+n]["Zombie"]!=undefined){
|
if(data_obj["Area"][k*8+n]["Zombie"]!=undefined){
|
||||||
data_obj["Area"][k*8+n]["Zombie"]["HP"] = data_obj["Area"][k*8+n]["Zombie"]["HP"] - temp["Plant"]["Weapon"][j]["Settings"]["Hurt"];
|
data_obj["Area"][k*8+n]["Zombie"]["HP"] = data_obj["Area"][k*8+n]["Zombie"]["HP"] - temp["Plant"]["Weapon"][j]["Settings"]["Hurt"];
|
||||||
if(data_obj["Area"][k*8+n]["Zombie"]["HP"]<0){
|
if(data_obj["Area"][k*8+n]["Zombie"]["HP"]<0){
|
||||||
Core.frame.SendMsg(connect,info,`位于${i}的${temp["Plant"]["Name"]}击败了位于${k*8+n}的${data_obj["Area"][k*8+n]["Zombie"]["Name"]}`);
|
Core.frame.SendMsg(connect,info,`位于${i}的${temp["Plant"]["Name"]}击败了位于${k*8+n}的${data_obj["Area"][k*8+n]["Zombie"]["Name"]}`);
|
||||||
data_obj["Area"][k*8+n]["Zombie"] = undefined;
|
data_obj["Area"][k*8+n]["Zombie"] = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(temp["Plant"]["Weapon"][j]["Type"]=="PowerMaker"){
|
if(temp["Plant"]["Weapon"][j]["Type"]=="PowerMaker"){
|
||||||
data_obj["Power"] = data_obj["Power"] + temp["Plant"]["Weapon"][j]["Settings"]["Count"];
|
data_obj["Power"] = data_obj["Power"] + temp["Plant"]["Weapon"][j]["Settings"]["Count"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(temp["Zombie"]!=undefined){
|
if(temp["Zombie"]!=undefined){
|
||||||
if(temp["Zombie"]["MoveTimer"]!=undefined&&temp["Zombie"]["MoveTimer"]!=0){
|
if(temp["Zombie"]["MoveTimer"]!=undefined&&temp["Zombie"]["MoveTimer"]!=0){
|
||||||
temp["Zombie"]["MoveTimer"] = temp["Zombie"]["MoveTimer"] - 1;
|
temp["Zombie"]["MoveTimer"] = temp["Zombie"]["MoveTimer"] - 1;
|
||||||
}else{
|
}else{
|
||||||
temp["Zombie"]["MoveTimer"] = temp["Zombie"]["Speed"];
|
temp["Zombie"]["MoveTimer"] = temp["Zombie"]["Speed"];
|
||||||
var k=Math.floor(i/8)*8;
|
var k=Math.floor(i/8)*8;
|
||||||
if(i-1<k){
|
if(i-1<k){
|
||||||
Core.frame.SendMsg(connect,info,`位于${i}的僵尸进入你的家。`);
|
Core.frame.SendMsg(connect,info,`位于${i}的僵尸进入你的家。`);
|
||||||
}else{
|
}else{
|
||||||
data_obj["Area"][i-1]["Zombie"] = temp["Zombie"];
|
data_obj["Area"][i-1]["Zombie"] = temp["Zombie"];
|
||||||
temp["Zombie"] = undefined;
|
temp["Zombie"] = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data_obj["Area"][i] = temp;
|
data_obj["Area"][i] = temp;
|
||||||
}
|
}
|
||||||
efs("./Addons/PVZ/GameData.json",JSON.stringify(data_obj),(err)=>{});
|
efs("./Addons/PVZ/GameData.json",JSON.stringify(data_obj),(err)=>{});
|
||||||
}
|
}
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
/*GetPath:function(dir){
|
/*GetPath:function(dir){
|
||||||
return `./Addons/PVP/${dir}`;
|
return `./Addons/PVP/${dir}`;
|
||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
Control:function(connect,message,user,info){
|
Control:function(connect,message,user,info){
|
||||||
var msg = new String(message);
|
var msg = new String(message);
|
||||||
if(msg.substr(0,4)=="进行游戏"){
|
if(msg.substr(0,4)=="进行游戏"){
|
||||||
time = new Number(msg.replace("进行游戏",""));
|
time = new Number(msg.replace("进行游戏",""));
|
||||||
PVZStart = true;
|
PVZStart = true;
|
||||||
setInterval(()=>{
|
setInterval(()=>{
|
||||||
if(PVZStart == true){
|
if(PVZStart == true){
|
||||||
GameMain(connect,info);
|
GameMain(connect,info);
|
||||||
}
|
}
|
||||||
},time*1000);
|
},time*1000);
|
||||||
Core.frame.SendMsg(connect,info,`已开始PVZ游戏`)
|
Core.frame.SendMsg(connect,info,`已开始PVZ游戏`)
|
||||||
};
|
};
|
||||||
if(msg=="结束游戏"){
|
if(msg=="结束游戏"){
|
||||||
PVZStart = false;
|
PVZStart = false;
|
||||||
Core.frame.SendMsg(connect,info,"已结束PVZ。");
|
Core.frame.SendMsg(connect,info,"已结束PVZ。");
|
||||||
};
|
};
|
||||||
if(msg.substr(0,2)=="种植"){
|
if(msg.substr(0,2)=="种植"){
|
||||||
var plant = msg.replace("种植","");
|
var plant = msg.replace("种植","");
|
||||||
if(plant.indexOf("||")==-1){
|
if(plant.indexOf("||")==-1){
|
||||||
Core.frame.SendMsg(connect,info,"请使用||将植物与位置分开。")
|
Core.frame.SendMsg(connect,info,"请使用||将植物与位置分开。")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var temp = plant.split("||");
|
var temp = plant.split("||");
|
||||||
fs.readFile("./Addons/PVZ/DataBase.json",(err,data)=>{
|
fs.readFile("./Addons/PVZ/DataBase.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if(data_obj["Plant"][temp[0]]==undefined){
|
if(data_obj["Plant"][temp[0]]==undefined){
|
||||||
Core.frame.SendMsg(connect,info,`没有${temp[0]}这个植物!!!`);
|
Core.frame.SendMsg(connect,info,`没有${temp[0]}这个植物!!!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(temp[1]<0&&temp[1]>64){
|
if(temp[1]<0&&temp[1]>64){
|
||||||
Core.frame.SendMsg(connect,info,`没有${temp[1]}这个格子。`)
|
Core.frame.SendMsg(connect,info,`没有${temp[1]}这个格子。`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./Addons/PVZ/GameData.json",(err2,data2)=>{
|
fs.readFile("./Addons/PVZ/GameData.json",(err2,data2)=>{
|
||||||
var data2_obj = JSON.parse(data2.toString());
|
var data2_obj = JSON.parse(data2.toString());
|
||||||
if(data2_obj["Area"][temp[1]]==undefined){
|
if(data2_obj["Area"][temp[1]]==undefined){
|
||||||
data2_obj["Area"][temp[1]] = {};
|
data2_obj["Area"][temp[1]] = {};
|
||||||
}
|
}
|
||||||
if(data2_obj["Area"][temp[1]]["Plant"]!=undefined&&data2_obj["Area"][temp[1]]["Plant"]!="NoThing"){
|
if(data2_obj["Area"][temp[1]]["Plant"]!=undefined&&data2_obj["Area"][temp[1]]["Plant"]!="NoThing"){
|
||||||
Core.frame.SendMsg(connect,info,`${temp[1]}已经有植物了。`);
|
Core.frame.SendMsg(connect,info,`${temp[1]}已经有植物了。`);
|
||||||
}
|
}
|
||||||
data2_obj["Area"][temp[1]]["Plant"] = data_obj["Plant"][temp[0]];
|
data2_obj["Area"][temp[1]]["Plant"] = data_obj["Plant"][temp[0]];
|
||||||
efs("./Addons/PVZ/GameData.json",JSON.stringify(data2_obj),(err3)=>{
|
efs("./Addons/PVZ/GameData.json",JSON.stringify(data2_obj),(err3)=>{
|
||||||
Core.frame.SendMsg(connect,info,`种植${temp[0]}到${temp[1]}成功!`);
|
Core.frame.SendMsg(connect,info,`种植${temp[0]}到${temp[1]}成功!`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
|
|
||||||
},
|
},
|
||||||
Control:function(connect,message,user){
|
Control:function(connect,message,user){
|
||||||
console.log(message);
|
console.log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
82
Aitest.js
82
Aitest.js
@ -1,42 +1,42 @@
|
|||||||
//const https = require('http');
|
//const https = require('http');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const md5 = crypto.createHash('md5');
|
const md5 = crypto.createHash('md5');
|
||||||
|
|
||||||
var params = new Object({
|
var params = new Object({
|
||||||
app_id:"2125346185",//APPID
|
app_id:"2125346185",//APPID
|
||||||
time_stamp: Date.parse(new Date())/1000,//时间戳
|
time_stamp: Date.parse(new Date())/1000,//时间戳
|
||||||
"nonce\_str":new String("A"+Math.floor(Math.random() * 100000000)),//随机文本
|
"nonce\_str":new String("A"+Math.floor(Math.random() * 100000000)),//随机文本
|
||||||
session:"927980270",//测试环境下账号伪造
|
session:"927980270",//测试环境下账号伪造
|
||||||
question:"你好呀"//测试环境下内容伪造
|
question:"你好呀"//测试环境下内容伪造
|
||||||
});
|
});
|
||||||
console.log(params);
|
console.log(params);
|
||||||
var key = "T6zpC15OkWJ9jP0a";//APP Key
|
var key = "T6zpC15OkWJ9jP0a";//APP Key
|
||||||
var p2 = new Object();
|
var p2 = new Object();
|
||||||
var k = Object.keys(params).sort();
|
var k = Object.keys(params).sort();
|
||||||
console.log(k)
|
console.log(k)
|
||||||
for(var i = 0;i<k.length;i++){
|
for(var i = 0;i<k.length;i++){
|
||||||
p2[k[i]] = params[k[i]];
|
p2[k[i]] = params[k[i]];
|
||||||
}
|
}
|
||||||
console.log(p2)
|
console.log(p2)
|
||||||
var Str="";
|
var Str="";
|
||||||
for(var i = 0;i<k.length;i++){
|
for(var i = 0;i<k.length;i++){
|
||||||
Str=Str+Object.keys(p2)[i]+"="+encodeURI(Object.values(p2)[i])+"&";
|
Str=Str+Object.keys(p2)[i]+"="+encodeURI(Object.values(p2)[i])+"&";
|
||||||
}
|
}
|
||||||
|
|
||||||
Str = Str+"app_key="+key;
|
Str = Str+"app_key="+key;
|
||||||
console.log(Str)
|
console.log(Str)
|
||||||
sign = md5.update(Str).digest("hex").toUpperCase();
|
sign = md5.update(Str).digest("hex").toUpperCase();
|
||||||
console.log(sign)
|
console.log(sign)
|
||||||
params["sign"] = sign;
|
params["sign"] = sign;
|
||||||
|
|
||||||
request.get({
|
request.get({
|
||||||
url:`https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat?${Str}&sign=${sign}`,
|
url:`https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat?${Str}&sign=${sign}`,
|
||||||
encoding:'utf8'
|
encoding:'utf8'
|
||||||
},(err,req,body)=>{
|
},(err,req,body)=>{
|
||||||
if(req.statusCode==200){
|
if(req.statusCode==200){
|
||||||
console.log(body);
|
console.log(body);
|
||||||
var an = JSON.parse(body)["data"]["answer"];
|
var an = JSON.parse(body)["data"]["answer"];
|
||||||
console.log(an);
|
console.log(an);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1,33 +1,33 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
exports.Creeper = ["Creeper?", "awwww man!", "So we back in the mine"];
|
exports.Creeper = ["Creeper?", "awwww man!", "So we back in the mine"];
|
||||||
var Creepering = 0;
|
var Creepering = 0;
|
||||||
Core.AddListener((c, info) => {
|
Core.AddListener((c, info) => {
|
||||||
if (Creepering != 0) {
|
if (Creepering != 0) {
|
||||||
var temp = true;
|
var temp = true;
|
||||||
if (info.message == exports.Creeper[Creepering]) {
|
if (info.message == exports.Creeper[Creepering]) {
|
||||||
Core.frame.SendMsg(c, info, exports.Creeper[Creepering + 1]);
|
Core.frame.SendMsg(c, info, exports.Creeper[Creepering + 1]);
|
||||||
Creepering = Creepering + 2;
|
Creepering = Creepering + 2;
|
||||||
temp = false;
|
temp = false;
|
||||||
if (Creepering > exports.Creeper.length) {
|
if (Creepering > exports.Creeper.length) {
|
||||||
Core.frame.SendMsg(c, info, "The End");
|
Core.frame.SendMsg(c, info, "The End");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (temp) {
|
if (temp) {
|
||||||
Core.frame.SendMsg(c, info, "有人发送了一个与Creeper无关的消息,Creeper进度已终止!");
|
Core.frame.SendMsg(c, info, "有人发送了一个与Creeper无关的消息,Creeper进度已终止!");
|
||||||
Creepering = 0;
|
Creepering = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.message == exports.Creeper[0] && Creepering == 0) {
|
if (info.message == exports.Creeper[0] && Creepering == 0) {
|
||||||
Creepering = 1;
|
Creepering = 1;
|
||||||
Core.frame.SendMsg(c, info, exports.Creeper[1]);
|
Core.frame.SendMsg(c, info, exports.Creeper[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
export var Creeper = ["Creeper?", "awwww man!","So we back in the mine"];
|
export var Creeper = ["Creeper?", "awwww man!","So we back in the mine"];
|
||||||
var Creepering = 0;
|
var Creepering = 0;
|
||||||
Core.AddListener((c, info) => {
|
Core.AddListener((c, info) => {
|
||||||
if (Creepering != 0) {
|
if (Creepering != 0) {
|
||||||
var temp = true;
|
var temp = true;
|
||||||
if (info.message == Creeper[Creepering]) {
|
if (info.message == Creeper[Creepering]) {
|
||||||
Core.frame.SendMsg(c, info, Creeper[Creepering + 1]);
|
Core.frame.SendMsg(c, info, Creeper[Creepering + 1]);
|
||||||
Creepering = Creepering + 2;
|
Creepering = Creepering + 2;
|
||||||
temp = false;
|
temp = false;
|
||||||
if (Creepering > Creeper.length) {
|
if (Creepering > Creeper.length) {
|
||||||
Core.frame.SendMsg(c, info, "The End");
|
Core.frame.SendMsg(c, info, "The End");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (temp) {
|
if (temp) {
|
||||||
Core.frame.SendMsg(c, info, "有人发送了一个与Creeper无关的消息,Creeper进度已终止!");
|
Core.frame.SendMsg(c, info, "有人发送了一个与Creeper无关的消息,Creeper进度已终止!");
|
||||||
Creepering = 0;
|
Creepering = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.message == Creeper[0]&&Creepering == 0) {
|
if (info.message == Creeper[0]&&Creepering == 0) {
|
||||||
Creepering = 1;
|
Creepering = 1;
|
||||||
Core.frame.SendMsg(c, info, Creeper[1]);
|
Core.frame.SendMsg(c, info, Creeper[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
18
AutoMake.bat
18
AutoMake.bat
@ -1,10 +1,10 @@
|
|||||||
@echo off
|
@echo off
|
||||||
echo Downloading!
|
echo Downloading!
|
||||||
start cmd /c npm install
|
start cmd /c npm install
|
||||||
echo Building!
|
echo Building!
|
||||||
start cmd /c tsc --build
|
start cmd /c tsc --build
|
||||||
echo Uploading!
|
echo Uploading!
|
||||||
git add .
|
git add .
|
||||||
git commit -m "%1 <AutoUpload>"
|
git commit -m "%1 <AutoUpload>"
|
||||||
git push origin master
|
git push origin master
|
||||||
exit /B
|
exit /B
|
||||||
46
BBS.js
46
BBS.js
@ -1,23 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//BBS.js => 提供一个论坛机制
|
//BBS.js => 提供一个论坛机制
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
(() => {
|
(() => {
|
||||||
var BBSCore = {
|
var BBSCore = {
|
||||||
GetUserPermission: ((User, BBS) => {
|
GetUserPermission: ((User, BBS) => {
|
||||||
return;
|
return;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
Core.AddListener((connect, info) => {
|
Core.AddListener((connect, info) => {
|
||||||
if (info.raw_message.substr(0, 3) != "BBS") {
|
if (info.raw_message.substr(0, 3) != "BBS") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
32
BBS.ts
32
BBS.ts
@ -1,17 +1,17 @@
|
|||||||
//BBS.js => 提供一个论坛机制
|
//BBS.js => 提供一个论坛机制
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
(()=>{
|
(()=>{
|
||||||
var BBSCore = {
|
var BBSCore = {
|
||||||
|
|
||||||
GetUserPermission:((User:Number|number,BBS:String)=>{//Get A User's Permission of A BBS Part.
|
GetUserPermission:((User:Number|number,BBS:String)=>{//Get A User's Permission of A BBS Part.
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
Core.AddListener((connect,info)=>{
|
Core.AddListener((connect,info)=>{
|
||||||
if(info.raw_message.substr(0,3)!="BBS"){
|
if(info.raw_message.substr(0,3)!="BBS"){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
285
CGI.js
285
CGI.js
@ -1,143 +1,144 @@
|
|||||||
const Key = "ONLINEAICORE";
|
const Key = "ONLINEAICORE";
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const net = require("net");
|
const net = require("net");
|
||||||
var HOOK = false;
|
const ServicePort = 8092;
|
||||||
var Session = "";
|
var HOOK = false;
|
||||||
console.log("["+new Date().toString()+"][./Core.js]服务器已启动");
|
var Session = "";
|
||||||
global.DEBUG = {};
|
console.log("["+new Date().toString()+"][./Core.js]服务器已启动");
|
||||||
global.DEBUG.Core = Core;
|
global.DEBUG = {};
|
||||||
var last = {};
|
global.DEBUG.Core = Core;
|
||||||
request.post({
|
var last = {};
|
||||||
url:"http://127.0.0.1:8080/auth",
|
request.post({
|
||||||
body:JSON.stringify({authKey:Key})
|
url:`http://127.0.0.1:${ServicePort}/auth`,
|
||||||
},(err,res)=>{
|
body:JSON.stringify({authKey:Key})
|
||||||
if(res == null){
|
},(err,res)=>{
|
||||||
console.log("["+new Date().toString()+"][./Core.js]系统断线.");
|
if(res == null){
|
||||||
return;
|
console.log("["+new Date().toString()+"][./Core.js]系统断线.");
|
||||||
}
|
return;
|
||||||
Session = JSON.parse(res.body).session;
|
}
|
||||||
request.post({
|
Session = JSON.parse(res.body).session;
|
||||||
url:"http://127.0.0.1:8080/verify",
|
request.post({
|
||||||
body:JSON.stringify({
|
url:`http://127.0.0.1:${ServicePort}/verify`,
|
||||||
sessionKey:Session,
|
body:JSON.stringify({
|
||||||
qq:2142562417
|
sessionKey:Session,
|
||||||
})
|
qq:2142562417
|
||||||
},(err2,res2)=>{
|
})
|
||||||
console.log("["+new Date().toString()+"][./Core.js]Session激活成功.");
|
},(err2,res2)=>{
|
||||||
console.log(Session);
|
console.log("["+new Date().toString()+"][./Core.js]Session激活成功.");
|
||||||
exports.HOOK = HOOK;
|
console.log(Session);
|
||||||
exports.frame={
|
exports.HOOK = HOOK;
|
||||||
|
exports.frame={
|
||||||
SendImg: function(c,info,p){
|
|
||||||
this.SetHook(true);
|
SendImg: function(c,info,p){
|
||||||
|
this.SetHook(true);
|
||||||
if(info.group != undefined){
|
|
||||||
var Kdata = JSON.stringify({
|
if(info.group != undefined){
|
||||||
sessionKey:Session,
|
var Kdata = JSON.stringify({
|
||||||
group:info.group_id,
|
sessionKey:Session,
|
||||||
messageChain:[{
|
group:info.group_id,
|
||||||
type:"Image",
|
messageChain:[{
|
||||||
path:p
|
type:"Image",
|
||||||
}]
|
path:p
|
||||||
});
|
}]
|
||||||
}else{
|
});
|
||||||
var Kdata = JSON.stringify({
|
}else{
|
||||||
sessionKey:Session,
|
var Kdata = JSON.stringify({
|
||||||
qq:info.user_id,
|
sessionKey:Session,
|
||||||
messageChain:[{
|
qq:info.user_id,
|
||||||
type:"Image",
|
messageChain:[{
|
||||||
path:p
|
type:"Image",
|
||||||
}]
|
path:p
|
||||||
});
|
}]
|
||||||
}
|
});
|
||||||
var BData = Buffer.from(Kdata);
|
}
|
||||||
var Ret = "";
|
var BData = Buffer.from(Kdata);
|
||||||
var To = "Friend";
|
var Ret = "";
|
||||||
if(info.group != undefined){
|
var To = "Friend";
|
||||||
To = "Group"
|
if(info.group != undefined){
|
||||||
}
|
To = "Group"
|
||||||
var Req = new net.Socket();
|
}
|
||||||
console.log(Kdata);
|
var Req = new net.Socket();
|
||||||
console.log(Kdata);
|
console.log(Kdata);
|
||||||
var MainData = `POST /send${To}Message HTTP/1.1\r\nHost: 127.0.0.1:8080\r\nContent-Type: application/json; charset=UTF-8;\r\nContent-Length:${BData.length}\r\n\r\n`;
|
console.log(Kdata);
|
||||||
Req.connect(8080,"127.0.0.1",()=>{
|
var MainData = `POST /send${To}Message HTTP/1.1\r\nHost: 127.0.0.1:${ServicePort}\r\nContent-Type: application/json; charset=UTF-8;\r\nContent-Length:${BData.length}\r\n\r\n`;
|
||||||
Req.write(MainData);
|
Req.connect(ServicePort,"127.0.0.1",()=>{
|
||||||
Req.write(BData);
|
Req.write(MainData);
|
||||||
Req.on("data",(data)=>{
|
Req.write(BData);
|
||||||
console.log(data.toString());
|
Req.on("data",(data)=>{
|
||||||
});
|
console.log(data.toString());
|
||||||
Req.on("end",()=>{
|
});
|
||||||
Req.end();
|
Req.on("end",()=>{
|
||||||
});
|
Req.end();
|
||||||
Req.on("close",()=>{
|
});
|
||||||
Req.end();
|
Req.on("close",()=>{
|
||||||
})
|
Req.end();
|
||||||
});
|
})
|
||||||
},
|
});
|
||||||
SendMsg: function (connect, info, message) {
|
},
|
||||||
|
SendMsg: function (connect, info, message) {
|
||||||
this.SetHook(true);
|
|
||||||
|
this.SetHook(true);
|
||||||
if(info.group != undefined){
|
|
||||||
var Kdata = JSON.stringify({
|
if(info.group != undefined){
|
||||||
sessionKey:Session,
|
var Kdata = JSON.stringify({
|
||||||
group:info.group_id,
|
sessionKey:Session,
|
||||||
messageChain:message
|
group:info.group_id,
|
||||||
});
|
messageChain:message
|
||||||
}else{
|
});
|
||||||
var Kdata = JSON.stringify({
|
}else{
|
||||||
sessionKey:Session,
|
var Kdata = JSON.stringify({
|
||||||
qq:info.user_id,
|
sessionKey:Session,
|
||||||
messageChain:message
|
qq:info.user_id,
|
||||||
});
|
messageChain:message
|
||||||
}
|
});
|
||||||
var BData = Buffer.from(Kdata);
|
}
|
||||||
var Ret = "";
|
var BData = Buffer.from(Kdata);
|
||||||
var To = "Friend";
|
var Ret = "";
|
||||||
if(info.group != undefined){
|
var To = "Friend";
|
||||||
To = "Group"
|
if(info.group != undefined){
|
||||||
}
|
To = "Group"
|
||||||
var Req = new net.Socket();
|
}
|
||||||
console.log(Kdata);
|
var Req = new net.Socket();
|
||||||
console.log(Kdata);
|
console.log(Kdata);
|
||||||
var MainData = `POST /send${To}Message HTTP/1.1\r\nHost: 127.0.0.1:8080\r\nContent-Type: application/json; charset=UTF-8;\r\nContent-Length:${BData.length}\r\n\r\n`;
|
console.log(Kdata);
|
||||||
Req.connect(8080,"127.0.0.1",()=>{
|
var MainData = `POST /send${To}Message HTTP/1.1\r\nHost: 127.0.0.1:${ServicePort}\r\nContent-Type: application/json; charset=UTF-8;\r\nContent-Length:${BData.length}\r\n\r\n`;
|
||||||
Req.write(MainData);
|
Req.connect(ServicePort,"127.0.0.1",()=>{
|
||||||
Req.write(BData);
|
Req.write(MainData);
|
||||||
Req.on("data",(data)=>{
|
Req.write(BData);
|
||||||
console.log(data.toString());
|
Req.on("data",(data)=>{
|
||||||
});
|
console.log(data.toString());
|
||||||
Req.on("end",()=>{
|
});
|
||||||
Req.end();
|
Req.on("end",()=>{
|
||||||
});
|
Req.end();
|
||||||
Req.on("close",()=>{
|
});
|
||||||
Req.end();
|
Req.on("close",()=>{
|
||||||
})
|
Req.end();
|
||||||
});
|
})
|
||||||
},
|
});
|
||||||
SetHook:function(value){
|
},
|
||||||
exports.HOOK = value;
|
SetHook:function(value){
|
||||||
}
|
exports.HOOK = value;
|
||||||
}
|
}
|
||||||
setInterval(()=>{
|
}
|
||||||
if(Session == ""){return}
|
setInterval(()=>{
|
||||||
request.get({
|
if(Session == ""){return}
|
||||||
url:`http://127.0.0.1:8080/fetchLatestMessage?sessionKey=${Session}&count=1`
|
request.get({
|
||||||
},(err,data)=>{
|
url:`http://127.0.0.1:${ServicePort}/fetchLatestMessage?sessionKey=${Session}&count=1`
|
||||||
if(data == null || data == undefined){return}
|
},(err,data)=>{
|
||||||
if(data.body.toString().substr(0,1)!="{"){return;}
|
if(data == null || data == undefined){return}
|
||||||
var MainData = JSON.parse(data.body);
|
if(data.body.toString().substr(0,1)!="{"){return;}
|
||||||
if(MainData == null || MainData == undefined){return};
|
var MainData = JSON.parse(data.body);
|
||||||
if(MainData.data == null||MainData.data == undefined){return};
|
if(MainData == null || MainData == undefined){return};
|
||||||
var data_obj = MainData.data[0];
|
if(MainData.data == null||MainData.data == undefined){return};
|
||||||
if(data_obj == last){
|
var data_obj = MainData.data[0];
|
||||||
return
|
if(data_obj == last){
|
||||||
}else{
|
return
|
||||||
Core.frame.CGI("",data_obj);
|
}else{
|
||||||
last = data_obj;
|
Core.frame.CGI("",data_obj);
|
||||||
}
|
last = data_obj;
|
||||||
});
|
}
|
||||||
},50);
|
});
|
||||||
});
|
},50);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@ -1 +1 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
224
Core.Class.js
224
Core.Class.js
@ -1,112 +1,112 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
exports.Weapons = new Map();
|
exports.Weapons = new Map();
|
||||||
exports.WeaponsWarhead = new Map();
|
exports.WeaponsWarhead = new Map();
|
||||||
class GameBlock {
|
class GameBlock {
|
||||||
}
|
}
|
||||||
exports.GameBlock = GameBlock;
|
exports.GameBlock = GameBlock;
|
||||||
exports.GameBlocks = new Map();
|
exports.GameBlocks = new Map();
|
||||||
class GameLocation {
|
class GameLocation {
|
||||||
}
|
}
|
||||||
exports.GameLocation = GameLocation;
|
exports.GameLocation = GameLocation;
|
||||||
class GamePlayer {
|
class GamePlayer {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.Language = new GameLanguage("zh_cn");
|
this.Language = new GameLanguage("zh_cn");
|
||||||
this.Money = 13000;
|
this.Money = 13000;
|
||||||
this.Factorys = new Map();
|
this.Factorys = new Map();
|
||||||
this.Units = [];
|
this.Units = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GamePlayer = GamePlayer;
|
exports.GamePlayer = GamePlayer;
|
||||||
class GameLanguage {
|
class GameLanguage {
|
||||||
Get(Source) {
|
Get(Source) {
|
||||||
var Result = this.Pack[Source.toString()];
|
var Result = this.Pack[Source.toString()];
|
||||||
if (Result) {
|
if (Result) {
|
||||||
return new String(Result);
|
return new String(Result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new String(Source);
|
return new String(Source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
constructor(Language) {
|
constructor(Language) {
|
||||||
this.Language = Language;
|
this.Language = Language;
|
||||||
this.Pack = fs.readFileSync(`./Language.${this.Language}.json`);
|
this.Pack = fs.readFileSync(`./Language.${this.Language}.json`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GameLanguage = GameLanguage;
|
exports.GameLanguage = GameLanguage;
|
||||||
class GameObjectRoot {
|
class GameObjectRoot {
|
||||||
UnderAttack(Weapon, Attacker) {
|
UnderAttack(Weapon, Attacker) {
|
||||||
if (this.Bind.Broken) {
|
if (this.Bind.Broken) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exports.Weapons.get(Weapon.valueOf()).Warhead.Attack(this, exports.Weapons.get(Weapon.valueOf()), Attacker);
|
exports.Weapons.get(Weapon.valueOf()).Warhead.Attack(this, exports.Weapons.get(Weapon.valueOf()), Attacker);
|
||||||
if (this.Health > 0) {
|
if (this.Health > 0) {
|
||||||
this.Bind.Broken = true;
|
this.Bind.Broken = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
constructor(Loader) {
|
constructor(Loader) {
|
||||||
const that = Loader;
|
const that = Loader;
|
||||||
//定义 that 为 Loader
|
//定义 that 为 Loader
|
||||||
this.Health = new Number(that.Health);
|
this.Health = new Number(that.Health);
|
||||||
this.Cost = new Number(that.Cost);
|
this.Cost = new Number(that.Cost);
|
||||||
this.Name = new String(that.Name);
|
this.Name = new String(that.Name);
|
||||||
this.Size = new Number(that.Size);
|
this.Size = new Number(that.Size);
|
||||||
this.Weapon = new String(that.Weapon);
|
this.Weapon = new String(that.Weapon);
|
||||||
this.Type = new String(that.Type);
|
this.Type = new String(that.Type);
|
||||||
this.BuildAble = new Boolean(that.BuildAble);
|
this.BuildAble = new Boolean(that.BuildAble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GameObjectRoot = GameObjectRoot;
|
exports.GameObjectRoot = GameObjectRoot;
|
||||||
class GameObject {
|
class GameObject {
|
||||||
constructor(Root, Owner) {
|
constructor(Root, Owner) {
|
||||||
this.Root = new GameObjectRoot(Root);
|
this.Root = new GameObjectRoot(Root);
|
||||||
this.Root.Bind = this;
|
this.Root.Bind = this;
|
||||||
this.Health = this.Root.Health;
|
this.Health = this.Root.Health;
|
||||||
this.Leven = 1;
|
this.Leven = 1;
|
||||||
this.Owner = Owner;
|
this.Owner = Owner;
|
||||||
this.Owner.Money = this.Owner.Money.valueOf() - this.Root.Cost.valueOf();
|
this.Owner.Money = this.Owner.Money.valueOf() - this.Root.Cost.valueOf();
|
||||||
this.Owner.Units[this.Owner.Units.length] = this;
|
this.Owner.Units[this.Owner.Units.length] = this;
|
||||||
this.Broken = false;
|
this.Broken = false;
|
||||||
if (this.Root.Type.valueOf() != "Building") {
|
if (this.Root.Type.valueOf() != "Building") {
|
||||||
// this.Location = this.Owner.Factorys.get(this.Root.Type.valueOf())[0].Location;
|
// this.Location = this.Owner.Factorys.get(this.Root.Type.valueOf())[0].Location;
|
||||||
}
|
}
|
||||||
// this.Location.Units[this.Location.Units.length] = this;
|
// this.Location.Units[this.Location.Units.length] = this;
|
||||||
// this.Location.UsedSize = this.Location.UsedSize.valueOf() + this.Root.Size.valueOf();
|
// this.Location.UsedSize = this.Location.UsedSize.valueOf() + this.Root.Size.valueOf();
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
Attack(that) {
|
Attack(that) {
|
||||||
if (this.Broken) {
|
if (this.Broken) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
that.Root.UnderAttack(this.Root.Weapon, this.Root);
|
that.Root.UnderAttack(this.Root.Weapon, this.Root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GameObject = GameObject;
|
exports.GameObject = GameObject;
|
||||||
class GameWeapon {
|
class GameWeapon {
|
||||||
constructor(Loader) {
|
constructor(Loader) {
|
||||||
const that = Loader;
|
const that = Loader;
|
||||||
this.Hurt = that.Hurt;
|
this.Hurt = that.Hurt;
|
||||||
this.Warhead = exports.WeaponsWarhead.get(that.Warhead.valueOf());
|
this.Warhead = exports.WeaponsWarhead.get(that.Warhead.valueOf());
|
||||||
this.Spawner_SpawnGameObjectRoot = that.Spawner_SpawnGameObjectRoot;
|
this.Spawner_SpawnGameObjectRoot = that.Spawner_SpawnGameObjectRoot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GameWeapon = GameWeapon;
|
exports.GameWeapon = GameWeapon;
|
||||||
class GameWeaponWarhead {
|
class GameWeaponWarhead {
|
||||||
Attack(GOR, GW, ATT) {
|
Attack(GOR, GW, ATT) {
|
||||||
// 真的就Empty呗;
|
// 真的就Empty呗;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
constructor(Attack) {
|
constructor(Attack) {
|
||||||
this.Attack = Attack;
|
this.Attack = Attack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GameWeaponWarhead = GameWeaponWarhead;
|
exports.GameWeaponWarhead = GameWeaponWarhead;
|
||||||
|
|||||||
72
Core.Init.js
72
Core.Init.js
@ -1,36 +1,36 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const GameCoreClass = __importStar(require("./Core.Class"));
|
const GameCoreClass = __importStar(require("./Core.Class"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
exports.GameObjectRoots = new Map();
|
exports.GameObjectRoots = new Map();
|
||||||
exports.RulesSourceData = JSON.parse(fs.readFileSync("./Rules.json").toString());
|
exports.RulesSourceData = JSON.parse(fs.readFileSync("./Rules.json").toString());
|
||||||
exports.RulesSourceDataOfGameObjectRoots = exports.RulesSourceData["GameObject"];
|
exports.RulesSourceDataOfGameObjectRoots = exports.RulesSourceData["GameObject"];
|
||||||
exports.RulesSourceDataOfGameWeapons = exports.RulesSourceData["Weapons"];
|
exports.RulesSourceDataOfGameWeapons = exports.RulesSourceData["Weapons"];
|
||||||
Object.keys(exports.RulesSourceDataOfGameObjectRoots).forEach((v) => {
|
Object.keys(exports.RulesSourceDataOfGameObjectRoots).forEach((v) => {
|
||||||
exports.GameObjectRoots.set(v, new GameCoreClass.GameObjectRoot(exports.RulesSourceDataOfGameObjectRoots[v]));
|
exports.GameObjectRoots.set(v, new GameCoreClass.GameObjectRoot(exports.RulesSourceDataOfGameObjectRoots[v]));
|
||||||
});
|
});
|
||||||
// 弹头是代码里面写好的
|
// 弹头是代码里面写好的
|
||||||
GameCoreClass.WeaponsWarhead.set("Standard", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
GameCoreClass.WeaponsWarhead.set("Standard", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
||||||
// 标准武器弹头
|
// 标准武器弹头
|
||||||
// 被攻击.血量 = 被攻击.血量 - 武器.伤害 * 随机(0.75,1.25)
|
// 被攻击.血量 = 被攻击.血量 - 武器.伤害 * 随机(0.75,1.25)
|
||||||
GOR.Bind.Health = GOR.Bind.Health.valueOf() - GW.Hurt.valueOf() * (Math.random() + 0.25);
|
GOR.Bind.Health = GOR.Bind.Health.valueOf() - GW.Hurt.valueOf() * (Math.random() + 0.25);
|
||||||
}));
|
}));
|
||||||
GameCoreClass.WeaponsWarhead.set("Spawner", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
GameCoreClass.WeaponsWarhead.set("Spawner", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
||||||
// 生成武器
|
// 生成武器
|
||||||
var SpawnGameObjectRoot = exports.GameObjectRoots.get(GW.Spawner_SpawnGameObjectRoot.valueOf());
|
var SpawnGameObjectRoot = exports.GameObjectRoots.get(GW.Spawner_SpawnGameObjectRoot.valueOf());
|
||||||
var Spawn = new GameCoreClass.GameObject(SpawnGameObjectRoot, ATT.Bind.Owner);
|
var Spawn = new GameCoreClass.GameObject(SpawnGameObjectRoot, ATT.Bind.Owner);
|
||||||
}));
|
}));
|
||||||
GameCoreClass.WeaponsWarhead.set("Kill", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
GameCoreClass.WeaponsWarhead.set("Kill", new GameCoreClass.GameWeaponWarhead((GOR, GW, ATT) => {
|
||||||
// 一击毙命
|
// 一击毙命
|
||||||
GOR.Bind.Broken = true;
|
GOR.Bind.Broken = true;
|
||||||
}));
|
}));
|
||||||
Object.keys(exports.RulesSourceDataOfGameWeapons).forEach((v) => {
|
Object.keys(exports.RulesSourceDataOfGameWeapons).forEach((v) => {
|
||||||
GameCoreClass.Weapons.set(v, new GameCoreClass.GameWeapon(exports.RulesSourceDataOfGameWeapons[v.valueOf()]));
|
GameCoreClass.Weapons.set(v, new GameCoreClass.GameWeapon(exports.RulesSourceDataOfGameWeapons[v.valueOf()]));
|
||||||
});
|
});
|
||||||
|
|||||||
152
Core.d.ts
vendored
152
Core.d.ts
vendored
@ -1,77 +1,77 @@
|
|||||||
import * as net from "net";
|
import * as net from "net";
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
/**QQ用户类:一个QQ号对应的人*/export class QQUser{
|
/**QQ用户类:一个QQ号对应的人*/export class QQUser{
|
||||||
/**岁数*/age:Number|number;
|
/**岁数*/age:Number|number;
|
||||||
/**昵称*/nickname:String|string;
|
/**昵称*/nickname:String|string;
|
||||||
/**性别*/sex:"male"|"unkonw"|""|String|string|undefined;
|
/**性别*/sex:"male"|"unkonw"|""|String|string|undefined;
|
||||||
/**QQ号*/user_id:number|Number;
|
/**QQ号*/user_id:number|Number;
|
||||||
/**地区*/area:String|null|undefined;
|
/**地区*/area:String|null|undefined;
|
||||||
/**群名片*/card:String|string|undefined;
|
/**群名片*/card:String|string|undefined;
|
||||||
/**发言等级*/level:String|string|undefined;
|
/**发言等级*/level:String|string|undefined;
|
||||||
/**群内角色*/role:"owner"|"user";
|
/**群内角色*/role:"owner"|"user";
|
||||||
/**群头衔*/title:string|String;
|
/**群头衔*/title:string|String;
|
||||||
}
|
}
|
||||||
/**消息类:一个消息对应的东西*/export class InfoType{
|
/**消息类:一个消息对应的东西*/export class InfoType{
|
||||||
Core:any;
|
Core:any;
|
||||||
/**匿名信息*/anonymous:Object|null|undefined;
|
/**匿名信息*/anonymous:Object|null|undefined;
|
||||||
/**字体*/font:number|Number;
|
/**字体*/font:number|Number;
|
||||||
/**群号*/group_id:number|Number|undefined;
|
/**群号*/group_id:number|Number|undefined;
|
||||||
/**消息内容*/message:String|string;
|
/**消息内容*/message:String|string;
|
||||||
/**消息号*/message_id:number|Number;
|
/**消息号*/message_id:number|Number;
|
||||||
/**消息类型*/message_type:"group"|"privace";
|
/**消息类型*/message_type:"group"|"privace";
|
||||||
/**未知*/post_type:String|string;
|
/**未知*/post_type:String|string;
|
||||||
/**消息*/raw_message:String|string;
|
/**消息*/raw_message:String|string;
|
||||||
/**AiQQ*/self_id:number|Number|2142562417;
|
/**AiQQ*/self_id:number|Number|2142562417;
|
||||||
/**发送者*/sender:QQUser;
|
/**发送者*/sender:QQUser;
|
||||||
/**类型2*/sub_type:String|string;
|
/**类型2*/sub_type:String|string;
|
||||||
/**时间戳*/time:number|Number;
|
/**时间戳*/time:number|Number;
|
||||||
/**发送者QQ*/user_id:number|Number;
|
/**发送者QQ*/user_id:number|Number;
|
||||||
}
|
}
|
||||||
/**原定于获取名称对应的QQ号,不过已经废弃了
|
/**原定于获取名称对应的QQ号,不过已经废弃了
|
||||||
* @param user_id 用户名称*/export function GetUser(user_id:String|string|Number|number):number;
|
* @param user_id 用户名称*/export function GetUser(user_id:String|string|Number|number):number;
|
||||||
/**HOOK:是否发送过消息*/export var HOOK: Boolean | boolean;
|
/**HOOK:是否发送过消息*/export var HOOK: Boolean | boolean;
|
||||||
declare interface InfoSocket{}
|
declare interface InfoSocket{}
|
||||||
/**添加事件监听器
|
/**添加事件监听器
|
||||||
* @param callback 回调函数
|
* @param callback 回调函数
|
||||||
*/export function AddListener(/**回调函数*/callback:((Connect:InfoSocket,Info:InfoType)=>void)):void;
|
*/export function AddListener(/**回调函数*/callback:((Connect:InfoSocket,Info:InfoType)=>void)):void;
|
||||||
/**Config类型*/declare interface Config<T>{
|
/**Config类型*/declare interface Config<T>{
|
||||||
/**
|
/**
|
||||||
* 读取某个人的Config
|
* 读取某个人的Config
|
||||||
* @param QQ QQ
|
* @param QQ QQ
|
||||||
*/
|
*/
|
||||||
ReadValue(QQ:Number|number):T;
|
ReadValue(QQ:Number|number):T;
|
||||||
/**
|
/**
|
||||||
* 写入某个人的Config
|
* 写入某个人的Config
|
||||||
* @param QQ QQ
|
* @param QQ QQ
|
||||||
* @param value 内容
|
* @param value 内容
|
||||||
*/
|
*/
|
||||||
WriteValue(QQ:Number|number,value:T):void;
|
WriteValue(QQ:Number|number,value:T):void;
|
||||||
API_GET():any;
|
API_GET():any;
|
||||||
constructor(Value:Array<T>):any;
|
constructor(Value:Array<T>):any;
|
||||||
}
|
}
|
||||||
/**部分公开功能*/export namespace frame{
|
/**部分公开功能*/export namespace frame{
|
||||||
/**禁言某人
|
/**禁言某人
|
||||||
* @param connect 会话
|
* @param connect 会话
|
||||||
* @param info 消息
|
* @param info 消息
|
||||||
* @param time 时长(单位:s)*/function Ban(connect:InfoSocket,info:InfoType,time:number):void;
|
* @param time 时长(单位:s)*/function Ban(connect:InfoSocket,info:InfoType,time:number):void;
|
||||||
/**设置HOOK的内容
|
/**设置HOOK的内容
|
||||||
* @param value TURE|FALSE;*/function SetHOOK(value:Boolean|boolean):void;
|
* @param value TURE|FALSE;*/function SetHOOK(value:Boolean|boolean):void;
|
||||||
/**发送消息
|
/**发送消息
|
||||||
* @param connect 会话
|
* @param connect 会话
|
||||||
* @param info 消息
|
* @param info 消息
|
||||||
* @param msg 发送内容*/function SendMsg(connect:InfoSocket,info:InfoType,msg:String|string):void;
|
* @param msg 发送内容*/function SendMsg(connect:InfoSocket,info:InfoType,msg:String|string):void;
|
||||||
/** \@某人
|
/** \@某人
|
||||||
* @param UserId QQ号
|
* @param UserId QQ号
|
||||||
*/function At(UserId:number|Number):string;
|
*/function At(UserId:number|Number):string;
|
||||||
/** 读取某个配置项目
|
/** 读取某个配置项目
|
||||||
* @param ConfigName 配置项名称
|
* @param ConfigName 配置项名称
|
||||||
*/function NReadSystemConfig(ConfigName:String|string):Config<any>;
|
*/function NReadSystemConfig(ConfigName:String|string):Config<any>;
|
||||||
function ReadSystemConfig(ConfigName:String|string):any;
|
function ReadSystemConfig(ConfigName:String|string):any;
|
||||||
function WriteSystemConfig(ConfigName:String|string,value:any):any;
|
function WriteSystemConfig(ConfigName:String|string,value:any):any;
|
||||||
/**写入某个配置项目
|
/**写入某个配置项目
|
||||||
* @param ConfigName 配置名称
|
* @param ConfigName 配置名称
|
||||||
* @param ConfigValue 配置内容
|
* @param ConfigValue 配置内容
|
||||||
*/function NWriteSystemConfig(ConfigName:String|string,ConfigValue:Config<any>):Boolean|boolean;
|
*/function NWriteSystemConfig(ConfigName:String|string,ConfigValue:Config<any>):Boolean|boolean;
|
||||||
function SendImg(Connect:InfoSocket,info:InfoType,Img:String):void;
|
function SendImg(Connect:InfoSocket,info:InfoType,Img:String):void;
|
||||||
function GetAt(C:InfoSocket,I:InfoType):String;
|
function GetAt(C:InfoSocket,I:InfoType):String;
|
||||||
}
|
}
|
||||||
543
Core.js
543
Core.js
@ -1,272 +1,273 @@
|
|||||||
const JSCGI = require("./CGI");
|
const JSCGI = require("./CGI");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const net = require("net");
|
const net = require("net");
|
||||||
var package = ["./Debug.js","./Money.js","./RedPacket.js","./抢劫.js","./公会系统.js","./Frame.js","./AddOns.js","./板砖.js","./DocMaker.js","./狗屁不通文章生成器.js"];
|
var package = ["./Debug.js","./Money.js","./RedPacket.js","./抢劫.js","./公会系统.js","./Frame.js","./AddOns.js","./板砖.js","./DocMaker.js","./狗屁不通文章生成器.js"];
|
||||||
var LastMessage = {};
|
var LastMessage = {};
|
||||||
var Listeners = [];
|
var Listeners = [];
|
||||||
var At = [];
|
var At = [];
|
||||||
global.LoadMoudel = (() => {
|
exports.ServicePort = 8092;
|
||||||
fs.exists("./MoudelV2.json", (ex) => {
|
global.LoadMoudel = (() => {
|
||||||
if (ex) {
|
fs.exists("./MoudelV2.json", (ex) => {
|
||||||
fs.readFile("./MoudelV2.json", (err, data) => {
|
if (ex) {
|
||||||
var data_obj = new Object(JSON.parse(data.toString()));
|
fs.readFile("./MoudelV2.json", (err, data) => {
|
||||||
var k = Object.keys(data_obj);
|
var data_obj = new Object(JSON.parse(data.toString()));
|
||||||
for (var i = 0; i < k.length; i++) {
|
var k = Object.keys(data_obj);
|
||||||
if (data_obj[k[i]].Allow) {
|
for (var i = 0; i < k.length; i++) {
|
||||||
console.log(`[${new Date().toString()}][${k[i]}]服务正在初始化!`);
|
if (data_obj[k[i]].Allow) {
|
||||||
if (data_obj[k[i]].FindIn == "fs" && fs.existsSync(require(process.cwd() + "/" + data_obj[k[i]].Path))) {
|
console.log(`[${new Date().toString()}][${k[i]}]服务正在初始化!`);
|
||||||
try{
|
if (data_obj[k[i]].FindIn == "fs" && fs.existsSync(require(process.cwd() + "/" + data_obj[k[i]].Path))) {
|
||||||
require(process.cwd() + "/" + data_obj[k[i]].Path);
|
try{
|
||||||
}catch(err){
|
require(process.cwd() + "/" + data_obj[k[i]].Path);
|
||||||
var CommandReal = fs.readFileSync(process.cwd() + "/" + data_obj[k[i]].Path);
|
}catch(err){
|
||||||
eval(CommandReal.toString());
|
var CommandReal = fs.readFileSync(process.cwd() + "/" + data_obj[k[i]].Path);
|
||||||
}
|
eval(CommandReal.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else {
|
});
|
||||||
fs.writeFile("./MoudelV2.json", JSON.stringify({}), (err) => { });
|
} else {
|
||||||
}
|
fs.writeFile("./MoudelV2.json", JSON.stringify({}), (err) => { });
|
||||||
});
|
}
|
||||||
})
|
});
|
||||||
global.LoadMoudel();
|
})
|
||||||
//var HOOK = false;
|
global.LoadMoudel();
|
||||||
exports.GetUser=function(user_id){
|
//var HOOK = false;
|
||||||
if(!fs.existsSync("./cname.json")){
|
exports.GetUser=function(user_id){
|
||||||
fs.writeFile("./cname.json",JSON.stringify({}),(err)=>{
|
if(!fs.existsSync("./cname.json")){
|
||||||
console.log(`[${new Date().toString()}][Core.js]cname.json初始化完成!`);
|
fs.writeFile("./cname.json",JSON.stringify({}),(err)=>{
|
||||||
});
|
console.log(`[${new Date().toString()}][Core.js]cname.json初始化完成!`);
|
||||||
return user_id;
|
});
|
||||||
}
|
return user_id;
|
||||||
var data = JSON.parse(fs.readFileSync("./cname.json").toString());
|
}
|
||||||
if(data[user_id]!=undefined){
|
var data = JSON.parse(fs.readFileSync("./cname.json").toString());
|
||||||
return data[user_id];
|
if(data[user_id]!=undefined){
|
||||||
}else{
|
return data[user_id];
|
||||||
return user_id;
|
}else{
|
||||||
}
|
return user_id;
|
||||||
};
|
}
|
||||||
exports.HOOK = JSCGI.HOOK;
|
};
|
||||||
exports.AddListener = ((callback)=>{
|
exports.HOOK = JSCGI.HOOK;
|
||||||
Listeners[Listeners.length] = callback;
|
exports.AddListener = ((callback)=>{
|
||||||
console.log(`[${new Date().toString()}]新的服务注册。服务ID为${Listeners.length - 1}`);
|
Listeners[Listeners.length] = callback;
|
||||||
return (Listeners.length - 1);
|
console.log(`[${new Date().toString()}]新的服务注册。服务ID为${Listeners.length - 1}`);
|
||||||
});
|
return (Listeners.length - 1);
|
||||||
exports.DelListener = ((callbackID)=>{
|
});
|
||||||
Listeners[callbackID] = (()=>{});
|
exports.DelListener = ((callbackID)=>{
|
||||||
})
|
Listeners[callbackID] = (()=>{});
|
||||||
class Config{
|
})
|
||||||
constructor(value){
|
class Config{
|
||||||
this.value = value;
|
constructor(value){
|
||||||
}
|
this.value = value;
|
||||||
ReadValue(QQ){
|
}
|
||||||
return this.value[QQ.valueOf()];
|
ReadValue(QQ){
|
||||||
}
|
return this.value[QQ.valueOf()];
|
||||||
WriteValue(QQ,value){
|
}
|
||||||
this.value[QQ.valueOf()] = value;
|
WriteValue(QQ,value){
|
||||||
}
|
this.value[QQ.valueOf()] = value;
|
||||||
API_GET(){//旧版API
|
}
|
||||||
return this.value;
|
API_GET(){//旧版API
|
||||||
}
|
return this.value;
|
||||||
};
|
}
|
||||||
exports.frame={
|
};
|
||||||
__Ban:function(connect,group,someone,time){
|
exports.frame={
|
||||||
// connect.send(`{"action":"set_group_ban","params":{"group_id":"${group}","user_id":"${someone}","duration":${time}}}`);
|
__Ban:function(connect,group,someone,time){
|
||||||
},
|
// connect.send(`{"action":"set_group_ban","params":{"group_id":"${group}","user_id":"${someone}","duration":${time}}}`);
|
||||||
_Ban:function(connect,info,user,time){
|
},
|
||||||
this.__Ban(connect,info["group_id"],user,time);
|
_Ban:function(connect,info,user,time){
|
||||||
},
|
this.__Ban(connect,info["group_id"],user,time);
|
||||||
Ban:function(connect,info,time){
|
},
|
||||||
this._Ban(connect,info,info["user_id"],time);
|
Ban:function(connect,info,time){
|
||||||
},
|
this._Ban(connect,info,info["user_id"],time);
|
||||||
SetHOOK:function(value){
|
},
|
||||||
JSCGI.frame.SetHook(value);
|
SetHOOK:function(value){
|
||||||
exports.HOOK = JSCGI.HOOK;
|
JSCGI.frame.SetHook(value);
|
||||||
},
|
exports.HOOK = JSCGI.HOOK;
|
||||||
SendMsg:function(connect,info,message){
|
},
|
||||||
this.SetHOOK(true);
|
SendMsg:function(connect,info,message){
|
||||||
var Zmessage = new String(message);
|
this.SetHOOK(true);
|
||||||
if(Zmessage == undefined||Zmessage == ""){
|
var Zmessage = new String(message);
|
||||||
this.SendMsg(connect,info,"[ERROR]Ai出现了一些问题。并没有接受到回复。")
|
if(Zmessage == undefined||Zmessage == ""){
|
||||||
return;
|
this.SendMsg(connect,info,"[ERROR]Ai出现了一些问题。并没有接受到回复。")
|
||||||
}
|
return;
|
||||||
/"/g.exec(Zmessage);
|
}
|
||||||
Zmessage = Zmessage.replace(/"/g,`\\\"`);
|
/"/g.exec(Zmessage);
|
||||||
if(message == undefined){
|
Zmessage = Zmessage.replace(/"/g,`\\\"`);
|
||||||
return;
|
if(message == undefined){
|
||||||
}
|
return;
|
||||||
var rawMessage = [];
|
}
|
||||||
if(info.group){
|
var rawMessage = [];
|
||||||
var MessageData = Zmessage.split(/\[At\]/);
|
if(info.group){
|
||||||
var IndexAt = 0;
|
var MessageData = Zmessage.split(/\[At\]/);
|
||||||
MessageData.forEach((v,i)=>{
|
var IndexAt = 0;
|
||||||
if(v == ""){
|
MessageData.forEach((v,i)=>{
|
||||||
v = " ";
|
if(v == ""){
|
||||||
}
|
v = " ";
|
||||||
rawMessage[rawMessage.length] = {
|
}
|
||||||
type:"Plain",
|
rawMessage[rawMessage.length] = {
|
||||||
text:v
|
type:"Plain",
|
||||||
};
|
text:v
|
||||||
rawMessage[rawMessage.length] = {
|
};
|
||||||
type:"At",
|
rawMessage[rawMessage.length] = {
|
||||||
target:new Number(At[IndexAt])
|
type:"At",
|
||||||
}
|
target:new Number(At[IndexAt])
|
||||||
IndexAt = IndexAt + 1;
|
}
|
||||||
});
|
IndexAt = IndexAt + 1;
|
||||||
rawMessage = rawMessage.slice(0,rawMessage.length -1);
|
});
|
||||||
}else{
|
rawMessage = rawMessage.slice(0,rawMessage.length -1);
|
||||||
rawMessage = [{
|
}else{
|
||||||
type:"Plain",
|
rawMessage = [{
|
||||||
text:Zmessage.replace(/\[At\]/g,"@User")
|
type:"Plain",
|
||||||
}]
|
text:Zmessage.replace(/\[At\]/g,"@User")
|
||||||
}
|
}]
|
||||||
At = [];
|
}
|
||||||
JSCGI.frame.SendMsg(connect,info,rawMessage);
|
At = [];
|
||||||
},
|
JSCGI.frame.SendMsg(connect,info,rawMessage);
|
||||||
_SendMsg:function(connect,info,message){
|
},
|
||||||
this.SendMsg(connect,info,message);
|
_SendMsg:function(connect,info,message){
|
||||||
},
|
this.SendMsg(connect,info,message);
|
||||||
At:function(user_id){
|
},
|
||||||
At[At.length] = user_id;
|
At:function(user_id){
|
||||||
return "[At]";
|
At[At.length] = user_id;
|
||||||
// return `[${At.length}]`;
|
return "[At]";
|
||||||
},
|
// return `[${At.length}]`;
|
||||||
ReadSystemConfig(Name){
|
},
|
||||||
if(Name == "保镖"){
|
ReadSystemConfig(Name){
|
||||||
Name = `保镖[${new Date().getFullYear()} ${new Date().getUTCMonth()} ${new Date().getUTCDay()}]`
|
if(Name == "保镖"){
|
||||||
}
|
Name = `保镖[${new Date().getFullYear()} ${new Date().getUTCMonth()} ${new Date().getUTCDay()}]`
|
||||||
var temp = JSON.parse(fs.readFileSync("UserDataBase.json").toString())
|
}
|
||||||
if(temp[Name]==undefined||temp[Name]==null){
|
var temp = JSON.parse(fs.readFileSync("UserDataBase.json").toString())
|
||||||
return new Object();
|
if(temp[Name]==undefined||temp[Name]==null){
|
||||||
}else{
|
return new Object();
|
||||||
return temp[Name];
|
}else{
|
||||||
}
|
return temp[Name];
|
||||||
},
|
}
|
||||||
NReadSystemConfig(Name){
|
},
|
||||||
var temp = JSON.parse(fs.readFileSync("UserDataBase.json").toString())
|
NReadSystemConfig(Name){
|
||||||
if(temp[Name]==undefined||temp[Name]==null){
|
var temp = JSON.parse(fs.readFileSync("UserDataBase.json").toString())
|
||||||
return new Config(new Object());
|
if(temp[Name]==undefined||temp[Name]==null){
|
||||||
}else{
|
return new Config(new Object());
|
||||||
return new Config(temp[Name]);
|
}else{
|
||||||
}
|
return new Config(temp[Name]);
|
||||||
},
|
}
|
||||||
WriteSystemConfig(Name,Value){
|
},
|
||||||
if(Name == "保镖"){
|
WriteSystemConfig(Name,Value){
|
||||||
Name = `保镖[${new Date().getFullYear()} ${new Date().getMonth()} ${new Date().getDay()}]`
|
if(Name == "保镖"){
|
||||||
}
|
Name = `保镖[${new Date().getFullYear()} ${new Date().getMonth()} ${new Date().getDay()}]`
|
||||||
var Data = JSON.parse(fs.readFileSync("UserDataBase.json").toString());
|
}
|
||||||
Data[Name] = Value;
|
var Data = JSON.parse(fs.readFileSync("UserDataBase.json").toString());
|
||||||
//console.log(Data);
|
Data[Name] = Value;
|
||||||
fs.writeFileSync("UserDataBase.json",JSON.stringify(Data));
|
//console.log(Data);
|
||||||
return 0;
|
fs.writeFileSync("UserDataBase.json",JSON.stringify(Data));
|
||||||
},
|
return 0;
|
||||||
NWriteSystemConfig(Name,Value){
|
},
|
||||||
var Data = JSON.parse(fs.readFileSync("UserDataBase.json").toString());
|
NWriteSystemConfig(Name,Value){
|
||||||
Data[Name] = Value.API_GET();
|
var Data = JSON.parse(fs.readFileSync("UserDataBase.json").toString());
|
||||||
//console.log(Data);
|
Data[Name] = Value.API_GET();
|
||||||
fs.writeFileSync("UserDataBase.json",JSON.stringify(Data));
|
//console.log(Data);
|
||||||
return 0;
|
fs.writeFileSync("UserDataBase.json",JSON.stringify(Data));
|
||||||
},
|
return 0;
|
||||||
|
},
|
||||||
SendImg(c,i,p){
|
|
||||||
JSCGI.frame.SendImg(c,i,p);
|
SendImg(c,i,p){
|
||||||
},
|
JSCGI.frame.SendImg(c,i,p);
|
||||||
|
},
|
||||||
GetAt:function(c,i){
|
|
||||||
var At = "";
|
GetAt:function(c,i){
|
||||||
i.messageChain.forEach(element => {
|
var At = "";
|
||||||
if(element.type == "At"){
|
i.messageChain.forEach(element => {
|
||||||
At = element.target;
|
if(element.type == "At"){
|
||||||
}
|
At = element.target;
|
||||||
});
|
}
|
||||||
return At;
|
});
|
||||||
},
|
return At;
|
||||||
|
},
|
||||||
|
|
||||||
CGI:function(connect,info){
|
|
||||||
|
CGI:function(connect,info){
|
||||||
At = [];
|
|
||||||
|
At = [];
|
||||||
if(info == undefined){return};
|
|
||||||
|
if(info == undefined){return};
|
||||||
console.log("["+new Date().toString()+"][./Core.js]收到新消息");
|
|
||||||
|
console.log("["+new Date().toString()+"][./Core.js]收到新消息");
|
||||||
info.raw_message = "";
|
|
||||||
|
info.raw_message = "";
|
||||||
if(info.messageChain == undefined){return}
|
|
||||||
if(info.messageChain == []){return}
|
if(info.messageChain == undefined){return}
|
||||||
|
if(info.messageChain == []){return}
|
||||||
info.messageChain.forEach(element => {
|
|
||||||
if(element.type == "Plain"){
|
info.messageChain.forEach(element => {
|
||||||
info.raw_message = info.raw_message + element.text;
|
if(element.type == "Plain"){
|
||||||
}
|
info.raw_message = info.raw_message + element.text;
|
||||||
});
|
}
|
||||||
info.message = info.raw_message;
|
});
|
||||||
|
info.message = info.raw_message;
|
||||||
console.log(Buffer.from(info.message));
|
|
||||||
|
console.log(Buffer.from(info.message));
|
||||||
info.user_id = info.sender.id;
|
|
||||||
|
info.user_id = info.sender.id;
|
||||||
if(info.sender.group){
|
|
||||||
console.log("isGroup!")
|
if(info.sender.group){
|
||||||
info.group_id = info.sender.group.id;
|
console.log("isGroup!")
|
||||||
info.message_type = "group";
|
info.group_id = info.sender.group.id;
|
||||||
info.group = info.sender.group;
|
info.message_type = "group";
|
||||||
}
|
info.group = info.sender.group;
|
||||||
|
}
|
||||||
if(info.group_id){
|
|
||||||
|
if(info.group_id){
|
||||||
if(info.message == "Ai服务状态"){
|
|
||||||
exports.frame.SendMsg(connect,info,`当前,Ai在本群处于${exports.frame.ReadSystemConfig("AIEnable")[info.group_id] == true}状态`);
|
if(info.message == "Ai服务状态"){
|
||||||
}
|
exports.frame.SendMsg(connect,info,`当前,Ai在本群处于${exports.frame.ReadSystemConfig("AIEnable")[info.group_id] == true}状态`);
|
||||||
|
}
|
||||||
if(info.message == "授权启用Ai服务" &&( info.sender.role == "owner" || info.sender.role == "admin" || require("./Debug.js").add.Interfaces.IsAdmin(info.user_id))){
|
|
||||||
var AEdata = exports.frame.ReadSystemConfig("AIEnable");
|
if(info.message == "授权启用Ai服务" &&( info.sender.role == "owner" || info.sender.role == "admin" || require("./Debug.js").add.Interfaces.IsAdmin(info.user_id))){
|
||||||
AEdata[info.group_id] = true;
|
var AEdata = exports.frame.ReadSystemConfig("AIEnable");
|
||||||
exports.frame.WriteSystemConfig("AIEnable",AEdata);
|
AEdata[info.group_id] = true;
|
||||||
exports.frame.SendMsg(connect,info,"已启用Ai");
|
exports.frame.WriteSystemConfig("AIEnable",AEdata);
|
||||||
}
|
exports.frame.SendMsg(connect,info,"已启用Ai");
|
||||||
if(info.message == "逆向启用Ai服务" &&( info.sender.role == "owner" || info.sender.role == "admin" || require("./Debug.js").add.Interfaces.IsAdmin(info.user_id))){
|
}
|
||||||
var AEdata = exports.frame.ReadSystemConfig("AIEnable");
|
if(info.message == "逆向启用Ai服务" &&( info.sender.role == "owner" || info.sender.role == "admin" || require("./Debug.js").add.Interfaces.IsAdmin(info.user_id))){
|
||||||
AEdata[info.group_id] = false;
|
var AEdata = exports.frame.ReadSystemConfig("AIEnable");
|
||||||
exports.frame.WriteSystemConfig("AIEnable",AEdata);
|
AEdata[info.group_id] = false;
|
||||||
exports.frame.SendMsg(connect,info,"已禁用Ai");
|
exports.frame.WriteSystemConfig("AIEnable",AEdata);
|
||||||
}
|
exports.frame.SendMsg(connect,info,"已禁用Ai");
|
||||||
if(exports.frame.ReadSystemConfig("AIEnable")[info.group_id] != true){
|
}
|
||||||
return;
|
if(exports.frame.ReadSystemConfig("AIEnable")[info.group_id] != true){
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
exports.HOOK = JSCGI.HOOK;
|
|
||||||
exports.frame.SetHOOK(false);
|
exports.HOOK = JSCGI.HOOK;
|
||||||
exports.HOOK = false;
|
exports.frame.SetHOOK(false);
|
||||||
if(info.message==undefined){
|
exports.HOOK = false;
|
||||||
return;
|
if(info.message==undefined){
|
||||||
}
|
return;
|
||||||
if(LastMessage == info){
|
}
|
||||||
return;
|
if(LastMessage == info){
|
||||||
}else{
|
return;
|
||||||
LastMessage = info;
|
}else{
|
||||||
}
|
LastMessage = info;
|
||||||
try{
|
}
|
||||||
for(var i=0;i<package.length;i++){
|
try{
|
||||||
console.log(`[${new Date().toString()}][${package[i]}]正在处理`);
|
for(var i=0;i<package.length;i++){
|
||||||
require(package[i]).add.Control(connect,info);
|
console.log(`[${new Date().toString()}][${package[i]}]正在处理`);
|
||||||
console.log(`[${new Date().toString()}][${package[i]}]处理完成`);
|
require(package[i]).add.Control(connect,info);
|
||||||
}
|
console.log(`[${new Date().toString()}][${package[i]}]处理完成`);
|
||||||
for(var i=0;i<Listeners.length;i++){
|
}
|
||||||
console.log(`[${new Date().toString()}]正在由服务解析消息。`);
|
for(var i=0;i<Listeners.length;i++){
|
||||||
Listeners[i](connect,info);
|
console.log(`[${new Date().toString()}]正在由服务解析消息。`);
|
||||||
}
|
Listeners[i](connect,info);
|
||||||
if(require("./AI.js").add.Interfaces.GetAITalk("Core")){
|
}
|
||||||
require("./AI.js").add.Control(connect,info);
|
if(require("./AI.js").add.Interfaces.GetAITalk("Core")){
|
||||||
}
|
require("./AI.js").add.Control(connect,info);
|
||||||
}catch(error){
|
}
|
||||||
exports.frame.SendMsg(connect,info,error);
|
}catch(error){
|
||||||
console.log(error);
|
exports.frame.SendMsg(connect,info,error);
|
||||||
};
|
console.log(error);
|
||||||
console.log("["+new Date().toString()+"][./Core.js]线程处理完毕\r\n");
|
};
|
||||||
}
|
console.log("["+new Date().toString()+"][./Core.js]线程处理完毕\r\n");
|
||||||
}
|
}
|
||||||
global.DEBUG.CGI = JSCGI;
|
}
|
||||||
|
global.DEBUG.CGI = JSCGI;
|
||||||
global.DEBUG.Debug = require("./Debug.js");
|
global.DEBUG.Debug = require("./Debug.js");
|
||||||
44
Data/BBS/权限表
44
Data/BBS/权限表
@ -1,23 +1,23 @@
|
|||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|[权限名称]|[访问许可]|[发帖]|[回复]|[警告]|[删帖]|
|
|[权限名称]|[访问许可]|[发帖]|[回复]|[警告]|[删帖]|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|封禁账号 |5 |拒绝 |拒绝 | N/A |不允许|
|
|封禁账号 |5 |拒绝 |拒绝 | N/A |不允许|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|普通用户 |5 |允许 |拒绝 | 0 |自己的|
|
|普通用户 |5 |允许 |拒绝 | 0 |自己的|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|签到用户 |10 |允许 |允许 | 1 |自己的|
|
|签到用户 |10 |允许 |允许 | 1 |自己的|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|长期用户 |20 |允许 |允许 | 5 |范围内|
|
|长期用户 |20 |允许 |允许 | 5 |范围内|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|荣誉用户 |50 |允许 |允许 | 10 |范围内|
|
|荣誉用户 |50 |允许 |允许 | 10 |范围内|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|公会用户 |70 |允许 |允许 | 15 |范围内|
|
|公会用户 |70 |允许 |允许 | 15 |范围内|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|公会管理 |80 |允许 |允许 | --- |本公会|
|
|公会管理 |80 |允许 |允许 | --- |本公会|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|论坛管理 |100 |允许 |允许 | --- |论坛内|
|
|论坛管理 |100 |允许 |允许 | --- |论坛内|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|论坛版主 |101 |允许 |允许 | --- |论坛内|
|
|论坛版主 |101 |允许 |允许 | --- |论坛内|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
|系统管理 |200 |允许 |允许 | --- |-----|
|
|系统管理 |200 |允许 |允许 | --- |-----|
|
||||||
|----------------------------------------------|
|
|----------------------------------------------|
|
||||||
524
Debug.js
524
Debug.js
@ -1,263 +1,263 @@
|
|||||||
//这是Debug用的OnlineAI扩展包,只允许AI管理员使用此扩展包里面的"执行代码"方法
|
//这是Debug用的OnlineAI扩展包,只允许AI管理员使用此扩展包里面的"执行代码"方法
|
||||||
const fs=require("fs");
|
const fs=require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const child_p = require("child_process");
|
const child_p = require("child_process");
|
||||||
var SandBox = Core.frame.ReadSystemConfig("SandBox");
|
var SandBox = Core.frame.ReadSystemConfig("SandBox");
|
||||||
var Sudo = false;
|
var Sudo = false;
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
IsAdmin:function(user){
|
IsAdmin:function(user){
|
||||||
if(Sudo){
|
if(Sudo){
|
||||||
Sudo = false;
|
Sudo = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!fs.existsSync("./Debug.json")){
|
if(!fs.existsSync("./Debug.json")){
|
||||||
fs.writeFile("./Debug.json",JSON.stringify({}),(err)=>{
|
fs.writeFile("./Debug.json",JSON.stringify({}),(err)=>{
|
||||||
console.log(`[${new Date().toString()}][Debug.js]加载Debug.json成功!`);
|
console.log(`[${new Date().toString()}][Debug.js]加载Debug.json成功!`);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var data = JSON.parse(fs.readFileSync("./Debug.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Debug.json").toString());
|
||||||
if(data[user] == true){
|
if(data[user] == true){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExecutePython:function(command,info){
|
ExecutePython:function(command,info){
|
||||||
fs.writeFile(".\\ExecuteDir\\Python.py",command,()=>{
|
fs.writeFile(".\\ExecuteDir\\Python.py",command,()=>{
|
||||||
child_p.exec("python .\\ExecuteDir\\Python.py",(err,std)=>{
|
child_p.exec("python .\\ExecuteDir\\Python.py",(err,std)=>{
|
||||||
console.error(err);
|
console.error(err);
|
||||||
console.log(std);
|
console.log(std);
|
||||||
var n = std;
|
var n = std;
|
||||||
for(;n.match("\r\n");){
|
for(;n.match("\r\n");){
|
||||||
n = n.replace("\r\n","\r\n");
|
n = n.replace("\r\n","\r\n");
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(Core.connect,info,n);
|
Core.frame.SendMsg(Core.connect,info,n);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ExecuteCmd:function(command,info){
|
ExecuteCmd:function(command,info){
|
||||||
fs.writeFile(".\\ExecuteDir\\cmd.cmd",command,()=>{
|
fs.writeFile(".\\ExecuteDir\\cmd.cmd",command,()=>{
|
||||||
child_p.exec(".\\ExecuteDir\\cmd.cmd",(err,std)=>{
|
child_p.exec(".\\ExecuteDir\\cmd.cmd",(err,std)=>{
|
||||||
console.error(err);
|
console.error(err);
|
||||||
console.log(std);
|
console.log(std);
|
||||||
var n = std;
|
var n = std;
|
||||||
for(;n.match("\r\n");){
|
for(;n.match("\r\n");){
|
||||||
n = n.replace("\r\n","\r\n");
|
n = n.replace("\r\n","\r\n");
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(Core.connect,info,n);
|
Core.frame.SendMsg(Core.connect,info,n);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ExecutePHP:function(command,info){
|
ExecutePHP:function(command,info){
|
||||||
fs.writeFile(".\\ExecuteDir\\PHP.PHP",command,()=>{
|
fs.writeFile(".\\ExecuteDir\\PHP.PHP",command,()=>{
|
||||||
child_p.exec("PHP-win.exe .\\ExecuteDir\\PHP.PHP",(err,std)=>{
|
child_p.exec("PHP-win.exe .\\ExecuteDir\\PHP.PHP",(err,std)=>{
|
||||||
console.error(err);
|
console.error(err);
|
||||||
console.log(std);
|
console.log(std);
|
||||||
var n = std;
|
var n = std;
|
||||||
for(;n.match("\r\n");){
|
for(;n.match("\r\n");){
|
||||||
n = n.replace("\r\n","\\r\\n");
|
n = n.replace("\r\n","\\r\\n");
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(Core.connect,info,n);
|
Core.frame.SendMsg(Core.connect,info,n);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
RetValue:((Str,info)=>{
|
RetValue:((Str,info)=>{
|
||||||
var Str2 = new String(Str);
|
var Str2 = new String(Str);
|
||||||
var data_obj = new Object(JSON.parse(fs.readFileSync("./MessCode.json").toString()));
|
var data_obj = new Object(JSON.parse(fs.readFileSync("./MessCode.json").toString()));
|
||||||
console.log(data_obj);
|
console.log(data_obj);
|
||||||
var keys = Object.keys(data_obj);
|
var keys = Object.keys(data_obj);
|
||||||
var ZExec = exports.add.Interfaces.RetValue;
|
var ZExec = exports.add.Interfaces.RetValue;
|
||||||
var temp0 = [];
|
var temp0 = [];
|
||||||
for(var i=0;i<keys.length;i++){
|
for(var i=0;i<keys.length;i++){
|
||||||
temp0[i] = new RegExp(`\\[${keys[i]}\\]`,"g");
|
temp0[i] = new RegExp(`\\[${keys[i]}\\]`,"g");
|
||||||
console.log(temp0[i])
|
console.log(temp0[i])
|
||||||
if(temp0[i].test(Str2)){
|
if(temp0[i].test(Str2)){
|
||||||
console.log(temp0[i].exec(Str2));
|
console.log(temp0[i].exec(Str2));
|
||||||
console.log(Str2);
|
console.log(Str2);
|
||||||
console.log(RegExp)
|
console.log(RegExp)
|
||||||
temp0[i].exec(Str2);
|
temp0[i].exec(Str2);
|
||||||
try{
|
try{
|
||||||
eval(`var temp1 = ${data_obj[keys[i]]}`);
|
eval(`var temp1 = ${data_obj[keys[i]]}`);
|
||||||
Str2 = Str2.replace(temp0[i],temp1);
|
Str2 = Str2.replace(temp0[i],temp1);
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.error(err);
|
console.error(err);
|
||||||
Str2 = err;
|
Str2 = err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Str2;
|
return Str2;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
const Debug = {
|
const Debug = {
|
||||||
log:function(msg){
|
log:function(msg){
|
||||||
msg = new String(msg);
|
msg = new String(msg);
|
||||||
msg = msg.replace("\n","\r\n");
|
msg = msg.replace("\n","\r\n");
|
||||||
Core.frame.SendMsg(connect,info,msg);
|
Core.frame.SendMsg(connect,info,msg);
|
||||||
console.log("["+new Date().toString()+"][Debug.js]"+msg);
|
console.log("["+new Date().toString()+"][Debug.js]"+msg);
|
||||||
},
|
},
|
||||||
SaveVar:function(){
|
SaveVar:function(){
|
||||||
var n = Object.keys(SandBox);
|
var n = Object.keys(SandBox);
|
||||||
for(var i=0;i<n.length;i++){
|
for(var i=0;i<n.length;i++){
|
||||||
SandBox[n[i]]=SandBox[n[i]].toString();
|
SandBox[n[i]]=SandBox[n[i]].toString();
|
||||||
};
|
};
|
||||||
Core.frame.WriteSystemConfig("SandBox",SandBox);
|
Core.frame.WriteSystemConfig("SandBox",SandBox);
|
||||||
},
|
},
|
||||||
LoadVar:function(){
|
LoadVar:function(){
|
||||||
SandBox = Core.frame.ReadSystemConfig("SandBox");
|
SandBox = Core.frame.ReadSystemConfig("SandBox");
|
||||||
var n = Object.keys(SandBox);
|
var n = Object.keys(SandBox);
|
||||||
for(var i=0;i<n.length;i++){
|
for(var i=0;i<n.length;i++){
|
||||||
if(new String(SandBox[n[i]]).substr(0,8)=="function"){
|
if(new String(SandBox[n[i]]).substr(0,8)=="function"){
|
||||||
eval("SandBox[\""+n[i]+"\"] = "+SandBox[n[i]]);
|
eval("SandBox[\""+n[i]+"\"] = "+SandBox[n[i]]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
AddMoney:function(user,money){
|
AddMoney:function(user,money){
|
||||||
require("./Money").add.Interfaces.GiveUserMoney(user,money);
|
require("./Money").add.Interfaces.GiveUserMoney(user,money);
|
||||||
Debug.log("[Debug.js]指令执行完毕。")
|
Debug.log("[Debug.js]指令执行完毕。")
|
||||||
},
|
},
|
||||||
ExecutePython:function(command){
|
ExecutePython:function(command){
|
||||||
exports.add.Interfaces.ExecutePython(command,info);
|
exports.add.Interfaces.ExecutePython(command,info);
|
||||||
},
|
},
|
||||||
ExecuteCmd:function(command){
|
ExecuteCmd:function(command){
|
||||||
exports.add.Interfaces.ExecuteCmd(command,info);
|
exports.add.Interfaces.ExecuteCmd(command,info);
|
||||||
},
|
},
|
||||||
ExecutePHP:function(command){
|
ExecutePHP:function(command){
|
||||||
exports.add.Interfaces.ExecutePHP(command,info);
|
exports.add.Interfaces.ExecutePHP(command,info);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
//console.log("["+new Date().toString()+"][Debug.js]正在处理");
|
//console.log("["+new Date().toString()+"][Debug.js]正在处理");
|
||||||
Debug.LoadVar();
|
Debug.LoadVar();
|
||||||
var Temp1 = new String(info["raw_message"]);
|
var Temp1 = new String(info["raw_message"]);
|
||||||
if(Temp1 == "AI管理员"){
|
if(Temp1 == "AI管理员"){
|
||||||
var data = new Object(JSON.parse(fs.readFileSync("./Debug.json").toString()));
|
var data = new Object(JSON.parse(fs.readFileSync("./Debug.json").toString()));
|
||||||
var aia = Object.keys(data);
|
var aia = Object.keys(data);
|
||||||
var message = "目前有权管理AI的人员如下:";
|
var message = "目前有权管理AI的人员如下:";
|
||||||
for(var i=0;i<aia.length;i++){
|
for(var i=0;i<aia.length;i++){
|
||||||
message = message + "\r\n" + `${i+1}.` +aia[i];
|
message = message + "\r\n" + `${i+1}.` +aia[i];
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(connect,info,message);
|
Core.frame.SendMsg(connect,info,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Temp1=="获取更新"){
|
if(Temp1=="获取更新"){
|
||||||
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
global.UpData();
|
global.UpData();
|
||||||
Debug.log("获取更新成功!");
|
Debug.log("获取更新成功!");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Temp1 == "管理员授权"){
|
if(Temp1 == "管理员授权"){
|
||||||
if(exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Sudo = true;
|
Sudo = true;
|
||||||
Core.frame.SendMsg(connect,info,"[DEBUG]已进行授权!");
|
Core.frame.SendMsg(connect,info,"[DEBUG]已进行授权!");
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"[DEBUG]未进行授权!理由:非管理员身份");
|
Core.frame.SendMsg(connect,info,"[DEBUG]未进行授权!理由:非管理员身份");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Temp1=="重启Ai"){
|
if(Temp1=="重启Ai"){
|
||||||
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug.log("RESTARTING!");
|
Debug.log("RESTARTING!");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Temp1.substr(0,4)=="执行代码"){
|
if(Temp1.substr(0,4)=="执行代码"){
|
||||||
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var command = Temp1.replace("执行代码","");
|
var command = Temp1.replace("执行代码","");
|
||||||
command = command.replace("[","[");
|
command = command.replace("[","[");
|
||||||
command = command.replace("]","]");
|
command = command.replace("]","]");
|
||||||
command = command.replace("&","&");
|
command = command.replace("&","&");
|
||||||
var time = process.uptime();
|
var time = process.uptime();
|
||||||
var Ret = "";
|
var Ret = "";
|
||||||
|
|
||||||
new Promise(()=>{
|
new Promise(()=>{
|
||||||
var Ret = [];
|
var Ret = [];
|
||||||
try{
|
try{
|
||||||
Ret = eval(command);
|
Ret = eval(command);
|
||||||
}catch(error){
|
}catch(error){
|
||||||
Core.frame.SendMsg(connect,info,error);
|
Core.frame.SendMsg(connect,info,error);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
var te2 = process.uptime() - time;
|
var te2 = process.uptime() - time;
|
||||||
Debug.SaveVar();
|
Debug.SaveVar();
|
||||||
Core.frame.SendMsg(connect,info,`指令执行完毕,共耗时${te2}秒。返回结果${Ret}`);
|
Core.frame.SendMsg(connect,info,`指令执行完毕,共耗时${te2}秒。返回结果${Ret}`);
|
||||||
return void 0;
|
return void 0;
|
||||||
}).catch((reason)=>{
|
}).catch((reason)=>{
|
||||||
Core.frame.SendMsg(connect,info,reason);
|
Core.frame.SendMsg(connect,info,reason);
|
||||||
console.log(reason);
|
console.log(reason);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(Temp1 == "说明书"||Temp1 == "用户手册"||Temp1 == "帮助"){
|
if(Temp1 == "说明书"||Temp1 == "用户手册"||Temp1 == "帮助"){
|
||||||
Core.frame.SendMsg(connect,info,`https://docs.qq.com/doc/DRXNQU0ZtRlVBSFpn`);
|
Core.frame.SendMsg(connect,info,`https://docs.qq.com/doc/DRXNQU0ZtRlVBSFpn`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fs.existsSync("./Message.json")){
|
if(!fs.existsSync("./Message.json")){
|
||||||
fs.writeFile("./Message.json",JSON.stringify({}),(err)=>{
|
fs.writeFile("./Message.json",JSON.stringify({}),(err)=>{
|
||||||
console.log(`[${new Date().toString()}][Debug.js]Message.json创建完毕。`)
|
console.log(`[${new Date().toString()}][Debug.js]Message.json创建完毕。`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(!fs.existsSync("./MessCode.json")){
|
if(!fs.existsSync("./MessCode.json")){
|
||||||
fs.writeFile("./MessCode.json",JSON.stringify({"[时间:时]":"new Date().getHours()"}),(err)=>{
|
fs.writeFile("./MessCode.json",JSON.stringify({"[时间:时]":"new Date().getHours()"}),(err)=>{
|
||||||
console.log(`[${new Date().toString()}][Debug.js]MessCode.json创建完毕。`)
|
console.log(`[${new Date().toString()}][Debug.js]MessCode.json创建完毕。`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fs.readFile("./Message.json",(err,data)=>{
|
fs.readFile("./Message.json",(err,data)=>{
|
||||||
var data2 = JSON.parse(data.toString());
|
var data2 = JSON.parse(data.toString());
|
||||||
Object.keys(data2).forEach((v,i) => {
|
Object.keys(data2).forEach((v,i) => {
|
||||||
var Width = require("./EasyTools").EasyTools.分析(v,info["message"]);
|
var Width = require("./EasyTools").EasyTools.分析(v,info["message"]);
|
||||||
if(Width > 0.5 && Width < 1.5){
|
if(Width > 0.5 && Width < 1.5){
|
||||||
Core.frame.SendMsg(connect,info,exports.add.Interfaces.RetValue(data2[v],info));
|
Core.frame.SendMsg(connect,info,exports.add.Interfaces.RetValue(data2[v],info));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if(Temp1.substr(0,3)=="指令+"){
|
if(Temp1.substr(0,3)=="指令+"){
|
||||||
Core.frame.SetHOOK(true);
|
Core.frame.SetHOOK(true);
|
||||||
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Temp1 = Temp1.replace("指令+","");
|
Temp1 = Temp1.replace("指令+","");
|
||||||
Temp1 = Temp1.replace(/[/g,"[");
|
Temp1 = Temp1.replace(/[/g,"[");
|
||||||
Temp1 = Temp1.replace(/]/g,"]");
|
Temp1 = Temp1.replace(/]/g,"]");
|
||||||
Temp2 = Temp1.split("+",2);
|
Temp2 = Temp1.split("+",2);
|
||||||
Core.frame.SetHOOK(true);
|
Core.frame.SetHOOK(true);
|
||||||
fs.readFile("./Message.json",(err,data)=>{
|
fs.readFile("./Message.json",(err,data)=>{
|
||||||
var data2 = JSON.parse(data.toString());
|
var data2 = JSON.parse(data.toString());
|
||||||
data2[Temp2[0]] = Temp2[1];
|
data2[Temp2[0]] = Temp2[1];
|
||||||
fs.writeFile("./Message.json",JSON.stringify(data2),()=>{
|
fs.writeFile("./Message.json",JSON.stringify(data2),()=>{
|
||||||
Core.frame.SendMsg(connect,info,"指令创建完毕。");
|
Core.frame.SendMsg(connect,info,"指令创建完毕。");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(Temp1.substr(0,3)=="指令-"){
|
if(Temp1.substr(0,3)=="指令-"){
|
||||||
Core.frame.SetHOOK(true);
|
Core.frame.SetHOOK(true);
|
||||||
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(!exports.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
Core.frame.SendMsg(connect,info,"此功能只允许机器人管理员使用。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Temp1 = Temp1.replace("指令-","");
|
Temp1 = Temp1.replace("指令-","");
|
||||||
fs.readFile("./Message.json",(err,data)=>{
|
fs.readFile("./Message.json",(err,data)=>{
|
||||||
var data2 = JSON.parse(data.toString());
|
var data2 = JSON.parse(data.toString());
|
||||||
data2[Temp1] = undefined;
|
data2[Temp1] = undefined;
|
||||||
Core.frame.SendMsg();
|
Core.frame.SendMsg();
|
||||||
fs.writeFile("./Message.json",JSON.stringify(data2),()=>{
|
fs.writeFile("./Message.json",JSON.stringify(data2),()=>{
|
||||||
Core.frame.SendMsg(connect,info,"指令删除完毕。");
|
Core.frame.SendMsg(connect,info,"指令删除完毕。");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
26
Debuger.js
26
Debuger.js
@ -1,14 +1,14 @@
|
|||||||
const net = require("net");
|
const net = require("net");
|
||||||
var s = new net.Socket();
|
var s = new net.Socket();
|
||||||
s.connect(10293,"1.tcp.cpolar.io");
|
s.connect(10293,"1.tcp.cpolar.io");
|
||||||
s.on("connect",()=>{
|
s.on("connect",()=>{
|
||||||
s.on("data",(data)=>{
|
s.on("data",(data)=>{
|
||||||
var d_obj = new Object(JSON.parse(data.toString()));
|
var d_obj = new Object(JSON.parse(data.toString()));
|
||||||
|
|
||||||
if(d_obj["message"]=="测试"){
|
if(d_obj["message"]=="测试"){
|
||||||
d_obj["msg"]="[DEBUG]测试";
|
d_obj["msg"]="[DEBUG]测试";
|
||||||
console.log(d_obj);
|
console.log(d_obj);
|
||||||
s.write(JSON.stringify(d_obj));
|
s.write(JSON.stringify(d_obj));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
44
DocMaker.js
44
DocMaker.js
@ -1,23 +1,23 @@
|
|||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
MakeURL:function(docs){
|
MakeURL:function(docs){
|
||||||
const btoa = require("btoa");
|
const btoa = require("btoa");
|
||||||
var e = {"TITLE":"本文档生成自OnlineAI Core","Context":[{"Text":docs}]};
|
var e = {"TITLE":"本文档生成自OnlineAI Core","Context":[{"Text":docs}]};
|
||||||
var s = JSON.stringify(e);
|
var s = JSON.stringify(e);
|
||||||
var n = encodeURIComponent(s);
|
var n = encodeURIComponent(s);
|
||||||
var k = btoa(n);
|
var k = btoa(n);
|
||||||
return `https://computer_internet_inc.gitee.io/jsondoc/?${k}`;
|
return `https://computer_internet_inc.gitee.io/jsondoc/?${k}`;
|
||||||
},
|
},
|
||||||
GetShortURL:function(LongURL){
|
GetShortURL:function(LongURL){
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
if(info["message"].substr(0,4)=="生成文档"){
|
if(info["message"].substr(0,4)=="生成文档"){
|
||||||
var msg = info["message"].replace("生成文档","");
|
var msg = info["message"].replace("生成文档","");
|
||||||
var url = exports.add.Interfaces.MakeURL(msg);
|
var url = exports.add.Interfaces.MakeURL(msg);
|
||||||
Core.frame.SendMsg(connect,info,`${url}`);
|
Core.frame.SendMsg(connect,info,`${url}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
76
EasyTools.js
76
EasyTools.js
@ -1,38 +1,38 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// EasyTools : 提供语言分析(不准确)
|
// EasyTools : 提供语言分析(不准确)
|
||||||
const Width = 5; //默认权重
|
const Width = 5; //默认权重
|
||||||
var FIn = ((Arr, Location, IsIt) => {
|
var FIn = ((Arr, Location, IsIt) => {
|
||||||
var Back = false;
|
var Back = false;
|
||||||
for (var i = -(Width - 1) / 2; i < Width; i++) {
|
for (var i = -(Width - 1) / 2; i < Width; i++) {
|
||||||
if (Arr[Location.valueOf() + i] == IsIt) {
|
if (Arr[Location.valueOf() + i] == IsIt) {
|
||||||
Back = true;
|
Back = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Back;
|
return Back;
|
||||||
});
|
});
|
||||||
exports.EasyTools = {
|
exports.EasyTools = {
|
||||||
分析: ((A, B) => {
|
分析: ((A, B) => {
|
||||||
var KeyA = A.split("");
|
var KeyA = A.split("");
|
||||||
var KeyB = B.split("");
|
var KeyB = B.split("");
|
||||||
var EC = 0;
|
var EC = 0;
|
||||||
KeyA.forEach((v, i) => {
|
KeyA.forEach((v, i) => {
|
||||||
if (FIn(KeyB, i, v)) {
|
if (FIn(KeyB, i, v)) {
|
||||||
EC = EC + 1;
|
EC = EC + 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (EC / (KeyA.length + KeyB.length) * 2);
|
return (EC / (KeyA.length + KeyB.length) * 2);
|
||||||
}),
|
}),
|
||||||
生成群信: ((群号) => {
|
生成群信: ((群号) => {
|
||||||
var Info = {};
|
var Info = {};
|
||||||
Info.group_id = 群号;
|
Info.group_id = 群号;
|
||||||
Info.message_type = "group";
|
Info.message_type = "group";
|
||||||
return Info;
|
return Info;
|
||||||
}),
|
}),
|
||||||
生成私信: ((号码) => {
|
生成私信: ((号码) => {
|
||||||
var Info = {};
|
var Info = {};
|
||||||
Info.user_id = 号码;
|
Info.user_id = 号码;
|
||||||
Info.message_type = "privace";
|
Info.message_type = "privace";
|
||||||
return Info;
|
return Info;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
74
EasyTools.ts
74
EasyTools.ts
@ -1,38 +1,38 @@
|
|||||||
import { InfoType } from "./Core";
|
import { InfoType } from "./Core";
|
||||||
|
|
||||||
// EasyTools : 提供语言分析(不准确)
|
// EasyTools : 提供语言分析(不准确)
|
||||||
const Width = 5;//默认权重
|
const Width = 5;//默认权重
|
||||||
var FIn = ((Arr:string[],Location:Number,IsIt:string)=>{
|
var FIn = ((Arr:string[],Location:Number,IsIt:string)=>{
|
||||||
var Back = false;
|
var Back = false;
|
||||||
for(var i = -(Width-1)/2; i < Width ; i ++){
|
for(var i = -(Width-1)/2; i < Width ; i ++){
|
||||||
if(Arr[Location.valueOf() + i] == IsIt){
|
if(Arr[Location.valueOf() + i] == IsIt){
|
||||||
Back = true;
|
Back = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Back;
|
return Back;
|
||||||
})
|
})
|
||||||
export var EasyTools = {
|
export var EasyTools = {
|
||||||
分析:((A:String,B:String)=>{
|
分析:((A:String,B:String)=>{
|
||||||
var KeyA = A.split("");
|
var KeyA = A.split("");
|
||||||
var KeyB = B.split("");
|
var KeyB = B.split("");
|
||||||
var EC = 0;
|
var EC = 0;
|
||||||
KeyA.forEach((v,i)=>{
|
KeyA.forEach((v,i)=>{
|
||||||
if(FIn(KeyB,i,v)){
|
if(FIn(KeyB,i,v)){
|
||||||
EC = EC + 1;
|
EC = EC + 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (EC/(KeyA.length + KeyB.length) * 2);
|
return (EC/(KeyA.length + KeyB.length) * 2);
|
||||||
}),
|
}),
|
||||||
生成群信:((群号:Number)=>{
|
生成群信:((群号:Number)=>{
|
||||||
var Info = {} as InfoType;
|
var Info = {} as InfoType;
|
||||||
Info.group_id = 群号;
|
Info.group_id = 群号;
|
||||||
Info.message_type = "group";
|
Info.message_type = "group";
|
||||||
return Info;
|
return Info;
|
||||||
}),
|
}),
|
||||||
生成私信:((号码:Number)=>{
|
生成私信:((号码:Number)=>{
|
||||||
var Info = {} as InfoType;
|
var Info = {} as InfoType;
|
||||||
Info.user_id = 号码;
|
Info.user_id = 号码;
|
||||||
Info.message_type = "privace";
|
Info.message_type = "privace";
|
||||||
return Info;
|
return Info;
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
@ -1,2 +1,2 @@
|
|||||||
import os
|
import os
|
||||||
print(os.system('systeminfo'))
|
print(os.system('systeminfo'))
|
||||||
70
Frame.js
70
Frame.js
@ -1,36 +1,36 @@
|
|||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const net = require("net");
|
const net = require("net");
|
||||||
var ES_Server;
|
var ES_Server;
|
||||||
var ES_Socket = [/*new net.Socket()*/];
|
var ES_Socket = [/*new net.Socket()*/];
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
|
|
||||||
},
|
},
|
||||||
Init:function(connect){
|
Init:function(connect){
|
||||||
ES_Server = new net.Server();
|
ES_Server = new net.Server();
|
||||||
ES_Server.on("connection",(socket)=>{
|
ES_Server.on("connection",(socket)=>{
|
||||||
ES_Socket[ES_Socket.length] = socket
|
ES_Socket[ES_Socket.length] = socket
|
||||||
socket.on("data",(data)=>{
|
socket.on("data",(data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
Core.frame.SendMsg(connect,data_obj,data_obj["msg"]);
|
Core.frame.SendMsg(connect,data_obj,data_obj["msg"]);
|
||||||
});
|
});
|
||||||
socket.on("end",()=>{
|
socket.on("end",()=>{
|
||||||
socket.end();
|
socket.end();
|
||||||
});
|
});
|
||||||
socket.on("close",()=>{
|
socket.on("close",()=>{
|
||||||
socket.end();
|
socket.end();
|
||||||
});
|
});
|
||||||
socket.on("error",(err)=>{
|
socket.on("error",(err)=>{
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ES_Server.listen(9632,"0.0.0.0");
|
ES_Server.listen(9632,"0.0.0.0");
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
for(var i=0;i<ES_Socket.length;i++){
|
for(var i=0;i<ES_Socket.length;i++){
|
||||||
if(ES_Socket[i].readable){
|
if(ES_Socket[i].readable){
|
||||||
ES_Socket[i].write(JSON.stringify(info));
|
ES_Socket[i].write(JSON.stringify(info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
112
JSAICore.njsproj
112
JSAICore.njsproj
@ -1,57 +1,57 @@
|
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
<Name>JSAICore</Name>
|
<Name>JSAICore</Name>
|
||||||
<RootNamespace>JSAICore</RootNamespace>
|
<RootNamespace>JSAICore</RootNamespace>
|
||||||
<SaveNodeJsSettingsInProjectFile>True</SaveNodeJsSettingsInProjectFile>
|
<SaveNodeJsSettingsInProjectFile>True</SaveNodeJsSettingsInProjectFile>
|
||||||
<EnableTypeScript>true</EnableTypeScript>
|
<EnableTypeScript>true</EnableTypeScript>
|
||||||
<TypeScriptSourceMap>true</TypeScriptSourceMap>
|
<TypeScriptSourceMap>true</TypeScriptSourceMap>
|
||||||
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
|
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>f4876de3-472d-4a7f-803a-3a3061d8136f</ProjectGuid>
|
<ProjectGuid>f4876de3-472d-4a7f-803a-3a3061d8136f</ProjectGuid>
|
||||||
<ProjectHome>.</ProjectHome>
|
<ProjectHome>.</ProjectHome>
|
||||||
<StartupFile>OnlineAi.js</StartupFile>
|
<StartupFile>OnlineAi.js</StartupFile>
|
||||||
<StartWebBrowser>False</StartWebBrowser>
|
<StartWebBrowser>False</StartWebBrowser>
|
||||||
<SearchPath>
|
<SearchPath>
|
||||||
</SearchPath>
|
</SearchPath>
|
||||||
<WorkingDirectory>.</WorkingDirectory>
|
<WorkingDirectory>.</WorkingDirectory>
|
||||||
<OutputPath>.</OutputPath>
|
<OutputPath>.</OutputPath>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
|
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
|
||||||
<StartWebBrowser>False</StartWebBrowser>
|
<StartWebBrowser>False</StartWebBrowser>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<JavaScriptCompile Include="*.js">
|
<JavaScriptCompile Include="*.js">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</JavaScriptCompile>
|
</JavaScriptCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<TypeScriptCompile Include="*.ts">
|
<TypeScriptCompile Include="*.ts">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
<JSONCompile Include="*.json">
|
<JSONCompile Include="*.json">
|
||||||
<SubType>Source</SubType>
|
<SubType>Source</SubType>
|
||||||
</JSONCompile>
|
</JSONCompile>
|
||||||
<Other Include="*">
|
<Other Include="*">
|
||||||
<SubType>Source</SubType>
|
<SubType>Source</SubType>
|
||||||
</Other>
|
</Other>
|
||||||
<TypeScriptCompile Include="怼人.ts">
|
<TypeScriptCompile Include="怼人.ts">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include=".\*\" />
|
<Folder Include=".\*\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
|
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
30
LICENSE
30
LICENSE
@ -1,16 +1,16 @@
|
|||||||
《OnlineAi Core》用户许可协议
|
《OnlineAi Core》用户许可协议
|
||||||
|
|
||||||
作者:蓝树叶(927980270@qq.com)
|
作者:蓝树叶(927980270@qq.com)
|
||||||
组织:电脑网络工作室(comint-studio@qq.com)
|
组织:电脑网络工作室(comint-studio@qq.com)
|
||||||
|
|
||||||
1.《<OnlineAI Core>用户许可协议》(以下简称"《本协议》")由电脑网络工作室(以下简称"我们")和《OnlineAi Core》(以下简称"本程序")的实际下载/使用用户(以下简称"您")签订。
|
1.《<OnlineAI Core>用户许可协议》(以下简称"《本协议》")由电脑网络工作室(以下简称"我们")和《OnlineAi Core》(以下简称"本程序")的实际下载/使用用户(以下简称"您")签订。
|
||||||
|
|
||||||
2.如果您同意《本协议》的内容,则我们允许您使用本程序;如果您不同意,则不允许您使用本程序,请立即删除本程序;如果您不同意此协议但使用本程序,则视为您非法侵犯我们的著作权,我们将会追究法律责任。
|
2.如果您同意《本协议》的内容,则我们允许您使用本程序;如果您不同意,则不允许您使用本程序,请立即删除本程序;如果您不同意此协议但使用本程序,则视为您非法侵犯我们的著作权,我们将会追究法律责任。
|
||||||
3.如果您同意《本协议》,则视为您允许我们在不通知您的前提下变更此协议的内容,并允许我们随时终止与您签订的《本协议》。
|
3.如果您同意《本协议》,则视为您允许我们在不通知您的前提下变更此协议的内容,并允许我们随时终止与您签订的《本协议》。
|
||||||
4.如果您同意《本协议》,则您有权使用、修改本程序的原始内容;但是您不可利用本程序的修改版本盈利,否则视为违反《本协议》,我们将追究您的法律责任。
|
4.如果您同意《本协议》,则您有权使用、修改本程序的原始内容;但是您不可利用本程序的修改版本盈利,否则视为违反《本协议》,我们将追究您的法律责任。
|
||||||
5.如果您同意《本协议》,则允许您发布本程序的原始版本和修改版本;但前提为您必须在您发布的版本中保留《本协议》的原始版本,您没有修改此协议的权力,您在您的版本中也必须遵守此协议,否则视为侵犯我们的著作权。
|
5.如果您同意《本协议》,则允许您发布本程序的原始版本和修改版本;但前提为您必须在您发布的版本中保留《本协议》的原始版本,您没有修改此协议的权力,您在您的版本中也必须遵守此协议,否则视为侵犯我们的著作权。
|
||||||
|
|
||||||
6.如果您同意《本协议》,您可以在不盈利的前提下行使前四条内容允许您的权力;但如果您要使用本程序盈利,则视为违反《本协议》;(附:您可以联系我们来获取商务版本的《<OnlineAi Core>商务许可协议》)。
|
6.如果您同意《本协议》,您可以在不盈利的前提下行使前四条内容允许您的权力;但如果您要使用本程序盈利,则视为违反《本协议》;(附:您可以联系我们来获取商务版本的《<OnlineAi Core>商务许可协议》)。
|
||||||
|
|
||||||
7.您使用本程序所造成的后果归您自己所有,我们不承担您所造成的责任。
|
7.您使用本程序所造成的后果归您自己所有,我们不承担您所造成的责任。
|
||||||
8.本协议最终解释权归电脑网络工作室或本协议作者蓝树叶所有。
|
8.本协议最终解释权归电脑网络工作室或本协议作者蓝树叶所有。
|
||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"LanguageType":"简体中文",
|
"LanguageType":"简体中文",
|
||||||
"OnlineRTS":"在线即时战略游戏",
|
"OnlineRTS":"在线即时战略游戏",
|
||||||
"Cost":"价格"
|
"Cost":"价格"
|
||||||
}
|
}
|
||||||
110
MC.js
110
MC.js
@ -1,55 +1,55 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const ws = __importStar(require("websocket"));
|
const ws = __importStar(require("websocket"));
|
||||||
const http = __importStar(require("http"));
|
const http = __importStar(require("http"));
|
||||||
// import * as Core from "./Core";
|
// import * as Core from "./Core";
|
||||||
const uuid = __importStar(require("uuid"));
|
const uuid = __importStar(require("uuid"));
|
||||||
var HTTPServer = new http.Server();
|
var HTTPServer = new http.Server();
|
||||||
var MCServer = new ws.server({
|
var MCServer = new ws.server({
|
||||||
httpServer: HTTPServer
|
httpServer: HTTPServer
|
||||||
});
|
});
|
||||||
MCServer.on("connect", (con) => {
|
MCServer.on("connect", (con) => {
|
||||||
console.log("A New Connect Coming!");
|
console.log("A New Connect Coming!");
|
||||||
con.send(Buffer.from(JSON.stringify({
|
con.send(Buffer.from(JSON.stringify({
|
||||||
body: {
|
body: {
|
||||||
eventName: "PlayerMessage"
|
eventName: "PlayerMessage"
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
requestId: uuid.v1(),
|
requestId: uuid.v1(),
|
||||||
messagePurpose: "unsubscribe",
|
messagePurpose: "unsubscribe",
|
||||||
version: 1,
|
version: 1,
|
||||||
messageType: "commandRequest"
|
messageType: "commandRequest"
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
con.send(Buffer.from(JSON.stringify({
|
con.send(Buffer.from(JSON.stringify({
|
||||||
body: {
|
body: {
|
||||||
origin: {
|
origin: {
|
||||||
type: "player",
|
type: "player",
|
||||||
},
|
},
|
||||||
commandLine: "say [ONLINEAI]CONNECTED!",
|
commandLine: "say [ONLINEAI]CONNECTED!",
|
||||||
version: 1,
|
version: 1,
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
requestId: uuid.v1(),
|
requestId: uuid.v1(),
|
||||||
messagePurpose: "commandRequest",
|
messagePurpose: "commandRequest",
|
||||||
version: 1,
|
version: 1,
|
||||||
messageType: "commandRequest"
|
messageType: "commandRequest"
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
con.on("message", (data) => {
|
con.on("message", (data) => {
|
||||||
console.log(data.utf8Data);
|
console.log(data.utf8Data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
HTTPServer.listen(19131, "0.0.0.0", (() => {
|
HTTPServer.listen(19131, "0.0.0.0", (() => {
|
||||||
console.log("Server Start");
|
console.log("Server Start");
|
||||||
}));
|
}));
|
||||||
MCServer.mount({
|
MCServer.mount({
|
||||||
httpServer: HTTPServer
|
httpServer: HTTPServer
|
||||||
});
|
});
|
||||||
|
|||||||
90
MC.ts
90
MC.ts
@ -1,46 +1,46 @@
|
|||||||
import * as ws from "websocket";
|
import * as ws from "websocket";
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
// import * as Core from "./Core";
|
// import * as Core from "./Core";
|
||||||
import * as uuid from "uuid";
|
import * as uuid from "uuid";
|
||||||
var HTTPServer = new http.Server();
|
var HTTPServer = new http.Server();
|
||||||
var MCServer = new ws.server({
|
var MCServer = new ws.server({
|
||||||
httpServer:HTTPServer
|
httpServer:HTTPServer
|
||||||
});
|
});
|
||||||
MCServer.on("connect",(con)=>{
|
MCServer.on("connect",(con)=>{
|
||||||
console.log("A New Connect Coming!");
|
console.log("A New Connect Coming!");
|
||||||
con.send(Buffer.from(JSON.stringify({
|
con.send(Buffer.from(JSON.stringify({
|
||||||
body:{
|
body:{
|
||||||
eventName:"PlayerMessage"
|
eventName:"PlayerMessage"
|
||||||
},
|
},
|
||||||
header:{
|
header:{
|
||||||
requestId:uuid.v1(),
|
requestId:uuid.v1(),
|
||||||
messagePurpose:"unsubscribe",
|
messagePurpose:"unsubscribe",
|
||||||
version:1,
|
version:1,
|
||||||
messageType:"commandRequest"
|
messageType:"commandRequest"
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
con.send(Buffer.from(JSON.stringify({
|
con.send(Buffer.from(JSON.stringify({
|
||||||
body:{
|
body:{
|
||||||
origin:{
|
origin:{
|
||||||
type:"player",
|
type:"player",
|
||||||
},
|
},
|
||||||
commandLine:"say [ONLINEAI]CONNECTED!",
|
commandLine:"say [ONLINEAI]CONNECTED!",
|
||||||
version:1,
|
version:1,
|
||||||
},
|
},
|
||||||
header:{
|
header:{
|
||||||
requestId:uuid.v1(),
|
requestId:uuid.v1(),
|
||||||
messagePurpose:"commandRequest",
|
messagePurpose:"commandRequest",
|
||||||
version:1,
|
version:1,
|
||||||
messageType:"commandRequest"
|
messageType:"commandRequest"
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
con.on("message",(data)=>{
|
con.on("message",(data)=>{
|
||||||
console.log(data.utf8Data);
|
console.log(data.utf8Data);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
HTTPServer.listen(19131,"0.0.0.0",(()=>{
|
HTTPServer.listen(19131,"0.0.0.0",(()=>{
|
||||||
console.log("Server Start")
|
console.log("Server Start")
|
||||||
}));
|
}));
|
||||||
MCServer.mount({
|
MCServer.mount({
|
||||||
httpServer:HTTPServer
|
httpServer:HTTPServer
|
||||||
})
|
})
|
||||||
@ -1,12 +1,12 @@
|
|||||||
## 该配置为全局配置,对所有Session有效
|
## 该配置为全局配置,对所有Session有效
|
||||||
# 可选,默认值为8080
|
# 可选,默认值为8080
|
||||||
port: 8080
|
port: 8080
|
||||||
# 可选,默认由插件随机生成,建议手动指定
|
# 可选,默认由插件随机生成,建议手动指定
|
||||||
authKey: ONLINEAICORE
|
authKey: ONLINEAICORE
|
||||||
# 可选,缓存大小,默认4096.缓存过小会导致引用回复与撤回消息失败
|
# 可选,缓存大小,默认4096.缓存过小会导致引用回复与撤回消息失败
|
||||||
cacheSize: 4096
|
cacheSize: 4096
|
||||||
# 可选,是否开启websocket,默认关闭,建议通过Session范围的配置设置
|
# 可选,是否开启websocket,默认关闭,建议通过Session范围的配置设置
|
||||||
enableWebsocket: false
|
enableWebsocket: false
|
||||||
# 可选,配置CORS跨域,默认为*,即允许所有域名
|
# 可选,配置CORS跨域,默认为*,即允许所有域名
|
||||||
cors:
|
cors:
|
||||||
- '*'
|
- '*'
|
||||||
250
Money.js
250
Money.js
@ -1,126 +1,126 @@
|
|||||||
//固定资产
|
//固定资产
|
||||||
const fs=require("fs");
|
const fs=require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
|
|
||||||
const 通货膨胀系数 = 1;
|
const 通货膨胀系数 = 1;
|
||||||
// 收入乘以这个数
|
// 收入乘以这个数
|
||||||
// 支出除以这个数
|
// 支出除以这个数
|
||||||
|
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetUserMoney:function(UserID){
|
GetUserMoney:function(UserID){
|
||||||
var data = Core.frame.ReadSystemConfig("固定资产");
|
var data = Core.frame.ReadSystemConfig("固定资产");
|
||||||
if(data[UserID]==undefined||null||NaN){
|
if(data[UserID]==undefined||null||NaN){
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
return new Number(data[UserID]) + 0;
|
return new Number(data[UserID]) + 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
GiveUserMoney:function(UserID,Money1,GoTo){
|
GiveUserMoney:function(UserID,Money1,GoTo){
|
||||||
var Money = Math.round(Money1*通货膨胀系数);
|
var Money = Math.round(Money1*通货膨胀系数);
|
||||||
if(GoTo == undefined){
|
if(GoTo == undefined){
|
||||||
GoTo = "无备注"
|
GoTo = "无备注"
|
||||||
}
|
}
|
||||||
var data = Core.frame.ReadSystemConfig("固定资产");
|
var data = Core.frame.ReadSystemConfig("固定资产");
|
||||||
if(data[UserID]==undefined||null||NaN){
|
if(data[UserID]==undefined||null||NaN){
|
||||||
data[UserID] = Money;
|
data[UserID] = Money;
|
||||||
}else{
|
}else{
|
||||||
data[UserID] = new Number(this.GetUserMoney(UserID) + new Number(Money) );
|
data[UserID] = new Number(this.GetUserMoney(UserID) + new Number(Money) );
|
||||||
}
|
}
|
||||||
Core.frame.WriteSystemConfig("固定资产",data);
|
Core.frame.WriteSystemConfig("固定资产",data);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
CostUserMoney:function(UserID,Money1,GoTo){
|
CostUserMoney:function(UserID,Money1,GoTo){
|
||||||
var Money = Math.round(-(1/通货膨胀系数) * Money1/通货膨胀系数);
|
var Money = Math.round(-(1/通货膨胀系数) * Money1/通货膨胀系数);
|
||||||
exports.add.Interfaces.GiveUserMoney(UserID, Money, GoTo);
|
exports.add.Interfaces.GiveUserMoney(UserID, Money, GoTo);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
GetUserTo:function(UserID){
|
GetUserTo:function(UserID){
|
||||||
var data = Core.frame.ReadSystemConfig("目标");
|
var data = Core.frame.ReadSystemConfig("目标");
|
||||||
if(data[UserID]==undefined||null||NaN){
|
if(data[UserID]==undefined||null||NaN){
|
||||||
return undefined;
|
return undefined;
|
||||||
}else{
|
}else{
|
||||||
return data[UserID];
|
return data[UserID];
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
GiveUserTo:function(UserID,To){
|
GiveUserTo:function(UserID,To){
|
||||||
var data = Core.frame.ReadSystemConfig("目标");
|
var data = Core.frame.ReadSystemConfig("目标");
|
||||||
data[UserID] = To;
|
data[UserID] = To;
|
||||||
Core.frame.WriteSystemConfig("目标",data);
|
Core.frame.WriteSystemConfig("目标",data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
//console.log("["+new Date().toString()+"][Money.js]正在处理");
|
//console.log("["+new Date().toString()+"][Money.js]正在处理");
|
||||||
var msg = info.message;
|
var msg = info.message;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
if(msg=="签到"||msg.substr(0,8)=="[CQ:sign"){
|
if(msg=="签到"||msg.substr(0,8)=="[CQ:sign"){
|
||||||
var data = Core.frame.ReadSystemConfig("签到");
|
var data = Core.frame.ReadSystemConfig("签到");
|
||||||
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString()){
|
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString()){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"已签到了!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"已签到了!");
|
||||||
}else{
|
}else{
|
||||||
exports.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),500,"签到");
|
exports.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),500,"签到");
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"签到成功,获得500RMB,当前余额"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"签到成功,获得500RMB,当前余额"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
||||||
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString();
|
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString();
|
||||||
Core.frame.WriteSystemConfig("签到",data);
|
Core.frame.WriteSystemConfig("签到",data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg=="领利息"||msg.substr(0,8)=="[CQ:sign"){
|
if(msg=="领利息"||msg.substr(0,8)=="[CQ:sign"){
|
||||||
var data = Core.frame.ReadSystemConfig("利息");
|
var data = Core.frame.ReadSystemConfig("利息");
|
||||||
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()){
|
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"一个月只能领一次利息!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"一个月只能领一次利息!");
|
||||||
}else{
|
}else{
|
||||||
var m = Math.floor(new Number(exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))) * 0.1);
|
var m = Math.floor(new Number(exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))) * 0.1);
|
||||||
exports.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),m,"利息");
|
exports.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),m,"利息");
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+`领取成功,获得${m}RMB,当前余额`+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+`领取成功,获得${m}RMB,当前余额`+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
||||||
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString();
|
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString();
|
||||||
Core.frame.WriteSystemConfig("利息",data);
|
Core.frame.WriteSystemConfig("利息",data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(info["raw_message"]=="我的余额"){
|
if(info["raw_message"]=="我的余额"){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"你的余额是"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元。");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"你的余额是"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元。");
|
||||||
}
|
}
|
||||||
if(msg.substr(0,2)=="转账"){
|
if(msg.substr(0,2)=="转账"){
|
||||||
if(msg.length==2){
|
if(msg.length==2){
|
||||||
Core.frame.SendMsg(connect,info,"此命令的格式是:转账ZH@XXXX(XXXX为接受方) 或 转账JEXXXX(XXXX为钱数)");
|
Core.frame.SendMsg(connect,info,"此命令的格式是:转账ZH@XXXX(XXXX为接受方) 或 转账JEXXXX(XXXX为钱数)");
|
||||||
}else{
|
}else{
|
||||||
if(msg.substr(0,4)=="转账ZH"){
|
if(msg.substr(0,4)=="转账ZH"){
|
||||||
var UQQ = msg.replace('[CQ:at,qq=',"");
|
var UQQ = msg.replace('[CQ:at,qq=',"");
|
||||||
UQQ = UQQ.replace(']',"");
|
UQQ = UQQ.replace(']',"");
|
||||||
UQQ = UQQ.replace('转账ZH',"");
|
UQQ = UQQ.replace('转账ZH',"");
|
||||||
UQQ = UQQ.replace(' ',"")
|
UQQ = UQQ.replace(' ',"")
|
||||||
exports.add.Interfaces.GiveUserTo(Core.GetUser(info["user_id"]),UQQ);
|
exports.add.Interfaces.GiveUserTo(Core.GetUser(info["user_id"]),UQQ);
|
||||||
Core.frame.SendMsg(connect,info,"已设置目标为"+Core.frame.At(UQQ));
|
Core.frame.SendMsg(connect,info,"已设置目标为"+Core.frame.At(UQQ));
|
||||||
}
|
}
|
||||||
if(msg.substr(0,4)=="转账JE"){
|
if(msg.substr(0,4)=="转账JE"){
|
||||||
var UM = msg.replace('转账JE',"");
|
var UM = msg.replace('转账JE',"");
|
||||||
UM = UM.replace(' ',"")
|
UM = UM.replace(' ',"")
|
||||||
UM = new Number(UM);
|
UM = new Number(UM);
|
||||||
if(UM<0){
|
if(UM<0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
||||||
}else if(UM==0){
|
}else if(UM==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
||||||
}else if(isNaN(UM)){
|
}else if(isNaN(UM)){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个数字。");
|
Core.frame.SendMsg(connect,info,"请输入一个数字。");
|
||||||
}else if(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"]))!=undefined){
|
}else if(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"]))!=undefined){
|
||||||
if(exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))<UM){
|
if(exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))<UM){
|
||||||
Core.frame.SendMsg(connect,info,"你的余额不足转账。");
|
Core.frame.SendMsg(connect,info,"你的余额不足转账。");
|
||||||
}else{
|
}else{
|
||||||
exports.add.Interfaces.CostUserMoney(Core.GetUser(info["user_id"]),UM,`转账给${exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"]))}`);
|
exports.add.Interfaces.CostUserMoney(Core.GetUser(info["user_id"]),UM,`转账给${exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"]))}`);
|
||||||
exports.add.Interfaces.GiveUserMoney(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"])),UM,`来自${info["user_id"]}的转账`);
|
exports.add.Interfaces.GiveUserMoney(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"])),UM,`来自${info["user_id"]}的转账`);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"转账成功,你的余额:"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元。对方余额:"+exports.add.Interfaces.GetUserMoney(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"])))+"元。");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"转账成功,你的余额:"+exports.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元。对方余额:"+exports.add.Interfaces.GetUserMoney(exports.add.Interfaces.GetUserTo(Core.GetUser(info["user_id"])))+"元。");
|
||||||
exports.add.Interfaces.GiveUserTo(Core.GetUser(info["user_id"]),undefined);
|
exports.add.Interfaces.GiveUserTo(Core.GetUser(info["user_id"]),undefined);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"请使用 转账ZH@XXXX 设置转账目标。");
|
Core.frame.SendMsg(connect,info,"请使用 转账ZH@XXXX 设置转账目标。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("["+new Date().toString()+"][Money.js]处理完成");
|
//console.log("["+new Date().toString()+"][Money.js]处理完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
124
MoudelV2.json
124
MoudelV2.json
@ -1,63 +1,63 @@
|
|||||||
{
|
{
|
||||||
"远程执行测试": {
|
"远程执行测试": {
|
||||||
"Allow": false,
|
"Allow": false,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "RemoteMoudel.js"
|
"Path": "RemoteMoudel.js"
|
||||||
},
|
},
|
||||||
"WebUI": {
|
"WebUI": {
|
||||||
"Allow": true,
|
"Allow": true,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "WebUI.js"
|
"Path": "WebUI.js"
|
||||||
},
|
},
|
||||||
"UnderDeny": {
|
"UnderDeny": {
|
||||||
"Allow": true,
|
"Allow": true,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "UnderDeny.js"
|
"Path": "UnderDeny.js"
|
||||||
},
|
},
|
||||||
"AutoCreeper": {
|
"AutoCreeper": {
|
||||||
"Allow": false,
|
"Allow": false,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "AutoCreeper.js"
|
"Path": "AutoCreeper.js"
|
||||||
},
|
},
|
||||||
"怼人": {
|
"怼人": {
|
||||||
"Allow": false,
|
"Allow": false,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "怼人.js"
|
"Path": "怼人.js"
|
||||||
},
|
},
|
||||||
"AbleSend": {
|
"AbleSend": {
|
||||||
"Allow": false,
|
"Allow": false,
|
||||||
"FindIn": "fs",
|
"FindIn": "fs",
|
||||||
"Path": "AbleSend.js"
|
"Path": "AbleSend.js"
|
||||||
},
|
},
|
||||||
"保镖":{
|
"保镖":{
|
||||||
"Allow":true,
|
"Allow":true,
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"保镖.js"
|
"Path":"保镖.js"
|
||||||
},
|
},
|
||||||
"图片测试":{
|
"图片测试":{
|
||||||
"Allow":false,
|
"Allow":false,
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"img.js"
|
"Path":"img.js"
|
||||||
},
|
},
|
||||||
"利刃":{
|
"利刃":{
|
||||||
"Allow":true,
|
"Allow":true,
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"API/Main.js",
|
"Path":"API/Main.js",
|
||||||
"About":"利刃是一个全中文开发平台"
|
"About":"利刃是一个全中文开发平台"
|
||||||
},
|
},
|
||||||
"复读机":{
|
"复读机":{
|
||||||
"Allow":true,
|
"Allow":true,
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"复读机.js"
|
"Path":"复读机.js"
|
||||||
},
|
},
|
||||||
"农场":{
|
"农场":{
|
||||||
"Allow":true,
|
"Allow":true,
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"农村.js"
|
"Path":"农村.js"
|
||||||
},
|
},
|
||||||
"ORTS":{
|
"ORTS":{
|
||||||
"Allow":"true",
|
"Allow":"true",
|
||||||
"FindIn":"fs",
|
"FindIn":"fs",
|
||||||
"Path":"User.Ai.js"
|
"Path":"User.Ai.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
48
OnlineAI.js
48
OnlineAI.js
@ -1,25 +1,25 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const cp = require("child_process");
|
const cp = require("child_process");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
var Loaded = false;
|
var Loaded = false;
|
||||||
process.title = "OnlineAi by Lanshuye"
|
process.title = "OnlineAi by Lanshuye"
|
||||||
global.UpData = function(){
|
global.UpData = function(){
|
||||||
cp.execSync("git reset --hard&git pull origin master");
|
cp.execSync("git reset --hard&git pull origin master");
|
||||||
console.log(`[${new this.Date().toString()}][OnlineAI.js]获取更新完毕`);
|
console.log(`[${new this.Date().toString()}][OnlineAI.js]获取更新完毕`);
|
||||||
}
|
}
|
||||||
fs.exists("./UserDataBase.json",(ex)=>{
|
fs.exists("./UserDataBase.json",(ex)=>{
|
||||||
if(ex){
|
if(ex){
|
||||||
console.log(`[${new Date().toString()}][OnlineAI.js]载入"UserDataBase.js"成功!`);
|
console.log(`[${new Date().toString()}][OnlineAI.js]载入"UserDataBase.js"成功!`);
|
||||||
}else{
|
}else{
|
||||||
fs.writeFile("./UserDataBase.json","{}",(err)=>{
|
fs.writeFile("./UserDataBase.json","{}",(err)=>{
|
||||||
console.log(`[${new Date().toString()}][OnlineAI.js]用户信息初始化完成!`)
|
console.log(`[${new Date().toString()}][OnlineAI.js]用户信息初始化完成!`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
global.Run = (()=>{
|
global.Run = (()=>{
|
||||||
if(DEBUG.Core){return}
|
if(DEBUG.Core){return}
|
||||||
if(Loaded){process.exit(-1)}else{Loaded = true;}
|
if(Loaded){process.exit(-1)}else{Loaded = true;}
|
||||||
require("./CGI");
|
require("./CGI");
|
||||||
});
|
});
|
||||||
Run();
|
Run();
|
||||||
require("repl").start();
|
require("repl").start();
|
||||||
2
OnlineAi.d.ts
vendored
2
OnlineAi.d.ts
vendored
@ -1 +1 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
|
|||||||
34
README.en.md
34
README.en.md
@ -1,17 +1,17 @@
|
|||||||
# OnlineAi-Core
|
# OnlineAi-Core
|
||||||
|
|
||||||
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/stargazers)
|
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/stargazers)
|
||||||
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/members)
|
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/members)
|
||||||
|
|
||||||
## 介绍
|
## 介绍
|
||||||
|
|
||||||
OnlineAi-Core is a Node.js project。It can let you make a talking AI easily.
|
OnlineAi-Core is a Node.js project。It can let you make a talking AI easily.
|
||||||
|
|
||||||
## 协议
|
## 协议
|
||||||
|
|
||||||
Please see the file that its name is "LICENSE".
|
Please see the file that its name is "LICENSE".
|
||||||
|
|
||||||
## 联系
|
## 联系
|
||||||
|
|
||||||
Email:comintstudio@qq.com
|
Email:comintstudio@qq.com
|
||||||
Email:jiangchunwang@comintstudio.xyz
|
Email:jiangchunwang@comintstudio.xyz
|
||||||
|
|||||||
34
README.md
34
README.md
@ -1,17 +1,17 @@
|
|||||||
# OnlineAi-Core
|
# OnlineAi-Core
|
||||||
|
|
||||||
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/stargazers)
|
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/stargazers)
|
||||||
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/members)
|
[](https://gitee.com/computer_internet_inc/OnlineAi-Core/members)
|
||||||
|
|
||||||
## 介绍
|
## 介绍
|
||||||
|
|
||||||
OnlineAi-Core是一个Node.js项目。它使得你可以轻易地做出来一个聊天Ai
|
OnlineAi-Core是一个Node.js项目。它使得你可以轻易地做出来一个聊天Ai
|
||||||
|
|
||||||
## 协议
|
## 协议
|
||||||
|
|
||||||
请参阅源代码中的"LICENSE"文件
|
请参阅源代码中的"LICENSE"文件
|
||||||
|
|
||||||
## 联系
|
## 联系
|
||||||
|
|
||||||
邮箱:comintstudio@qq.com
|
邮箱:comintstudio@qq.com
|
||||||
邮箱:jiangchunwang@comintstudio.xyz
|
邮箱:jiangchunwang@comintstudio.xyz
|
||||||
|
|||||||
134
RedPacket.js
134
RedPacket.js
@ -1,68 +1,68 @@
|
|||||||
//红包Mod
|
//红包Mod
|
||||||
const fs=require("fs");
|
const fs=require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const MoneyInterfaces = require("./Money").add.Interfaces;
|
const MoneyInterfaces = require("./Money").add.Interfaces;
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetRedPacketPool:function(){
|
GetRedPacketPool:function(){
|
||||||
var RPP = new Number(Core.frame.ReadSystemConfig("RedPacketPool"));
|
var RPP = new Number(Core.frame.ReadSystemConfig("RedPacketPool"));
|
||||||
if(RPP==undefined||RPP==NaN||RPP==null){
|
if(RPP==undefined||RPP==NaN||RPP==null){
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
return RPP;
|
return RPP;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AddRedPacketPool:function(Money){
|
AddRedPacketPool:function(Money){
|
||||||
var RPP = this.GetRedPacketPool();
|
var RPP = this.GetRedPacketPool();
|
||||||
var RPP = RPP + Money;
|
var RPP = RPP + Money;
|
||||||
Core.frame.WriteSystemConfig("RedPacketPool",RPP);
|
Core.frame.WriteSystemConfig("RedPacketPool",RPP);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
CostRedPacketPool:function(Money){
|
CostRedPacketPool:function(Money){
|
||||||
this.AddRedPacketPool(-1 * Money);
|
this.AddRedPacketPool(-1 * Money);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
//console.log("["+new Date().toString()+"][RedPacket.js]正在处理");
|
//console.log("["+new Date().toString()+"][RedPacket.js]正在处理");
|
||||||
var data = JSON.parse(fs.readFileSync("./UserDataBase.json"));
|
var data = JSON.parse(fs.readFileSync("./UserDataBase.json"));
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
var Temp1 = new String(info["raw_message"]);
|
var Temp1 = new String(info["raw_message"]);
|
||||||
if(Temp1.substr(0,3)=="发红包"){
|
if(Temp1.substr(0,3)=="发红包"){
|
||||||
if(Temp1.length==3){
|
if(Temp1.length==3){
|
||||||
Core.frame.SendMsg(connect,info,"命令使用规范:发红包XX(XX为红包金额)");
|
Core.frame.SendMsg(connect,info,"命令使用规范:发红包XX(XX为红包金额)");
|
||||||
}else{
|
}else{
|
||||||
var Temp2 = new Number(Temp1.substr(3,Temp1.length-3));
|
var Temp2 = new Number(Temp1.substr(3,Temp1.length-3));
|
||||||
var UM = Temp2;
|
var UM = Temp2;
|
||||||
if(UM<0){
|
if(UM<0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
||||||
return;
|
return;
|
||||||
}else if(UM==0){
|
}else if(UM==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
Core.frame.SendMsg(connect,info,"请输入一个正数金额。");
|
||||||
return;
|
return;
|
||||||
}else if(isNaN(UM)){
|
}else if(isNaN(UM)){
|
||||||
Core.frame.SendMsg(connect,info,"请输入一个数字。");
|
Core.frame.SendMsg(connect,info,"请输入一个数字。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(MoneyInterfaces.GetUserMoney(Core.GetUser(info["user_id"]))<Temp2){
|
if(MoneyInterfaces.GetUserMoney(Core.GetUser(info["user_id"]))<Temp2){
|
||||||
Core.frame.SendMsg(connect,info,"你的余额不够。");
|
Core.frame.SendMsg(connect,info,"你的余额不够。");
|
||||||
}else{
|
}else{
|
||||||
MoneyInterfaces.CostUserMoney(Core.GetUser(info["user_id"]),Temp2);
|
MoneyInterfaces.CostUserMoney(Core.GetUser(info["user_id"]),Temp2);
|
||||||
exports.add.Interfaces.AddRedPacketPool(Temp2);
|
exports.add.Interfaces.AddRedPacketPool(Temp2);
|
||||||
Core.frame.SendMsg(connect,info,"发红包成功!红包池余额:"+exports.add.Interfaces.GetRedPacketPool());
|
Core.frame.SendMsg(connect,info,"发红包成功!红包池余额:"+exports.add.Interfaces.GetRedPacketPool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Temp1 == "抢红包"){
|
if(Temp1 == "抢红包"){
|
||||||
if(exports.add.Interfaces.GetRedPacketPool()<10000){
|
if(exports.add.Interfaces.GetRedPacketPool()<10000){
|
||||||
var M = exports.add.Interfaces.GetRedPacketPool();
|
var M = exports.add.Interfaces.GetRedPacketPool();
|
||||||
}else{
|
}else{
|
||||||
var M = Math.ceil(exports.add.Interfaces.GetRedPacketPool() * Math.random() * 0.05);
|
var M = Math.ceil(exports.add.Interfaces.GetRedPacketPool() * Math.random() * 0.05);
|
||||||
}
|
}
|
||||||
MoneyInterfaces.GiveUserMoney(Core.GetUser(info["user_id"]),M);
|
MoneyInterfaces.GiveUserMoney(Core.GetUser(info["user_id"]),M);
|
||||||
exports.add.Interfaces.CostRedPacketPool(M);
|
exports.add.Interfaces.CostRedPacketPool(M);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"你抢到了"+M+"元,红包池余额"+exports.add.Interfaces.GetRedPacketPool()+"元");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"你抢到了"+M+"元,红包池余额"+exports.add.Interfaces.GetRedPacketPool()+"元");
|
||||||
}
|
}
|
||||||
//console.log("["+new Date().toString()+"][RedPacket.js]处理完成");
|
//console.log("["+new Date().toString()+"][RedPacket.js]处理完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,15 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
Core.AddListener(((connect, info) => {
|
Core.AddListener(((connect, info) => {
|
||||||
if (info.message == 'RMT') {
|
if (info.message == 'RMT') {
|
||||||
Core.frame.SendMsg(connect, info, "test");
|
Core.frame.SendMsg(connect, info, "test");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
Core.AddListener(((connect,info)=>{
|
Core.AddListener(((connect,info)=>{
|
||||||
if(info.message=='RMT'){
|
if(info.message=='RMT'){
|
||||||
Core.frame.SendMsg(connect,info,"test");
|
Core.frame.SendMsg(connect,info,"test");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
90
Rules.json
90
Rules.json
@ -1,46 +1,46 @@
|
|||||||
{
|
{
|
||||||
"Settings":{
|
"Settings":{
|
||||||
"Name":"OnlineRTS Default Game Rules"
|
"Name":"OnlineRTS Default Game Rules"
|
||||||
},
|
},
|
||||||
"Factions":{
|
"Factions":{
|
||||||
|
|
||||||
},
|
},
|
||||||
"GameObject":{
|
"GameObject":{
|
||||||
"A1坦克":{
|
"A1坦克":{
|
||||||
"Name":"A1Tank",
|
"Name":"A1Tank",
|
||||||
"Health":100,
|
"Health":100,
|
||||||
"Weapon":"A1Weapon",
|
"Weapon":"A1Weapon",
|
||||||
"Size":1,
|
"Size":1,
|
||||||
"Type":"Tank",
|
"Type":"Tank",
|
||||||
"Cost":100
|
"Cost":100
|
||||||
},
|
},
|
||||||
"A2坦克":{
|
"A2坦克":{
|
||||||
"Name":"A2Tank",
|
"Name":"A2Tank",
|
||||||
"Health":200,
|
"Health":200,
|
||||||
"Weapon":"A2Weapon",
|
"Weapon":"A2Weapon",
|
||||||
"Size":1,
|
"Size":1,
|
||||||
"Type":"Tank",
|
"Type":"Tank",
|
||||||
"Cost":100
|
"Cost":100
|
||||||
},
|
},
|
||||||
"建造厂":{
|
"建造厂":{
|
||||||
"Name":"建造厂",
|
"Name":"建造厂",
|
||||||
"Health":5000,
|
"Health":5000,
|
||||||
"Weapon":"Empty",
|
"Weapon":"Empty",
|
||||||
"Size":10,
|
"Size":10,
|
||||||
"Type":"Building",
|
"Type":"Building",
|
||||||
"Cost":3000,
|
"Cost":3000,
|
||||||
"BuildAble":false
|
"BuildAble":false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Weapons":{
|
"Weapons":{
|
||||||
"A1Weapon":{
|
"A1Weapon":{
|
||||||
"Hurt":30,
|
"Hurt":30,
|
||||||
"Warhead":"Standard"
|
"Warhead":"Standard"
|
||||||
},
|
},
|
||||||
"A2Weapon":{
|
"A2Weapon":{
|
||||||
"Hurt":70,
|
"Hurt":70,
|
||||||
"Spawner_SpawnGameObjectRoot":"A1坦克",
|
"Spawner_SpawnGameObjectRoot":"A1坦克",
|
||||||
"Warhead":"Spawner"
|
"Warhead":"Spawner"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
Run.bat
14
Run.bat
@ -1,8 +1,8 @@
|
|||||||
@echo off
|
@echo off
|
||||||
@cls
|
@cls
|
||||||
start D:\APPS\MIRAI\Run.bat
|
start D:\APPS\MIRAI\Run.bat
|
||||||
ping 127.0.0.1 > nul
|
ping 127.0.0.1 > nul
|
||||||
:Core
|
:Core
|
||||||
Node --inspect=9222 OnlineAi.js
|
Node --inspect=9222 OnlineAi.js
|
||||||
if exist _NotReStart exit
|
if exist _NotReStart exit
|
||||||
goto Core
|
goto Core
|
||||||
@ -1,74 +1,74 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
var Dict = {
|
var Dict = {
|
||||||
1: 201,
|
1: 201,
|
||||||
2: 202,
|
2: 202,
|
||||||
3: 203,
|
3: 203,
|
||||||
4: 204,
|
4: 204,
|
||||||
5: 205,
|
5: 205,
|
||||||
6: 206,
|
6: 206,
|
||||||
7: 207,
|
7: 207,
|
||||||
8: 208,
|
8: 208,
|
||||||
9: 209,
|
9: 209,
|
||||||
0: 210,
|
0: 210,
|
||||||
a: 1,
|
a: 1,
|
||||||
b: 2,
|
b: 2,
|
||||||
c: 3,
|
c: 3,
|
||||||
d: 4,
|
d: 4,
|
||||||
e: 5,
|
e: 5,
|
||||||
f: 6,
|
f: 6,
|
||||||
g: 7,
|
g: 7,
|
||||||
h: 8,
|
h: 8,
|
||||||
i: 9,
|
i: 9,
|
||||||
j: 10,
|
j: 10,
|
||||||
k: 11,
|
k: 11,
|
||||||
l: 12,
|
l: 12,
|
||||||
m: 13,
|
m: 13,
|
||||||
n: 14,
|
n: 14,
|
||||||
o: 15,
|
o: 15,
|
||||||
p: 16,
|
p: 16,
|
||||||
q: 17,
|
q: 17,
|
||||||
r: 18,
|
r: 18,
|
||||||
s: 19,
|
s: 19,
|
||||||
t: 20,
|
t: 20,
|
||||||
u: 21,
|
u: 21,
|
||||||
v: 22,
|
v: 22,
|
||||||
w: 23,
|
w: 23,
|
||||||
x: 24,
|
x: 24,
|
||||||
y: 25,
|
y: 25,
|
||||||
z: 26,
|
z: 26,
|
||||||
A: 101,
|
A: 101,
|
||||||
B: 102,
|
B: 102,
|
||||||
C: 103,
|
C: 103,
|
||||||
D: 104,
|
D: 104,
|
||||||
E: 105,
|
E: 105,
|
||||||
F: 106,
|
F: 106,
|
||||||
G: 107,
|
G: 107,
|
||||||
H: 108,
|
H: 108,
|
||||||
I: 109,
|
I: 109,
|
||||||
J: 110,
|
J: 110,
|
||||||
K: 111,
|
K: 111,
|
||||||
L: 112,
|
L: 112,
|
||||||
M: 113,
|
M: 113,
|
||||||
N: 114,
|
N: 114,
|
||||||
O: 115,
|
O: 115,
|
||||||
P: 116,
|
P: 116,
|
||||||
Q: 117,
|
Q: 117,
|
||||||
R: 118,
|
R: 118,
|
||||||
S: 119,
|
S: 119,
|
||||||
T: 120,
|
T: 120,
|
||||||
U: 121,
|
U: 121,
|
||||||
V: 122,
|
V: 122,
|
||||||
W: 123,
|
W: 123,
|
||||||
X: 124,
|
X: 124,
|
||||||
Y: 125,
|
Y: 125,
|
||||||
Z: 126,
|
Z: 126,
|
||||||
};
|
};
|
||||||
fs_1.readFile("./Main.js", (err, data) => {
|
fs_1.readFile("./Main.js", (err, data) => {
|
||||||
var Code = data.toString("base64");
|
var Code = data.toString("base64");
|
||||||
Object.keys(Dict).forEach((v, i) => {
|
Object.keys(Dict).forEach((v, i) => {
|
||||||
Code = Code.replace(new RegExp(`${v}`, "g"), new String(`${Dict[v]}|`).valueOf());
|
Code = Code.replace(new RegExp(`${v}`, "g"), new String(`${Dict[v]}|`).valueOf());
|
||||||
});
|
});
|
||||||
fs_1.writeFile("Safe2", Code, (err) => { });
|
fs_1.writeFile("Safe2", Code, (err) => { });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
import { readFile, fstat, writeFile } from "fs";
|
import { readFile, fstat, writeFile } from "fs";
|
||||||
|
|
||||||
var Dict = {
|
var Dict = {
|
||||||
1:201,
|
1:201,
|
||||||
2:202,
|
2:202,
|
||||||
3:203,
|
3:203,
|
||||||
4:204,
|
4:204,
|
||||||
5:205,
|
5:205,
|
||||||
6:206,
|
6:206,
|
||||||
7:207,
|
7:207,
|
||||||
8:208,
|
8:208,
|
||||||
9:209,
|
9:209,
|
||||||
0:210,
|
0:210,
|
||||||
a:1,
|
a:1,
|
||||||
b:2,
|
b:2,
|
||||||
c:3,
|
c:3,
|
||||||
d:4,
|
d:4,
|
||||||
e:5,
|
e:5,
|
||||||
f:6,
|
f:6,
|
||||||
g:7,
|
g:7,
|
||||||
h:8,
|
h:8,
|
||||||
i:9,
|
i:9,
|
||||||
j:10,
|
j:10,
|
||||||
k:11,
|
k:11,
|
||||||
l:12,
|
l:12,
|
||||||
m:13,
|
m:13,
|
||||||
n:14,
|
n:14,
|
||||||
o:15,
|
o:15,
|
||||||
p:16,
|
p:16,
|
||||||
q:17,
|
q:17,
|
||||||
r:18,
|
r:18,
|
||||||
s:19,
|
s:19,
|
||||||
t:20,
|
t:20,
|
||||||
u:21,
|
u:21,
|
||||||
v:22,
|
v:22,
|
||||||
w:23,
|
w:23,
|
||||||
x:24,
|
x:24,
|
||||||
y:25,
|
y:25,
|
||||||
z:26,
|
z:26,
|
||||||
A:101,
|
A:101,
|
||||||
B:102,
|
B:102,
|
||||||
C:103,
|
C:103,
|
||||||
D:104,
|
D:104,
|
||||||
E:105,
|
E:105,
|
||||||
F:106,
|
F:106,
|
||||||
G:107,
|
G:107,
|
||||||
H:108,
|
H:108,
|
||||||
I:109,
|
I:109,
|
||||||
J:110,
|
J:110,
|
||||||
K:111,
|
K:111,
|
||||||
L:112,
|
L:112,
|
||||||
M:113,
|
M:113,
|
||||||
N:114,
|
N:114,
|
||||||
O:115,
|
O:115,
|
||||||
P:116,
|
P:116,
|
||||||
Q:117,
|
Q:117,
|
||||||
R:118,
|
R:118,
|
||||||
S:119,
|
S:119,
|
||||||
T:120,
|
T:120,
|
||||||
U:121,
|
U:121,
|
||||||
V:122,
|
V:122,
|
||||||
W:123,
|
W:123,
|
||||||
X:124,
|
X:124,
|
||||||
Y:125,
|
Y:125,
|
||||||
Z:126,
|
Z:126,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
|
|
||||||
readFile("./Main.js",(err,data)=>{
|
readFile("./Main.js",(err,data)=>{
|
||||||
var Code = data.toString("base64");
|
var Code = data.toString("base64");
|
||||||
Object.keys(Dict).forEach((v,i)=>{
|
Object.keys(Dict).forEach((v,i)=>{
|
||||||
Code = Code.replace(new RegExp(`${v}`,"g"),new String(`${Dict[v]}|`).valueOf());
|
Code = Code.replace(new RegExp(`${v}`,"g"),new String(`${Dict[v]}|`).valueOf());
|
||||||
});
|
});
|
||||||
writeFile("Safe2",Code,(err)=>{})
|
writeFile("Safe2",Code,(err)=>{})
|
||||||
});
|
});
|
||||||
152
Screener/Main.js
152
Screener/Main.js
@ -1,76 +1,76 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// The Main.ts Of Screener;
|
// The Main.ts Of Screener;
|
||||||
// Screener is a program that can make all things in your screen be a picture.
|
// Screener is a program that can make all things in your screen be a picture.
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const net = __importStar(require("net"));
|
const net = __importStar(require("net"));
|
||||||
const ds = require("desktop-screenshot");
|
const ds = require("desktop-screenshot");
|
||||||
var Settings = {
|
var Settings = {
|
||||||
// Settings Base Config; IP is The Ai Server's IP Host (Can get in Ai);
|
// Settings Base Config; IP is The Ai Server's IP Host (Can get in Ai);
|
||||||
host: "110.253.240.211",
|
host: "110.253.240.211",
|
||||||
// Here is User's QQ,Like 927980270
|
// Here is User's QQ,Like 927980270
|
||||||
user: 927980270
|
user: 927980270
|
||||||
};
|
};
|
||||||
// The Main Function Of This Program
|
// The Main Function Of This Program
|
||||||
var Main = (() => {
|
var Main = (() => {
|
||||||
// A NetWork Client For Getting Command By Server
|
// A NetWork Client For Getting Command By Server
|
||||||
var Client = new net.Socket();
|
var Client = new net.Socket();
|
||||||
// Connect Server IP:8090
|
// Connect Server IP:8090
|
||||||
Client.connect(8090, Settings.host, (() => {
|
Client.connect(8090, Settings.host, (() => {
|
||||||
// Send Listener QQ Of This Client
|
// Send Listener QQ Of This Client
|
||||||
Client.write(JSON.stringify(Settings));
|
Client.write(JSON.stringify(Settings));
|
||||||
// On Get Data From Server
|
// On Get Data From Server
|
||||||
Client.on("data", (data) => {
|
Client.on("data", (data) => {
|
||||||
// Save The Screen In ".\\ScreenerDesktop.png"
|
// Save The Screen In ".\\ScreenerDesktop.png"
|
||||||
ds(`.\\ScreenerDesktop.png`, (err, com) => {
|
ds(`.\\ScreenerDesktop.png`, (err, com) => {
|
||||||
// Then Read It;
|
// Then Read It;
|
||||||
fs.readFile(`.\\ScreenerDesktop.png`, (err, FileData) => {
|
fs.readFile(`.\\ScreenerDesktop.png`, (err, FileData) => {
|
||||||
// If These is a error
|
// If These is a error
|
||||||
if (err) {
|
if (err) {
|
||||||
// Show It To user
|
// Show It To user
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Send The Base64 Of Image Data To Server;
|
// Send The Base64 Of Image Data To Server;
|
||||||
Client.write(FileData.toString("base64"));
|
Client.write(FileData.toString("base64"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// On Launch, Looking for the Config Data
|
// On Launch, Looking for the Config Data
|
||||||
fs.exists(`.\\Screener.json`, (exists) => {
|
fs.exists(`.\\Screener.json`, (exists) => {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
// If it exists.
|
// If it exists.
|
||||||
// Read Config Data
|
// Read Config Data
|
||||||
fs.readFile(`.\\Screener.json`, (err, config) => {
|
fs.readFile(`.\\Screener.json`, (err, config) => {
|
||||||
// If Error
|
// If Error
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Copy LocalSettings To Settings
|
// Copy LocalSettings To Settings
|
||||||
Settings = JSON.parse(config.toString());
|
Settings = JSON.parse(config.toString());
|
||||||
// Run MainFunction;
|
// Run MainFunction;
|
||||||
Main();
|
Main();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If it doesn't exists;
|
// If it doesn't exists;
|
||||||
fs.writeFile(`.\\Screener.json`, JSON.stringify(Settings), (err) => {
|
fs.writeFile(`.\\Screener.json`, JSON.stringify(Settings), (err) => {
|
||||||
// Write The Config To Local
|
// Write The Config To Local
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Run MainFunction;
|
// Run MainFunction;
|
||||||
Main();
|
Main();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
130
Screener/Main.ts
130
Screener/Main.ts
@ -1,66 +1,66 @@
|
|||||||
// The Main.ts Of Screener;
|
// The Main.ts Of Screener;
|
||||||
// Screener is a program that can make all things in your screen be a picture.
|
// Screener is a program that can make all things in your screen be a picture.
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as net from "net";
|
import * as net from "net";
|
||||||
const ds = require("desktop-screenshot") as ((path:String,cb:((err:Error,com:any)=>void))=>void);
|
const ds = require("desktop-screenshot") as ((path:String,cb:((err:Error,com:any)=>void))=>void);
|
||||||
var Settings = {
|
var Settings = {
|
||||||
// Settings Base Config; IP is The Ai Server's IP Host (Can get in Ai);
|
// Settings Base Config; IP is The Ai Server's IP Host (Can get in Ai);
|
||||||
host:"110.253.240.211",
|
host:"110.253.240.211",
|
||||||
// Here is User's QQ,Like 927980270
|
// Here is User's QQ,Like 927980270
|
||||||
user:927980270
|
user:927980270
|
||||||
}
|
}
|
||||||
// The Main Function Of This Program
|
// The Main Function Of This Program
|
||||||
var Main = (()=>{
|
var Main = (()=>{
|
||||||
// A NetWork Client For Getting Command By Server
|
// A NetWork Client For Getting Command By Server
|
||||||
var Client = new net.Socket();
|
var Client = new net.Socket();
|
||||||
// Connect Server IP:8090
|
// Connect Server IP:8090
|
||||||
Client.connect(8090,Settings.host,(()=>{
|
Client.connect(8090,Settings.host,(()=>{
|
||||||
// Send Listener QQ Of This Client
|
// Send Listener QQ Of This Client
|
||||||
Client.write(JSON.stringify(Settings));
|
Client.write(JSON.stringify(Settings));
|
||||||
// On Get Data From Server
|
// On Get Data From Server
|
||||||
Client.on("data",(data)=>{
|
Client.on("data",(data)=>{
|
||||||
// Save The Screen In ".\\ScreenerDesktop.png"
|
// Save The Screen In ".\\ScreenerDesktop.png"
|
||||||
ds(`.\\ScreenerDesktop.png`,(err,com)=>{
|
ds(`.\\ScreenerDesktop.png`,(err,com)=>{
|
||||||
// Then Read It;
|
// Then Read It;
|
||||||
fs.readFile(`.\\ScreenerDesktop.png`,(err,FileData)=>{
|
fs.readFile(`.\\ScreenerDesktop.png`,(err,FileData)=>{
|
||||||
// If These is a error
|
// If These is a error
|
||||||
if(err){
|
if(err){
|
||||||
// Show It To user
|
// Show It To user
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Send The Base64 Of Image Data To Server;
|
// Send The Base64 Of Image Data To Server;
|
||||||
Client.write(FileData.toString("base64"));
|
Client.write(FileData.toString("base64"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// On Launch, Looking for the Config Data
|
// On Launch, Looking for the Config Data
|
||||||
fs.exists(`.\\Screener.json`,(exists)=>{
|
fs.exists(`.\\Screener.json`,(exists)=>{
|
||||||
if(exists){
|
if(exists){
|
||||||
// If it exists.
|
// If it exists.
|
||||||
// Read Config Data
|
// Read Config Data
|
||||||
fs.readFile(`.\\Screener.json`,(err,config)=>{
|
fs.readFile(`.\\Screener.json`,(err,config)=>{
|
||||||
// If Error
|
// If Error
|
||||||
if(err){
|
if(err){
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Copy LocalSettings To Settings
|
// Copy LocalSettings To Settings
|
||||||
Settings = JSON.parse(config.toString());
|
Settings = JSON.parse(config.toString());
|
||||||
// Run MainFunction;
|
// Run MainFunction;
|
||||||
Main();
|
Main();
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
// If it doesn't exists;
|
// If it doesn't exists;
|
||||||
fs.writeFile(`.\\Screener.json`,JSON.stringify(Settings),(err)=>{
|
fs.writeFile(`.\\Screener.json`,JSON.stringify(Settings),(err)=>{
|
||||||
// Write The Config To Local
|
// Write The Config To Local
|
||||||
if(err){
|
if(err){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Run MainFunction;
|
// Run MainFunction;
|
||||||
Main();
|
Main();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1 +1 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
@ -1,74 +1,74 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
var Dict = {
|
var Dict = {
|
||||||
a: 1,
|
a: 1,
|
||||||
b: 2,
|
b: 2,
|
||||||
c: 3,
|
c: 3,
|
||||||
d: 4,
|
d: 4,
|
||||||
e: 5,
|
e: 5,
|
||||||
f: 6,
|
f: 6,
|
||||||
g: 7,
|
g: 7,
|
||||||
h: 8,
|
h: 8,
|
||||||
i: 9,
|
i: 9,
|
||||||
j: 10,
|
j: 10,
|
||||||
k: 11,
|
k: 11,
|
||||||
l: 12,
|
l: 12,
|
||||||
m: 13,
|
m: 13,
|
||||||
n: 14,
|
n: 14,
|
||||||
o: 15,
|
o: 15,
|
||||||
p: 16,
|
p: 16,
|
||||||
q: 17,
|
q: 17,
|
||||||
r: 18,
|
r: 18,
|
||||||
s: 19,
|
s: 19,
|
||||||
t: 20,
|
t: 20,
|
||||||
u: 21,
|
u: 21,
|
||||||
v: 22,
|
v: 22,
|
||||||
w: 23,
|
w: 23,
|
||||||
x: 24,
|
x: 24,
|
||||||
y: 25,
|
y: 25,
|
||||||
z: 26,
|
z: 26,
|
||||||
A: 101,
|
A: 101,
|
||||||
B: 102,
|
B: 102,
|
||||||
C: 103,
|
C: 103,
|
||||||
D: 104,
|
D: 104,
|
||||||
E: 105,
|
E: 105,
|
||||||
F: 106,
|
F: 106,
|
||||||
G: 107,
|
G: 107,
|
||||||
H: 108,
|
H: 108,
|
||||||
I: 109,
|
I: 109,
|
||||||
J: 110,
|
J: 110,
|
||||||
K: 111,
|
K: 111,
|
||||||
L: 112,
|
L: 112,
|
||||||
M: 113,
|
M: 113,
|
||||||
N: 114,
|
N: 114,
|
||||||
O: 115,
|
O: 115,
|
||||||
P: 116,
|
P: 116,
|
||||||
Q: 117,
|
Q: 117,
|
||||||
R: 118,
|
R: 118,
|
||||||
S: 119,
|
S: 119,
|
||||||
T: 120,
|
T: 120,
|
||||||
U: 121,
|
U: 121,
|
||||||
V: 122,
|
V: 122,
|
||||||
W: 123,
|
W: 123,
|
||||||
X: 124,
|
X: 124,
|
||||||
Y: 125,
|
Y: 125,
|
||||||
Z: 126,
|
Z: 126,
|
||||||
1: 201,
|
1: 201,
|
||||||
2: 202,
|
2: 202,
|
||||||
3: 203,
|
3: 203,
|
||||||
4: 204,
|
4: 204,
|
||||||
5: 205,
|
5: 205,
|
||||||
6: 206,
|
6: 206,
|
||||||
7: 207,
|
7: 207,
|
||||||
8: 208,
|
8: 208,
|
||||||
9: 209,
|
9: 209,
|
||||||
0: 210,
|
0: 210,
|
||||||
};
|
};
|
||||||
fs_1.readFile("./Safe2", (err, data) => {
|
fs_1.readFile("./Safe2", (err, data) => {
|
||||||
var Code = data.toString();
|
var Code = data.toString();
|
||||||
Object.values(Dict).forEach((v, i) => {
|
Object.values(Dict).forEach((v, i) => {
|
||||||
Code = Code.replace(new RegExp(`${v}|`, "g"), new String(Object.keys(Dict)[i]).valueOf());
|
Code = Code.replace(new RegExp(`${v}|`, "g"), new String(Object.keys(Dict)[i]).valueOf());
|
||||||
});
|
});
|
||||||
fs_1.writeFile("UnSafe2", Buffer.from(Code, "base64"), (err) => { });
|
fs_1.writeFile("UnSafe2", Buffer.from(Code, "base64"), (err) => { });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,75 +1,75 @@
|
|||||||
import { readFile, fstat, writeFile } from "fs";
|
import { readFile, fstat, writeFile } from "fs";
|
||||||
|
|
||||||
var Dict = {
|
var Dict = {
|
||||||
a:1,
|
a:1,
|
||||||
b:2,
|
b:2,
|
||||||
c:3,
|
c:3,
|
||||||
d:4,
|
d:4,
|
||||||
e:5,
|
e:5,
|
||||||
f:6,
|
f:6,
|
||||||
g:7,
|
g:7,
|
||||||
h:8,
|
h:8,
|
||||||
i:9,
|
i:9,
|
||||||
j:10,
|
j:10,
|
||||||
k:11,
|
k:11,
|
||||||
l:12,
|
l:12,
|
||||||
m:13,
|
m:13,
|
||||||
n:14,
|
n:14,
|
||||||
o:15,
|
o:15,
|
||||||
p:16,
|
p:16,
|
||||||
q:17,
|
q:17,
|
||||||
r:18,
|
r:18,
|
||||||
s:19,
|
s:19,
|
||||||
t:20,
|
t:20,
|
||||||
u:21,
|
u:21,
|
||||||
v:22,
|
v:22,
|
||||||
w:23,
|
w:23,
|
||||||
x:24,
|
x:24,
|
||||||
y:25,
|
y:25,
|
||||||
z:26,
|
z:26,
|
||||||
A:101,
|
A:101,
|
||||||
B:102,
|
B:102,
|
||||||
C:103,
|
C:103,
|
||||||
D:104,
|
D:104,
|
||||||
E:105,
|
E:105,
|
||||||
F:106,
|
F:106,
|
||||||
G:107,
|
G:107,
|
||||||
H:108,
|
H:108,
|
||||||
I:109,
|
I:109,
|
||||||
J:110,
|
J:110,
|
||||||
K:111,
|
K:111,
|
||||||
L:112,
|
L:112,
|
||||||
M:113,
|
M:113,
|
||||||
N:114,
|
N:114,
|
||||||
O:115,
|
O:115,
|
||||||
P:116,
|
P:116,
|
||||||
Q:117,
|
Q:117,
|
||||||
R:118,
|
R:118,
|
||||||
S:119,
|
S:119,
|
||||||
T:120,
|
T:120,
|
||||||
U:121,
|
U:121,
|
||||||
V:122,
|
V:122,
|
||||||
W:123,
|
W:123,
|
||||||
X:124,
|
X:124,
|
||||||
Y:125,
|
Y:125,
|
||||||
Z:126,
|
Z:126,
|
||||||
1:201,
|
1:201,
|
||||||
2:202,
|
2:202,
|
||||||
3:203,
|
3:203,
|
||||||
4:204,
|
4:204,
|
||||||
5:205,
|
5:205,
|
||||||
6:206,
|
6:206,
|
||||||
7:207,
|
7:207,
|
||||||
8:208,
|
8:208,
|
||||||
9:209,
|
9:209,
|
||||||
0:210,
|
0:210,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
|
|
||||||
readFile("./Safe2",(err,data)=>{
|
readFile("./Safe2",(err,data)=>{
|
||||||
var Code = data.toString();
|
var Code = data.toString();
|
||||||
Object.values(Dict).forEach((v,i)=>{
|
Object.values(Dict).forEach((v,i)=>{
|
||||||
Code = Code.replace(new RegExp(`${v}|`,"g"),new String(Object.keys(Dict)[i]).valueOf());
|
Code = Code.replace(new RegExp(`${v}|`,"g"),new String(Object.keys(Dict)[i]).valueOf());
|
||||||
});
|
});
|
||||||
writeFile("UnSafe2",Buffer.from(Code,"base64"),(err)=>{})
|
writeFile("UnSafe2",Buffer.from(Code,"base64"),(err)=>{})
|
||||||
});
|
});
|
||||||
@ -1 +1 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
die("{\"Allow\":false}")
|
die("{\"Allow\":false}")
|
||||||
?>
|
?>
|
||||||
@ -1,11 +1,11 @@
|
|||||||
*{
|
*{
|
||||||
margin:0px;
|
margin:0px;
|
||||||
}
|
}
|
||||||
#UserInfo{
|
#UserInfo{
|
||||||
width:100%;
|
width:100%;
|
||||||
height:5%;
|
height:5%;
|
||||||
background-color:#CCCCCC79;
|
background-color:#CCCCCC79;
|
||||||
}
|
}
|
||||||
#Body{
|
#Body{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@ -1,45 +1,45 @@
|
|||||||
<html lang="Zh-cn">
|
<html lang="Zh-cn">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>首页</title>
|
<title>首页</title>
|
||||||
<link rel="stylesheet" href="index.css">
|
<link rel="stylesheet" href="index.css">
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var User;
|
var User;
|
||||||
var UserInfo;
|
var UserInfo;
|
||||||
//var AJAX = new XMLHttpRequest();
|
//var AJAX = new XMLHttpRequest();
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
UserInfo = document.getElementById("UserInfo");
|
UserInfo = document.getElementById("UserInfo");
|
||||||
if(localStorage.getItem("User")==undefined){
|
if(localStorage.getItem("User")==undefined){
|
||||||
var User = {"ID":"Visitor"};
|
var User = {"ID":"Visitor"};
|
||||||
UserInfo.getElementsByClassName("UserName").item(0).innerHTML = "游客账户";
|
UserInfo.getElementsByClassName("UserName").item(0).innerHTML = "游客账户";
|
||||||
UserInfo.getElementsByClassName("Link").item(0).innerHTML = "登录";
|
UserInfo.getElementsByClassName("Link").item(0).innerHTML = "登录";
|
||||||
UserInfo.getElementsByClassName("Link").item(0).onclick = function(){
|
UserInfo.getElementsByClassName("Link").item(0).onclick = function(){
|
||||||
var AJAX = new XMLHttpRequest();
|
var AJAX = new XMLHttpRequest();
|
||||||
AJAX.open("get","login.html");
|
AJAX.open("get","login.html");
|
||||||
AJAX.send();
|
AJAX.send();
|
||||||
AJAX.onreadystatechange = function(ev){
|
AJAX.onreadystatechange = function(ev){
|
||||||
document.getElementById("Body").innerHTML = AJAX.response;
|
document.getElementById("Body").innerHTML = AJAX.response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
var User = JSON.parse(localStorage.getItem("OnlineAIUser"));
|
var User = JSON.parse(localStorage.getItem("OnlineAIUser"));
|
||||||
UserInfo.getElementsByClassName("UserName").item(0).innerHTML = User.ID;
|
UserInfo.getElementsByClassName("UserName").item(0).innerHTML = User.ID;
|
||||||
UserInfo.getElementsByClassName("Link").item(0).innerHTML = "注销";
|
UserInfo.getElementsByClassName("Link").item(0).innerHTML = "注销";
|
||||||
UserInfo.getElementsByClassName("Link").item(0).onclick = function(){
|
UserInfo.getElementsByClassName("Link").item(0).onclick = function(){
|
||||||
alert(2);
|
alert(2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
</script>
|
</script>
|
||||||
<div id="Top"><a id="Title"></a></div>
|
<div id="Top"><a id="Title"></a></div>
|
||||||
</head>
|
</head>
|
||||||
<body id="Body">
|
<body id="Body">
|
||||||
<div id="UserInfo">
|
<div id="UserInfo">
|
||||||
<a class="UserName"></a>||<a class="Link"></a>
|
<a class="UserName"></a>||<a class="Link"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -1,28 +1,28 @@
|
|||||||
<div id="Login">
|
<div id="Login">
|
||||||
<a>账户:</a><input type="text" class="LoginUserName" /><br>
|
<a>账户:</a><input type="text" class="LoginUserName" /><br>
|
||||||
<a>密码:</a><input type="password" class="LoginPassWord" /><br>
|
<a>密码:</a><input type="password" class="LoginPassWord" /><br>
|
||||||
<button class="LoginButton">登录</button>
|
<button class="LoginButton">登录</button>
|
||||||
<a class="LoginInfo" style="color:#FF0000"></a>
|
<a class="LoginInfo" style="color:#FF0000"></a>
|
||||||
<script>
|
<script>
|
||||||
var Login;
|
var Login;
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
Login = document.getElementById("Login");
|
Login = document.getElementById("Login");
|
||||||
Login.getElementsByClassName("LoginButton").item(0).onclick = function(){
|
Login.getElementsByClassName("LoginButton").item(0).onclick = function(){
|
||||||
var LUN = Login.getElementsByClassName("LoginUserName").item(0).nodeValue;
|
var LUN = Login.getElementsByClassName("LoginUserName").item(0).nodeValue;
|
||||||
var LPW = Login.getElementsByClassName("LoginPassWord").item(0).nodeValue;
|
var LPW = Login.getElementsByClassName("LoginPassWord").item(0).nodeValue;
|
||||||
var AJAX = new XMLHttpRequest();
|
var AJAX = new XMLHttpRequest();
|
||||||
AJAX.open("get",`CGI.php?Do=Login&UserName=${LUN}&PassWord=${LPW}`);
|
AJAX.open("get",`CGI.php?Do=Login&UserName=${LUN}&PassWord=${LPW}`);
|
||||||
AJAX.onreadystatechange = function(){
|
AJAX.onreadystatechange = function(){
|
||||||
var data = JSON.parse(AJAX.responseText);
|
var data = JSON.parse(AJAX.responseText);
|
||||||
if(data["Allow"]){
|
if(data["Allow"]){
|
||||||
var User = {"ID":LUN};
|
var User = {"ID":LUN};
|
||||||
localStorage.setItem("User",JSON.stringify(User));
|
localStorage.setItem("User",JSON.stringify(User));
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}else{
|
}else{
|
||||||
Login.getElementsByClassName("LoginInfo").item(0).innerHtml = "账号或者密码错误,请重新尝试。";
|
Login.getElementsByClassName("LoginInfo").item(0).innerHtml = "账号或者密码错误,请重新尝试。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
@ -1 +1 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
412
UD/UnderDeny.js
412
UD/UnderDeny.js
@ -1,206 +1,206 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//《UnderDeny》 For OnlineAi Version!!!
|
//《UnderDeny》 For OnlineAi Version!!!
|
||||||
//Author:Lanshuye
|
//Author:Lanshuye
|
||||||
//Version (OnlineAi) <ALL>
|
//Version (OnlineAi) <ALL>
|
||||||
//Version (MoudelCE) <ALL>
|
//Version (MoudelCE) <ALL>
|
||||||
//Version (This Mod) <1.0>
|
//Version (This Mod) <1.0>
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
class GameAction {
|
class GameAction {
|
||||||
Execute(c, i, Temp_this) {
|
Execute(c, i, Temp_this) {
|
||||||
if (Temp_this.Type == "对话") {
|
if (Temp_this.Type == "对话") {
|
||||||
Core.frame.SendMsg(c, i, `${Temp_this.Settings.对话_内容}`);
|
Core.frame.SendMsg(c, i, `${Temp_this.Settings.对话_内容}`);
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "跳转") {
|
if (Temp_this.Type == "跳转") {
|
||||||
var data = fs.readFileSync("./UnderDenyData/Player.json");
|
var data = fs.readFileSync("./UnderDenyData/Player.json");
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
data_obj[i.user_id.toString()].Schedule = Temp_this.Settings.跳转_目标.valueOf();
|
data_obj[i.user_id.toString()].Schedule = Temp_this.Settings.跳转_目标.valueOf();
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "判断") {
|
if (Temp_this.Type == "判断") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if (data_obj[i.user_id.toString()].Vars[Temp_this.Settings.判断_变量.valueOf()] == Temp_this.Settings.判断_依据.valueOf()) {
|
if (data_obj[i.user_id.toString()].Vars[Temp_this.Settings.判断_变量.valueOf()] == Temp_this.Settings.判断_依据.valueOf()) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.判断_执行;
|
var s = Temp_this.Settings.判断_执行;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "变量") {
|
if (Temp_this.Type == "变量") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
data_obj[i.user_id.toString()].Vars[Temp_this.Settings.变量_设置.valueOf()] = Temp_this.Settings.变量_内容.valueOf();
|
data_obj[i.user_id.toString()].Vars[Temp_this.Settings.变量_设置.valueOf()] = Temp_this.Settings.变量_内容.valueOf();
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "随机") {
|
if (Temp_this.Type == "随机") {
|
||||||
var rom = Math.floor(Math.random() * 100);
|
var rom = Math.floor(Math.random() * 100);
|
||||||
if (rom < Temp_this.Settings.触发_几率.valueOf()) {
|
if (rom < Temp_this.Settings.触发_几率.valueOf()) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.触发_回调;
|
var s = Temp_this.Settings.触发_回调;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Temp_this.Settings.触发_否则 != undefined || Temp_this.Settings.触发_否则 != null) {
|
if (Temp_this.Settings.触发_否则 != undefined || Temp_this.Settings.触发_否则 != null) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.触发_否则;
|
var s = Temp_this.Settings.触发_否则;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "战斗=>扣血") {
|
if (Temp_this.Type == "战斗=>扣血") {
|
||||||
var data_obj = JSON.parse(fs.readFileSync("./UnderDenyData/Player.json").toString());
|
var data_obj = JSON.parse(fs.readFileSync("./UnderDenyData/Player.json").toString());
|
||||||
var Player = new PlayerData(data_obj[i.user_id.toString()].Info);
|
var Player = new PlayerData(data_obj[i.user_id.toString()].Info);
|
||||||
console.log(Temp_this.Settings);
|
console.log(Temp_this.Settings);
|
||||||
Player.HP = Player.HP.valueOf() - Temp_this.Settings.战斗_扣血.valueOf();
|
Player.HP = Player.HP.valueOf() - Temp_this.Settings.战斗_扣血.valueOf();
|
||||||
Core.frame.SendMsg(c, i, `${Temp_this.Settings.战斗_目标}对你使用了${Temp_this.Settings.战斗_弹幕},造成${Temp_this.Settings.战斗_扣血}点伤害,你剩余${Player.HP}点血量。`);
|
Core.frame.SendMsg(c, i, `${Temp_this.Settings.战斗_目标}对你使用了${Temp_this.Settings.战斗_弹幕},造成${Temp_this.Settings.战斗_扣血}点伤害,你剩余${Player.HP}点血量。`);
|
||||||
data_obj[i.user_id.toString()].Info = Player;
|
data_obj[i.user_id.toString()].Info = Player;
|
||||||
if (Player.HP < 0) {
|
if (Player.HP < 0) {
|
||||||
data_obj[i.user_id.toString()] = undefined;
|
data_obj[i.user_id.toString()] = undefined;
|
||||||
Core.frame.SendMsg(c, i, `你失败了\r\n${Core.frame.At(i.user_id)}保持你的决心。`);
|
Core.frame.SendMsg(c, i, `你失败了\r\n${Core.frame.At(i.user_id)}保持你的决心。`);
|
||||||
}
|
}
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), (err2) => { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
Create(that) {
|
Create(that) {
|
||||||
if (that != undefined) {
|
if (that != undefined) {
|
||||||
this.Type = that.Type;
|
this.Type = that.Type;
|
||||||
this.Settings = that.Settings;
|
this.Settings = that.Settings;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.Type = "";
|
this.Type = "";
|
||||||
this.Settings = {};
|
this.Settings = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Item {
|
class Item {
|
||||||
}
|
}
|
||||||
class PlayerData {
|
class PlayerData {
|
||||||
constructor(PlayerData) {
|
constructor(PlayerData) {
|
||||||
this.LOVE = PlayerData.LOVE;
|
this.LOVE = PlayerData.LOVE;
|
||||||
this.EXP = PlayerData.EXP;
|
this.EXP = PlayerData.EXP;
|
||||||
this.HP = PlayerData.HP;
|
this.HP = PlayerData.HP;
|
||||||
this.Item = PlayerData.Item;
|
this.Item = PlayerData.Item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class UDPlayer {
|
class UDPlayer {
|
||||||
constructor(PlayerS) {
|
constructor(PlayerS) {
|
||||||
this.Schedule = PlayerS.Schedule;
|
this.Schedule = PlayerS.Schedule;
|
||||||
this.Vars = PlayerS.Vars;
|
this.Vars = PlayerS.Vars;
|
||||||
this.Info = new PlayerData(PlayerS.Info);
|
this.Info = new PlayerData(PlayerS.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`[${new Date().toString()}][UnderDeny OA定制版]正在载入数据...`);
|
console.log(`[${new Date().toString()}][UnderDeny OA定制版]正在载入数据...`);
|
||||||
Core.AddListener((connect, info) => {
|
Core.AddListener((connect, info) => {
|
||||||
if (info.message.substr(0, 2) != "UD") {
|
if (info.message.substr(0, 2) != "UD") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = new String(info.message.replace("UD", ""));
|
var msg = new String(info.message.replace("UD", ""));
|
||||||
if (msg == "开始游戏") {
|
if (msg == "开始游戏") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] != undefined) {
|
if (PlayerData[info.user_id.toString()] != undefined) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你还在进行游戏,发送\"UD重置\"才可以重新开始`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你还在进行游戏,发送\"UD重置\"才可以重新开始`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerData[info.user_id.toString()] = { Schedule: "Start", Vars: {}, Info: { LOVE: 0, EXP: 0, HP: 21, Item: [] } };
|
PlayerData[info.user_id.toString()] = { Schedule: "Start", Vars: {}, Info: { LOVE: 0, EXP: 0, HP: 21, Item: [] } };
|
||||||
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
||||||
var data_obj = JSON.parse(data2.toString());
|
var data_obj = JSON.parse(data2.toString());
|
||||||
PlayerData[info.user_id.toString()].Vars = data_obj["Settings"]["init"];
|
PlayerData[info.user_id.toString()].Vars = data_obj["Settings"]["init"];
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err2) => {
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err2) => {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},UD初始化完成。发送\"UD查看剧情\"来开始游戏吧`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},UD初始化完成。发送\"UD查看剧情\"来开始游戏吧`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "重置") {
|
if (msg == "重置") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
PlayerData[info.user_id.toString()] = undefined;
|
PlayerData[info.user_id.toString()] = undefined;
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err2) => {
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err2) => {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},重置成功!`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},重置成功!`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "查看剧情") {
|
if (msg == "查看剧情") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
||||||
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
||||||
var Data = JSON.parse(data2.toString());
|
var Data = JSON.parse(data2.toString());
|
||||||
var GameInfo = Data["Game"][ThisPlayer.Schedule.valueOf()].Info;
|
var GameInfo = Data["Game"][ThisPlayer.Schedule.valueOf()].Info;
|
||||||
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
||||||
var YouCanDo = "<你可以选择的行动>\\r\\n";
|
var YouCanDo = "<你可以选择的行动>\\r\\n";
|
||||||
Object.keys(GameAct).forEach(element => {
|
Object.keys(GameAct).forEach(element => {
|
||||||
YouCanDo = `${YouCanDo}UD行动${element}\\r\\n`;
|
YouCanDo = `${YouCanDo}UD行动${element}\\r\\n`;
|
||||||
});
|
});
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)}\\r\\n${GameInfo}\\r\\n${YouCanDo}<UNDERDENY>`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)}\\r\\n${GameInfo}\\r\\n${YouCanDo}<UNDERDENY>`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "进行存档") {
|
if (msg == "进行存档") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
||||||
var data2_obj = JSON.parse(data2.toString());
|
var data2_obj = JSON.parse(data2.toString());
|
||||||
if (data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveAble != true) {
|
if (data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveAble != true) {
|
||||||
Core.frame.SendMsg(connect, info, "此时你无法存档。");
|
Core.frame.SendMsg(connect, info, "此时你无法存档。");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerData[`${info.user_id}_SAVE`] = PlayerData[info.user_id.toString()];
|
PlayerData[`${info.user_id}_SAVE`] = PlayerData[info.user_id.toString()];
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err3) => { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), (err3) => { });
|
||||||
Core.frame.SendMsg(connect, info, data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveInfo);
|
Core.frame.SendMsg(connect, info, data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg.substr(0, 2) == "行动") {
|
if (msg.substr(0, 2) == "行动") {
|
||||||
var action = msg.replace("行动", "");
|
var action = msg.replace("行动", "");
|
||||||
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
fs.readFile("./UnderDenyData/Player.json", (err, data) => {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},你没有进行游戏,发送\"UD开始游戏\"来开始游戏。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
||||||
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
fs.readFile("./UnderDenyData/Script.json", (err2, data2) => {
|
||||||
var Data = JSON.parse(data2.toString());
|
var Data = JSON.parse(data2.toString());
|
||||||
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
||||||
if (GameAct[action] == undefined) {
|
if (GameAct[action] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},没有这个行动,请检查后再发送。`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(info.user_id)},没有这个行动,请检查后再发送。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ActionGroup = GameAct[action];
|
var ActionGroup = GameAct[action];
|
||||||
var Act = new GameAction();
|
var Act = new GameAction();
|
||||||
for (var i = 0; i < ActionGroup.length; i++) {
|
for (var i = 0; i < ActionGroup.length; i++) {
|
||||||
Act.Create(ActionGroup[i]).Execute(connect, info, Act.Create(ActionGroup[i]));
|
Act.Create(ActionGroup[i]).Execute(connect, info, Act.Create(ActionGroup[i]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
424
UnderDeny.js
424
UnderDeny.js
@ -1,212 +1,212 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//《UnderDeny》 For OnlineAi Version!!!
|
//《UnderDeny》 For OnlineAi Version!!!
|
||||||
//Author:Lanshuye
|
//Author:Lanshuye
|
||||||
//Version (OnlineAi) <ALL>
|
//Version (OnlineAi) <ALL>
|
||||||
//Version (MoudelCE) <ALL>
|
//Version (MoudelCE) <ALL>
|
||||||
//Version (This Mod) <1.0>
|
//Version (This Mod) <1.0>
|
||||||
var Core = __importStar(require("./Core"));
|
var Core = __importStar(require("./Core"));
|
||||||
var fs = __importStar(require("fs"));
|
var fs = __importStar(require("fs"));
|
||||||
var GameAction = /** @class */ (function () {
|
var GameAction = /** @class */ (function () {
|
||||||
function GameAction() {
|
function GameAction() {
|
||||||
this.Type = "";
|
this.Type = "";
|
||||||
this.Settings = {};
|
this.Settings = {};
|
||||||
}
|
}
|
||||||
GameAction.prototype.Execute = function (c, i, Temp_this) {
|
GameAction.prototype.Execute = function (c, i, Temp_this) {
|
||||||
if (Temp_this.Type == "对话") {
|
if (Temp_this.Type == "对话") {
|
||||||
Core.frame.SendMsg(c, i, "" + Temp_this.Settings.对话_内容);
|
Core.frame.SendMsg(c, i, "" + Temp_this.Settings.对话_内容);
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "跳转") {
|
if (Temp_this.Type == "跳转") {
|
||||||
var data = fs.readFileSync("./UnderDenyData/Player.json");
|
var data = fs.readFileSync("./UnderDenyData/Player.json");
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
data_obj[i.user_id.toString()].Schedule = Temp_this.Settings.跳转_目标.valueOf();
|
data_obj[i.user_id.toString()].Schedule = Temp_this.Settings.跳转_目标.valueOf();
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "判断") {
|
if (Temp_this.Type == "判断") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
if (data_obj[i.user_id.toString()].Vars[Temp_this.Settings.判断_变量.valueOf()] == Temp_this.Settings.判断_依据.valueOf()) {
|
if (data_obj[i.user_id.toString()].Vars[Temp_this.Settings.判断_变量.valueOf()] == Temp_this.Settings.判断_依据.valueOf()) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.判断_执行;
|
var s = Temp_this.Settings.判断_执行;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "变量") {
|
if (Temp_this.Type == "变量") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
data_obj[i.user_id.toString()].Vars[Temp_this.Settings.变量_设置.valueOf()] = Temp_this.Settings.变量_内容.valueOf();
|
data_obj[i.user_id.toString()].Vars[Temp_this.Settings.变量_设置.valueOf()] = Temp_this.Settings.变量_内容.valueOf();
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "随机") {
|
if (Temp_this.Type == "随机") {
|
||||||
var rom = Math.floor(Math.random() * 100);
|
var rom = Math.floor(Math.random() * 100);
|
||||||
if (rom < Temp_this.Settings.触发_几率.valueOf()) {
|
if (rom < Temp_this.Settings.触发_几率.valueOf()) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.触发_回调;
|
var s = Temp_this.Settings.触发_回调;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Temp_this.Settings.触发_否则 != undefined || Temp_this.Settings.触发_否则 != null) {
|
if (Temp_this.Settings.触发_否则 != undefined || Temp_this.Settings.触发_否则 != null) {
|
||||||
var temp = new GameAction();
|
var temp = new GameAction();
|
||||||
var s = Temp_this.Settings.触发_否则;
|
var s = Temp_this.Settings.触发_否则;
|
||||||
for (var j = 0; j < s.length; j++) {
|
for (var j = 0; j < s.length; j++) {
|
||||||
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
temp.Create(s[j]).Execute(c, i, temp.Create(s[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Temp_this.Type == "战斗=>扣血") {
|
if (Temp_this.Type == "战斗=>扣血") {
|
||||||
var data_obj = JSON.parse(fs.readFileSync("./UnderDenyData/Player.json").toString());
|
var data_obj = JSON.parse(fs.readFileSync("./UnderDenyData/Player.json").toString());
|
||||||
var Player = new PlayerData(data_obj[i.user_id.toString()].Info);
|
var Player = new PlayerData(data_obj[i.user_id.toString()].Info);
|
||||||
console.log(Temp_this.Settings);
|
console.log(Temp_this.Settings);
|
||||||
Player.HP = Player.HP.valueOf() - Temp_this.Settings.战斗_扣血.valueOf();
|
Player.HP = Player.HP.valueOf() - Temp_this.Settings.战斗_扣血.valueOf();
|
||||||
Core.frame.SendMsg(c, i, Temp_this.Settings.战斗_目标 + "\u5BF9\u4F60\u4F7F\u7528\u4E86" + Temp_this.Settings.战斗_弹幕 + "\uFF0C\u9020\u6210" + Temp_this.Settings.战斗_扣血 + "\u70B9\u4F24\u5BB3\uFF0C\u4F60\u5269\u4F59" + Player.HP + "\u70B9\u8840\u91CF\u3002");
|
Core.frame.SendMsg(c, i, Temp_this.Settings.战斗_目标 + "\u5BF9\u4F60\u4F7F\u7528\u4E86" + Temp_this.Settings.战斗_弹幕 + "\uFF0C\u9020\u6210" + Temp_this.Settings.战斗_扣血 + "\u70B9\u4F24\u5BB3\uFF0C\u4F60\u5269\u4F59" + Player.HP + "\u70B9\u8840\u91CF\u3002");
|
||||||
data_obj[i.user_id.toString()].Info = Player;
|
data_obj[i.user_id.toString()].Info = Player;
|
||||||
if (Player.HP < 0) {
|
if (Player.HP < 0) {
|
||||||
data_obj[i.user_id.toString()] = undefined;
|
data_obj[i.user_id.toString()] = undefined;
|
||||||
Core.frame.SendMsg(c, i, "\u4F60\u5931\u8D25\u4E86\r\n" + Core.frame.At(i.user_id) + "\u4FDD\u6301\u4F60\u7684\u51B3\u5FC3\u3002");
|
Core.frame.SendMsg(c, i, "\u4F60\u5931\u8D25\u4E86\r\n" + Core.frame.At(i.user_id) + "\u4FDD\u6301\u4F60\u7684\u51B3\u5FC3\u3002");
|
||||||
}
|
}
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(data_obj), function (err2) { });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
;
|
;
|
||||||
GameAction.prototype.Create = function (that) {
|
GameAction.prototype.Create = function (that) {
|
||||||
if (that != undefined) {
|
if (that != undefined) {
|
||||||
this.Type = that.Type;
|
this.Type = that.Type;
|
||||||
this.Settings = that.Settings;
|
this.Settings = that.Settings;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
return GameAction;
|
return GameAction;
|
||||||
}());
|
}());
|
||||||
var Item = /** @class */ (function () {
|
var Item = /** @class */ (function () {
|
||||||
function Item() {
|
function Item() {
|
||||||
}
|
}
|
||||||
return Item;
|
return Item;
|
||||||
}());
|
}());
|
||||||
var PlayerData = /** @class */ (function () {
|
var PlayerData = /** @class */ (function () {
|
||||||
function PlayerData(PlayerData) {
|
function PlayerData(PlayerData) {
|
||||||
this.LOVE = PlayerData.LOVE;
|
this.LOVE = PlayerData.LOVE;
|
||||||
this.EXP = PlayerData.EXP;
|
this.EXP = PlayerData.EXP;
|
||||||
this.HP = PlayerData.HP;
|
this.HP = PlayerData.HP;
|
||||||
this.Item = PlayerData.Item;
|
this.Item = PlayerData.Item;
|
||||||
}
|
}
|
||||||
return PlayerData;
|
return PlayerData;
|
||||||
}());
|
}());
|
||||||
var UDPlayer = /** @class */ (function () {
|
var UDPlayer = /** @class */ (function () {
|
||||||
function UDPlayer(PlayerS) {
|
function UDPlayer(PlayerS) {
|
||||||
this.Schedule = PlayerS.Schedule;
|
this.Schedule = PlayerS.Schedule;
|
||||||
this.Vars = PlayerS.Vars;
|
this.Vars = PlayerS.Vars;
|
||||||
this.Info = new PlayerData(PlayerS.Info);
|
this.Info = new PlayerData(PlayerS.Info);
|
||||||
}
|
}
|
||||||
return UDPlayer;
|
return UDPlayer;
|
||||||
}());
|
}());
|
||||||
console.log("[" + new Date().toString() + "][UnderDeny OA\u5B9A\u5236\u7248]\u6B63\u5728\u8F7D\u5165\u6570\u636E...");
|
console.log("[" + new Date().toString() + "][UnderDeny OA\u5B9A\u5236\u7248]\u6B63\u5728\u8F7D\u5165\u6570\u636E...");
|
||||||
Core.AddListener(function (connect, info) {
|
Core.AddListener(function (connect, info) {
|
||||||
if (info.message.substr(0, 2) != "UD") {
|
if (info.message.substr(0, 2) != "UD") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = new String(info.message.replace("UD", ""));
|
var msg = new String(info.message.replace("UD", ""));
|
||||||
if (msg == "开始游戏") {
|
if (msg == "开始游戏") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] != undefined) {
|
if (PlayerData[info.user_id.toString()] != undefined) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u8FD8\u5728\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u91CD\u7F6E\"\u624D\u53EF\u4EE5\u91CD\u65B0\u5F00\u59CB");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u8FD8\u5728\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u91CD\u7F6E\"\u624D\u53EF\u4EE5\u91CD\u65B0\u5F00\u59CB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerData[info.user_id.toString()] = { Schedule: "Start", Vars: {}, Info: { LOVE: 0, EXP: 0, HP: 21, Item: [] } };
|
PlayerData[info.user_id.toString()] = { Schedule: "Start", Vars: {}, Info: { LOVE: 0, EXP: 0, HP: 21, Item: [] } };
|
||||||
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
||||||
var data_obj = JSON.parse(data2.toString());
|
var data_obj = JSON.parse(data2.toString());
|
||||||
PlayerData[info.user_id.toString()].Vars = data_obj["Settings"]["init"];
|
PlayerData[info.user_id.toString()].Vars = data_obj["Settings"]["init"];
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err2) {
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err2) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",UD\u521D\u59CB\u5316\u5B8C\u6210\u3002\u53D1\u9001\"UD\u67E5\u770B\u5267\u60C5\"\u6765\u5F00\u59CB\u6E38\u620F\u5427");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",UD\u521D\u59CB\u5316\u5B8C\u6210\u3002\u53D1\u9001\"UD\u67E5\u770B\u5267\u60C5\"\u6765\u5F00\u59CB\u6E38\u620F\u5427");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "重置") {
|
if (msg == "重置") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
PlayerData[info.user_id.toString()] = undefined;
|
PlayerData[info.user_id.toString()] = undefined;
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err2) {
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err2) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u91CD\u7F6E\u6210\u529F!");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u91CD\u7F6E\u6210\u529F!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "查看剧情") {
|
if (msg == "查看剧情") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
||||||
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
||||||
var Data = JSON.parse(data2.toString());
|
var Data = JSON.parse(data2.toString());
|
||||||
var GameInfo = Data["Game"][ThisPlayer.Schedule.valueOf()].Info;
|
var GameInfo = Data["Game"][ThisPlayer.Schedule.valueOf()].Info;
|
||||||
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
||||||
var YouCanDo = "<你可以选择的行动>\\r\\n";
|
var YouCanDo = "<你可以选择的行动>\\r\\n";
|
||||||
Object.keys(GameAct).forEach(function (element) {
|
Object.keys(GameAct).forEach(function (element) {
|
||||||
YouCanDo = YouCanDo + "UD\u884C\u52A8" + element + "\\r\\n";
|
YouCanDo = YouCanDo + "UD\u884C\u52A8" + element + "\\r\\n";
|
||||||
});
|
});
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + "\\r\\n" + GameInfo + "\\r\\n" + YouCanDo + "<UNDERDENY>");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + "\\r\\n" + GameInfo + "\\r\\n" + YouCanDo + "<UNDERDENY>");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg == "进行存档") {
|
if (msg == "进行存档") {
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
||||||
var data2_obj = JSON.parse(data2.toString());
|
var data2_obj = JSON.parse(data2.toString());
|
||||||
if (data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveAble != true) {
|
if (data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveAble != true) {
|
||||||
Core.frame.SendMsg(connect, info, "此时你无法存档。");
|
Core.frame.SendMsg(connect, info, "此时你无法存档。");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerData[info.user_id + "_SAVE"] = PlayerData[info.user_id.toString()];
|
PlayerData[info.user_id + "_SAVE"] = PlayerData[info.user_id.toString()];
|
||||||
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err3) { });
|
fs.writeFile("./UnderDenyData/Player.json", JSON.stringify(PlayerData), function (err3) { });
|
||||||
Core.frame.SendMsg(connect, info, data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveInfo);
|
Core.frame.SendMsg(connect, info, data2_obj["Game"][PlayerData[info.user_id.toString()].Schedule].SaveInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (msg.substr(0, 2) == "行动") {
|
if (msg.substr(0, 2) == "行动") {
|
||||||
var action = msg.replace("行动", "");
|
var action = msg.replace("行动", "");
|
||||||
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
fs.readFile("./UnderDenyData/Player.json", function (err, data) {
|
||||||
var PlayerData = JSON.parse(data.toString());
|
var PlayerData = JSON.parse(data.toString());
|
||||||
if (PlayerData[info.user_id.toString()] == undefined) {
|
if (PlayerData[info.user_id.toString()] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u4F60\u6CA1\u6709\u8FDB\u884C\u6E38\u620F\uFF0C\u53D1\u9001\"UD\u5F00\u59CB\u6E38\u620F\"\u6765\u5F00\u59CB\u6E38\u620F\u3002");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
var ThisPlayer = new UDPlayer(PlayerData[info.user_id.toString()]);
|
||||||
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
fs.readFile("./UnderDenyData/Script.json", function (err2, data2) {
|
||||||
var Data = JSON.parse(data2.toString());
|
var Data = JSON.parse(data2.toString());
|
||||||
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
var GameAct = Data["Game"][ThisPlayer.Schedule.valueOf()].Actions;
|
||||||
if (GameAct[action] == undefined) {
|
if (GameAct[action] == undefined) {
|
||||||
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u6CA1\u6709\u8FD9\u4E2A\u884C\u52A8\uFF0C\u8BF7\u68C0\u67E5\u540E\u518D\u53D1\u9001\u3002");
|
Core.frame.SendMsg(connect, info, Core.frame.At(info.user_id) + ",\u6CA1\u6709\u8FD9\u4E2A\u884C\u52A8\uFF0C\u8BF7\u68C0\u67E5\u540E\u518D\u53D1\u9001\u3002");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ActionGroup = GameAct[action];
|
var ActionGroup = GameAct[action];
|
||||||
var Act = new GameAction();
|
var Act = new GameAction();
|
||||||
for (var i = 0; i < ActionGroup.length; i++) {
|
for (var i = 0; i < ActionGroup.length; i++) {
|
||||||
Act.Create(ActionGroup[i]).Execute(connect, info, Act.Create(ActionGroup[i]));
|
Act.Create(ActionGroup[i]).Execute(connect, info, Act.Create(ActionGroup[i]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
294
User.Ai.js
294
User.Ai.js
@ -1,147 +1,147 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// ORTS For OnlineAi Interface
|
// ORTS For OnlineAi Interface
|
||||||
const CoreClass = __importStar(require("./Core.Class"));
|
const CoreClass = __importStar(require("./Core.Class"));
|
||||||
const CoreInit = __importStar(require("./Core.Init"));
|
const CoreInit = __importStar(require("./Core.Init"));
|
||||||
const AiCore = __importStar(require("./Core"));
|
const AiCore = __importStar(require("./Core"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
var ORTSData = {};
|
var ORTSData = {};
|
||||||
var ORTSGameObjectPointer = new Map();
|
var ORTSGameObjectPointer = new Map();
|
||||||
ORTSData.Player = new Map();
|
ORTSData.Player = new Map();
|
||||||
if (fs.existsSync("./ORTSDataBase.json")) {
|
if (fs.existsSync("./ORTSDataBase.json")) {
|
||||||
var ORTSDataBase = JSON.parse(fs.readFileSync("./ORTSDataBase.json").toString());
|
var ORTSDataBase = JSON.parse(fs.readFileSync("./ORTSDataBase.json").toString());
|
||||||
Object.keys(ORTSDataBase).forEach((v, i) => {
|
Object.keys(ORTSDataBase).forEach((v, i) => {
|
||||||
ORTSData.Player.set(new Number(v), ORTSData[v]);
|
ORTSData.Player.set(new Number(v), ORTSData[v]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
AiCore.AddListener((AiConnect, AiMessage) => {
|
AiCore.AddListener((AiConnect, AiMessage) => {
|
||||||
if (AiMessage.message.substr(0, 4) != "ORTS") {
|
if (AiMessage.message.substr(0, 4) != "ORTS") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var UserData = ORTSData.Player.get(AiCore.GetUser(AiMessage.user_id));
|
var UserData = ORTSData.Player.get(AiCore.GetUser(AiMessage.user_id));
|
||||||
var Command = AiMessage.message.replace("ORTS", "");
|
var Command = AiMessage.message.replace("ORTS", "");
|
||||||
if (Command == "信息") {
|
if (Command == "信息") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `用户名称:${AiMessage.sender.nickname}\r\n用户资金:${UserData.Money}\r\n用户单位:${UserData.Units.length}`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `用户名称:${AiMessage.sender.nickname}\r\n用户资金:${UserData.Money}\r\n用户单位:${UserData.Units.length}`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Command.substr(0, 2) == "建造") {
|
if (Command.substr(0, 2) == "建造") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var BuildingUnitName = Command.replace("建造", "");
|
var BuildingUnitName = Command.replace("建造", "");
|
||||||
if (!CoreInit.GameObjectRoots.has(BuildingUnitName)) {
|
if (!CoreInit.GameObjectRoots.has(BuildingUnitName)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},没有这个单位`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},没有这个单位`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var BuildingGameObjectRoot = CoreInit.GameObjectRoots.get(BuildingUnitName);
|
var BuildingGameObjectRoot = CoreInit.GameObjectRoots.get(BuildingUnitName);
|
||||||
if (UserData.Money < BuildingGameObjectRoot.Cost) {
|
if (UserData.Money < BuildingGameObjectRoot.Cost) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},你的资金不足.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},你的资金不足.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(BuildingGameObjectRoot);
|
console.log(BuildingGameObjectRoot);
|
||||||
if (BuildingGameObjectRoot.BuildAble == false) {
|
if (BuildingGameObjectRoot.BuildAble == false) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},此单位不可建造`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},此单位不可建造`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new CoreClass.GameObject(BuildingGameObjectRoot, UserData);
|
new CoreClass.GameObject(BuildingGameObjectRoot, UserData);
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},建造完成.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiMessage.user_id)},建造完成.`);
|
||||||
}
|
}
|
||||||
if (Command.substr(0, 2) == "选择") {
|
if (Command.substr(0, 2) == "选择") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Chooser = new Number(Command.replace("选择", "")).valueOf();
|
var Chooser = new Number(Command.replace("选择", "")).valueOf();
|
||||||
if (isNaN(Chooser)) {
|
if (isNaN(Chooser)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},请输入一个具体的编号`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},请输入一个具体的编号`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!UserData.Units[Chooser]) {
|
if (!UserData.Units[Chooser]) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},没有这个单位`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},没有这个单位`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ORTSGameObjectPointer.set(AiMessage.user_id, UserData.Units[Chooser]);
|
ORTSGameObjectPointer.set(AiMessage.user_id, UserData.Units[Chooser]);
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},已选中单位<${UserData.Language.Get(UserData.Units[Chooser].Root.Name)}>`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},已选中单位<${UserData.Language.Get(UserData.Units[Chooser].Root.Name)}>`);
|
||||||
}
|
}
|
||||||
if (Command == "查看") {
|
if (Command == "查看") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ORTSGameObjectPointer.has(AiMessage.user_id)) {
|
if (!ORTSGameObjectPointer.has(AiMessage.user_id)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有选中单位`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有选中单位`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var UnitStatus = (() => { if (ORTSGameObjectPointer.get(AiMessage.user_id).Broken) {
|
var UnitStatus = (() => { if (ORTSGameObjectPointer.get(AiMessage.user_id).Broken) {
|
||||||
return "损毁";
|
return "损毁";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "正常";
|
return "正常";
|
||||||
} })();
|
} })();
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `选中单位<${UserData.Language.Get(ORTSGameObjectPointer.get(AiMessage.user_id).Root.Name)}>\r\n状态:${UnitStatus}\r\n血量:${ORTSGameObjectPointer.get(AiMessage.user_id).Health}\\${ORTSGameObjectPointer.get(AiMessage.user_id).Root.Health}\r\n等级:${ORTSGameObjectPointer.get(AiMessage.user_id).Leven}`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `选中单位<${UserData.Language.Get(ORTSGameObjectPointer.get(AiMessage.user_id).Root.Name)}>\r\n状态:${UnitStatus}\r\n血量:${ORTSGameObjectPointer.get(AiMessage.user_id).Health}\\${ORTSGameObjectPointer.get(AiMessage.user_id).Root.Health}\r\n等级:${ORTSGameObjectPointer.get(AiMessage.user_id).Leven}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Command == "列表") {
|
if (Command == "列表") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Ret = "单位列表:";
|
var Ret = "单位列表:";
|
||||||
UserData.Units.forEach((v, i) => {
|
UserData.Units.forEach((v, i) => {
|
||||||
Ret = Ret + "\r\n" + i + "." + UserData.Language.Get(v.Root.Name) + (() => { if (v.Broken) {
|
Ret = Ret + "\r\n" + i + "." + UserData.Language.Get(v.Root.Name) + (() => { if (v.Broken) {
|
||||||
return "[阵亡]";
|
return "[阵亡]";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "";
|
return "";
|
||||||
} })();
|
} })();
|
||||||
});
|
});
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, Ret);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, Ret);
|
||||||
}
|
}
|
||||||
if (Command.substr(0, 2) == "攻击") {
|
if (Command.substr(0, 2) == "攻击") {
|
||||||
if (!UserData) {
|
if (!UserData) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有注册ORTS.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var AttackPointer = new Number(Command.replace("攻击", "")).valueOf();
|
var AttackPointer = new Number(Command.replace("攻击", "")).valueOf();
|
||||||
if (AiCore.frame.GetAt(AiConnect, AiMessage)) {
|
if (AiCore.frame.GetAt(AiConnect, AiMessage)) {
|
||||||
AttackPointer = new Number(AiCore.frame.GetAt(AiConnect, AiMessage)).valueOf();
|
AttackPointer = new Number(AiCore.frame.GetAt(AiConnect, AiMessage)).valueOf();
|
||||||
}
|
}
|
||||||
if (isNaN(AttackPointer)) {
|
if (isNaN(AttackPointer)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},请提供一个用户.`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},请提供一个用户.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ORTSGameObjectPointer.has(AiMessage.user_id)) {
|
if (!ORTSGameObjectPointer.has(AiMessage.user_id)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有选中单位`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},你没有选中单位`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ORTSData.Player.has(AttackPointer)) {
|
if (!ORTSData.Player.has(AttackPointer)) {
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},这个用户暂未注册ORTS`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},这个用户暂未注册ORTS`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var UnderAttacker = ORTSData.Player.get(AttackPointer);
|
var UnderAttacker = ORTSData.Player.get(AttackPointer);
|
||||||
for (var UnitID = 0; (UnitID < UnderAttacker.Units.length) && (!UnderAttacker.Units[UnitID].Broken); UnitID++) { }
|
for (var UnitID = 0; (UnitID < UnderAttacker.Units.length) && (!UnderAttacker.Units[UnitID].Broken); UnitID++) { }
|
||||||
ORTSGameObjectPointer.get(AiMessage.user_id).Attack(UnderAttacker.Units[UnitID]);
|
ORTSGameObjectPointer.get(AiMessage.user_id).Attack(UnderAttacker.Units[UnitID]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Command == "注册") {
|
if (Command == "注册") {
|
||||||
UserData = new CoreClass.GamePlayer();
|
UserData = new CoreClass.GamePlayer();
|
||||||
UserData.Units[0] = new CoreClass.GameObject(CoreInit.GameObjectRoots.get("建造厂"), UserData);
|
UserData.Units[0] = new CoreClass.GameObject(CoreInit.GameObjectRoots.get("建造厂"), UserData);
|
||||||
ORTSData.Player.set(AiCore.GetUser(AiMessage.user_id), UserData);
|
ORTSData.Player.set(AiCore.GetUser(AiMessage.user_id), UserData);
|
||||||
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},注册成功`);
|
AiCore.frame.SendMsg(AiConnect, AiMessage, `${AiCore.frame.At(AiCore.GetUser(AiMessage.user_id))},注册成功`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.writeFile("./ORTSDataBase.json", JSON.stringify(ORTSData.Player), (err) => { });
|
fs.writeFile("./ORTSDataBase.json", JSON.stringify(ORTSData.Player), (err) => { });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
{"固定资产":{"862869995":1550,"927980270":13642,"1285908631":500,"2284888681":899,"2645989614":550,"2868445034":1050,"3054331058":1100,"3569808588":1000},"利息":{"862869995":"20206","927980270":"20209","2645989614":"20206","2868445034":"20206","3054331058":"20207"},"领工资":{"862869995":"202063","927980270":"202094","2284888681":"202064","2868445034":"202064","3054331058":"202072","3569808588":"202066"},"签到":{"862869995":"202063","927980270":"202095","1285908631":"202061","2284888681":"202064","2645989614":"202064","2868445034":"202061","3054331058":"202072","3569808588":"202066"},"RedPacketPool":0,"SandBox":{},"目标":{},"AITalk":{"927980270":false,"2868445034":false,"Core":true},"板砖":{},"公会系统":{"927980270":"共学社"},"AIEnable":{"545541668":true,"588932037":true,"776148636":true,"963936042":true,"966138955":true}}
|
{"固定资产":{"862869995":1550,"927980270":16142,"1285908631":500,"2284888681":899,"2645989614":550,"2868445034":1050,"3054331058":1100,"3569808588":1000},"利息":{"862869995":"20206","927980270":"20209","2645989614":"20206","2868445034":"20206","3054331058":"20207"},"领工资":{"862869995":"202063","927980270":"202090","2284888681":"202064","2868445034":"202064","3054331058":"202072","3569808588":"202066"},"签到":{"862869995":"202063","927980270":"202093","1285908631":"202061","2284888681":"202064","2645989614":"202064","2868445034":"202061","3054331058":"202072","3569808588":"202066"},"RedPacketPool":0,"SandBox":{},"目标":{},"AITalk":{"927980270":false,"2868445034":false,"Core":true},"板砖":{},"公会系统":{"927980270":"共学社"},"AIEnable":{"545541668":true,"588932037":true,"776148636":true,"963936042":true,"966138955":true}}
|
||||||
242
WebUI.html
242
WebUI.html
@ -1,122 +1,122 @@
|
|||||||
<html lang="zh-cn">
|
<html lang="zh-cn">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width,height=device-height, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,height=device-height, initial-scale=1.0">
|
||||||
<title>OnlineAi Core WebUI</title>
|
<title>OnlineAi Core WebUI</title>
|
||||||
<style>
|
<style>
|
||||||
*{
|
*{
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.onload = ((ev)=>{
|
window.onload = ((ev)=>{
|
||||||
document.getElementById("UserName").innerText = "管理员";
|
document.getElementById("UserName").innerText = "管理员";
|
||||||
document.getElementById("message").innerText = "";
|
document.getElementById("message").innerText = "";
|
||||||
setInterval((()=>{
|
setInterval((()=>{
|
||||||
var min = new Date().getMinutes();
|
var min = new Date().getMinutes();
|
||||||
if(new String(min).length==1){
|
if(new String(min).length==1){
|
||||||
min = `0${min}`;
|
min = `0${min}`;
|
||||||
}
|
}
|
||||||
var sec = new Date().getSeconds();
|
var sec = new Date().getSeconds();
|
||||||
if(new String(sec).length==1){
|
if(new String(sec).length==1){
|
||||||
sec = `0${sec}`;
|
sec = `0${sec}`;
|
||||||
}
|
}
|
||||||
document.getElementById("Timer").innerText = `${new Date().getHours()}:${min}:${sec}`;
|
document.getElementById("Timer").innerText = `${new Date().getHours()}:${min}:${sec}`;
|
||||||
var ajax = new XMLHttpRequest();
|
var ajax = new XMLHttpRequest();
|
||||||
ajax.open("GET","OAC_GETCOUNT");
|
ajax.open("GET","OAC_GETCOUNT");
|
||||||
ajax.send();
|
ajax.send();
|
||||||
var t = false;
|
var t = false;
|
||||||
ajax.onreadystatechange = (()=>{
|
ajax.onreadystatechange = (()=>{
|
||||||
var data_obj = ajax.responseText;
|
var data_obj = ajax.responseText;
|
||||||
if(data_obj == undefined||data_obj==""){
|
if(data_obj == undefined||data_obj==""){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(t){
|
if(t){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t = !t;
|
t = !t;
|
||||||
document.getElementById("Count").innerText = data_obj;
|
document.getElementById("Count").innerText = data_obj;
|
||||||
})
|
})
|
||||||
}),750);
|
}),750);
|
||||||
window.GetMsg = (()=>{
|
window.GetMsg = (()=>{
|
||||||
document.getElementById("message").innerText = "";
|
document.getElementById("message").innerText = "";
|
||||||
var ajax = new XMLHttpRequest();
|
var ajax = new XMLHttpRequest();
|
||||||
ajax.open("GET","OAC_GETMESSAGE");
|
ajax.open("GET","OAC_GETMESSAGE");
|
||||||
ajax.send();
|
ajax.send();
|
||||||
var t = false;
|
var t = false;
|
||||||
ajax.onreadystatechange = (()=>{
|
ajax.onreadystatechange = (()=>{
|
||||||
var data_obj = ajax.responseText;
|
var data_obj = ajax.responseText;
|
||||||
if(data_obj == undefined||data_obj==""){
|
if(data_obj == undefined||data_obj==""){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(t){
|
if(t){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t = !t;
|
t = !t;
|
||||||
data_obj = new Object(JSON.parse(data_obj));
|
data_obj = new Object(JSON.parse(data_obj));
|
||||||
for(var i=0;i<Object.keys(data_obj).length;i++){
|
for(var i=0;i<Object.keys(data_obj).length;i++){
|
||||||
document.getElementById("message").innerText = `${document.getElementById("message").innerText}${Object.keys(data_obj)[i]} => ${data_obj[Object.keys(data_obj)[i]]}\r\n`
|
document.getElementById("message").innerText = `${document.getElementById("message").innerText}${Object.keys(data_obj)[i]} => ${data_obj[Object.keys(data_obj)[i]]}\r\n`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
GetMsg();
|
GetMsg();
|
||||||
document.getElementById("Ai::Restart").onclick = (()=>{
|
document.getElementById("Ai::Restart").onclick = (()=>{
|
||||||
var ajax = new XMLHttpRequest();
|
var ajax = new XMLHttpRequest();
|
||||||
ajax.open("GET","/OAC_RESTART");
|
ajax.open("GET","/OAC_RESTART");
|
||||||
ajax.send();
|
ajax.send();
|
||||||
ajax.onreadystatechange = (()=>{
|
ajax.onreadystatechange = (()=>{
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
var SETMSG = (()=>{
|
var SETMSG = (()=>{
|
||||||
var set = `${document.getElementById("MRMessageName").value}_${document.getElementById("MRMessageValue").value}`
|
var set = `${document.getElementById("MRMessageName").value}_${document.getElementById("MRMessageValue").value}`
|
||||||
var ajax = new XMLHttpRequest();
|
var ajax = new XMLHttpRequest();
|
||||||
ajax.open("GET",`OAC_SETMESSAGE_${set}`);
|
ajax.open("GET",`OAC_SETMESSAGE_${set}`);
|
||||||
ajax.send();
|
ajax.send();
|
||||||
var t = false;
|
var t = false;
|
||||||
ajax.onreadystatechange = (()=>{
|
ajax.onreadystatechange = (()=>{
|
||||||
var data_obj = ajax.responseText;
|
var data_obj = ajax.responseText;
|
||||||
if(data_obj == undefined||data_obj==""){
|
if(data_obj == undefined||data_obj==""){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(t){
|
if(t){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t = !t;
|
t = !t;
|
||||||
if(data_obj == "DONE"){
|
if(data_obj == "DONE"){
|
||||||
GetMsg();
|
GetMsg();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body style="text-align: center;font-family:'思源宋体';">
|
<body style="text-align: center;font-family:'思源宋体';">
|
||||||
<div style="float:right;width:10%;height:5%;">
|
<div style="float:right;width:10%;height:5%;">
|
||||||
<a>欢迎您,<a id="UserName"></a></a><br><a id="Timer">00:00:00</a>
|
<a>欢迎您,<a id="UserName"></a></a><br><a id="Timer">00:00:00</a>
|
||||||
<hr>
|
<hr>
|
||||||
<a style="color:red">请妥善保管此地址,<br/>本服务有权<a href="#" id="Ai::Restart" style="color:red;text-decoration:none">重启Ai。</a></a>
|
<a style="color:red">请妥善保管此地址,<br/>本服务有权<a href="#" id="Ai::Restart" style="color:red;text-decoration:none">重启Ai。</a></a>
|
||||||
<hr>
|
<hr>
|
||||||
<a>OnlineAi作者:<a href="https://gitee.com/lanshuye" style="color:black;text-decoration:none">蓝树叶</a></a>
|
<a>OnlineAi作者:<a href="https://gitee.com/lanshuye" style="color:black;text-decoration:none">蓝树叶</a></a>
|
||||||
<hr>
|
<hr>
|
||||||
<a>实时消息数:</a><a id="Count">0</a>
|
<a>实时消息数:</a><a id="Count">0</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="float: right;width:2px;background: #000000;height: 90%;;"></div>
|
<div style="float: right;width:2px;background: #000000;height: 90%;;"></div>
|
||||||
<div style="width:90%;height:100%;">
|
<div style="width:90%;height:100%;">
|
||||||
<h1>OnlineAi Core调度管理中心</h1>
|
<h1>OnlineAi Core调度管理中心</h1>
|
||||||
<hr>
|
<hr>
|
||||||
<div style="width:100%;height:90%;">
|
<div style="width:100%;height:90%;">
|
||||||
<div style="width: 2%;height: 90%;float: left;"></div>
|
<div style="width: 2%;height: 90%;float: left;"></div>
|
||||||
<div id="message" style="background:#999999;width:96%;float: left;text-align: left;"></div>
|
<div id="message" style="background:#999999;width:96%;float: left;text-align: left;"></div>
|
||||||
<hr>
|
<hr>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="MessageSettings" style="float: left;text-align: left;">
|
<div id="MessageSettings" style="float: left;text-align: left;">
|
||||||
Ai权限码:<input id="WebPassword" class="SET"/><br />
|
Ai权限码:<input id="WebPassword" class="SET"/><br />
|
||||||
消息名称:<input id="MRMessageName" class="SET"/><br />
|
消息名称:<input id="MRMessageName" class="SET"/><br />
|
||||||
消息回复:<input id="MRMessageValue" class="SET"/><br />
|
消息回复:<input id="MRMessageValue" class="SET"/><br />
|
||||||
<button onclick="SETMSG();">设置消息</button>
|
<button onclick="SETMSG();">设置消息</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
216
WebUI.js
216
WebUI.js
@ -1,108 +1,108 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const net = __importStar(require("net"));
|
const net = __importStar(require("net"));
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
var MainConnect;
|
var MainConnect;
|
||||||
var MainGroup;
|
var MainGroup;
|
||||||
var ServerWeb = new net.Server();
|
var ServerWeb = new net.Server();
|
||||||
var MessageCount = 0;
|
var MessageCount = 0;
|
||||||
ServerWeb.on("listening", () => {
|
ServerWeb.on("listening", () => {
|
||||||
process.on("exit", () => {
|
process.on("exit", () => {
|
||||||
ServerWeb.close();
|
ServerWeb.close();
|
||||||
});
|
});
|
||||||
ServerWeb.on("connection", (UserSock) => {
|
ServerWeb.on("connection", (UserSock) => {
|
||||||
UserSock.on("data", (data) => {
|
UserSock.on("data", (data) => {
|
||||||
if (data.toString().indexOf(" ") != 0) {
|
if (data.toString().indexOf(" ") != 0) {
|
||||||
var path = data.toString().split(" ");
|
var path = data.toString().split(" ");
|
||||||
if (path == undefined) {
|
if (path == undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (path[1] == "/") {
|
if (path[1] == "/") {
|
||||||
fs.readFile("./WebUI.html", (err, data) => {
|
fs.readFile("./WebUI.html", (err, data) => {
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||||
UserSock.write(data);
|
UserSock.write(data);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (path[1].substr(0, 5) == "/OAC_") {
|
else if (path[1].substr(0, 5) == "/OAC_") {
|
||||||
var Do = path[1].replace("/OAC_", "");
|
var Do = path[1].replace("/OAC_", "");
|
||||||
if (Do == "GETMESSAGE") {
|
if (Do == "GETMESSAGE") {
|
||||||
fs.readFile("./Message.json", (err, data) => {
|
fs.readFile("./Message.json", (err, data) => {
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||||
UserSock.write(data);
|
UserSock.write(data);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (Do.substr(0, new String("SETMESSAGE_").length) == "SETMESSAGE_") {
|
else if (Do.substr(0, new String("SETMESSAGE_").length) == "SETMESSAGE_") {
|
||||||
var Token = Do.replace("SETMESSAGE_", "");
|
var Token = Do.replace("SETMESSAGE_", "");
|
||||||
var T2 = Token.split("_");
|
var T2 = Token.split("_");
|
||||||
fs.readFile("./Message.json", (err, data) => {
|
fs.readFile("./Message.json", (err, data) => {
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
T2[0] = decodeURIComponent(T2[0]);
|
T2[0] = decodeURIComponent(T2[0]);
|
||||||
if (T2[1] == "") {
|
if (T2[1] == "") {
|
||||||
T2[1] = undefined;
|
T2[1] = undefined;
|
||||||
data_obj[T2[0]] = undefined;
|
data_obj[T2[0]] = undefined;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data_obj[T2[0]] = decodeURIComponent(T2[1]);
|
data_obj[T2[0]] = decodeURIComponent(T2[1]);
|
||||||
}
|
}
|
||||||
fs.writeFile("./Message.json", JSON.stringify(data_obj), (err) => {
|
fs.writeFile("./Message.json", JSON.stringify(data_obj), (err) => {
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String("DONE").length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String("DONE").length}\r\n\r\n`);
|
||||||
UserSock.write(new String("DONE").valueOf());
|
UserSock.write(new String("DONE").valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (Do == "GETCOUNT") {
|
else if (Do == "GETCOUNT") {
|
||||||
var ret = new String(MessageCount);
|
var ret = new String(MessageCount);
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||||
UserSock.write(ret.valueOf());
|
UserSock.write(ret.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
}
|
}
|
||||||
else if (Do == "RESTART") {
|
else if (Do == "RESTART") {
|
||||||
var ret = new String("DOING!");
|
var ret = new String("DOING!");
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||||
UserSock.write(ret.valueOf());
|
UserSock.write(ret.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
else if (Do == "GETSERVICES") {
|
else if (Do == "GETSERVICES") {
|
||||||
fs.readFile("./MoudelV2.json", (err2, data2) => {
|
fs.readFile("./MoudelV2.json", (err2, data2) => {
|
||||||
var ret = data2;
|
var ret = data2;
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${ret.length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${ret.length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||||
UserSock.write(ret);
|
UserSock.write(ret);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var data2 = "404";
|
var data2 = "404";
|
||||||
UserSock.write(`HTTP/1.1 404\r\nContent-Length: ${data2.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 404\r\nContent-Length: ${data2.length}\r\n\r\n`);
|
||||||
UserSock.write(data2.valueOf());
|
UserSock.write(data2.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UserSock.end("HTTP/1.1 404");
|
UserSock.end("HTTP/1.1 404");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UserSock.on("close", () => {
|
UserSock.on("close", () => {
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
UserSock.on("end", () => {
|
UserSock.on("end", () => {
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ServerWeb.listen(8081, "127.0.0.1");
|
ServerWeb.listen(8081, "0.0.0.0");
|
||||||
Core.AddListener((connect, Info) => {
|
Core.AddListener((connect, Info) => {
|
||||||
MessageCount = MessageCount.valueOf() + 1;
|
MessageCount = MessageCount.valueOf() + 1;
|
||||||
});
|
});
|
||||||
|
|||||||
182
WebUI.ts
182
WebUI.ts
@ -1,92 +1,92 @@
|
|||||||
import * as net from "net";
|
import * as net from "net";
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
var MainConnect:Core.InfoSocket;
|
var MainConnect:Core.InfoSocket;
|
||||||
var MainGroup:Core.InfoType;
|
var MainGroup:Core.InfoType;
|
||||||
var ServerWeb = new net.Server();
|
var ServerWeb = new net.Server();
|
||||||
var MessageCount:Number = 0;
|
var MessageCount:Number = 0;
|
||||||
ServerWeb.on("listening",()=>{
|
ServerWeb.on("listening",()=>{
|
||||||
process.on("exit",()=>{
|
process.on("exit",()=>{
|
||||||
ServerWeb.close();
|
ServerWeb.close();
|
||||||
});
|
});
|
||||||
ServerWeb.on("connection",(UserSock)=>{
|
ServerWeb.on("connection",(UserSock)=>{
|
||||||
UserSock.on("data",(data)=>{
|
UserSock.on("data",(data)=>{
|
||||||
if(data.toString().indexOf(" ")!=0){
|
if(data.toString().indexOf(" ")!=0){
|
||||||
var path = data.toString().split(" ");
|
var path = data.toString().split(" ");
|
||||||
if(path == undefined){
|
if(path == undefined){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(path[1]=="/"){
|
if(path[1]=="/"){
|
||||||
fs.readFile("./WebUI.html",(err,data)=>{
|
fs.readFile("./WebUI.html",(err,data)=>{
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||||
UserSock.write(data);
|
UserSock.write(data);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
}else if(path[1].substr(0,5)=="/OAC_"){
|
}else if(path[1].substr(0,5)=="/OAC_"){
|
||||||
var Do = path[1].replace("/OAC_","");
|
var Do = path[1].replace("/OAC_","");
|
||||||
if(Do == "GETMESSAGE"){
|
if(Do == "GETMESSAGE"){
|
||||||
fs.readFile("./Message.json",(err,data)=>{
|
fs.readFile("./Message.json",(err,data)=>{
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||||
UserSock.write(data);
|
UserSock.write(data);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
}else if(Do.substr(0,new String("SETMESSAGE_").length) == "SETMESSAGE_"){
|
}else if(Do.substr(0,new String("SETMESSAGE_").length) == "SETMESSAGE_"){
|
||||||
var Token = Do.replace("SETMESSAGE_","");
|
var Token = Do.replace("SETMESSAGE_","");
|
||||||
var T2:string[]|undefined[] = Token.split("_");
|
var T2:string[]|undefined[] = Token.split("_");
|
||||||
fs.readFile("./Message.json",(err,data)=>{
|
fs.readFile("./Message.json",(err,data)=>{
|
||||||
var data_obj = JSON.parse(data.toString());
|
var data_obj = JSON.parse(data.toString());
|
||||||
T2[0] = decodeURIComponent(T2[0] as string);
|
T2[0] = decodeURIComponent(T2[0] as string);
|
||||||
if(T2[1]==""){
|
if(T2[1]==""){
|
||||||
T2[1] = undefined;
|
T2[1] = undefined;
|
||||||
data_obj[T2[0] as string] = undefined;
|
data_obj[T2[0] as string] = undefined;
|
||||||
}else{
|
}else{
|
||||||
data_obj[T2[0] as string] = decodeURIComponent(T2[1] as string);
|
data_obj[T2[0] as string] = decodeURIComponent(T2[1] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFile("./Message.json",JSON.stringify(data_obj),(err)=>{
|
fs.writeFile("./Message.json",JSON.stringify(data_obj),(err)=>{
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String("DONE").length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String("DONE").length}\r\n\r\n`);
|
||||||
UserSock.write(new String("DONE").valueOf());
|
UserSock.write(new String("DONE").valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}else if(Do == "GETCOUNT"){
|
}else if(Do == "GETCOUNT"){
|
||||||
var ret = new String(MessageCount);
|
var ret = new String(MessageCount);
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
||||||
UserSock.write(ret.valueOf());
|
UserSock.write(ret.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
}else if(Do == "RESTART"){
|
}else if(Do == "RESTART"){
|
||||||
var ret = new String("DOING!");
|
var ret = new String("DOING!");
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
||||||
UserSock.write(ret.valueOf());
|
UserSock.write(ret.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
process.exit();
|
process.exit();
|
||||||
}else if(Do == "GETSERVICES"){
|
}else if(Do == "GETSERVICES"){
|
||||||
fs.readFile("./MoudelV2.json",(err2,data2)=>{
|
fs.readFile("./MoudelV2.json",(err2,data2)=>{
|
||||||
var ret = data2;
|
var ret = data2;
|
||||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${ret.length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${ret.length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
||||||
UserSock.write(ret);
|
UserSock.write(ret);
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
var data2:String ="404";
|
var data2:String ="404";
|
||||||
UserSock.write(`HTTP/1.1 404\r\nContent-Length: ${data2.length}\r\n\r\n`);
|
UserSock.write(`HTTP/1.1 404\r\nContent-Length: ${data2.length}\r\n\r\n`);
|
||||||
UserSock.write(data2.valueOf());
|
UserSock.write(data2.valueOf());
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
UserSock.end("HTTP/1.1 404");
|
UserSock.end("HTTP/1.1 404");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UserSock.on("close",()=>{
|
UserSock.on("close",()=>{
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
});
|
});
|
||||||
UserSock.on("end",()=>{
|
UserSock.on("end",()=>{
|
||||||
UserSock.end();
|
UserSock.end();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ServerWeb.listen(8081,"127.0.0.1");
|
ServerWeb.listen(8081,"0.0.0.0");
|
||||||
Core.AddListener((connect:Core.InfoSocket,Info:Core.InfoType)=>{
|
Core.AddListener((connect:Core.InfoSocket,Info:Core.InfoType)=>{
|
||||||
MessageCount = MessageCount.valueOf() + 1;
|
MessageCount = MessageCount.valueOf() + 1;
|
||||||
})
|
})
|
||||||
114
img.js
114
img.js
@ -1,57 +1,57 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const canvas = __importStar(require("canvas"));
|
const canvas = __importStar(require("canvas"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const debug = require("./Debug");
|
const debug = require("./Debug");
|
||||||
const ds = require("desktop-screenshot");
|
const ds = require("desktop-screenshot");
|
||||||
const request = __importStar(require("request"));
|
const request = __importStar(require("request"));
|
||||||
(() => {
|
(() => {
|
||||||
var con = new canvas.Canvas(100, 100);
|
var con = new canvas.Canvas(100, 100);
|
||||||
var mai = con.getContext("2d");
|
var mai = con.getContext("2d");
|
||||||
mai.fillStyle = "#ffffff";
|
mai.fillStyle = "#ffffff";
|
||||||
mai.fillRect(0, 0, 100, 100);
|
mai.fillRect(0, 0, 100, 100);
|
||||||
mai.fillStyle = "#000000";
|
mai.fillStyle = "#000000";
|
||||||
mai.font = "24px '思源宋体'";
|
mai.font = "24px '思源宋体'";
|
||||||
// mai.fillText("天依没了",10,50);
|
// mai.fillText("天依没了",10,50);
|
||||||
var Buf = con.toBuffer("image/png");
|
var Buf = con.toBuffer("image/png");
|
||||||
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png", Buf, () => {
|
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png", Buf, () => {
|
||||||
});
|
});
|
||||||
Core.AddListener((c, i) => {
|
Core.AddListener((c, i) => {
|
||||||
if (i.message == "图片测试") {
|
if (i.message == "图片测试") {
|
||||||
Core.frame.SendImg(c, i, "1.png");
|
Core.frame.SendImg(c, i, "1.png");
|
||||||
}
|
}
|
||||||
if (i.message == "屏幕截图" && debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))) {
|
if (i.message == "屏幕截图" && debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))) {
|
||||||
ds("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\Screen.png", (err, com) => {
|
ds("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\Screen.png", (err, com) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Core.frame.SendImg(c, i, "Screen.png");
|
Core.frame.SendImg(c, i, "Screen.png");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (i.message == "服务器IP") {
|
if (i.message == "服务器IP") {
|
||||||
if (debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))) {
|
if (debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))) {
|
||||||
request.get("http://api.ipify.org", (err, req) => {
|
request.get("http://api.ipify.org", (err, req) => {
|
||||||
Core.frame.SendMsg(c, i, req.body);
|
Core.frame.SendMsg(c, i, req.body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
request.get("http://api.ipify.org", (err, req) => {
|
request.get("http://api.ipify.org", (err, req) => {
|
||||||
var IP = req.body.split(".");
|
var IP = req.body.split(".");
|
||||||
IP[2] = "*";
|
IP[2] = "*";
|
||||||
IP[3] = "*";
|
IP[3] = "*";
|
||||||
Core.frame.SendMsg(c, i, `${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
Core.frame.SendMsg(c, i, `${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
92
img.ts
92
img.ts
@ -1,47 +1,47 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
import * as canvas from "canvas";
|
import * as canvas from "canvas";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
const debug:LibDebug = require("./Debug");
|
const debug:LibDebug = require("./Debug");
|
||||||
const ds = require("desktop-screenshot");
|
const ds = require("desktop-screenshot");
|
||||||
import * as request from "request";
|
import * as request from "request";
|
||||||
(()=>{
|
(()=>{
|
||||||
var con = new canvas.Canvas(100,100);
|
var con = new canvas.Canvas(100,100);
|
||||||
var mai = con.getContext("2d");
|
var mai = con.getContext("2d");
|
||||||
mai.fillStyle = "#ffffff";
|
mai.fillStyle = "#ffffff";
|
||||||
mai.fillRect(0,0,100,100);
|
mai.fillRect(0,0,100,100);
|
||||||
mai.fillStyle = "#000000";
|
mai.fillStyle = "#000000";
|
||||||
mai.font = "24px '思源宋体'";
|
mai.font = "24px '思源宋体'";
|
||||||
// mai.fillText("天依没了",10,50);
|
// mai.fillText("天依没了",10,50);
|
||||||
var Buf = con.toBuffer("image/png");
|
var Buf = con.toBuffer("image/png");
|
||||||
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png",Buf,()=>{
|
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png",Buf,()=>{
|
||||||
|
|
||||||
});
|
});
|
||||||
Core.AddListener((c,i)=>{
|
Core.AddListener((c,i)=>{
|
||||||
if(i.message == "图片测试"){
|
if(i.message == "图片测试"){
|
||||||
Core.frame.SendImg(c,i,"1.png");
|
Core.frame.SendImg(c,i,"1.png");
|
||||||
}
|
}
|
||||||
if(i.message == "屏幕截图" && debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
if(i.message == "屏幕截图" && debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
||||||
ds("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\Screen.png",(err:any,com:any)=>{
|
ds("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\Screen.png",(err:any,com:any)=>{
|
||||||
if(err){
|
if(err){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendImg(c,i,"Screen.png");
|
Core.frame.SendImg(c,i,"Screen.png");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(i.message == "服务器IP"){
|
if(i.message == "服务器IP"){
|
||||||
if(debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
if(debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
||||||
request.get("http://api.ipify.org",(err,req)=>{
|
request.get("http://api.ipify.org",(err,req)=>{
|
||||||
Core.frame.SendMsg(c,i,req.body);
|
Core.frame.SendMsg(c,i,req.body);
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
request.get("http://api.ipify.org",(err,req)=>{
|
request.get("http://api.ipify.org",(err,req)=>{
|
||||||
var IP = (req.body as string).split(".");
|
var IP = (req.body as string).split(".");
|
||||||
IP[2] = "*";
|
IP[2] = "*";
|
||||||
IP[3] = "*";
|
IP[3] = "*";
|
||||||
Core.frame.SendMsg(c,i,`${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
Core.frame.SendMsg(c,i,`${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
38
lib.d.ts
vendored
38
lib.d.ts
vendored
@ -1,20 +1,20 @@
|
|||||||
declare interface LibMoney{
|
declare interface LibMoney{
|
||||||
add:{
|
add:{
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetUserMoney(UserID:Number):Number
|
GetUserMoney(UserID:Number):Number
|
||||||
GiveUserMoney(UserID:Number,Count:Number):void;
|
GiveUserMoney(UserID:Number,Count:Number):void;
|
||||||
CostUserMoney(UserID:Number,Count:Number):void;
|
CostUserMoney(UserID:Number,Count:Number):void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare interface LibDebug{
|
declare interface LibDebug{
|
||||||
add:{
|
add:{
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
/**
|
/**
|
||||||
* 查询一个用户是否为Ai管理员
|
* 查询一个用户是否为Ai管理员
|
||||||
* @param UserID 要查询的用户的QQ
|
* @param UserID 要查询的用户的QQ
|
||||||
*/
|
*/
|
||||||
IsAdmin(UserID:Number):Boolean;
|
IsAdmin(UserID:Number):Boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1 +1 @@
|
|||||||
a006da68cee2e5948f791e89043c9fd33dcfa03a
|
a006da68cee2e5948f791e89043c9fd33dcfa03a
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
C:\Users\1\source\repos\JSAICore\JSAICore\obj\Debug\JSAICore.njsproj.CoreCompileInputs.cache
|
C:\Users\1\source\repos\JSAICore\JSAICore\obj\Debug\JSAICore.njsproj.CoreCompileInputs.cache
|
||||||
C:\Users\1\source\repos\JSAICore\JSAICore\bin\Microsoft.NodejsTools.WebRole.dll
|
C:\Users\1\source\repos\JSAICore\JSAICore\bin\Microsoft.NodejsTools.WebRole.dll
|
||||||
C:\Users\1\source\repos\JSAICore\JSAICore\obj\Debug\JSAICore.njsprojAssemblyReference.cache
|
C:\Users\1\source\repos\JSAICore\JSAICore\obj\Debug\JSAICore.njsprojAssemblyReference.cache
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "Run.bat",
|
"run": "nodejs ./Core.js",
|
||||||
"test": "Node OnlineAI.js",
|
"test": "Node OnlineAI.js",
|
||||||
"get": "npm install",
|
"get": "npm install",
|
||||||
"build": "tsc --build&git add .&git commit -m \"@Build\"&git push origin master"
|
"build": "tsc --build&git add .&git commit -m \"@Build\"&git push origin master"
|
||||||
|
|||||||
18
test2.js
18
test2.js
@ -1,10 +1,10 @@
|
|||||||
const icovn = require("iconv-lite");
|
const icovn = require("iconv-lite");
|
||||||
console.log(icovn.encode("你好","utf8"));
|
console.log(icovn.encode("你好","utf8"));
|
||||||
console.log(icovn.encode("你好","gbk"));
|
console.log(icovn.encode("你好","gbk"));
|
||||||
console.log(icovn.encode("你好","utf8").toString());
|
console.log(icovn.encode("你好","utf8").toString());
|
||||||
console.log(icovn.encode("你好","gbk").toString());
|
console.log(icovn.encode("你好","gbk").toString());
|
||||||
|
|
||||||
console.log(icovn.decode(Buffer.from("你好"),"utf8"));
|
console.log(icovn.decode(Buffer.from("你好"),"utf8"));
|
||||||
console.log(icovn.decode(Buffer.from("你好"),"gbk"));
|
console.log(icovn.decode(Buffer.from("你好"),"gbk"));
|
||||||
console.log(icovn.decode(Buffer.from("你好"),"utf8").toString());
|
console.log(icovn.decode(Buffer.from("你好"),"utf8").toString());
|
||||||
console.log(icovn.decode(Buffer.from("你好"),"gbk").toString());
|
console.log(icovn.decode(Buffer.from("你好"),"gbk").toString());
|
||||||
50
保镖.i.js
50
保镖.i.js
@ -1,25 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// .i.ts : Interface TS文件
|
// .i.ts : Interface TS文件
|
||||||
class 数字 extends Number {
|
class 数字 extends Number {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
exports.使用用户保镖 = ((用户) => {
|
exports.使用用户保镖 = ((用户) => {
|
||||||
var 数据 = Core.frame.ReadSystemConfig("保镖");
|
var 数据 = Core.frame.ReadSystemConfig("保镖");
|
||||||
if (数据[用户.valueOf()] == undefined || new Number(数据[用户.valueOf()]).valueOf() < 0) {
|
if (数据[用户.valueOf()] == undefined || new Number(数据[用户.valueOf()]).valueOf() < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
数据[用户.valueOf()] = 数据[用户.valueOf()] - 1;
|
数据[用户.valueOf()] = 数据[用户.valueOf()] - 1;
|
||||||
Core.frame.WriteSystemConfig("保镖", 数据);
|
Core.frame.WriteSystemConfig("保镖", 数据);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
24
保镖.i.ts
24
保镖.i.ts
@ -1,13 +1,13 @@
|
|||||||
// .i.ts : Interface TS文件
|
// .i.ts : Interface TS文件
|
||||||
class 数字 extends Number{};
|
class 数字 extends Number{};
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
export var 使用用户保镖 = ((用户:数字)=>{
|
export var 使用用户保镖 = ((用户:数字)=>{
|
||||||
var 数据 = Core.frame.ReadSystemConfig("保镖");
|
var 数据 = Core.frame.ReadSystemConfig("保镖");
|
||||||
if(数据[用户.valueOf()] == undefined || new Number(数据[用户.valueOf()]).valueOf() < 0){
|
if(数据[用户.valueOf()] == undefined || new Number(数据[用户.valueOf()]).valueOf() < 0){
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
数据[用户.valueOf()] = 数据[用户.valueOf()] - 1;
|
数据[用户.valueOf()] = 数据[用户.valueOf()] - 1;
|
||||||
Core.frame.WriteSystemConfig("保镖",数据);
|
Core.frame.WriteSystemConfig("保镖",数据);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
72
保镖.js
72
保镖.js
@ -1,36 +1,36 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// 保镖.ts 提供一个为你防护的保镖
|
// 保镖.ts 提供一个为你防护的保镖
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const Money = require("./Money");
|
const Money = require("./Money");
|
||||||
const 保镖配置 = {
|
const 保镖配置 = {
|
||||||
聘请定价: 1000,
|
聘请定价: 1000,
|
||||||
使用次数: 5,
|
使用次数: 5,
|
||||||
禁言权重: 25
|
禁言权重: 25
|
||||||
};
|
};
|
||||||
exports.Interfaces = {};
|
exports.Interfaces = {};
|
||||||
Core.AddListener((connect, info) => {
|
Core.AddListener((connect, info) => {
|
||||||
if (info.message == "聘请保镖") {
|
if (info.message == "聘请保镖") {
|
||||||
if (Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id)) < 保镖配置.聘请定价) {
|
if (Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id)) < 保镖配置.聘请定价) {
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(Core.GetUser(info.user_id))},你的余额不足${保镖配置.聘请定价},不能聘请保镖.`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(Core.GetUser(info.user_id))},你的余额不足${保镖配置.聘请定价},不能聘请保镖.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Data = Core.frame.ReadSystemConfig("保镖");
|
var Data = Core.frame.ReadSystemConfig("保镖");
|
||||||
var User保镖 = new Number(Data[Core.GetUser(info.user_id)]);
|
var User保镖 = new Number(Data[Core.GetUser(info.user_id)]);
|
||||||
if (isNaN(User保镖)) {
|
if (isNaN(User保镖)) {
|
||||||
User保镖 = 0;
|
User保镖 = 0;
|
||||||
}
|
}
|
||||||
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id), 保镖配置.聘请定价);
|
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id), 保镖配置.聘请定价);
|
||||||
User保镖 = User保镖 + 保镖配置.使用次数;
|
User保镖 = User保镖 + 保镖配置.使用次数;
|
||||||
Data[Core.GetUser(info.user_id)] = User保镖;
|
Data[Core.GetUser(info.user_id)] = User保镖;
|
||||||
Core.frame.WriteSystemConfig("保镖", Data);
|
Core.frame.WriteSystemConfig("保镖", Data);
|
||||||
Core.frame.SendMsg(connect, info, `${Core.frame.At(Core.GetUser(info.user_id))},聘请保镖成功,你剩下${User保镖}位保镖,还剩${Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))}RMB.`);
|
Core.frame.SendMsg(connect, info, `${Core.frame.At(Core.GetUser(info.user_id))},聘请保镖成功,你剩下${User保镖}位保镖,还剩${Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))}RMB.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
52
保镖.ts
52
保镖.ts
@ -1,27 +1,27 @@
|
|||||||
// 保镖.ts 提供一个为你防护的保镖
|
// 保镖.ts 提供一个为你防护的保镖
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
const Money:LibMoney = require("./Money") as LibMoney;
|
const Money:LibMoney = require("./Money") as LibMoney;
|
||||||
const 保镖配置 = {
|
const 保镖配置 = {
|
||||||
聘请定价:1000,
|
聘请定价:1000,
|
||||||
使用次数:5,
|
使用次数:5,
|
||||||
禁言权重:25
|
禁言权重:25
|
||||||
}
|
}
|
||||||
export var Interfaces = {};
|
export var Interfaces = {};
|
||||||
Core.AddListener((connect,info)=>{
|
Core.AddListener((connect,info)=>{
|
||||||
if(info.message == "聘请保镖"){
|
if(info.message == "聘请保镖"){
|
||||||
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id)) < 保镖配置.聘请定价){
|
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id)) < 保镖配置.聘请定价){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info.user_id))},你的余额不足${保镖配置.聘请定价},不能聘请保镖.`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info.user_id))},你的余额不足${保镖配置.聘请定价},不能聘请保镖.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var Data = Core.frame.ReadSystemConfig("保镖");
|
var Data = Core.frame.ReadSystemConfig("保镖");
|
||||||
var User保镖 = new Number(Data[Core.GetUser(info.user_id)]) as number;
|
var User保镖 = new Number(Data[Core.GetUser(info.user_id)]) as number;
|
||||||
if(isNaN(User保镖)){
|
if(isNaN(User保镖)){
|
||||||
User保镖 = 0;
|
User保镖 = 0;
|
||||||
}
|
}
|
||||||
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id),保镖配置.聘请定价);
|
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id),保镖配置.聘请定价);
|
||||||
User保镖 = User保镖 + 保镖配置.使用次数;
|
User保镖 = User保镖 + 保镖配置.使用次数;
|
||||||
Data[Core.GetUser(info.user_id)] = User保镖;
|
Data[Core.GetUser(info.user_id)] = User保镖;
|
||||||
Core.frame.WriteSystemConfig("保镖",Data);
|
Core.frame.WriteSystemConfig("保镖",Data);
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info.user_id))},聘请保镖成功,你剩下${User保镖}位保镖,还剩${Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))}RMB.`)
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info.user_id))},聘请保镖成功,你剩下${User保镖}位保镖,还剩${Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))}RMB.`)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
414
公会系统.js
414
公会系统.js
@ -1,208 +1,208 @@
|
|||||||
//固定资产
|
//固定资产
|
||||||
const fs=require("fs");
|
const fs=require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const Money = require("./Money");
|
const Money = require("./Money");
|
||||||
fs.exists("./Data",(ex)=>{
|
fs.exists("./Data",(ex)=>{
|
||||||
if(!ex){
|
if(!ex){
|
||||||
fs.mkdir("./Data");
|
fs.mkdir("./Data");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
fs.exists("./Data/公会.json",(ex)=>{
|
fs.exists("./Data/公会.json",(ex)=>{
|
||||||
if(!ex){
|
if(!ex){
|
||||||
fs.writeFile("./Data/公会.json",JSON.stringify({}),(err)=>{
|
fs.writeFile("./Data/公会.json",JSON.stringify({}),(err)=>{
|
||||||
console.log(`[${new Date().toString()}][${module.filename}]创建公会档案记录。`)
|
console.log(`[${new Date().toString()}][${module.filename}]创建公会档案记录。`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetUserPublic:function(UserID){
|
GetUserPublic:function(UserID){
|
||||||
var data = Core.frame.ReadSystemConfig("公会系统");
|
var data = Core.frame.ReadSystemConfig("公会系统");
|
||||||
if(data[UserID]==undefined||null||NaN){
|
if(data[UserID]==undefined||null||NaN){
|
||||||
return "[无工会]";
|
return "[无工会]";
|
||||||
}else{
|
}else{
|
||||||
return data[UserID];
|
return data[UserID];
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
SetUserPublic:function(UserID,公会){
|
SetUserPublic:function(UserID,公会){
|
||||||
var data = Core.frame.ReadSystemConfig("公会系统");
|
var data = Core.frame.ReadSystemConfig("公会系统");
|
||||||
data[UserID] = 公会;
|
data[UserID] = 公会;
|
||||||
Core.frame.WriteSystemConfig("公会系统",data);
|
Core.frame.WriteSystemConfig("公会系统",data);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
CreatePublic:function(info,gh){
|
CreatePublic:function(info,gh){
|
||||||
公会 = gh[0]
|
公会 = gh[0]
|
||||||
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
data[公会]={};
|
data[公会]={};
|
||||||
data[公会]["Name"] = 公会;
|
data[公会]["Name"] = 公会;
|
||||||
data[公会]["Owner"] = Core.GetUser(info["user_id"]);
|
data[公会]["Owner"] = Core.GetUser(info["user_id"]);
|
||||||
data[公会]["Admin"] = {};
|
data[公会]["Admin"] = {};
|
||||||
data[公会]["Admin"][Core.GetUser(info["user_id"])] = true;
|
data[公会]["Admin"][Core.GetUser(info["user_id"])] = true;
|
||||||
data[公会]["Higher"] = gh[1];
|
data[公会]["Higher"] = gh[1];
|
||||||
data[公会]["Info"] = "暂无介绍";
|
data[公会]["Info"] = "暂无介绍";
|
||||||
if(info["group_id"]!=undefined){
|
if(info["group_id"]!=undefined){
|
||||||
data[公会]["CreationByGroup"] = info["group_id"];
|
data[公会]["CreationByGroup"] = info["group_id"];
|
||||||
}else{
|
}else{
|
||||||
data[公会]["CreationByGroup"] = "暂无";
|
data[公会]["CreationByGroup"] = "暂无";
|
||||||
}
|
}
|
||||||
data[公会]["Downer"] = [];
|
data[公会]["Downer"] = [];
|
||||||
fs.writeFileSync("./Data/公会.json",JSON.stringify(data));
|
fs.writeFileSync("./Data/公会.json",JSON.stringify(data));
|
||||||
var data2 = Core.frame.ReadSystemConfig("公会系统");
|
var data2 = Core.frame.ReadSystemConfig("公会系统");
|
||||||
data2[Core.GetUser(info["user_id"])] = 公会;
|
data2[Core.GetUser(info["user_id"])] = 公会;
|
||||||
Core.frame.WriteSystemConfig("公会系统",data2);
|
Core.frame.WriteSystemConfig("公会系统",data2);
|
||||||
},
|
},
|
||||||
GetPublicInfo:function(公会){
|
GetPublicInfo:function(公会){
|
||||||
if(!exports.add.Interfaces.IsPublic(公会)){return `${false}`;}
|
if(!exports.add.Interfaces.IsPublic(公会)){return `${false}`;}
|
||||||
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
var br = "\r\n"
|
var br = "\r\n"
|
||||||
var info = `公会名称:${data[公会]["Name"]}${br}会长:${data[公会]["Owner"]}${Core.frame.At(data[公会]["Owner"])}${br}介绍:${data[公会]["Info"]}${br}交流群:${data[公会]["CreationByGroup"]}`;
|
var info = `公会名称:${data[公会]["Name"]}${br}会长:${data[公会]["Owner"]}${Core.frame.At(data[公会]["Owner"])}${br}介绍:${data[公会]["Info"]}${br}交流群:${data[公会]["CreationByGroup"]}`;
|
||||||
return info;
|
return info;
|
||||||
},
|
},
|
||||||
IsPublic:function(公会){
|
IsPublic:function(公会){
|
||||||
var data =JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data =JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
if(data[公会]!=undefined||NaN||null){
|
if(data[公会]!=undefined||NaN||null){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SetPublicValue:function(公会,Key,Value){
|
SetPublicValue:function(公会,Key,Value){
|
||||||
fs.readFile("./Data/公会.json",(err,data)=>{
|
fs.readFile("./Data/公会.json",(err,data)=>{
|
||||||
d2 = JSON.parse(data.toString());
|
d2 = JSON.parse(data.toString());
|
||||||
d2[公会][Key] = Value;
|
d2[公会][Key] = Value;
|
||||||
fs.writeFile("./Data/公会.json",JSON.stringify(d2),()=>{
|
fs.writeFile("./Data/公会.json",JSON.stringify(d2),()=>{
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
GetPublicValue:function(公会,Key){
|
GetPublicValue:function(公会,Key){
|
||||||
console.log(公会);
|
console.log(公会);
|
||||||
console.log(Key);
|
console.log(Key);
|
||||||
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
console.log(data);
|
console.log(data);
|
||||||
return data[公会][Key];
|
return data[公会][Key];
|
||||||
},
|
},
|
||||||
GetuserLeven:function(公会,user){
|
GetuserLeven:function(公会,user){
|
||||||
console.log(公会);
|
console.log(公会);
|
||||||
console.log(user);
|
console.log(user);
|
||||||
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if(user == data[公会]["Owner"]){
|
if(user == data[公会]["Owner"]){
|
||||||
return 3;//公会会长
|
return 3;//公会会长
|
||||||
};
|
};
|
||||||
var od = new Object(data[公会]["Admin"]);
|
var od = new Object(data[公会]["Admin"]);
|
||||||
for(var i=0;i<Object.keys(od).length;i++){
|
for(var i=0;i<Object.keys(od).length;i++){
|
||||||
if(user == Object.keys(od)[i]){
|
if(user == Object.keys(od)[i]){
|
||||||
return 2;//公会管理员
|
return 2;//公会管理员
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(exports.add.Interfaces.GetUserPublic(user) == 公会){
|
if(exports.add.Interfaces.GetUserPublic(user) == 公会){
|
||||||
return 1;//公会成员
|
return 1;//公会成员
|
||||||
}
|
}
|
||||||
return 0;//有啥关?没啥关!!!
|
return 0;//有啥关?没啥关!!!
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
//console.log("["+new Date().toString()+"][公会系统.js]正在处理");
|
//console.log("["+new Date().toString()+"][公会系统.js]正在处理");
|
||||||
var data = Core.frame.ReadSystemConfig("领工资");
|
var data = Core.frame.ReadSystemConfig("领工资");
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
var msg = new String(info["raw_message"]);
|
var msg = new String(info["raw_message"]);
|
||||||
if(msg=="领工资"){
|
if(msg=="领工资"){
|
||||||
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString()){
|
if(data[Core.GetUser(info["user_id"])]==date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString()){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"已领过工资了!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"已领过工资了!");
|
||||||
}else{
|
}else{
|
||||||
Money.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),500);
|
Money.add.Interfaces.GiveUserMoney(Core.GetUser(info["user_id"]),500);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"领工资成功,获得500RMB,当前余额"+Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"领工资成功,获得500RMB,当前余额"+Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"])));
|
||||||
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString();
|
data[Core.GetUser(info["user_id"])]=date.getFullYear().toString()+date.getMonth().toString()+date.getDay().toString();
|
||||||
Core.frame.WriteSystemConfig("领工资",data);
|
Core.frame.WriteSystemConfig("领工资",data);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if(msg.substr(0,4)=="创建公会"){
|
if(msg.substr(0,4)=="创建公会"){
|
||||||
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))<5000){
|
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))<5000){
|
||||||
Core.frame.SendMsg(connect,info,"您的余额不足5000,无法创建公会!");
|
Core.frame.SendMsg(connect,info,"您的余额不足5000,无法创建公会!");
|
||||||
}else{
|
}else{
|
||||||
if(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))!="[无工会]"){
|
if(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))!="[无工会]"){
|
||||||
Core.frame.SendMsg(connect,info,"您已经加入了一个公会!");
|
Core.frame.SendMsg(connect,info,"您已经加入了一个公会!");
|
||||||
}else{
|
}else{
|
||||||
var n = msg.replace("创建公会","");
|
var n = msg.replace("创建公会","");
|
||||||
n2 = n.split("+");
|
n2 = n.split("+");
|
||||||
if(n.length==0){
|
if(n.length==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
||||||
}else{
|
}else{
|
||||||
if(exports.add.Interfaces.IsPublic(n)){
|
if(exports.add.Interfaces.IsPublic(n)){
|
||||||
Core.frame.SendMsg(connect,info,"此公会已存在,请输入别的公会名称");
|
Core.frame.SendMsg(connect,info,"此公会已存在,请输入别的公会名称");
|
||||||
}else{
|
}else{
|
||||||
exports.add.Interfaces.CreatePublic(info,n2);
|
exports.add.Interfaces.CreatePublic(info,n2);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",创建公会成功!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",创建公会成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(msg=="公会列表"){
|
if(msg=="公会列表"){
|
||||||
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
var data = JSON.parse(fs.readFileSync("./Data/公会.json").toString());
|
||||||
var o = Object.keys(data);
|
var o = Object.keys(data);
|
||||||
var f="公会列表如下:";
|
var f="公会列表如下:";
|
||||||
for(var i=0;i<o.length;i++){
|
for(var i=0;i<o.length;i++){
|
||||||
f = f +"\\r\\n" + (i+1) + "." + o[i]
|
f = f +"\\r\\n" + (i+1) + "." + o[i]
|
||||||
}
|
}
|
||||||
Core.frame.SendMsg(connect,info,f);
|
Core.frame.SendMsg(connect,info,f);
|
||||||
};
|
};
|
||||||
if(msg.substr(0,4)=="加入公会"){
|
if(msg.substr(0,4)=="加入公会"){
|
||||||
if(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))!="[无工会]"){
|
if(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))!="[无工会]"){
|
||||||
Core.frame.SendMsg(connect,info,"您已经加入了一个公会!");
|
Core.frame.SendMsg(connect,info,"您已经加入了一个公会!");
|
||||||
}else{
|
}else{
|
||||||
var n = msg.replace("加入公会","");
|
var n = msg.replace("加入公会","");
|
||||||
if(n.length==0){
|
if(n.length==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
||||||
}else{
|
}else{
|
||||||
exports.add.Interfaces.SetUserPublic(Core.GetUser(info["user_id"]),n);
|
exports.add.Interfaces.SetUserPublic(Core.GetUser(info["user_id"]),n);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",加入公会成功!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",加入公会成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(msg=="查看我的公会"){
|
if(msg=="查看我的公会"){
|
||||||
console.log(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])));
|
console.log(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])));
|
||||||
Core.frame.SendMsg(connect,info,exports.add.Interfaces.GetPublicInfo(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))));
|
Core.frame.SendMsg(connect,info,exports.add.Interfaces.GetPublicInfo(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"]))));
|
||||||
};
|
};
|
||||||
if(msg=="退出公会"){
|
if(msg=="退出公会"){
|
||||||
exports.add.Interfaces.SetUserPublic(Core.GetUser(info["user_id"]),"[无工会]");
|
exports.add.Interfaces.SetUserPublic(Core.GetUser(info["user_id"]),"[无工会]");
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",退出公会成功!");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+",退出公会成功!");
|
||||||
};
|
};
|
||||||
if(msg.substr(0,4)=="查看公会"){
|
if(msg.substr(0,4)=="查看公会"){
|
||||||
var n = msg.replace("查看公会","");
|
var n = msg.replace("查看公会","");
|
||||||
if(n.length==0){
|
if(n.length==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
Core.frame.SendMsg(connect,info,"请输入公会名称");
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,exports.add.Interfaces.GetPublicInfo(n));
|
Core.frame.SendMsg(connect,info,exports.add.Interfaces.GetPublicInfo(n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(msg.substr(0,6)=="设置公会简介"){
|
if(msg.substr(0,6)=="设置公会简介"){
|
||||||
var n = msg.replace("设置公会简介","");
|
var n = msg.replace("设置公会简介","");
|
||||||
if(n.length==0){
|
if(n.length==0){
|
||||||
Core.frame.SendMsg(connect,info,"请输入简介内容");
|
Core.frame.SendMsg(connect,info,"请输入简介内容");
|
||||||
}else{
|
}else{
|
||||||
if(exports.add.Interfaces.GetuserLeven(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])))>=2){
|
if(exports.add.Interfaces.GetuserLeven(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])))>=2){
|
||||||
Core.frame.SendMsg(connect,info,"你不是公会管理员");
|
Core.frame.SendMsg(connect,info,"你不是公会管理员");
|
||||||
}
|
}
|
||||||
exports.add.Interfaces.SetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Info",n);
|
exports.add.Interfaces.SetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Info",n);
|
||||||
Core.frame.SendMsg(connect,info,"设置完毕");
|
Core.frame.SendMsg(connect,info,"设置完毕");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(msg.substr(0,6)=="设置公会管理"){
|
if(msg.substr(0,6)=="设置公会管理"){
|
||||||
var n = msg.replace("设置公会管理","");
|
var n = msg.replace("设置公会管理","");
|
||||||
n = n.replace("[CQ:At,qq=","");
|
n = n.replace("[CQ:At,qq=","");
|
||||||
n = n.replace("]","");
|
n = n.replace("]","");
|
||||||
n = n.replace(" ","");
|
n = n.replace(" ","");
|
||||||
if(exports.add.Interfaces.GetuserLeven(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),Core.GetUser(info["user_id"])) == 3){
|
if(exports.add.Interfaces.GetuserLeven(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),Core.GetUser(info["user_id"])) == 3){
|
||||||
var data = exports.add.Interfaces.GetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Admin");
|
var data = exports.add.Interfaces.GetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Admin");
|
||||||
data[n] = true;
|
data[n] = true;
|
||||||
exports.add.Interfaces.SetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Admin",data);
|
exports.add.Interfaces.SetPublicValue(exports.add.Interfaces.GetUserPublic(Core.GetUser(info["user_id"])),"Admin",data);
|
||||||
Core.frame.SendMsg(connect,info,"设置完毕");
|
Core.frame.SendMsg(connect,info,"设置完毕");
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"必须公会会长才可以设置管理员");
|
Core.frame.SendMsg(connect,info,"必须公会会长才可以设置管理员");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
农场.json
16
农场.json
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"农业":{
|
"农业":{
|
||||||
"小麦":{
|
"小麦":{
|
||||||
"种子":10,
|
"种子":10,
|
||||||
"售价":20,
|
"售价":20,
|
||||||
"生长":60
|
"生长":60
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
30
农场Lib.d.ts
vendored
30
农场Lib.d.ts
vendored
@ -1,16 +1,16 @@
|
|||||||
interface 作物{
|
interface 作物{
|
||||||
种子:number|Number;
|
种子:number|Number;
|
||||||
售价:number|Number;
|
售价:number|Number;
|
||||||
生长:number|Number;
|
生长:number|Number;
|
||||||
}
|
}
|
||||||
interface 农场Lib{
|
interface 农场Lib{
|
||||||
农业:any;
|
农业:any;
|
||||||
}
|
}
|
||||||
interface User农场Data{
|
interface User农场Data{
|
||||||
菜地:作物单位[]
|
菜地:作物单位[]
|
||||||
}
|
}
|
||||||
interface 作物单位{
|
interface 作物单位{
|
||||||
类型:String|string;
|
类型:String|string;
|
||||||
成熟:Number|number;
|
成熟:Number|number;
|
||||||
已采摘?:Boolean|boolean;
|
已采摘?:Boolean|boolean;
|
||||||
}
|
}
|
||||||
158
农村.js
158
农村.js
@ -1,79 +1,79 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const MoneyInterfaces = require("./Money").add.Interfaces;
|
const MoneyInterfaces = require("./Money").add.Interfaces;
|
||||||
const 农场Config = {
|
const 农场Config = {
|
||||||
前缀: "农场",
|
前缀: "农场",
|
||||||
配置: "农场.json",
|
配置: "农场.json",
|
||||||
数据: "农场Data.json"
|
数据: "农场Data.json"
|
||||||
};
|
};
|
||||||
var 农场配置;
|
var 农场配置;
|
||||||
var 农场数据;
|
var 农场数据;
|
||||||
fs.readFile(农场Config.配置, (err, data) => {
|
fs.readFile(农场Config.配置, (err, data) => {
|
||||||
农场配置 = JSON.parse(data.toString());
|
农场配置 = JSON.parse(data.toString());
|
||||||
});
|
});
|
||||||
fs.readFile(农场Config.数据, (err, data) => {
|
fs.readFile(农场Config.数据, (err, data) => {
|
||||||
农场数据 = JSON.parse(data.toString());
|
农场数据 = JSON.parse(data.toString());
|
||||||
});
|
});
|
||||||
Core.AddListener((c, i) => {
|
Core.AddListener((c, i) => {
|
||||||
if (i.message.substr(0, 农场Config.前缀.length) != 农场Config.前缀) {
|
if (i.message.substr(0, 农场Config.前缀.length) != 农场Config.前缀) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (农场数据[Core.GetUser(i.user_id)] == undefined) {
|
if (农场数据[Core.GetUser(i.user_id)] == undefined) {
|
||||||
农场数据[Core.GetUser(i.user_id)] = {
|
农场数据[Core.GetUser(i.user_id)] = {
|
||||||
菜地: []
|
菜地: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var Command = i.message.replace(农场Config.前缀, "");
|
var Command = i.message.replace(农场Config.前缀, "");
|
||||||
if (Command.substr(0, 2) == "种植") {
|
if (Command.substr(0, 2) == "种植") {
|
||||||
var 作物 = Command.replace("种植", "");
|
var 作物 = Command.replace("种植", "");
|
||||||
var 作物Config = 农场配置.农业[作物];
|
var 作物Config = 农场配置.农业[作物];
|
||||||
if (作物Config == undefined) {
|
if (作物Config == undefined) {
|
||||||
Core.frame.SendMsg(c, i, Core.frame.At(i.user_id) + ",没有这个作物。");
|
Core.frame.SendMsg(c, i, Core.frame.At(i.user_id) + ",没有这个作物。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
if (MoneyInterfaces.GetUserMoney(i.user_id) < 作物Config.种子) {
|
if (MoneyInterfaces.GetUserMoney(i.user_id) < 作物Config.种子) {
|
||||||
Core.frame.SendMsg(c, i, Core.frame.At(i.user_id) + ",你的钱不够。");
|
Core.frame.SendMsg(c, i, Core.frame.At(i.user_id) + ",你的钱不够。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地[农场数据[Core.GetUser(i.user_id)].菜地.length] = {
|
农场数据[Core.GetUser(i.user_id)].菜地[农场数据[Core.GetUser(i.user_id)].菜地.length] = {
|
||||||
类型: 作物,
|
类型: 作物,
|
||||||
成熟: Math.round(new Date().getTime() / 1000 + 作物Config.生长.valueOf())
|
成熟: Math.round(new Date().getTime() / 1000 + 作物Config.生长.valueOf())
|
||||||
};
|
};
|
||||||
MoneyInterfaces.CostUserMoney(Core.GetUser(i.user_id), 作物Config.种子);
|
MoneyInterfaces.CostUserMoney(Core.GetUser(i.user_id), 作物Config.种子);
|
||||||
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你使用${作物Config.种子}点金币购买了${作物},它将会在${作物Config.生长}秒后完成生长。`);
|
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你使用${作物Config.种子}点金币购买了${作物},它将会在${作物Config.生长}秒后完成生长。`);
|
||||||
}
|
}
|
||||||
if (Command.substr(0, 2) == "采摘") {
|
if (Command.substr(0, 2) == "采摘") {
|
||||||
var UserMoneyAdd = 0;
|
var UserMoneyAdd = 0;
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v, index) => {
|
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v, index) => {
|
||||||
if (v.成熟 < new Date().getTime() / 1000) {
|
if (v.成熟 < new Date().getTime() / 1000) {
|
||||||
if (农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true) {
|
if (农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserMoneyAdd = UserMoneyAdd + 农场配置.农业[v.类型.valueOf()].售价.valueOf();
|
UserMoneyAdd = UserMoneyAdd + 农场配置.农业[v.类型.valueOf()].售价.valueOf();
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 = true;
|
农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MoneyInterfaces.GiveUserMoney(Core.GetUser(i.user_id), UserMoneyAdd);
|
MoneyInterfaces.GiveUserMoney(Core.GetUser(i.user_id), UserMoneyAdd);
|
||||||
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你采摘了你的菜地中的成熟的作物,获得了${UserMoneyAdd}点金币。`);
|
Core.frame.SendMsg(c, i, `${Core.frame.At(Core.GetUser(i.user_id))},你采摘了你的菜地中的成熟的作物,获得了${UserMoneyAdd}点金币。`);
|
||||||
var temp = [];
|
var temp = [];
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v, index) => {
|
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v, index) => {
|
||||||
if (农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true) {
|
if (农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
temp[temp.length] = v;
|
temp[temp.length] = v;
|
||||||
});
|
});
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地 = temp;
|
农场数据[Core.GetUser(i.user_id)].菜地 = temp;
|
||||||
}
|
}
|
||||||
fs.writeFile(农场Config.数据, JSON.stringify(new Object(农场数据)), (err) => { });
|
fs.writeFile(农场Config.数据, JSON.stringify(new Object(农场数据)), (err) => { });
|
||||||
});
|
});
|
||||||
// Core.AddInterface("农村",())
|
// Core.AddInterface("农村",())
|
||||||
|
|||||||
154
农村.ts
154
农村.ts
@ -1,78 +1,78 @@
|
|||||||
import * as Core from "./Core"
|
import * as Core from "./Core"
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
const MoneyInterfaces = (require("./Money") as LibMoney).add.Interfaces;
|
const MoneyInterfaces = (require("./Money") as LibMoney).add.Interfaces;
|
||||||
|
|
||||||
const 农场Config = {
|
const 农场Config = {
|
||||||
前缀:"农场",
|
前缀:"农场",
|
||||||
配置:"农场.json",
|
配置:"农场.json",
|
||||||
数据:"农场Data.json"
|
数据:"农场Data.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
var 农场配置:农场Lib;
|
var 农场配置:农场Lib;
|
||||||
var 农场数据:User农场Data[];
|
var 农场数据:User农场Data[];
|
||||||
fs.readFile(农场Config.配置,(err,data)=>{
|
fs.readFile(农场Config.配置,(err,data)=>{
|
||||||
农场配置 = JSON.parse(data.toString()) as 农场Lib;
|
农场配置 = JSON.parse(data.toString()) as 农场Lib;
|
||||||
});
|
});
|
||||||
fs.readFile(农场Config.数据,(err,data)=>{
|
fs.readFile(农场Config.数据,(err,data)=>{
|
||||||
农场数据 = JSON.parse(data.toString()) as User农场Data[];
|
农场数据 = JSON.parse(data.toString()) as User农场Data[];
|
||||||
})
|
})
|
||||||
Core.AddListener((c,i)=>{
|
Core.AddListener((c,i)=>{
|
||||||
if(i.message.substr( 0, 农场Config.前缀.length) != 农场Config.前缀){
|
if(i.message.substr( 0, 农场Config.前缀.length) != 农场Config.前缀){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(农场数据[Core.GetUser(i.user_id)] == undefined){
|
if(农场数据[Core.GetUser(i.user_id)] == undefined){
|
||||||
农场数据[Core.GetUser(i.user_id)] = {
|
农场数据[Core.GetUser(i.user_id)] = {
|
||||||
菜地:[]
|
菜地:[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var Command = i.message.replace(农场Config.前缀,"");
|
var Command = i.message.replace(农场Config.前缀,"");
|
||||||
if( Command.substr(0,2) == "种植"){
|
if( Command.substr(0,2) == "种植"){
|
||||||
var 作物 = Command.replace("种植","");
|
var 作物 = Command.replace("种植","");
|
||||||
var 作物Config = 农场配置.农业[作物] as 作物;
|
var 作物Config = 农场配置.农业[作物] as 作物;
|
||||||
if(作物Config == undefined){
|
if(作物Config == undefined){
|
||||||
Core.frame.SendMsg(c,i,Core.frame.At(i.user_id)+",没有这个作物。");
|
Core.frame.SendMsg(c,i,Core.frame.At(i.user_id)+",没有这个作物。");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if( MoneyInterfaces.GetUserMoney(i.user_id) < 作物Config.种子 ){
|
if( MoneyInterfaces.GetUserMoney(i.user_id) < 作物Config.种子 ){
|
||||||
Core.frame.SendMsg(c,i,Core.frame.At(i.user_id)+",你的钱不够。")
|
Core.frame.SendMsg(c,i,Core.frame.At(i.user_id)+",你的钱不够。")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地[农场数据[Core.GetUser(i.user_id)].菜地.length] = {
|
农场数据[Core.GetUser(i.user_id)].菜地[农场数据[Core.GetUser(i.user_id)].菜地.length] = {
|
||||||
类型:作物,
|
类型:作物,
|
||||||
成熟:Math.round(new Date().getTime()/1000 + 作物Config.生长.valueOf())
|
成熟:Math.round(new Date().getTime()/1000 + 作物Config.生长.valueOf())
|
||||||
}
|
}
|
||||||
MoneyInterfaces.CostUserMoney(Core.GetUser(i.user_id),作物Config.种子);
|
MoneyInterfaces.CostUserMoney(Core.GetUser(i.user_id),作物Config.种子);
|
||||||
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你使用${作物Config.种子}点金币购买了${作物},它将会在${作物Config.生长}秒后完成生长。`);
|
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你使用${作物Config.种子}点金币购买了${作物},它将会在${作物Config.生长}秒后完成生长。`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Command.substr(0,2) == "采摘" ){
|
if( Command.substr(0,2) == "采摘" ){
|
||||||
var UserMoneyAdd = 0;
|
var UserMoneyAdd = 0;
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v,index)=>{
|
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v,index)=>{
|
||||||
if(v.成熟 < new Date().getTime()/1000 ){
|
if(v.成熟 < new Date().getTime()/1000 ){
|
||||||
if(农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true){
|
if(农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserMoneyAdd = UserMoneyAdd + (农场配置.农业[v.类型.valueOf()] as 作物).售价.valueOf();
|
UserMoneyAdd = UserMoneyAdd + (农场配置.农业[v.类型.valueOf()] as 作物).售价.valueOf();
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 = true;
|
农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MoneyInterfaces.GiveUserMoney(Core.GetUser(i.user_id),UserMoneyAdd);
|
MoneyInterfaces.GiveUserMoney(Core.GetUser(i.user_id),UserMoneyAdd);
|
||||||
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你采摘了你的菜地中的成熟的作物,获得了${UserMoneyAdd}点金币。`);
|
Core.frame.SendMsg(c,i,`${Core.frame.At(Core.GetUser(i.user_id))},你采摘了你的菜地中的成熟的作物,获得了${UserMoneyAdd}点金币。`);
|
||||||
|
|
||||||
var temp:作物单位[] = [];
|
var temp:作物单位[] = [];
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v,index)=>{
|
农场数据[Core.GetUser(i.user_id)].菜地.forEach((v,index)=>{
|
||||||
if(农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true){
|
if(农场数据[Core.GetUser(i.user_id)].菜地[index].已采摘 == true){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
temp[temp.length] = v;
|
temp[temp.length] = v;
|
||||||
});
|
});
|
||||||
农场数据[Core.GetUser(i.user_id)].菜地 = temp;
|
农场数据[Core.GetUser(i.user_id)].菜地 = temp;
|
||||||
}
|
}
|
||||||
if( Command == "查看" ){
|
if( Command == "查看" ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFile(农场Config.数据,JSON.stringify(new Object(农场数据)),(err)=>{});
|
fs.writeFile(农场Config.数据,JSON.stringify(new Object(农场数据)),(err)=>{});
|
||||||
});
|
});
|
||||||
// Core.AddInterface("农村",())
|
// Core.AddInterface("农村",())
|
||||||
@ -1,20 +1,20 @@
|
|||||||
<html lang="zh-cn">
|
<html lang="zh-cn">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>利刃后端 WebIDE</title>
|
<title>利刃后端 WebIDE</title>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
指令:<input type="text" id="CommandName" />
|
指令:<input type="text" id="CommandName" />
|
||||||
<a id="Info">下载</a>
|
<a id="Info">下载</a>
|
||||||
<br>消息:<br>
|
<br>消息:<br>
|
||||||
<center>
|
<center>
|
||||||
<textarea id="Main" style="width:80%;height:60%;"></textarea>
|
<textarea id="Main" style="width:80%;height:60%;"></textarea>
|
||||||
<a id="Editing">0</a><button id="Last">上一个</button><button id="Next">下一个</button>
|
<a id="Editing">0</a><button id="Last">上一个</button><button id="Next">下一个</button>
|
||||||
<input type="text" id="Execute" style="width:80%;"/>
|
<input type="text" id="Execute" style="width:80%;"/>
|
||||||
</center>
|
</center>
|
||||||
<button id="OutPut">下载</button>
|
<button id="OutPut">下载</button>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
32
利刃Editor/lib.d.ts
vendored
32
利刃Editor/lib.d.ts
vendored
@ -1,17 +1,17 @@
|
|||||||
declare interface Addons{
|
declare interface Addons{
|
||||||
Config:AddonsConfig,
|
Config:AddonsConfig,
|
||||||
Base:AddonsBase,
|
Base:AddonsBase,
|
||||||
Using:any;
|
Using:any;
|
||||||
}
|
}
|
||||||
declare interface AddonsConfig{
|
declare interface AddonsConfig{
|
||||||
Name:String,
|
Name:String,
|
||||||
Author:String
|
Author:String
|
||||||
}
|
}
|
||||||
declare interface AddonsBase{
|
declare interface AddonsBase{
|
||||||
Const:any,
|
Const:any,
|
||||||
Function:any;
|
Function:any;
|
||||||
}
|
}
|
||||||
declare interface AddonsUsing{
|
declare interface AddonsUsing{
|
||||||
Content:String,
|
Content:String,
|
||||||
Execute:Array<String>;
|
Execute:Array<String>;
|
||||||
}
|
}
|
||||||
@ -1,91 +1,91 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
window.onload = (() => {
|
window.onload = (() => {
|
||||||
Core();
|
Core();
|
||||||
});
|
});
|
||||||
var Core = (() => {
|
var Core = (() => {
|
||||||
var Using = 0;
|
var Using = 0;
|
||||||
var Editing = {
|
var Editing = {
|
||||||
Config: {
|
Config: {
|
||||||
Name: "Addons",
|
Name: "Addons",
|
||||||
Author: "User"
|
Author: "User"
|
||||||
},
|
},
|
||||||
Base: {
|
Base: {
|
||||||
Const: {},
|
Const: {},
|
||||||
Function: {}
|
Function: {}
|
||||||
},
|
},
|
||||||
Using: {}
|
Using: {}
|
||||||
};
|
};
|
||||||
if (localStorage.getItem("[利刃]储存") != undefined && localStorage.getItem("[利刃]储存") != null) {
|
if (localStorage.getItem("[利刃]储存") != undefined && localStorage.getItem("[利刃]储存") != null) {
|
||||||
Editing = JSON.parse(localStorage.getItem("[利刃]储存"));
|
Editing = JSON.parse(localStorage.getItem("[利刃]储存"));
|
||||||
}
|
}
|
||||||
var CommandName = document.getElementById("CommandName");
|
var CommandName = document.getElementById("CommandName");
|
||||||
var Main = document.getElementById("Main");
|
var Main = document.getElementById("Main");
|
||||||
var Info = document.getElementById("Info");
|
var Info = document.getElementById("Info");
|
||||||
var OutPut = document.getElementById("OutPut");
|
var OutPut = document.getElementById("OutPut");
|
||||||
var EditingExec = document.getElementById("Editing");
|
var EditingExec = document.getElementById("Editing");
|
||||||
var Last = document.getElementById("Last");
|
var Last = document.getElementById("Last");
|
||||||
var Next = document.getElementById("Next");
|
var Next = document.getElementById("Next");
|
||||||
var Execute = document.getElementById("Execute");
|
var Execute = document.getElementById("Execute");
|
||||||
CommandName.onchange = ((ev) => {
|
CommandName.onchange = ((ev) => {
|
||||||
if (Editing.Using[CommandName.value]) {
|
if (Editing.Using[CommandName.value]) {
|
||||||
Main.value = Editing.Using[CommandName.value].Content;
|
Main.value = Editing.Using[CommandName.value].Content;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Main.value = "";
|
Main.value = "";
|
||||||
Editing.Using[CommandName.value] = { Content: "", Execute: [] };
|
Editing.Using[CommandName.value] = { Content: "", Execute: [] };
|
||||||
}
|
}
|
||||||
Using = 0;
|
Using = 0;
|
||||||
if (Editing.Using[CommandName.value].Execute[Using]) {
|
if (Editing.Using[CommandName.value].Execute[Using]) {
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Main.onchange = ((ev) => {
|
Main.onchange = ((ev) => {
|
||||||
console.log(Main.value);
|
console.log(Main.value);
|
||||||
Editing.Using[CommandName.value].Content = Main.value;
|
Editing.Using[CommandName.value].Content = Main.value;
|
||||||
if (Main.value == "") {
|
if (Main.value == "") {
|
||||||
Editing.Using[CommandName.value] = undefined;
|
Editing.Using[CommandName.value] = undefined;
|
||||||
}
|
}
|
||||||
localStorage.setItem("[利刃]储存", JSON.stringify(Editing));
|
localStorage.setItem("[利刃]储存", JSON.stringify(Editing));
|
||||||
});
|
});
|
||||||
OutPut.onclick = ((ev) => {
|
OutPut.onclick = ((ev) => {
|
||||||
var Z = Info;
|
var Z = Info;
|
||||||
Z.href = window.URL.createObjectURL(new Blob([JSON.stringify(Editing)]));
|
Z.href = window.URL.createObjectURL(new Blob([JSON.stringify(Editing)]));
|
||||||
Z.download = "main.lib.json";
|
Z.download = "main.lib.json";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Z.dispatchEvent(new MouseEvent("click"));
|
Z.dispatchEvent(new MouseEvent("click"));
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
Last.onclick = (() => {
|
Last.onclick = (() => {
|
||||||
if (Using == 0) {
|
if (Using == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Using = Using - 1;
|
Using = Using - 1;
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
if (Editing.Using[CommandName.value].Execute[Using]) {
|
if (Editing.Using[CommandName.value].Execute[Using]) {
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Next.onclick = (() => {
|
Next.onclick = (() => {
|
||||||
Using = Using + 1;
|
Using = Using + 1;
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
if (Editing.Using[CommandName.value].Execute[Using]) {
|
if (Editing.Using[CommandName.value].Execute[Using]) {
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Execute.onchange = (() => {
|
Execute.onchange = (() => {
|
||||||
Editing.Using[CommandName.value].Execute[Using] = Execute.value;
|
Editing.Using[CommandName.value].Execute[Using] = Execute.value;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,88 +1,88 @@
|
|||||||
window.onload = (()=>{
|
window.onload = (()=>{
|
||||||
Core();
|
Core();
|
||||||
})
|
})
|
||||||
var Core = (()=>{
|
var Core = (()=>{
|
||||||
var Using = 0;
|
var Using = 0;
|
||||||
var Editing:Addons = {
|
var Editing:Addons = {
|
||||||
Config:{
|
Config:{
|
||||||
Name:"Addons",
|
Name:"Addons",
|
||||||
Author:"User"
|
Author:"User"
|
||||||
},
|
},
|
||||||
Base:{
|
Base:{
|
||||||
Const:{},
|
Const:{},
|
||||||
Function:{}
|
Function:{}
|
||||||
},
|
},
|
||||||
Using:{}
|
Using:{}
|
||||||
}
|
}
|
||||||
if(localStorage.getItem("[利刃]储存") != undefined && localStorage.getItem("[利刃]储存") != null){
|
if(localStorage.getItem("[利刃]储存") != undefined && localStorage.getItem("[利刃]储存") != null){
|
||||||
Editing = JSON.parse(localStorage.getItem("[利刃]储存") as string) as Addons;
|
Editing = JSON.parse(localStorage.getItem("[利刃]储存") as string) as Addons;
|
||||||
}
|
}
|
||||||
var CommandName = document.getElementById("CommandName") as HTMLInputElement;
|
var CommandName = document.getElementById("CommandName") as HTMLInputElement;
|
||||||
var Main = document.getElementById("Main") as HTMLTextAreaElement;
|
var Main = document.getElementById("Main") as HTMLTextAreaElement;
|
||||||
var Info = document.getElementById("Info") as HTMLAnchorElement;
|
var Info = document.getElementById("Info") as HTMLAnchorElement;
|
||||||
var OutPut = document.getElementById("OutPut") as HTMLButtonElement;
|
var OutPut = document.getElementById("OutPut") as HTMLButtonElement;
|
||||||
var EditingExec = document.getElementById("Editing") as HTMLAnchorElement;
|
var EditingExec = document.getElementById("Editing") as HTMLAnchorElement;
|
||||||
var Last = document.getElementById("Last") as HTMLButtonElement;
|
var Last = document.getElementById("Last") as HTMLButtonElement;
|
||||||
var Next = document.getElementById("Next") as HTMLButtonElement;
|
var Next = document.getElementById("Next") as HTMLButtonElement;
|
||||||
var Execute = document.getElementById("Execute") as HTMLInputElement;
|
var Execute = document.getElementById("Execute") as HTMLInputElement;
|
||||||
CommandName.onchange = ((ev)=>{
|
CommandName.onchange = ((ev)=>{
|
||||||
if(Editing.Using[CommandName.value]){
|
if(Editing.Using[CommandName.value]){
|
||||||
Main.value = Editing.Using[CommandName.value].Content;
|
Main.value = Editing.Using[CommandName.value].Content;
|
||||||
}else{
|
}else{
|
||||||
Main.value = "";
|
Main.value = "";
|
||||||
Editing.Using[CommandName.value] = {Content:"",Execute:[]}
|
Editing.Using[CommandName.value] = {Content:"",Execute:[]}
|
||||||
}
|
}
|
||||||
Using = 0;
|
Using = 0;
|
||||||
if(Editing.Using[CommandName.value].Execute[Using]){
|
if(Editing.Using[CommandName.value].Execute[Using]){
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}else{
|
}else{
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Main.onchange = ((ev)=>{
|
Main.onchange = ((ev)=>{
|
||||||
console.log(Main.value);
|
console.log(Main.value);
|
||||||
Editing.Using[CommandName.value].Content = Main.value;
|
Editing.Using[CommandName.value].Content = Main.value;
|
||||||
|
|
||||||
if(Main.value == ""){
|
if(Main.value == ""){
|
||||||
Editing.Using[CommandName.value] = undefined;
|
Editing.Using[CommandName.value] = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem("[利刃]储存",JSON.stringify(Editing));
|
localStorage.setItem("[利刃]储存",JSON.stringify(Editing));
|
||||||
});
|
});
|
||||||
OutPut.onclick = ((ev)=>{
|
OutPut.onclick = ((ev)=>{
|
||||||
var Z = Info;
|
var Z = Info;
|
||||||
Z.href = window.URL.createObjectURL(new Blob([JSON.stringify(Editing)]));
|
Z.href = window.URL.createObjectURL(new Blob([JSON.stringify(Editing)]));
|
||||||
Z.download = "main.lib.json";
|
Z.download = "main.lib.json";
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
Z.dispatchEvent(new MouseEvent("click"));
|
Z.dispatchEvent(new MouseEvent("click"));
|
||||||
},500);
|
},500);
|
||||||
});
|
});
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
Last.onclick = (()=>{
|
Last.onclick = (()=>{
|
||||||
if(Using == 0){
|
if(Using == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Using = Using - 1;
|
Using = Using - 1;
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
if(Editing.Using[CommandName.value].Execute[Using]){
|
if(Editing.Using[CommandName.value].Execute[Using]){
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}else{
|
}else{
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Next.onclick = (()=>{
|
Next.onclick = (()=>{
|
||||||
Using = Using + 1;
|
Using = Using + 1;
|
||||||
EditingExec.innerText = `${Using}`;
|
EditingExec.innerText = `${Using}`;
|
||||||
if(Editing.Using[CommandName.value].Execute[Using]){
|
if(Editing.Using[CommandName.value].Execute[Using]){
|
||||||
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
Execute.value = Editing.Using[CommandName.value].Execute[Using];
|
||||||
}else{
|
}else{
|
||||||
Editing.Using[CommandName.value].Execute[Using] = "";
|
Editing.Using[CommandName.value].Execute[Using] = "";
|
||||||
Execute.value = "";
|
Execute.value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Execute.onchange = (()=>{
|
Execute.onchange = (()=>{
|
||||||
Editing.Using[CommandName.value].Execute[Using] = Execute.value;
|
Editing.Using[CommandName.value].Execute[Using] = Execute.value;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
50
复读机.js
50
复读机.js
@ -1,25 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
(() => {
|
(() => {
|
||||||
var LastMsg = "";
|
var LastMsg = "";
|
||||||
var LastMsg2 = "";
|
var LastMsg2 = "";
|
||||||
Core.AddListener((Connect, Info) => {
|
Core.AddListener((Connect, Info) => {
|
||||||
if (Info.message == LastMsg && Core.HOOK) {
|
if (Info.message == LastMsg && Core.HOOK) {
|
||||||
if (LastMsg == LastMsg2) {
|
if (LastMsg == LastMsg2) {
|
||||||
Core.frame.SendMsg(Connect, Info, LastMsg);
|
Core.frame.SendMsg(Connect, Info, LastMsg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LastMsg2 = LastMsg;
|
LastMsg2 = LastMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LastMsg = Info.message;
|
LastMsg = Info.message;
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
28
复读机.ts
28
复读机.ts
@ -1,15 +1,15 @@
|
|||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
(()=>{
|
(()=>{
|
||||||
var LastMsg:String = "";
|
var LastMsg:String = "";
|
||||||
var LastMsg2:String = "";
|
var LastMsg2:String = "";
|
||||||
Core.AddListener((Connect,Info)=>{
|
Core.AddListener((Connect,Info)=>{
|
||||||
if(Info.message == LastMsg && Core.HOOK){
|
if(Info.message == LastMsg && Core.HOOK){
|
||||||
if(LastMsg == LastMsg2){
|
if(LastMsg == LastMsg2){
|
||||||
Core.frame.SendMsg(Connect,Info,LastMsg);
|
Core.frame.SendMsg(Connect,Info,LastMsg);
|
||||||
}else{
|
}else{
|
||||||
LastMsg2 = LastMsg;
|
LastMsg2 = LastMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LastMsg = Info.message;
|
LastMsg = Info.message;
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
144
怼人.js
144
怼人.js
@ -1,72 +1,72 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//Please Use UTF-8
|
//Please Use UTF-8
|
||||||
const Core = __importStar(require("./Core"));
|
const Core = __importStar(require("./Core"));
|
||||||
(() => {
|
(() => {
|
||||||
var 怼人目标 = {};
|
var 怼人目标 = {};
|
||||||
var 怼人台词 = {
|
var 怼人台词 = {
|
||||||
"_无法识别": ["呵呵", "怎么地", "辣鸡"],
|
"_无法识别": ["呵呵", "怎么地", "辣鸡"],
|
||||||
"询问": ["不行", "不好", "放弃吧", "不咋地", "你不行"],
|
"询问": ["不行", "不好", "放弃吧", "不咋地", "你不行"],
|
||||||
"意见": ["我就这样", "有本事打我啊", "辣鸡"],
|
"意见": ["我就这样", "有本事打我啊", "辣鸡"],
|
||||||
"请求": ["我就不,你能拿我怎么样!?", "并不!"],
|
"请求": ["我就不,你能拿我怎么样!?", "并不!"],
|
||||||
"骂人": ["你是什么我不知道,但是我知道你不是什么。那就是你不是人。", "虽然我不是人,但你比我更不是人。", "你是东西吗?", "Are you a thing?"],
|
"骂人": ["你是什么我不知道,但是我知道你不是什么。那就是你不是人。", "虽然我不是人,但你比我更不是人。", "你是东西吗?", "Are you a thing?"],
|
||||||
"投降": ["本Ai被你怼哭了", "懒得和你计较了", "我不怼你了,对牛弹琴又有何用呢?", "我就暂且饶过你一次。"]
|
"投降": ["本Ai被你怼哭了", "懒得和你计较了", "我不怼你了,对牛弹琴又有何用呢?", "我就暂且饶过你一次。"]
|
||||||
};
|
};
|
||||||
Core.AddListener((c, i) => {
|
Core.AddListener((c, i) => {
|
||||||
if (i.message.indexOf("投降") != -1) {
|
if (i.message.indexOf("投降") != -1) {
|
||||||
if (怼人目标[i.user_id]) {
|
if (怼人目标[i.user_id]) {
|
||||||
怼人目标[i.user_id] = 0;
|
怼人目标[i.user_id] = 0;
|
||||||
Core.frame.SendMsg(c, i, "哈哈!投降了吧!就你敢还和我怼?");
|
Core.frame.SendMsg(c, i, "哈哈!投降了吧!就你敢还和我怼?");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Core.frame.SendMsg(c, i, "我本来也没想怼你啊。");
|
Core.frame.SendMsg(c, i, "我本来也没想怼你啊。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (怼人目标[i.user_id] > 0) {
|
if (怼人目标[i.user_id] > 0) {
|
||||||
if (i.message.indexOf("你这人") != -1 || i.message.indexOf("你") != -1 || i.message.indexOf("这") != -1) {
|
if (i.message.indexOf("你这人") != -1 || i.message.indexOf("你") != -1 || i.message.indexOf("这") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.意见[new Number(Math.floor(怼人台词.意见.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.意见[new Number(Math.floor(怼人台词.意见.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
else if (i.message.indexOf("怎么样") != -1 || i.message.indexOf("吗") != -1 || i.message.indexOf("如何") != -1) {
|
else if (i.message.indexOf("怎么样") != -1 || i.message.indexOf("吗") != -1 || i.message.indexOf("如何") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.询问[new Number(Math.floor(怼人台词.询问.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.询问[new Number(Math.floor(怼人台词.询问.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
else if (i.message.indexOf("请") != -1) {
|
else if (i.message.indexOf("请") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.请求[new Number(Math.floor(怼人台词.请求.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.请求[new Number(Math.floor(怼人台词.请求.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
else if (i.message.indexOf("我") != -1 || i.message.indexOf("什么") != -1) {
|
else if (i.message.indexOf("我") != -1 || i.message.indexOf("什么") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.骂人[new Number(Math.floor(怼人台词.骂人.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.骂人[new Number(Math.floor(怼人台词.骂人.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词._无法识别[new Number(Math.floor(怼人台词._无法识别.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词._无法识别[new Number(Math.floor(怼人台词._无法识别.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
怼人目标[i.user_id] = 怼人目标[i.user_id] - 1;
|
怼人目标[i.user_id] = 怼人目标[i.user_id] - 1;
|
||||||
if (怼人目标[i.user_id] == 0) {
|
if (怼人目标[i.user_id] == 0) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.投降[new Number(Math.floor(怼人台词.投降.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.投降[new Number(Math.floor(怼人台词.投降.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i.message == "怼我" || i.message == "怼人") {
|
if (i.message == "怼我" || i.message == "怼人") {
|
||||||
Core.frame.SendMsg(c, i, "行啊!接招!");
|
Core.frame.SendMsg(c, i, "行啊!接招!");
|
||||||
怼人目标[i.user_id] = 10;
|
怼人目标[i.user_id] = 10;
|
||||||
}
|
}
|
||||||
if (i.message.substr(0, 1) == "怼" || i.message.substr(0, 3) == "帮我怼") {
|
if (i.message.substr(0, 1) == "怼" || i.message.substr(0, 3) == "帮我怼") {
|
||||||
var qq = i.message.replace("怼", "");
|
var qq = i.message.replace("怼", "");
|
||||||
if (qq == "我") {
|
if (qq == "我") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (qq == "人") {
|
if (qq == "人") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qq = qq.replace("帮我", "");
|
qq = qq.replace("帮我", "");
|
||||||
qq = qq.replace("[CQ:at,qq=", "");
|
qq = qq.replace("[CQ:at,qq=", "");
|
||||||
qq = qq.replace("]", "");
|
qq = qq.replace("]", "");
|
||||||
怼人目标[qq] = 10;
|
怼人目标[qq] = 10;
|
||||||
Core.frame.SendMsg(c, i, `我会去怼${Core.frame.At(new Number(qq))}的`);
|
Core.frame.SendMsg(c, i, `我会去怼${Core.frame.At(new Number(qq))}的`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
114
怼人.ts
114
怼人.ts
@ -1,58 +1,58 @@
|
|||||||
//Please Use UTF-8
|
//Please Use UTF-8
|
||||||
import * as Core from "./Core";
|
import * as Core from "./Core";
|
||||||
(() => {//OnLoad
|
(() => {//OnLoad
|
||||||
var 怼人目标 = {} as any;
|
var 怼人目标 = {} as any;
|
||||||
var 怼人台词 = {
|
var 怼人台词 = {
|
||||||
"_无法识别": ["呵呵", "怎么地","辣鸡"],
|
"_无法识别": ["呵呵", "怎么地","辣鸡"],
|
||||||
"询问": ["不行", "不好", "放弃吧", "不咋地", "你不行"],
|
"询问": ["不行", "不好", "放弃吧", "不咋地", "你不行"],
|
||||||
"意见": ["我就这样", "有本事打我啊", "辣鸡"],
|
"意见": ["我就这样", "有本事打我啊", "辣鸡"],
|
||||||
"请求": ["我就不,你能拿我怎么样!?", "并不!"],
|
"请求": ["我就不,你能拿我怎么样!?", "并不!"],
|
||||||
"骂人": ["你是什么我不知道,但是我知道你不是什么。那就是你不是人。", "虽然我不是人,但你比我更不是人。", "你是东西吗?", "Are you a thing?"],
|
"骂人": ["你是什么我不知道,但是我知道你不是什么。那就是你不是人。", "虽然我不是人,但你比我更不是人。", "你是东西吗?", "Are you a thing?"],
|
||||||
"投降":["本Ai被你怼哭了","懒得和你计较了","我不怼你了,对牛弹琴又有何用呢?","我就暂且饶过你一次。"]
|
"投降":["本Ai被你怼哭了","懒得和你计较了","我不怼你了,对牛弹琴又有何用呢?","我就暂且饶过你一次。"]
|
||||||
}
|
}
|
||||||
Core.AddListener((c, i) => {
|
Core.AddListener((c, i) => {
|
||||||
if (i.message.indexOf("投降") != -1) {
|
if (i.message.indexOf("投降") != -1) {
|
||||||
if (怼人目标[i.user_id as number]) {
|
if (怼人目标[i.user_id as number]) {
|
||||||
怼人目标[i.user_id as number] = 0;
|
怼人目标[i.user_id as number] = 0;
|
||||||
Core.frame.SendMsg(c, i, "哈哈!投降了吧!就你敢还和我怼?");
|
Core.frame.SendMsg(c, i, "哈哈!投降了吧!就你敢还和我怼?");
|
||||||
} else {
|
} else {
|
||||||
Core.frame.SendMsg(c, i, "我本来也没想怼你啊。");
|
Core.frame.SendMsg(c, i, "我本来也没想怼你啊。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (怼人目标[i.user_id as number] > 0) {
|
if (怼人目标[i.user_id as number] > 0) {
|
||||||
if (i.message.indexOf("你这人") != -1 || i.message.indexOf("你") != -1 || i.message.indexOf("这") != -1) {
|
if (i.message.indexOf("你这人") != -1 || i.message.indexOf("你") != -1 || i.message.indexOf("这") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.意见[new Number(Math.floor(怼人台词.意见.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.意见[new Number(Math.floor(怼人台词.意见.length * Math.random())).valueOf()]);
|
||||||
} else if (i.message.indexOf("怎么样") != -1 || i.message.indexOf("吗") != -1 || i.message.indexOf("如何") != -1) {
|
} else if (i.message.indexOf("怎么样") != -1 || i.message.indexOf("吗") != -1 || i.message.indexOf("如何") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.询问[new Number(Math.floor(怼人台词.询问.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.询问[new Number(Math.floor(怼人台词.询问.length * Math.random())).valueOf()]);
|
||||||
} else if (i.message.indexOf("请") != -1) {
|
} else if (i.message.indexOf("请") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.请求[new Number(Math.floor(怼人台词.请求.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.请求[new Number(Math.floor(怼人台词.请求.length * Math.random())).valueOf()]);
|
||||||
} else if (i.message.indexOf("我") != -1 || i.message.indexOf("什么") != -1) {
|
} else if (i.message.indexOf("我") != -1 || i.message.indexOf("什么") != -1) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.骂人[new Number(Math.floor(怼人台词.骂人.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.骂人[new Number(Math.floor(怼人台词.骂人.length * Math.random())).valueOf()]);
|
||||||
} else {
|
} else {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词._无法识别[new Number(Math.floor(怼人台词._无法识别.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词._无法识别[new Number(Math.floor(怼人台词._无法识别.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
怼人目标[i.user_id as number] = 怼人目标[i.user_id as number] - 1;
|
怼人目标[i.user_id as number] = 怼人目标[i.user_id as number] - 1;
|
||||||
if (怼人目标[i.user_id as number] == 0) {
|
if (怼人目标[i.user_id as number] == 0) {
|
||||||
Core.frame.SendMsg(c, i, 怼人台词.投降[new Number(Math.floor(怼人台词.投降.length * Math.random())).valueOf()]);
|
Core.frame.SendMsg(c, i, 怼人台词.投降[new Number(Math.floor(怼人台词.投降.length * Math.random())).valueOf()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i.message == "怼我" || i.message == "怼人") {
|
if (i.message == "怼我" || i.message == "怼人") {
|
||||||
Core.frame.SendMsg(c, i, "行啊!接招!");
|
Core.frame.SendMsg(c, i, "行啊!接招!");
|
||||||
怼人目标[i.user_id as number] = 10;
|
怼人目标[i.user_id as number] = 10;
|
||||||
}
|
}
|
||||||
if (i.message.substr(0, 1) == "怼" || i.message.substr(0, 3) == "帮我怼") {
|
if (i.message.substr(0, 1) == "怼" || i.message.substr(0, 3) == "帮我怼") {
|
||||||
var qq = i.message.replace("怼", "");
|
var qq = i.message.replace("怼", "");
|
||||||
if (qq == "我") {
|
if (qq == "我") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (qq == "人") {
|
if (qq == "人") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qq = qq.replace("帮我", "");
|
qq = qq.replace("帮我", "");
|
||||||
qq = qq.replace("[CQ:at,qq=", "");
|
qq = qq.replace("[CQ:at,qq=", "");
|
||||||
qq = qq.replace("]", "");
|
qq = qq.replace("]", "");
|
||||||
怼人目标[qq] = 10;
|
怼人目标[qq] = 10;
|
||||||
Core.frame.SendMsg(c, i, `我会去怼${Core.frame.At(new Number(qq))}的`);
|
Core.frame.SendMsg(c, i, `我会去怼${Core.frame.At(new Number(qq))}的`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
88
抢劫.js
88
抢劫.js
@ -1,45 +1,45 @@
|
|||||||
//固定资产
|
//固定资产
|
||||||
const fs=require("fs");
|
const fs=require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const MoneyInterfaces = require("./Money").add.Interfaces;
|
const MoneyInterfaces = require("./Money").add.Interfaces;
|
||||||
const 保镖In = require("./保镖.i");
|
const 保镖In = require("./保镖.i");
|
||||||
exports.add={
|
exports.add={
|
||||||
Interfaces:{},
|
Interfaces:{},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
//console.log("["+new Date().toString()+"][抢劫.js]正在处理");
|
//console.log("["+new Date().toString()+"][抢劫.js]正在处理");
|
||||||
var Temp1 = new String(info["raw_message"]);
|
var Temp1 = new String(info["raw_message"]);
|
||||||
if(Temp1.substr(0,2)=="抢劫"){
|
if(Temp1.substr(0,2)=="抢劫"){
|
||||||
if(Temp1.length == 2){
|
if(Temp1.length == 2){
|
||||||
Core.frame.SendMsg(connect,info,"此命令的格式是:抢劫@XX(XX为要被抢劫的人)")
|
Core.frame.SendMsg(connect,info,"此命令的格式是:抢劫@XX(XX为要被抢劫的人)")
|
||||||
}else{
|
}else{
|
||||||
var UQQ = Temp1.replace('[CQ:at,qq=',"");
|
var UQQ = Temp1.replace('[CQ:at,qq=',"");
|
||||||
UQQ = UQQ.replace(']',"");
|
UQQ = UQQ.replace(']',"");
|
||||||
UQQ = UQQ.replace('抢劫',"");
|
UQQ = UQQ.replace('抢劫',"");
|
||||||
UQQ = UQQ.replace(' ',"");
|
UQQ = UQQ.replace(' ',"");
|
||||||
At = Core.frame.GetAt(connect,info);if(At){UQQ=At}
|
At = Core.frame.GetAt(connect,info);if(At){UQQ=At}
|
||||||
if(保镖In.使用用户保镖(Core.GetUser(UQQ))){
|
if(保镖In.使用用户保镖(Core.GetUser(UQQ))){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可抢劫。");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可抢劫。");
|
||||||
}else{
|
}else{
|
||||||
if(isNaN(new Number(UQQ).valueOf())){
|
if(isNaN(new Number(UQQ).valueOf())){
|
||||||
if(UQQ.indexOf("@") != -1){
|
if(UQQ.indexOf("@") != -1){
|
||||||
Core.frame.SendMsg(connect,info,"你可能是复制了一个At,目前AI暂不支持At复制,请使用At选择框或者输入QQ号码");
|
Core.frame.SendMsg(connect,info,"你可能是复制了一个At,目前AI暂不支持At复制,请使用At选择框或者输入QQ号码");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(MoneyInterfaces.GetUserMoney(UQQ)<1000){
|
if(MoneyInterfaces.GetUserMoney(UQQ)<1000){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(UQQ)+"的余额不足1000,不可抢劫。");
|
Core.frame.SendMsg(connect,info,Core.frame.At(UQQ)+"的余额不足1000,不可抢劫。");
|
||||||
}else{
|
}else{
|
||||||
var Temp2 = Math.ceil(Math.random() * MoneyInterfaces.GetUserMoney(Core.GetUser(UQQ)) * 0.25);
|
var Temp2 = Math.ceil(Math.random() * MoneyInterfaces.GetUserMoney(Core.GetUser(UQQ)) * 0.25);
|
||||||
if(UQQ == Core.GetUser(info["user_id"])){
|
if(UQQ == Core.GetUser(info["user_id"])){
|
||||||
Temp2 = 0;
|
Temp2 = 0;
|
||||||
}
|
}
|
||||||
MoneyInterfaces.GiveUserMoney(Core.GetUser(info["user_id"]),Temp2,`抢劫${UQQ}`);
|
MoneyInterfaces.GiveUserMoney(Core.GetUser(info["user_id"]),Temp2,`抢劫${UQQ}`);
|
||||||
MoneyInterfaces.CostUserMoney(UQQ,Temp2,`被${info["user_id"]}抢劫`);
|
MoneyInterfaces.CostUserMoney(UQQ,Temp2,`被${info["user_id"]}抢劫`);
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"抢劫成功!你抢到"+Temp2+"元,你的余额"+MoneyInterfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info["user_id"]))+"抢劫成功!你抢到"+Temp2+"元,你的余额"+MoneyInterfaces.GetUserMoney(Core.GetUser(info["user_id"]))+"元");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("["+new Date().toString()+"][抢劫.js]处理完成");
|
//console.log("["+new Date().toString()+"][抢劫.js]处理完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
228
板砖.js
228
板砖.js
@ -1,115 +1,115 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const Core = require("./Core");
|
const Core = require("./Core");
|
||||||
const Money = require("./Money");
|
const Money = require("./Money");
|
||||||
const Debug = require("./Debug");
|
const Debug = require("./Debug");
|
||||||
const 保镖In = require("./保镖.i");
|
const 保镖In = require("./保镖.i");
|
||||||
exports.add = {
|
exports.add = {
|
||||||
Interfaces:{
|
Interfaces:{
|
||||||
GetUser板砖:function(user_id){
|
GetUser板砖:function(user_id){
|
||||||
var data_obj = Core.frame.ReadSystemConfig("板砖");
|
var data_obj = Core.frame.ReadSystemConfig("板砖");
|
||||||
return data_obj[user_id];
|
return data_obj[user_id];
|
||||||
},
|
},
|
||||||
GiveUser板砖:function(user_id,count){
|
GiveUser板砖:function(user_id,count){
|
||||||
var data_obj = Core.frame.ReadSystemConfig("板砖");
|
var data_obj = Core.frame.ReadSystemConfig("板砖");
|
||||||
data_obj[user_id] = this.GetUser板砖(user_id) + count;
|
data_obj[user_id] = this.GetUser板砖(user_id) + count;
|
||||||
Core.frame.WriteSystemConfig("板砖",data_obj);
|
Core.frame.WriteSystemConfig("板砖",data_obj);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Control:function(connect,info){
|
Control:function(connect,info){
|
||||||
var message = new String(info["message"]);
|
var message = new String(info["message"]);
|
||||||
console.log("a");
|
console.log("a");
|
||||||
console.log(message);
|
console.log(message);
|
||||||
if(message=="购买板砖"){
|
if(message=="购买板砖"){
|
||||||
console.log("b");
|
console.log("b");
|
||||||
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))>100){
|
if(Money.add.Interfaces.GetUserMoney(Core.GetUser(info["user_id"]))>100){
|
||||||
Money.add.Interfaces.CostUserMoney(Core.GetUser(info["user_id"]),100);
|
Money.add.Interfaces.CostUserMoney(Core.GetUser(info["user_id"]),100);
|
||||||
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),1);
|
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),1);
|
||||||
Core.frame.SendMsg(connect,info,`消耗金币 * 100\r\n<获得板砖>\r\n[板砖]*1\r\n<持有板砖>\r\n[板砖]*${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}`);
|
Core.frame.SendMsg(connect,info,`消耗金币 * 100\r\n<获得板砖>\r\n[板砖]*1\r\n<持有板砖>\r\n[板砖]*${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}`);
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"你的金币不足100。");
|
Core.frame.SendMsg(connect,info,"你的金币不足100。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(message.substr(0,4)=="批发板砖"||message.substr(0,6)=="批量购买板砖"){
|
if(message.substr(0,4)=="批发板砖"||message.substr(0,6)=="批量购买板砖"){
|
||||||
var count = new Number(message.replace("批发板砖","").replace("批量购买板砖",""));
|
var count = new Number(message.replace("批发板砖","").replace("批量购买板砖",""));
|
||||||
if(count<0||isNaN(count)){
|
if(count<0||isNaN(count)){
|
||||||
Core.frame.SendMsg(connect,info,"Are you kidding me?");
|
Core.frame.SendMsg(connect,info,"Are you kidding me?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!(Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))>count*100)){
|
if(!(Money.add.Interfaces.GetUserMoney(Core.GetUser(info.user_id))>count*100)){
|
||||||
Core.frame.SendMsg(connect,info,"你再批发就破产了。");
|
Core.frame.SendMsg(connect,info,"你再批发就破产了。");
|
||||||
}else{
|
}else{
|
||||||
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id),100*count);
|
Money.add.Interfaces.CostUserMoney(Core.GetUser(info.user_id),100*count);
|
||||||
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info.user_id),count);
|
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info.user_id),count);
|
||||||
Core.frame.SendMsg(connect,info,`消耗金币 * ${100*count}\\r\\n<获得板砖>\\r\\n[板砖]*${count}\\r\\n<持有板砖>\\r\\n[板砖]*${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}`);
|
Core.frame.SendMsg(connect,info,`消耗金币 * ${100*count}\\r\\n<获得板砖>\\r\\n[板砖]*${count}\\r\\n<持有板砖>\\r\\n[板砖]*${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(message.substr(0,3)=="敲板砖"){
|
if(message.substr(0,3)=="敲板砖"){
|
||||||
var Tuser = message.replace("敲板砖","");
|
var Tuser = message.replace("敲板砖","");
|
||||||
Tuser = Tuser.replace("[CQ:at,qq=","");
|
Tuser = Tuser.replace("[CQ:at,qq=","");
|
||||||
Tuser = Tuser.replace("]","");
|
Tuser = Tuser.replace("]","");
|
||||||
Tuser = Tuser.replace(" ","");
|
Tuser = Tuser.replace(" ","");
|
||||||
At = Core.frame.GetAt(connect,info);if(At){Tuser=At}
|
At = Core.frame.GetAt(connect,info);if(At){Tuser=At}
|
||||||
if(保镖In.使用用户保镖(Core.GetUser(Tuser))){
|
if(保镖In.使用用户保镖(Core.GetUser(Tuser))){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可敲板砖");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可敲板砖");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Tuser == Core.GetUser(info["user_id"])){
|
if(Tuser == Core.GetUser(info["user_id"])){
|
||||||
Core.frame.SendMsg(connect,info,"不可以敲自己");
|
Core.frame.SendMsg(connect,info,"不可以敲自己");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))>=1){
|
if(!exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))>=1){
|
||||||
Core.frame.SendMsg(connect,info,"你没有板砖,快去购买一个吧!");
|
Core.frame.SendMsg(connect,info,"你没有板砖,快去购买一个吧!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(Tuser))){
|
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(Tuser))){
|
||||||
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},你们AI管理员别内斗了行不!?`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},你们AI管理员别内斗了行不!?`);
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"AI管理员不可以被板砖攻击。");
|
Core.frame.SendMsg(connect,info,"AI管理员不可以被板砖攻击。");
|
||||||
Core.frame.Ban(connect,info,60);
|
Core.frame.Ban(connect,info,60);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var BT = Math.floor(Math.random()*300);
|
var BT = Math.floor(Math.random()*300);
|
||||||
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),-1);
|
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),-1);
|
||||||
Core.frame._Ban(connect,info,Tuser,BT);
|
Core.frame._Ban(connect,info,Tuser,BT);
|
||||||
Core.frame.SendMsg(connect,info,`敲板砖成功,已禁言${Core.frame.At(Tuser)}长达${BT}秒。你剩余${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}个板砖。`);
|
Core.frame.SendMsg(connect,info,`敲板砖成功,已禁言${Core.frame.At(Tuser)}长达${BT}秒。你剩余${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}个板砖。`);
|
||||||
}
|
}
|
||||||
if(message.substr(0,4)=="批量砸人"||message.substr(0,5)=="批量敲板砖"){
|
if(message.substr(0,4)=="批量砸人"||message.substr(0,5)=="批量敲板砖"){
|
||||||
var Tuser = message.replace("批量砸人","").replace("批量敲板砖","");
|
var Tuser = message.replace("批量砸人","").replace("批量敲板砖","");
|
||||||
var E = Tuser.split("|");
|
var E = Tuser.split("|");
|
||||||
var TuserZ = E[0].replace("[CQ:at,qq=","");
|
var TuserZ = E[0].replace("[CQ:at,qq=","");
|
||||||
TuserZ = TuserZ.replace("]","");
|
TuserZ = TuserZ.replace("]","");
|
||||||
TuserZ = TuserZ.replace(" ","");
|
TuserZ = TuserZ.replace(" ","");
|
||||||
At = Core.frame.GetAt(connect,info);if(At){TuserZ=At}
|
At = Core.frame.GetAt(connect,info);if(At){TuserZ=At}
|
||||||
if(保镖In.使用用户保镖(Core.GetUser(Tuser))){
|
if(保镖In.使用用户保镖(Core.GetUser(Tuser))){
|
||||||
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可敲板砖");
|
Core.frame.SendMsg(connect,info,Core.frame.At(Core.GetUser(info.user_id))+"对方有保镖,不可敲板砖");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(TuserZ == Core.GetUser(info["user_id"])){
|
if(TuserZ == Core.GetUser(info["user_id"])){
|
||||||
Core.frame.SendMsg(connect,info,"不可以敲自己");
|
Core.frame.SendMsg(connect,info,"不可以敲自己");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))>=new Number(E[1])){
|
if(!exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))>=new Number(E[1])){
|
||||||
Core.frame.SendMsg(connect,info,"你没有板砖,快去购买一个吧!");
|
Core.frame.SendMsg(connect,info,"你没有板砖,快去购买一个吧!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(TuserZ))){
|
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(TuserZ))){
|
||||||
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
if(Debug.add.Interfaces.IsAdmin(Core.GetUser(info["user_id"]))){
|
||||||
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},你们AI管理员别内斗了行不!?`);
|
Core.frame.SendMsg(connect,info,`${Core.frame.At(Core.GetUser(info["user_id"]))},你们AI管理员别内斗了行不!?`);
|
||||||
}else{
|
}else{
|
||||||
Core.frame.SendMsg(connect,info,"AI管理员不可以被板砖攻击。");
|
Core.frame.SendMsg(connect,info,"AI管理员不可以被板砖攻击。");
|
||||||
Core.frame.Ban(connect,info,60);
|
Core.frame.Ban(connect,info,60);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var BT = Math.floor(Math.random()*300) * E[1];
|
var BT = Math.floor(Math.random()*300) * E[1];
|
||||||
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),-E[1]);
|
exports.add.Interfaces.GiveUser板砖(Core.GetUser(info["user_id"]),-E[1]);
|
||||||
if(BT > 30*24*60*60){
|
if(BT > 30*24*60*60){
|
||||||
BT = 30*24*60*60 - 1;
|
BT = 30*24*60*60 - 1;
|
||||||
}
|
}
|
||||||
Core.frame._Ban(connect,info,TuserZ,BT);
|
Core.frame._Ban(connect,info,TuserZ,BT);
|
||||||
Core.frame.SendMsg(connect,info,`敲板砖成功,已禁言${Core.frame.At(TuserZ)}长达${BT}秒。你剩余${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}个板砖。`);
|
Core.frame.SendMsg(connect,info,`敲板砖成功,已禁言${Core.frame.At(TuserZ)}长达${BT}秒。你剩余${exports.add.Interfaces.GetUser板砖(Core.GetUser(info["user_id"]))}个板砖。`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
某些文件未显示,因为此 diff 中更改的文件太多 显示更多
在新工单中引用
屏蔽一个用户