编译ts,IP查询服务,WebUI修正
这个提交包含在:
14
Debug.js
14
Debug.js
@ -271,6 +271,20 @@ exports.add={
|
||||
});
|
||||
});
|
||||
}
|
||||
if(Temp1 == "服务器IP"){
|
||||
if(debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
||||
require("request").get("http://api.ipify.org",(err,req)=>{
|
||||
Core.frame.SendMsg(c,i,req.body);
|
||||
});
|
||||
}else{
|
||||
require("request").get("http://api.ipify.org",(err,req)=>{
|
||||
var IP = (req.body).split(".");
|
||||
IP[2] = "*";
|
||||
IP[3] = "*";
|
||||
Core.frame.SendMsg(c,i,`${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(Upload,6*60*60*1000)
|
||||
51
GeoGeBra.js
51
GeoGeBra.js
@ -1 +1,50 @@
|
||||
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Core = __importStar(require("./Core"));
|
||||
const fs = __importStar(require("fs"));
|
||||
var GGB = require("node-geogebra");
|
||||
var Pool = new GGB.GGBPool({ plotters: 1, ggb: 'local' });
|
||||
var PoolReady = false;
|
||||
var Plotter;
|
||||
Pool.ready().then(async () => {
|
||||
PoolReady = true;
|
||||
Plotter = await Pool.getGGBPlotter;
|
||||
});
|
||||
Core.AddListener((c, i) => {
|
||||
if (i.message.substring(0, 2) != "绘图") {
|
||||
return;
|
||||
}
|
||||
;
|
||||
var Command = i.message.replace("绘图", "");
|
||||
Plotter.evalGGBScript([Command]);
|
||||
Core.frame.SendMsg(c, i, "[GeoGeBra]执行完成,正在渲染。");
|
||||
Core.frame.SendImg(c, i, "");
|
||||
Plotter.export("png").then(function (v) {
|
||||
fs.writeFile("/home/pi/AI/temp/img.png", v, () => {
|
||||
Core.frame.SendImg(c, i, "/home/pi/AI/temp/img.png");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
39
WRH.js
39
WRH.js
@ -1,3 +1,42 @@
|
||||
"use strict";
|
||||
// Word Recitation Helper
|
||||
// 单词背诵助手
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Core = __importStar(require("./Core"));
|
||||
const command = {
|
||||
"prefix": "WRH",
|
||||
"answer": "ANS ",
|
||||
"key": "KEY",
|
||||
"require": "REQ",
|
||||
"select": "SEL ",
|
||||
"rankinglist": "RAL"
|
||||
};
|
||||
Core.AddListener((c, i) => {
|
||||
if (i.message.substring(0, command.prefix.length) == command.prefix) {
|
||||
var subcommand = i.message.replace(command.prefix, "");
|
||||
subcommand;
|
||||
}
|
||||
});
|
||||
|
||||
32
WebUI.js
32
WebUI.js
@ -35,8 +35,12 @@ ServerWeb.on("listening", () => {
|
||||
ServerWeb.close();
|
||||
});
|
||||
ServerWeb.on("connection", (UserSock) => {
|
||||
UserSock.end("102");
|
||||
// UserSock.end("102");
|
||||
var TOC = setTimeout(() => {
|
||||
UserSock.end("102 Timeout");
|
||||
}, 500);
|
||||
UserSock.on("data", (data) => {
|
||||
clearTimeout(TOC);
|
||||
if (data.toString().indexOf(" ") != 0) {
|
||||
var path = data.toString().split(" ");
|
||||
if (path == undefined) {
|
||||
@ -49,7 +53,7 @@ ServerWeb.on("listening", () => {
|
||||
UserSock.end();
|
||||
});
|
||||
}
|
||||
else if (path[1].substr(0, 5) == "/OAC_") {
|
||||
else if (path[1].substring(0, 5) == "/OAC_") {
|
||||
var Do = path[1].replace("/OAC_", "");
|
||||
if (Do == "GETMESSAGE") {
|
||||
fs.readFile("./Message.json", (err, data) => {
|
||||
@ -58,7 +62,7 @@ ServerWeb.on("listening", () => {
|
||||
UserSock.end();
|
||||
});
|
||||
}
|
||||
else if (Do.substr(0, new String("SETMESSAGE_").length) == "SETMESSAGE_") {
|
||||
else if (Do.substring(0, new String("SETMESSAGE_").length) == "SETMESSAGE_") {
|
||||
var Token = Do.replace("SETMESSAGE_", "");
|
||||
var T2 = Token.split("_");
|
||||
fs.readFile("./Message.json", (err, data) => {
|
||||
@ -85,11 +89,20 @@ ServerWeb.on("listening", () => {
|
||||
UserSock.end();
|
||||
}
|
||||
else if (Do == "RESTART") {
|
||||
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(ret.valueOf());
|
||||
UserSock.end();
|
||||
process.exit();
|
||||
// 先检测是来自v4还是v6,如果是v4则正常退出,如果是v6则报403 Forbidden
|
||||
var IsIPv4 = !(UserSock.address().toString().match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]/) == null);
|
||||
var ret = new String("");
|
||||
if (IsIPv4) {
|
||||
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.end(ret.valueOf());
|
||||
process.exit();
|
||||
}
|
||||
else {
|
||||
ret = new String("我们不允许IPv6重启Ai");
|
||||
UserSock.write(`HTTP/1.1 403 Forbidden\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||
UserSock.end(ret.valueOf());
|
||||
}
|
||||
}
|
||||
else if (Do == "GETSERVICES") {
|
||||
fs.readFile("./MoudelV2.json", (err2, data2) => {
|
||||
@ -119,7 +132,8 @@ ServerWeb.on("listening", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
ServerWeb.listen(8081, "127.0.0.1");
|
||||
ServerWeb.listen(8093, "0.0.0.0");
|
||||
ServerWeb.listen(8093, "::1");
|
||||
Core.AddListener((connect, Info) => {
|
||||
MessageCount = MessageCount.valueOf() + 1;
|
||||
});
|
||||
|
||||
32
WebUI.ts
32
WebUI.ts
@ -10,8 +10,12 @@ ServerWeb.on("listening",()=>{
|
||||
ServerWeb.close();
|
||||
});
|
||||
ServerWeb.on("connection",(UserSock)=>{
|
||||
UserSock.end("102");
|
||||
// UserSock.end("102");
|
||||
var TOC = setTimeout(()=>{
|
||||
UserSock.end("102 Timeout")
|
||||
},500)
|
||||
UserSock.on("data",(data)=>{
|
||||
clearTimeout(TOC)
|
||||
if(data.toString().indexOf(" ")!=0){
|
||||
var path = data.toString().split(" ");
|
||||
if(path == undefined){
|
||||
@ -23,7 +27,7 @@ ServerWeb.on("listening",()=>{
|
||||
UserSock.write(data);
|
||||
UserSock.end();
|
||||
});
|
||||
}else if(path[1].substr(0,5)=="/OAC_"){
|
||||
}else if(path[1].substring(0,5)=="/OAC_"){
|
||||
var Do = path[1].replace("/OAC_","");
|
||||
if(Do == "GETMESSAGE"){
|
||||
fs.readFile("./Message.json",(err,data)=>{
|
||||
@ -31,7 +35,7 @@ ServerWeb.on("listening",()=>{
|
||||
UserSock.write(data);
|
||||
UserSock.end();
|
||||
});
|
||||
}else if(Do.substr(0,new String("SETMESSAGE_").length) == "SETMESSAGE_"){
|
||||
}else if(Do.substring(0,new String("SETMESSAGE_").length) == "SETMESSAGE_"){
|
||||
var Token = Do.replace("SETMESSAGE_","");
|
||||
var T2:string[]|undefined[] = Token.split("_");
|
||||
fs.readFile("./Message.json",(err,data)=>{
|
||||
@ -56,11 +60,20 @@ ServerWeb.on("listening",()=>{
|
||||
UserSock.write(ret.valueOf());
|
||||
UserSock.end();
|
||||
}else if(Do == "RESTART"){
|
||||
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(ret.valueOf());
|
||||
UserSock.end();
|
||||
process.exit();
|
||||
|
||||
// 先检测是来自v4还是v6,如果是v4则正常退出,如果是v6则报403 Forbidden
|
||||
var IsIPv4 = !(UserSock.address().toString().match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]/) == null)
|
||||
var ret = new String("");
|
||||
if(IsIPv4){
|
||||
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.end(ret.valueOf());
|
||||
process.exit();
|
||||
}else{
|
||||
ret = new String("我们不允许IPv6重启Ai");
|
||||
UserSock.write(`HTTP/1.1 403 Forbidden\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`)
|
||||
UserSock.end(ret.valueOf());
|
||||
}
|
||||
}else if(Do == "GETSERVICES"){
|
||||
fs.readFile("./MoudelV2.json",(err2,data2)=>{
|
||||
var ret = data2;
|
||||
@ -87,7 +100,8 @@ ServerWeb.on("listening",()=>{
|
||||
})
|
||||
});
|
||||
});
|
||||
ServerWeb.listen(8081,"127.0.0.1");
|
||||
ServerWeb.listen(8093,"0.0.0.0");
|
||||
ServerWeb.listen(8093,"::1");
|
||||
Core.AddListener((connect:Core.InfoSocket,Info:Core.InfoType)=>{
|
||||
MessageCount = MessageCount.valueOf() + 1;
|
||||
})
|
||||
28
img.js
28
img.js
@ -24,22 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Core = __importStar(require("./Core"));
|
||||
const canvas = __importStar(require("canvas"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const debug = require("./Debug");
|
||||
const ds = require("desktop-screenshot");
|
||||
const request = __importStar(require("request"));
|
||||
(() => {
|
||||
var con = new canvas.Canvas(100, 100);
|
||||
var mai = con.getContext("2d");
|
||||
mai.fillStyle = "#ffffff";
|
||||
mai.fillRect(0, 0, 100, 100);
|
||||
mai.fillStyle = "#000000";
|
||||
mai.font = "24px '思源宋体'";
|
||||
// mai.fillText("天依没了",10,50);
|
||||
var Buf = con.toBuffer("image/png");
|
||||
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png", Buf, () => {
|
||||
});
|
||||
Core.AddListener((c, i) => {
|
||||
if (i.message == "图片测试") {
|
||||
Core.frame.SendImg(c, i, "1.png");
|
||||
@ -54,20 +41,5 @@ const request = __importStar(require("request"));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (i.message == "服务器IP") {
|
||||
if (debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))) {
|
||||
request.get("http://api.ipify.org", (err, req) => {
|
||||
Core.frame.SendMsg(c, i, req.body);
|
||||
});
|
||||
}
|
||||
else {
|
||||
request.get("http://api.ipify.org", (err, req) => {
|
||||
var IP = req.body.split(".");
|
||||
IP[2] = "*";
|
||||
IP[3] = "*";
|
||||
Core.frame.SendMsg(c, i, `${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
29
img.ts
29
img.ts
@ -1,21 +1,10 @@
|
||||
import * as Core from "./Core";
|
||||
import * as canvas from "canvas";
|
||||
// import * as canvas from "canvas";
|
||||
import * as fs from "fs";
|
||||
const debug:LibDebug = require("./Debug");
|
||||
const ds = require("desktop-screenshot");
|
||||
import * as request from "request";
|
||||
// import * as request from "request";
|
||||
(()=>{
|
||||
var con = new canvas.Canvas(100,100);
|
||||
var mai = con.getContext("2d");
|
||||
mai.fillStyle = "#ffffff";
|
||||
mai.fillRect(0,0,100,100);
|
||||
mai.fillStyle = "#000000";
|
||||
mai.font = "24px '思源宋体'";
|
||||
// mai.fillText("天依没了",10,50);
|
||||
var Buf = con.toBuffer("image/png");
|
||||
fs.writeFile("D:\\APPS\\MIRAI\\plugins\\MiraiAPIHTTP\\images\\1.png",Buf,()=>{
|
||||
|
||||
});
|
||||
Core.AddListener((c,i)=>{
|
||||
if(i.message == "图片测试"){
|
||||
Core.frame.SendImg(c,i,"1.png");
|
||||
@ -29,19 +18,5 @@ import * as request from "request";
|
||||
}
|
||||
});
|
||||
}
|
||||
if(i.message == "服务器IP"){
|
||||
if(debug.add.Interfaces.IsAdmin(Core.GetUser(i.user_id))){
|
||||
request.get("http://api.ipify.org",(err,req)=>{
|
||||
Core.frame.SendMsg(c,i,req.body);
|
||||
});
|
||||
}else{
|
||||
request.get("http://api.ipify.org",(err,req)=>{
|
||||
var IP = (req.body as string).split(".");
|
||||
IP[2] = "*";
|
||||
IP[3] = "*";
|
||||
Core.frame.SendMsg(c,i,`${IP[0]}.${IP[1]}.${IP[2]}.${IP[3]}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
6
sdwebuiapic/api.js
普通文件
6
sdwebuiapic/api.js
普通文件
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = (() => {
|
||||
var API = {};
|
||||
return API;
|
||||
})();
|
||||
在新工单中引用
屏蔽一个用户