koishi-plugin-gl-bot 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +4 -0
- package/lib/gl/index.d.ts +83 -0
- package/lib/gl/index.js +51 -0
- package/lib/gl/type.d.ts +0 -0
- package/lib/gl/type.js +0 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +4 -20
- package/lib/mcsManager/api.d.ts +25 -0
- package/lib/mcsManager/api.js +96 -0
- package/lib/mcsManager/bot.d.ts +14 -0
- package/lib/mcsManager/bot.js +42 -0
- package/lib/mcsManager/commands/base.d.ts +2 -0
- package/lib/mcsManager/commands/base.js +6 -0
- package/lib/mcsManager/commands/index.d.ts +7 -0
- package/lib/mcsManager/commands/index.js +13 -0
- package/lib/mcsManager/commands/reset.d.ts +12 -0
- package/lib/mcsManager/commands/reset.js +45 -0
- package/lib/mcsManager/config.d.ts +18 -0
- package/lib/mcsManager/config.js +24 -0
- package/lib/mcsManager/constants.d.ts +8 -0
- package/lib/mcsManager/constants.js +12 -0
- package/lib/mcsManager/index.d.ts +26 -0
- package/lib/mcsManager/index.js +21 -0
- package/lib/mcsManager/instance.d.ts +16 -0
- package/lib/mcsManager/instance.js +18 -0
- package/lib/mcsManager/panel.d.ts +24 -0
- package/lib/mcsManager/panel.js +121 -0
- package/lib/mcsManager/type.d.ts +115 -0
- package/lib/mcsManager/type.js +2 -0
- package/lib/mcsManager/ws.d.ts +24 -0
- package/lib/mcsManager/ws.js +116 -0
- package/lib/queQiao/index.d.ts +108 -0
- package/lib/queQiao/index.js +437 -0
- package/lib/queQiao/locale/en-US.json +1 -0
- package/lib/queQiao/locale/en-US.yml +9 -0
- package/lib/queQiao/locale/zh-CN.json +1 -0
- package/lib/queQiao/locale/zh-CN.yml +9 -0
- package/lib/queQiao/mcwss.d.ts +61 -0
- package/lib/queQiao/mcwss.js +260 -0
- package/lib/queQiao/values.d.ts +72 -0
- package/lib/queQiao/values.js +155 -0
- package/lib/utils/game.mc.d.ts +4 -0
- package/lib/utils/game.mc.js +29 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +17 -0
- package/package.json +11 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCSManagerPanel = void 0;
|
|
4
|
+
const koishi_1 = require("koishi");
|
|
5
|
+
const lodash_es_1 = require("lodash-es");
|
|
6
|
+
const api_1 = require("./api");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const instance_1 = require("./instance");
|
|
9
|
+
const ws_1 = require("./ws");
|
|
10
|
+
const logger = new koishi_1.Logger('mcsmanager-panel');
|
|
11
|
+
class MCSManagerPanel {
|
|
12
|
+
constructor(ctx, config) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.isInitialized = false;
|
|
16
|
+
// 所有远程节点及其实例列表
|
|
17
|
+
this.remotes = [];
|
|
18
|
+
// 远程连接Map表
|
|
19
|
+
this.remoteConnectionsMap = new Map();
|
|
20
|
+
this.api = new api_1.MCSManagerAPI(ctx.http, config.mcManagerHost);
|
|
21
|
+
this.initialize();
|
|
22
|
+
}
|
|
23
|
+
async initialize() {
|
|
24
|
+
if (this.isInitialized) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.isInitialized = true;
|
|
28
|
+
const { mcManagerUsername, mcManagerPassword } = this.config;
|
|
29
|
+
await this.api.login(mcManagerUsername, mcManagerPassword);
|
|
30
|
+
await this.api.getUserInfo();
|
|
31
|
+
await this.handleRemoteServices();
|
|
32
|
+
await this.getAvailableRemoteInstance();
|
|
33
|
+
}
|
|
34
|
+
// 获取远程服务及其实例列表
|
|
35
|
+
async handleRemoteServices() {
|
|
36
|
+
const remoteList = await this.api.getServiceRemoteList();
|
|
37
|
+
for (const remote of remoteList) {
|
|
38
|
+
const instanceList = await this.api.getServiceRemoteInstanceList(remote.uuid);
|
|
39
|
+
this.remotes.push({
|
|
40
|
+
instances: instanceList.map(item => new instance_1.MCSManagerInstance(this.ctx, this.config, this.api, this, remote, item)),
|
|
41
|
+
...remote,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
logger.info(`已获取到 ${this.remotes.length} 个远程节点及其实例 ${this.remotes.reduce((acc, remote) => acc + remote.instances.length, 0)} 个`);
|
|
45
|
+
}
|
|
46
|
+
// 遍历所有远程节点 选择正在运行中的实力 建立远程连接
|
|
47
|
+
getAvailableRemoteInstance() {
|
|
48
|
+
for (const remote of this.remotes) {
|
|
49
|
+
for (const instance of remote.instances) {
|
|
50
|
+
this.createMCSManagerConnection(remote, instance.cfg);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// 创建远程连接
|
|
55
|
+
async createMCSManagerConnection(remote, instance) {
|
|
56
|
+
if ((0, lodash_es_1.isEqual)(instance.status, constants_1.RemoteInstanceStatusEnum.RUNNING)) {
|
|
57
|
+
const uuid = instance.instanceUuid;
|
|
58
|
+
// 已存在的实例且连接中 直接返回
|
|
59
|
+
if (this.remoteConnectionsMap.has(uuid) &&
|
|
60
|
+
this.remoteConnectionsMap.get(uuid).connect.connected) {
|
|
61
|
+
return this.remoteConnectionsMap.get(uuid);
|
|
62
|
+
}
|
|
63
|
+
// 上限检测
|
|
64
|
+
if (this.remoteConnectionsMap.size >=
|
|
65
|
+
this.config.mcManagerMaxRemoteConnections) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// 试图自动获取认证信息
|
|
69
|
+
if ((0, koishi_1.isEmpty)(remote.auth)) {
|
|
70
|
+
const instanceConnectAuth = await this.api.getServiceInstanceConnectAuth(remote.uuid, instance.instanceUuid);
|
|
71
|
+
remote.auth = instanceConnectAuth;
|
|
72
|
+
}
|
|
73
|
+
if (remote.auth) {
|
|
74
|
+
const ws = new ws_1.MCSManagerWebSocketIO(this.ctx, this.config, this.api, remote, instance, remote.auth);
|
|
75
|
+
this.remoteConnectionsMap.set(uuid, ws);
|
|
76
|
+
return ws;
|
|
77
|
+
}
|
|
78
|
+
logger.error(`远程实例 ${instance.config.nickname} 缺少连接认证信息,无法建立连接`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 模糊搜索实例 通过 实例名称
|
|
82
|
+
async searchInstanceByName(instanceName) {
|
|
83
|
+
const instanceMap = new Map();
|
|
84
|
+
const keywords = instanceName.length < 10 ? instanceName.split('') : [];
|
|
85
|
+
for (const remote of this.remotes) {
|
|
86
|
+
for (const instance of remote.instances) {
|
|
87
|
+
// 连词搜索
|
|
88
|
+
if (instance.cfg.config.nickname.includes(instanceName)) {
|
|
89
|
+
instanceMap.set(instance.cfg.instanceUuid, {
|
|
90
|
+
remote,
|
|
91
|
+
instance,
|
|
92
|
+
sort: 1,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// 分词搜索
|
|
96
|
+
if (keywords.length) {
|
|
97
|
+
// 索引词权重
|
|
98
|
+
keywords.forEach(keyword => {
|
|
99
|
+
if (instance.cfg.config.nickname.includes(keyword)) {
|
|
100
|
+
if (!instanceMap.has(instance.cfg.instanceUuid)) {
|
|
101
|
+
instanceMap.set(instance.cfg.instanceUuid, {
|
|
102
|
+
remote,
|
|
103
|
+
instance,
|
|
104
|
+
sort: 1,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// 已存在则增加权重
|
|
109
|
+
const record = instanceMap.get(instance.cfg.instanceUuid);
|
|
110
|
+
record.sort += 1;
|
|
111
|
+
instanceMap.set(instance.cfg.instanceUuid, record);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return Array.from(instanceMap.values()).sort((a, b) => b.sort - a.sort);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.MCSManagerPanel = MCSManagerPanel;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { RemoteInstanceStatusEnum } from './constants';
|
|
2
|
+
import { MCSManagerInstance } from './instance';
|
|
3
|
+
export interface MCManagerPanelResponse<T> {
|
|
4
|
+
status: number;
|
|
5
|
+
data: T;
|
|
6
|
+
time: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UserInfo {
|
|
9
|
+
uuid: string;
|
|
10
|
+
userName: string;
|
|
11
|
+
loginTime: string;
|
|
12
|
+
registerTime: string;
|
|
13
|
+
instances: [];
|
|
14
|
+
permission: number;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
isInit: boolean;
|
|
17
|
+
opennumberFA: boolean;
|
|
18
|
+
secret: string;
|
|
19
|
+
token: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ServiceRemoteItem {
|
|
22
|
+
uuid: string;
|
|
23
|
+
ip: string;
|
|
24
|
+
port: number;
|
|
25
|
+
prefix: string;
|
|
26
|
+
available: boolean;
|
|
27
|
+
remarks: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ServiceRemoteItemCustom extends ServiceRemoteItem {
|
|
30
|
+
instances: MCSManagerInstance[];
|
|
31
|
+
auth?: ServiceInstanceConnectAuth;
|
|
32
|
+
}
|
|
33
|
+
export interface ServiceRemoteInstanceItem {
|
|
34
|
+
instanceUuid: string;
|
|
35
|
+
started: number;
|
|
36
|
+
status: RemoteInstanceStatusEnum;
|
|
37
|
+
config: ServiceRemoteInstanceItemConfig;
|
|
38
|
+
info: ServiceRemoteInstanceInfo;
|
|
39
|
+
}
|
|
40
|
+
export interface ServiceRemoteInstanceItemConfig {
|
|
41
|
+
nickname: string;
|
|
42
|
+
startCommand: string;
|
|
43
|
+
stopCommand: string;
|
|
44
|
+
cwd: string;
|
|
45
|
+
ie: string;
|
|
46
|
+
oe: string;
|
|
47
|
+
createDatetime: number;
|
|
48
|
+
lastDatetime: number;
|
|
49
|
+
type: string;
|
|
50
|
+
tag: [];
|
|
51
|
+
endTime: number;
|
|
52
|
+
fileCode: string;
|
|
53
|
+
processType: string;
|
|
54
|
+
updateCommand: string;
|
|
55
|
+
crlf: number;
|
|
56
|
+
category: number;
|
|
57
|
+
enableRcon: false;
|
|
58
|
+
rconPassword: string;
|
|
59
|
+
rconPort: number;
|
|
60
|
+
rconIp: string;
|
|
61
|
+
actionCommandList: [];
|
|
62
|
+
terminalOption: {
|
|
63
|
+
haveColor: false;
|
|
64
|
+
pty: true;
|
|
65
|
+
ptyWindowCol: number;
|
|
66
|
+
ptyWindowRow: number;
|
|
67
|
+
};
|
|
68
|
+
eventTask: {
|
|
69
|
+
autoStart: false;
|
|
70
|
+
autoRestart: false;
|
|
71
|
+
ignore: false;
|
|
72
|
+
};
|
|
73
|
+
docker: {
|
|
74
|
+
containerName: string;
|
|
75
|
+
image: string;
|
|
76
|
+
ports: [];
|
|
77
|
+
extraVolumes: [];
|
|
78
|
+
memory: number;
|
|
79
|
+
networkMode: string;
|
|
80
|
+
networkAliases: [];
|
|
81
|
+
cpusetCpus: string;
|
|
82
|
+
cpuUsage: number;
|
|
83
|
+
maxSpace: number;
|
|
84
|
+
io: number;
|
|
85
|
+
network: number;
|
|
86
|
+
workingDir: string;
|
|
87
|
+
env: [];
|
|
88
|
+
changeWorkdir: false;
|
|
89
|
+
};
|
|
90
|
+
pingConfig: {
|
|
91
|
+
ip: string;
|
|
92
|
+
port: number;
|
|
93
|
+
type: number;
|
|
94
|
+
};
|
|
95
|
+
extraServiceConfig: {
|
|
96
|
+
openFrpTunnelId: string;
|
|
97
|
+
openFrpToken: string;
|
|
98
|
+
isOpenFrp: false;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface ServiceRemoteInstanceInfo {
|
|
102
|
+
mcPingOnline: true;
|
|
103
|
+
currentPlayers: number;
|
|
104
|
+
maxPlayers: number;
|
|
105
|
+
version: string;
|
|
106
|
+
fileLock: number;
|
|
107
|
+
playersChart: [];
|
|
108
|
+
openFrpStatus: false;
|
|
109
|
+
latency: number;
|
|
110
|
+
}
|
|
111
|
+
export interface ServiceInstanceConnectAuth {
|
|
112
|
+
password: string;
|
|
113
|
+
addr: string;
|
|
114
|
+
prefix: string;
|
|
115
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as io from 'socket.io-client';
|
|
2
|
+
import { Context } from 'koishi';
|
|
3
|
+
import { GLBotConfigType } from '../gl';
|
|
4
|
+
import { MCSManagerAPI } from './api';
|
|
5
|
+
import { ServiceInstanceConnectAuth, ServiceRemoteInstanceItem, ServiceRemoteItemCustom } from './type';
|
|
6
|
+
export declare class MCSManagerWebSocketIO {
|
|
7
|
+
private readonly ctx;
|
|
8
|
+
private readonly config;
|
|
9
|
+
private readonly api;
|
|
10
|
+
private remote;
|
|
11
|
+
private instance;
|
|
12
|
+
private auth;
|
|
13
|
+
connect: io.Socket;
|
|
14
|
+
isAuthenticated: boolean;
|
|
15
|
+
constructor(ctx: Context, config: GLBotConfigType, api: MCSManagerAPI, remote: ServiceRemoteItemCustom, instance: ServiceRemoteInstanceItem, auth: ServiceInstanceConnectAuth);
|
|
16
|
+
initialize(): void;
|
|
17
|
+
sendCommand(command: string): void;
|
|
18
|
+
private bindEvents;
|
|
19
|
+
private onConnect;
|
|
20
|
+
private onDisconnect;
|
|
21
|
+
private onReconnect;
|
|
22
|
+
private onConnectError;
|
|
23
|
+
authenticate(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MCSManagerWebSocketIO = void 0;
|
|
37
|
+
const io = __importStar(require("socket.io-client"));
|
|
38
|
+
const koishi_1 = require("koishi");
|
|
39
|
+
const lodash_es_1 = require("lodash-es");
|
|
40
|
+
const logger = new koishi_1.Logger('mcsmanager-ws');
|
|
41
|
+
class MCSManagerWebSocketIO {
|
|
42
|
+
constructor(ctx, config, api, remote, instance, auth) {
|
|
43
|
+
this.ctx = ctx;
|
|
44
|
+
this.config = config;
|
|
45
|
+
this.api = api;
|
|
46
|
+
this.remote = remote;
|
|
47
|
+
this.instance = instance;
|
|
48
|
+
this.auth = auth;
|
|
49
|
+
// 是否已认证通过
|
|
50
|
+
this.isAuthenticated = false;
|
|
51
|
+
this.initialize();
|
|
52
|
+
}
|
|
53
|
+
initialize() {
|
|
54
|
+
if (this.connect) {
|
|
55
|
+
this.connect.close();
|
|
56
|
+
}
|
|
57
|
+
this.connect = io.connect(this.config.mcManagerWs, {
|
|
58
|
+
multiplex: false,
|
|
59
|
+
reconnectionDelayMax: 1000 * 3,
|
|
60
|
+
timeout: 1000 * 3,
|
|
61
|
+
reconnection: true,
|
|
62
|
+
reconnectionAttempts: 2000,
|
|
63
|
+
});
|
|
64
|
+
this.bindEvents();
|
|
65
|
+
logger.info(`正在连接到 MCSManager 实例服务器 [${this.remote.remarks}] - ${this.instance.config.nickname} ...`);
|
|
66
|
+
}
|
|
67
|
+
// 发送MC指令到远程实例
|
|
68
|
+
sendCommand(command) {
|
|
69
|
+
this.connect.emit('stream/input', {
|
|
70
|
+
data: { command },
|
|
71
|
+
});
|
|
72
|
+
logger.warn(`已向远程实例 ${this.instance.config.nickname} 发送指令:${command}`);
|
|
73
|
+
}
|
|
74
|
+
bindEvents() {
|
|
75
|
+
this.connect.on('connect', this.onConnect.bind(this));
|
|
76
|
+
this.connect.on('disconnect', this.onDisconnect.bind(this));
|
|
77
|
+
this.connect.on('reconnect', this.onReconnect.bind(this));
|
|
78
|
+
this.connect.on('connect_error', this.onConnectError.bind(this));
|
|
79
|
+
}
|
|
80
|
+
onConnect() {
|
|
81
|
+
this.authenticate();
|
|
82
|
+
}
|
|
83
|
+
onDisconnect(reason) {
|
|
84
|
+
logger.warn(`与 MCSManager 实例服务器的连接已断开,原因:${reason}`);
|
|
85
|
+
}
|
|
86
|
+
onReconnect(attemptNumber) {
|
|
87
|
+
logger.info(`正在重新连接到 MCSManager 实例服务器,尝试次数:${attemptNumber}`);
|
|
88
|
+
}
|
|
89
|
+
onConnectError(error) {
|
|
90
|
+
logger.error(`连接 MCSManager 实例服务器时出错:${error.message}`);
|
|
91
|
+
}
|
|
92
|
+
authenticate() {
|
|
93
|
+
this.connect.once('auth', ({ event, status }) => {
|
|
94
|
+
this.connect.once('stream/auth', pack => {
|
|
95
|
+
if ((0, lodash_es_1.isEqual)(event, 'auth') &&
|
|
96
|
+
(0, lodash_es_1.isEqual)(status, 200) &&
|
|
97
|
+
(0, lodash_es_1.isEqual)(pack.status, 200) &&
|
|
98
|
+
(0, lodash_es_1.isEqual)(pack.data, true)) {
|
|
99
|
+
logger.info(`已成功连接到 MCSManager 实例服务器 [${this.remote.remarks}] - ${this.instance.config.nickname} `);
|
|
100
|
+
this.isAuthenticated = true;
|
|
101
|
+
return pack;
|
|
102
|
+
}
|
|
103
|
+
logger.error(`远程实例 ${this.instance.config.nickname} 认证失败,无法建立连接`);
|
|
104
|
+
});
|
|
105
|
+
this.connect.emit('stream/auth', {
|
|
106
|
+
data: {
|
|
107
|
+
password: this.auth.password,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
this.connect.emit('auth', {
|
|
112
|
+
data: this.config.mcManagerKey,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.MCSManagerWebSocketIO = MCSManagerWebSocketIO;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Context, Schema } from 'koishi';
|
|
2
|
+
import { GLBotConfigType } from '../gl';
|
|
3
|
+
export declare const name = "minecraft-sync-msg";
|
|
4
|
+
export interface WsMessageData {
|
|
5
|
+
api: string;
|
|
6
|
+
data: {
|
|
7
|
+
message: [
|
|
8
|
+
{
|
|
9
|
+
text: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare class MinecraftSyncMsg {
|
|
16
|
+
private ctx;
|
|
17
|
+
private config;
|
|
18
|
+
private ws;
|
|
19
|
+
private rcon;
|
|
20
|
+
private isDisposing;
|
|
21
|
+
private reconnectAttempts;
|
|
22
|
+
private reconnectIntervalId;
|
|
23
|
+
private plFork;
|
|
24
|
+
private enUS;
|
|
25
|
+
private zhCN;
|
|
26
|
+
constructor(ctx: Context, config: GLBotConfigType);
|
|
27
|
+
private initialize;
|
|
28
|
+
private setupRcon;
|
|
29
|
+
private connectToRcon;
|
|
30
|
+
private setupWebSocket;
|
|
31
|
+
private connectWebSocket;
|
|
32
|
+
private bindWebSocketEvents;
|
|
33
|
+
private handleWsOpen;
|
|
34
|
+
private handleWsMessage;
|
|
35
|
+
private handleWsClose;
|
|
36
|
+
private handleWsError;
|
|
37
|
+
private setupWatchChannel;
|
|
38
|
+
private reconnectWebSocket;
|
|
39
|
+
private clearReconnectInterval;
|
|
40
|
+
private setupMessageHandler;
|
|
41
|
+
private isValidChannel;
|
|
42
|
+
private isMessageCommand;
|
|
43
|
+
private isRconCommand;
|
|
44
|
+
private handleMessageCommand;
|
|
45
|
+
private handleRconCommand;
|
|
46
|
+
private sendRconCommand;
|
|
47
|
+
private extractAndRemoveColor;
|
|
48
|
+
private broadcastToChannels;
|
|
49
|
+
private setupDisposeHandler;
|
|
50
|
+
private dispose;
|
|
51
|
+
}
|
|
52
|
+
declare namespace MinecraftSyncMsg {
|
|
53
|
+
const Config: Schema<Schemastery.ObjectS<{
|
|
54
|
+
wsServer: Schema<"客户端" | "服务端", "客户端" | "服务端">;
|
|
55
|
+
wsHost: Schema<string, string>;
|
|
56
|
+
wsPort: Schema<number, number>;
|
|
57
|
+
Token: Schema<string, string>;
|
|
58
|
+
serverName: Schema<string, string>;
|
|
59
|
+
joinMsg: Schema<string, string>;
|
|
60
|
+
event: Schema<number | readonly ("AsyncPlayerChatEvent" | "PlayerCommandPreprocessEvent" | "PlayerDeathEvent" | "PlayerJoinEvent" | "PlayerQuitEvent")[], number>;
|
|
61
|
+
maxReconnectCount: Schema<number, number>;
|
|
62
|
+
maxReconnectInterval: Schema<number, number>;
|
|
63
|
+
}> | Schemastery.ObjectS<{
|
|
64
|
+
rconEnable: Schema<boolean, boolean>;
|
|
65
|
+
rconServerHost: Schema<string, string>;
|
|
66
|
+
rconServerPort: Schema<number, number>;
|
|
67
|
+
rconPassword: Schema<string, string>;
|
|
68
|
+
alluser: Schema<boolean, boolean>;
|
|
69
|
+
superuser: Schema<string[], string[]>;
|
|
70
|
+
commonCmd: Schema<string[], string[]>;
|
|
71
|
+
cannotCmd: Schema<string[], string[]>;
|
|
72
|
+
}> | Schemastery.ObjectS<{
|
|
73
|
+
sendToChannel: Schema<string[], string[]>;
|
|
74
|
+
watchChannel: Schema<string[], string[]>;
|
|
75
|
+
sendprefix: Schema<string, string>;
|
|
76
|
+
cmdprefix: Schema<string, string>;
|
|
77
|
+
hideConnect: Schema<boolean, boolean>;
|
|
78
|
+
locale: Schema<"zh-CN" | "en-US", "zh-CN" | "en-US">;
|
|
79
|
+
}>, {
|
|
80
|
+
wsServer: "客户端" | "服务端";
|
|
81
|
+
wsHost: string;
|
|
82
|
+
wsPort: number;
|
|
83
|
+
Token: string;
|
|
84
|
+
serverName: string;
|
|
85
|
+
joinMsg: string;
|
|
86
|
+
event: number;
|
|
87
|
+
maxReconnectCount: number;
|
|
88
|
+
maxReconnectInterval: number;
|
|
89
|
+
} & import("cosmokit").Dict & {
|
|
90
|
+
rconEnable: boolean;
|
|
91
|
+
rconServerHost: string;
|
|
92
|
+
rconServerPort: number;
|
|
93
|
+
rconPassword: string;
|
|
94
|
+
alluser: boolean;
|
|
95
|
+
superuser: string[];
|
|
96
|
+
commonCmd: string[];
|
|
97
|
+
cannotCmd: string[];
|
|
98
|
+
} & {
|
|
99
|
+
sendToChannel: string[];
|
|
100
|
+
watchChannel: string[];
|
|
101
|
+
sendprefix: string;
|
|
102
|
+
cmdprefix: string;
|
|
103
|
+
hideConnect: boolean;
|
|
104
|
+
locale: "zh-CN" | "en-US";
|
|
105
|
+
}>;
|
|
106
|
+
const usage = "\n \u63D2\u4EF6\u4F7F\u7528\u8BE6\u60C5\u8BF7\u770B [v2.x](https://blog.iin0.cn/views/myblog/mc/wskoishitomc.html) \n *** \u6CE8\u610F *** \n * \u547D\u4EE4\u53D1\u9001\u524D\u7F00(\u4E0D\u80FD\u4E3A\u7A7A)\u548C\u6D88\u606F\u53D1\u9001\u524D\u7F00(\u53EF\u4EE5\u4E3A\u7A7A)\u4E0D\u80FD\u76F8\u540C\n * forge\u7AEF\u4E0D\u652F\u6301PlayerCommandPreprocessEvent\u4E8B\u4EF6\n * * \u539F\u7248\u7AEF\u4EC5\u652F\u6301\u804A\u5929\u3001\u52A0\u5165\u3001\u79BB\u5F00\u4E8B\u4EF6\n * sendToChannel\u7684\u683C\u5F0F\u4E3A{platform}:{groupId},\u5982\uFF1A`discord:123456`\n * v2.1.0-beta\u53EF\u4EE5\u901A\u8FC7`\u672C\u5730\u5316`\u81EA\u5B9A\u4E49\u5BF9\u5E94\u4E8B\u4EF6\u53D1\u9001\u683C\u5F0F\n - action\u8282\u70B9\u7684{0}\u662F\u73A9\u5BB6\u540D\u79F0{1}\u662F\u6D88\u606F\n - message\u8282\u70B9\u4E2D\u7684{0}\u662F\u5E73\u53F0{1}\u662F\u7528\u6237\u540D\n ";
|
|
107
|
+
}
|
|
108
|
+
export default MinecraftSyncMsg;
|