koishi-plugin-gl-bot 0.0.9 → 0.0.10
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/lib/constants/env.d.ts +0 -0
- package/lib/constants/env.js +0 -0
- package/lib/gl/index.type.d.ts +0 -0
- package/lib/gl/index.type.js +0 -0
- package/lib/mcsManager/api.d.ts +3 -1
- package/lib/mcsManager/api.js +22 -7
- package/lib/mcsManager/bot.d.ts +2 -2
- package/lib/mcsManager/bot.js +2 -2
- package/lib/mcsManager/commands/index.d.ts +3 -0
- package/lib/mcsManager/commands/index.js +7 -1
- package/lib/mcsManager/commands/list.d.ts +11 -0
- package/lib/mcsManager/commands/list.js +26 -0
- package/lib/mcsManager/commands/{reset.d.ts → restart.d.ts} +1 -1
- package/lib/mcsManager/commands/restart.js +61 -0
- package/lib/mcsManager/commands/start.d.ts +12 -0
- package/lib/mcsManager/commands/{reset.js → start.js} +19 -11
- package/lib/mcsManager/constants.d.ts +4 -0
- package/lib/mcsManager/constants.js +4 -0
- package/lib/mcsManager/instance.d.ts +3 -1
- package/lib/mcsManager/instance.js +8 -2
- package/lib/mcsManager/panel.js +6 -4
- package/lib/mcsManager/ws.js +5 -5
- package/lib/queQiao/index.js +2 -2
- package/lib/queQiao/locale/en-US.yml +9 -9
- package/lib/queQiao/locale/zh-CN.yml +9 -9
- package/package.json +3 -3
- package/lib/mcsManager/commands/base.d.ts +0 -2
- package/lib/mcsManager/commands/base.js +0 -6
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/mcsManager/api.d.ts
CHANGED
|
@@ -21,5 +21,7 @@ export declare class MCSManagerAPI {
|
|
|
21
21
|
page_size?: number;
|
|
22
22
|
}): Promise<ServiceRemoteInstanceItem[]>;
|
|
23
23
|
getServiceInstanceConnectAuth(remoteUUID: string, instanceId: string): Promise<ServiceInstanceConnectAuth | null>;
|
|
24
|
-
restartRemoteInstance(daemonId: string, instanceId: string): Promise<
|
|
24
|
+
restartRemoteInstance(daemonId: string, instanceId: string): Promise<boolean>;
|
|
25
|
+
stopRemoteInstance(daemonId: string, instanceId: string): Promise<boolean>;
|
|
26
|
+
startRemoteInstance(daemonId: string, instanceId: string): Promise<boolean>;
|
|
25
27
|
}
|
package/lib/mcsManager/api.js
CHANGED
|
@@ -72,19 +72,34 @@ class MCSManagerAPI {
|
|
|
72
72
|
})).data.data ?? null);
|
|
73
73
|
}
|
|
74
74
|
async restartRemoteInstance(daemonId, instanceId) {
|
|
75
|
-
|
|
76
|
-
daemonId,
|
|
77
|
-
uuid: instanceId,
|
|
78
|
-
token: this.userInfo.token,
|
|
79
|
-
});
|
|
80
|
-
return this.http(`${this.baseUrl}/protected_instance/restart`, {
|
|
75
|
+
return ((await this.http(`${this.baseUrl}/protected_instance/restart`, {
|
|
81
76
|
headers: this.requestHeaders,
|
|
82
77
|
params: {
|
|
83
78
|
daemonId,
|
|
84
79
|
uuid: instanceId,
|
|
85
80
|
token: this.userInfo.token,
|
|
86
81
|
},
|
|
87
|
-
});
|
|
82
|
+
})).data.data?.instanceUuid === instanceId);
|
|
83
|
+
}
|
|
84
|
+
async stopRemoteInstance(daemonId, instanceId) {
|
|
85
|
+
return ((await this.http(`${this.baseUrl}/protected_instance/stop`, {
|
|
86
|
+
headers: this.requestHeaders,
|
|
87
|
+
params: {
|
|
88
|
+
daemonId,
|
|
89
|
+
uuid: instanceId,
|
|
90
|
+
token: this.userInfo.token,
|
|
91
|
+
},
|
|
92
|
+
})).data.data?.instanceUuid === instanceId);
|
|
93
|
+
}
|
|
94
|
+
async startRemoteInstance(daemonId, instanceId) {
|
|
95
|
+
return ((await this.http(`${this.baseUrl}/protected_instance/open`, {
|
|
96
|
+
headers: this.requestHeaders,
|
|
97
|
+
params: {
|
|
98
|
+
daemonId,
|
|
99
|
+
uuid: instanceId,
|
|
100
|
+
token: this.userInfo.token,
|
|
101
|
+
},
|
|
102
|
+
})).data.data?.instanceUuid === instanceId);
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
exports.MCSManagerAPI = MCSManagerAPI;
|
package/lib/mcsManager/bot.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
2
|
import { GLBotConfigType } from '../gl';
|
|
3
|
-
import {
|
|
3
|
+
import { MCBotListCommand, MCBotRestartCommand, MCBotStartCommand } from './commands';
|
|
4
4
|
import { MCSManagerPanel } from './panel';
|
|
5
5
|
export declare class MCSManagerBot {
|
|
6
6
|
readonly ctx: Context;
|
|
@@ -8,7 +8,7 @@ export declare class MCSManagerBot {
|
|
|
8
8
|
readonly panel: MCSManagerPanel;
|
|
9
9
|
constructor(ctx: Context, config: GLBotConfigType, panel: MCSManagerPanel);
|
|
10
10
|
help(): string[];
|
|
11
|
-
commands(): (typeof
|
|
11
|
+
commands(): (typeof MCBotListCommand | typeof MCBotRestartCommand | typeof MCBotStartCommand)[];
|
|
12
12
|
initialize(): Promise<void>;
|
|
13
13
|
private registerCommands;
|
|
14
14
|
}
|
package/lib/mcsManager/bot.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MCSManagerBot = void 0;
|
|
4
|
-
const
|
|
4
|
+
const commands_1 = require("./commands");
|
|
5
5
|
class MCSManagerBot {
|
|
6
6
|
constructor(ctx, config, panel) {
|
|
7
7
|
this.ctx = ctx;
|
|
@@ -20,7 +20,7 @@ class MCSManagerBot {
|
|
|
20
20
|
];
|
|
21
21
|
}
|
|
22
22
|
commands() {
|
|
23
|
-
return [
|
|
23
|
+
return [commands_1.MCBotRestartCommand, commands_1.MCBotListCommand, commands_1.MCBotStartCommand];
|
|
24
24
|
}
|
|
25
25
|
async initialize() {
|
|
26
26
|
this.ctx.on('ready', async () => {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
2
|
import { GLBotConfigType } from '../../gl';
|
|
3
|
+
export { MCBotListCommand } from './list';
|
|
4
|
+
export { MCBotRestartCommand } from './restart';
|
|
5
|
+
export { MCBotStartCommand } from './start';
|
|
3
6
|
export declare class MCBotCommandBase {
|
|
4
7
|
readonly ctx: Context;
|
|
5
8
|
readonly config: GLBotConfigType;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MCBotCommandBase = void 0;
|
|
3
|
+
exports.MCBotCommandBase = exports.MCBotStartCommand = exports.MCBotRestartCommand = exports.MCBotListCommand = void 0;
|
|
4
4
|
const koishi_1 = require("koishi");
|
|
5
|
+
var list_1 = require("./list");
|
|
6
|
+
Object.defineProperty(exports, "MCBotListCommand", { enumerable: true, get: function () { return list_1.MCBotListCommand; } });
|
|
7
|
+
var restart_1 = require("./restart");
|
|
8
|
+
Object.defineProperty(exports, "MCBotRestartCommand", { enumerable: true, get: function () { return restart_1.MCBotRestartCommand; } });
|
|
9
|
+
var start_1 = require("./start");
|
|
10
|
+
Object.defineProperty(exports, "MCBotStartCommand", { enumerable: true, get: function () { return start_1.MCBotStartCommand; } });
|
|
5
11
|
const logger = new koishi_1.Logger('mcsmanager-command');
|
|
6
12
|
class MCBotCommandBase {
|
|
7
13
|
constructor(ctx, config) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCBotListCommand = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
/**
|
|
6
|
+
* 服务器列表指令
|
|
7
|
+
*
|
|
8
|
+
* @example 服务器 列表
|
|
9
|
+
*/
|
|
10
|
+
class MCBotListCommand {
|
|
11
|
+
constructor(bot) {
|
|
12
|
+
this.bot = bot;
|
|
13
|
+
bot.ctx.command('服务器.列表 <status>').action(async (_, status) => {
|
|
14
|
+
return await this.handle(status);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async handle(status) {
|
|
18
|
+
await this.bot.panel.handleRemoteServices();
|
|
19
|
+
const nameInstances = (await this.bot.panel.searchInstanceByName('')).filter(item => !status ||
|
|
20
|
+
constants_1.RemoteInstanceStatusName[item.instance.cfg.status] === status);
|
|
21
|
+
return `${'='.repeat(10)}服务器列表${'='.repeat(10)}\n${nameInstances
|
|
22
|
+
.map((item, index) => `${index + 1}. [${constants_1.RemoteInstanceStatusName[item.instance.cfg.status]}] ${item.instance.cfg.config.nickname}`)
|
|
23
|
+
.join('\n')}\n ${'='.repeat(20)} `;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.MCBotListCommand = MCBotListCommand;
|
|
@@ -5,7 +5,7 @@ import { MCSManagerBot } from '../bot';
|
|
|
5
5
|
*
|
|
6
6
|
* @example 服务器 重启 神话
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class MCBotRestartCommand {
|
|
9
9
|
private readonly bot;
|
|
10
10
|
constructor(bot: MCSManagerBot);
|
|
11
11
|
handle(session: Session<never, never, Context>, name: string): Promise<string>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCBotRestartCommand = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
// const logger = new Logger('mcsmanager-reset');
|
|
6
|
+
const tempSelections = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* 服务器重启指令
|
|
9
|
+
*
|
|
10
|
+
* @example 服务器 重启 神话
|
|
11
|
+
*/
|
|
12
|
+
class MCBotRestartCommand {
|
|
13
|
+
constructor(bot) {
|
|
14
|
+
this.bot = bot;
|
|
15
|
+
bot.ctx
|
|
16
|
+
.command('服务器.重启 <name...>')
|
|
17
|
+
.action(async ({ session }, ...name) => {
|
|
18
|
+
return await this.handle(session, name.join(' '));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async handle(session, name) {
|
|
22
|
+
let selectIndex = -1;
|
|
23
|
+
const userId = Number(session.event.user.id);
|
|
24
|
+
// 溯源前搜索项
|
|
25
|
+
if (tempSelections.has(userId) && !isNaN(Number(name))) {
|
|
26
|
+
selectIndex = Number(name) - 1;
|
|
27
|
+
name = tempSelections.get(userId);
|
|
28
|
+
}
|
|
29
|
+
tempSelections.delete(userId);
|
|
30
|
+
const nameInstances = await this.bot.panel.searchInstanceByName(name);
|
|
31
|
+
if (nameInstances.length === 0) {
|
|
32
|
+
return `未找到名称包含 "${name}" 的服务器实例`;
|
|
33
|
+
}
|
|
34
|
+
if (nameInstances.length > 1 && selectIndex === -1) {
|
|
35
|
+
tempSelections.set(userId, name);
|
|
36
|
+
return `请输入序号以选择:\n\n${nameInstances
|
|
37
|
+
.map((item, index) => `${index + 1}. [${constants_1.RemoteInstanceStatusName[item.instance.cfg.status]}] ${item.instance.cfg.config.nickname}`)
|
|
38
|
+
.join('\n')}\n ==== 例如发送: (服务器 重启 1) ====`;
|
|
39
|
+
}
|
|
40
|
+
const targetInstance = selectIndex !== -1 ? nameInstances[selectIndex] : nameInstances[0];
|
|
41
|
+
if (!targetInstance || !targetInstance.instance) {
|
|
42
|
+
return `未找到名称包含 "${name}" 的服务器实例`;
|
|
43
|
+
}
|
|
44
|
+
const { cfg } = targetInstance.instance;
|
|
45
|
+
switch (cfg.status) {
|
|
46
|
+
// 关闭状态:启动
|
|
47
|
+
case constants_1.RemoteInstanceStatusEnum.RUNNING:
|
|
48
|
+
await targetInstance.instance.restartInstance();
|
|
49
|
+
this.bot.panel.handleRemoteServices();
|
|
50
|
+
return `已向服务器实例 "${cfg.config.nickname}" 发送重启操作`;
|
|
51
|
+
// 启动状态:重启
|
|
52
|
+
case constants_1.RemoteInstanceStatusEnum.STOPPED:
|
|
53
|
+
await targetInstance.instance.startInstance();
|
|
54
|
+
this.bot.panel.handleRemoteServices();
|
|
55
|
+
return `已向服务器实例 "${cfg.config.nickname}" 发送启动操作`;
|
|
56
|
+
default:
|
|
57
|
+
return `服务器实例 "${cfg.config.nickname}" 当前状态为 ${cfg.status},无法执行重启操作`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.MCBotRestartCommand = MCBotRestartCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context, Session } from 'koishi';
|
|
2
|
+
import { MCSManagerBot } from '../bot';
|
|
3
|
+
/**
|
|
4
|
+
* 服务器启动指令
|
|
5
|
+
*
|
|
6
|
+
* @example 服务器 启动 神话
|
|
7
|
+
*/
|
|
8
|
+
export declare class MCBotStartCommand {
|
|
9
|
+
private readonly bot;
|
|
10
|
+
constructor(bot: MCSManagerBot);
|
|
11
|
+
handle(session: Session<never, never, Context>, name: string): Promise<string>;
|
|
12
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MCBotStartCommand = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const constants_1 = require("../constants");
|
|
5
|
-
// const logger = new Logger('mcsmanager-reset');
|
|
6
6
|
const tempSelections = new Map();
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 服务器启动指令
|
|
9
9
|
*
|
|
10
|
-
* @example 服务器
|
|
10
|
+
* @example 服务器 启动 神话
|
|
11
11
|
*/
|
|
12
|
-
class
|
|
12
|
+
class MCBotStartCommand {
|
|
13
13
|
constructor(bot) {
|
|
14
14
|
this.bot = bot;
|
|
15
15
|
bot.ctx
|
|
16
|
-
.command('
|
|
17
|
-
.action(async ({ session },
|
|
16
|
+
.command('服务器.启动 <name...>')
|
|
17
|
+
.action(async ({ session }, ...name) => {
|
|
18
18
|
return await this.handle(session, name.join(' '));
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -35,11 +35,19 @@ class MCBotResetCommand {
|
|
|
35
35
|
tempSelections.set(userId, name);
|
|
36
36
|
return `请输入序号以选择:\n\n${nameInstances
|
|
37
37
|
.map((item, index) => `${index + 1}. [${constants_1.RemoteInstanceStatusName[item.instance.cfg.status]}] ${item.instance.cfg.config.nickname}`)
|
|
38
|
-
.join('\n')}\n ==== 例如发送: (服务器
|
|
38
|
+
.join('\n')}\n ==== 例如发送: (服务器 启动 1) ====`;
|
|
39
39
|
}
|
|
40
40
|
const targetInstance = selectIndex !== -1 ? nameInstances[selectIndex] : nameInstances[0];
|
|
41
|
-
targetInstance.instance
|
|
42
|
-
|
|
41
|
+
if (!targetInstance || !targetInstance.instance) {
|
|
42
|
+
return `未找到名称包含 "${name}" 的服务器实例`;
|
|
43
|
+
}
|
|
44
|
+
const { cfg } = targetInstance.instance;
|
|
45
|
+
if ((0, lodash_1.isEqual)(cfg.status, constants_1.RemoteInstanceStatusEnum.STOPPED)) {
|
|
46
|
+
await targetInstance.instance.startInstance();
|
|
47
|
+
this.bot.panel.handleRemoteServices();
|
|
48
|
+
return `已向服务器实例 "${cfg.config.nickname}" 发送启动操作`;
|
|
49
|
+
}
|
|
50
|
+
return `服务器实例 "${cfg.config.nickname}" 当前状态为 ${cfg.status},无法执行启动操作`;
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
exports.
|
|
53
|
+
exports.MCBotStartCommand = MCBotStartCommand;
|
|
@@ -4,9 +4,13 @@ exports.RemoteInstanceStatusName = exports.RemoteInstanceStatusEnum = void 0;
|
|
|
4
4
|
var RemoteInstanceStatusEnum;
|
|
5
5
|
(function (RemoteInstanceStatusEnum) {
|
|
6
6
|
RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["STOPPED"] = 0] = "STOPPED";
|
|
7
|
+
RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["STARTING"] = 1] = "STARTING";
|
|
8
|
+
RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["STOPPING"] = 2] = "STOPPING";
|
|
7
9
|
RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["RUNNING"] = 3] = "RUNNING";
|
|
8
10
|
})(RemoteInstanceStatusEnum || (exports.RemoteInstanceStatusEnum = RemoteInstanceStatusEnum = {}));
|
|
9
11
|
exports.RemoteInstanceStatusName = {
|
|
10
12
|
[RemoteInstanceStatusEnum.STOPPED]: '已停止',
|
|
13
|
+
[RemoteInstanceStatusEnum.STARTING]: '启动中',
|
|
14
|
+
[RemoteInstanceStatusEnum.STOPPING]: '停止中',
|
|
11
15
|
[RemoteInstanceStatusEnum.RUNNING]: '运行中',
|
|
12
16
|
};
|
|
@@ -12,5 +12,7 @@ export declare class MCSManagerInstance {
|
|
|
12
12
|
cfg: ServiceRemoteInstanceItem;
|
|
13
13
|
isAuthenticated: boolean;
|
|
14
14
|
constructor(ctx: Context, config: GLBotConfigType, api: MCSManagerAPI, panel: MCSManagerPanel, remote: ServiceRemoteItem, cfg: ServiceRemoteInstanceItem);
|
|
15
|
-
restartInstance():
|
|
15
|
+
restartInstance(): Promise<boolean>;
|
|
16
|
+
stopInstance(): Promise<boolean>;
|
|
17
|
+
startInstance(): Promise<boolean>;
|
|
16
18
|
}
|
|
@@ -11,8 +11,14 @@ class MCSManagerInstance {
|
|
|
11
11
|
this.cfg = cfg;
|
|
12
12
|
this.isAuthenticated = false;
|
|
13
13
|
}
|
|
14
|
-
restartInstance() {
|
|
15
|
-
this.api.restartRemoteInstance(this.remote.uuid, this.cfg.instanceUuid);
|
|
14
|
+
async restartInstance() {
|
|
15
|
+
return await this.api.restartRemoteInstance(this.remote.uuid, this.cfg.instanceUuid);
|
|
16
|
+
}
|
|
17
|
+
async stopInstance() {
|
|
18
|
+
return await this.api.stopRemoteInstance(this.remote.uuid, this.cfg.instanceUuid);
|
|
19
|
+
}
|
|
20
|
+
async startInstance() {
|
|
21
|
+
return await this.api.startRemoteInstance(this.remote.uuid, this.cfg.instanceUuid);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
exports.MCSManagerInstance = MCSManagerInstance;
|
package/lib/mcsManager/panel.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MCSManagerPanel = void 0;
|
|
4
4
|
const koishi_1 = require("koishi");
|
|
5
|
-
const
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
6
|
const api_1 = require("./api");
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
8
|
const instance_1 = require("./instance");
|
|
@@ -31,16 +31,18 @@ class MCSManagerPanel {
|
|
|
31
31
|
await this.handleRemoteServices();
|
|
32
32
|
await this.getAvailableRemoteInstance();
|
|
33
33
|
}
|
|
34
|
-
// 获取远程服务及其实例列表
|
|
34
|
+
// 获取远程服务及其实例列表 [全量]
|
|
35
35
|
async handleRemoteServices() {
|
|
36
36
|
const remoteList = await this.api.getServiceRemoteList();
|
|
37
|
+
const insertList = [];
|
|
37
38
|
for (const remote of remoteList) {
|
|
38
39
|
const instanceList = await this.api.getServiceRemoteInstanceList(remote.uuid);
|
|
39
|
-
|
|
40
|
+
insertList.push({
|
|
40
41
|
instances: instanceList.map(item => new instance_1.MCSManagerInstance(this.ctx, this.config, this.api, this, remote, item)),
|
|
41
42
|
...remote,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
this.remotes = insertList;
|
|
44
46
|
logger.info(`已获取到 ${this.remotes.length} 个远程节点及其实例 ${this.remotes.reduce((acc, remote) => acc + remote.instances.length, 0)} 个`);
|
|
45
47
|
}
|
|
46
48
|
// 遍历所有远程节点 选择正在运行中的实力 建立远程连接
|
|
@@ -53,7 +55,7 @@ class MCSManagerPanel {
|
|
|
53
55
|
}
|
|
54
56
|
// 创建远程连接
|
|
55
57
|
async createMCSManagerConnection(remote, instance) {
|
|
56
|
-
if ((0,
|
|
58
|
+
if ((0, lodash_1.isEqual)(instance.status, constants_1.RemoteInstanceStatusEnum.RUNNING)) {
|
|
57
59
|
const uuid = instance.instanceUuid;
|
|
58
60
|
// 已存在的实例且连接中 直接返回
|
|
59
61
|
if (this.remoteConnectionsMap.has(uuid) &&
|
package/lib/mcsManager/ws.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.MCSManagerWebSocketIO = void 0;
|
|
37
37
|
const io = __importStar(require("socket.io-client"));
|
|
38
38
|
const koishi_1 = require("koishi");
|
|
39
|
-
const
|
|
39
|
+
const lodash_1 = require("lodash");
|
|
40
40
|
const logger = new koishi_1.Logger('mcsmanager-ws');
|
|
41
41
|
class MCSManagerWebSocketIO {
|
|
42
42
|
constructor(ctx, config, api, remote, instance, auth) {
|
|
@@ -92,10 +92,10 @@ class MCSManagerWebSocketIO {
|
|
|
92
92
|
authenticate() {
|
|
93
93
|
this.connect.once('auth', ({ event, status }) => {
|
|
94
94
|
this.connect.once('stream/auth', pack => {
|
|
95
|
-
if ((0,
|
|
96
|
-
(0,
|
|
97
|
-
(0,
|
|
98
|
-
(0,
|
|
95
|
+
if ((0, lodash_1.isEqual)(event, 'auth') &&
|
|
96
|
+
(0, lodash_1.isEqual)(status, 200) &&
|
|
97
|
+
(0, lodash_1.isEqual)(pack.status, 200) &&
|
|
98
|
+
(0, lodash_1.isEqual)(pack.data, true)) {
|
|
99
99
|
logger.info(`已成功连接到 MCSManager 实例服务器 [${this.remote.remarks}] - ${this.instance.config.nickname} `);
|
|
100
100
|
this.isAuthenticated = true;
|
|
101
101
|
return pack;
|
package/lib/queQiao/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.name = void 0;
|
|
7
7
|
const koishi_1 = require("koishi");
|
|
8
|
-
const
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
9
|
const rcon_client_1 = require("rcon-client");
|
|
10
10
|
const ws_1 = require("ws");
|
|
11
11
|
const constants_1 = require("../constants");
|
|
@@ -364,7 +364,7 @@ class MinecraftSyncMsg {
|
|
|
364
364
|
.map(str => str.replace(`${bot.platform}:`, ''));
|
|
365
365
|
console.log(this.config.sendToChannel);
|
|
366
366
|
if (process.env.NODE_ENV === 'development') {
|
|
367
|
-
logger.info((0,
|
|
367
|
+
logger.info((0, lodash_1.isString)(message)
|
|
368
368
|
? message
|
|
369
369
|
: message.map(el => el.attrs.content).join(''));
|
|
370
370
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
minecraft-sync-msg:
|
|
2
|
-
action:
|
|
3
|
-
PlayerJoinEvent:
|
|
4
|
-
PlayerCommandPreprocessEvent:
|
|
5
|
-
PlayerDeathEvent:
|
|
6
|
-
AsyncPlayerChatEvent:
|
|
7
|
-
PlayerQuitEvent:
|
|
8
|
-
message:
|
|
9
|
-
MCReceivePrefix:
|
|
1
|
+
minecraft-sync-msg:
|
|
2
|
+
action:
|
|
3
|
+
PlayerJoinEvent: '[join] Player {0} joined the game'
|
|
4
|
+
PlayerCommandPreprocessEvent: '[command] Player {0} executed command'
|
|
5
|
+
PlayerDeathEvent: '[death] Player {0} meet the god'
|
|
6
|
+
AsyncPlayerChatEvent: '[chat] Player {0} said: {1}'
|
|
7
|
+
PlayerQuitEvent: '[quit] Player {0} left the game'
|
|
8
|
+
message:
|
|
9
|
+
MCReceivePrefix: '({0})[{1}]'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
minecraft-sync-msg:
|
|
2
|
-
action:
|
|
3
|
-
PlayerJoinEvent:
|
|
4
|
-
PlayerCommandPreprocessEvent:
|
|
5
|
-
PlayerDeathEvent:
|
|
6
|
-
AsyncPlayerChatEvent:
|
|
7
|
-
PlayerQuitEvent:
|
|
8
|
-
message:
|
|
9
|
-
MCReceivePrefix:
|
|
1
|
+
minecraft-sync-msg:
|
|
2
|
+
action:
|
|
3
|
+
PlayerJoinEvent: '[加入]{0} 加入了服务器!'
|
|
4
|
+
PlayerCommandPreprocessEvent: '[指令]{0} 执行了指令'
|
|
5
|
+
PlayerDeathEvent: '[死亡]{0} 与山长眠!'
|
|
6
|
+
AsyncPlayerChatEvent: '[聊天]{0} 说:{1}'
|
|
7
|
+
PlayerQuitEvent: '[离开]{0} 离开了服务器!'
|
|
8
|
+
message:
|
|
9
|
+
MCReceivePrefix: '({0})[{1}]'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-gl-bot",
|
|
3
3
|
"description": "GleamSlime Koishi Rebot Plugins",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"contributors": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@koishijs/client": "^5.30.11",
|
|
31
|
-
"@types/lodash
|
|
31
|
+
"@types/lodash": "^4.17.21",
|
|
32
32
|
"typescript": "^5.9.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"lodash
|
|
44
|
+
"lodash": "^4.17.21",
|
|
45
45
|
"rcon-client": "^4.2.5",
|
|
46
46
|
"socket.io-client": "^4.8.2",
|
|
47
47
|
"ws": "^8.18.3"
|