koishi-plugin-gl-bot 0.0.7 → 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.
Files changed (49) hide show
  1. package/dist/index.js +1 -1
  2. package/lib/constants/index.d.ts +1 -0
  3. package/lib/constants/index.js +4 -0
  4. package/lib/gl/index.d.ts +83 -0
  5. package/lib/gl/index.js +51 -0
  6. package/lib/gl/type.d.ts +0 -0
  7. package/lib/gl/type.js +0 -0
  8. package/lib/index.d.ts +2 -5
  9. package/lib/index.js +6 -0
  10. package/lib/mcsManager/api.d.ts +25 -0
  11. package/lib/mcsManager/api.js +96 -0
  12. package/lib/mcsManager/bot.d.ts +14 -0
  13. package/lib/mcsManager/bot.js +42 -0
  14. package/lib/mcsManager/commands/base.d.ts +2 -0
  15. package/lib/mcsManager/commands/base.js +6 -0
  16. package/lib/mcsManager/commands/index.d.ts +7 -0
  17. package/lib/mcsManager/commands/index.js +13 -0
  18. package/lib/mcsManager/commands/reset.d.ts +12 -0
  19. package/lib/mcsManager/commands/reset.js +45 -0
  20. package/lib/mcsManager/config.d.ts +18 -0
  21. package/lib/mcsManager/config.js +24 -0
  22. package/lib/mcsManager/constants.d.ts +8 -0
  23. package/lib/mcsManager/constants.js +12 -0
  24. package/lib/mcsManager/index.d.ts +26 -0
  25. package/lib/mcsManager/index.js +21 -0
  26. package/lib/mcsManager/instance.d.ts +16 -0
  27. package/lib/mcsManager/instance.js +18 -0
  28. package/lib/mcsManager/panel.d.ts +24 -0
  29. package/lib/mcsManager/panel.js +121 -0
  30. package/lib/mcsManager/type.d.ts +115 -0
  31. package/lib/mcsManager/type.js +2 -0
  32. package/lib/mcsManager/ws.d.ts +24 -0
  33. package/lib/mcsManager/ws.js +116 -0
  34. package/lib/queQiao/index.d.ts +108 -0
  35. package/lib/queQiao/index.js +437 -0
  36. package/lib/queQiao/locale/en-US.json +1 -0
  37. package/lib/queQiao/locale/en-US.yml +9 -0
  38. package/lib/queQiao/locale/zh-CN.json +1 -0
  39. package/lib/queQiao/locale/zh-CN.yml +9 -0
  40. package/lib/queQiao/mcwss.d.ts +61 -0
  41. package/lib/queQiao/mcwss.js +260 -0
  42. package/lib/queQiao/values.d.ts +72 -0
  43. package/lib/queQiao/values.js +155 -0
  44. package/lib/utils/game.mc.d.ts +4 -0
  45. package/lib/utils/game.mc.js +29 -0
  46. package/lib/utils/index.d.ts +1 -0
  47. package/lib/utils/index.js +17 -0
  48. package/package.json +14 -4
  49. package/src/index.ts +0 -20
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{resolveComponent as r,createBlock as a,openBlock as s,withCtx as _,createTextVNode as p}from"vue";const l=(t,e)=>{const o=t.__vccOpts||t;for(const[n,c]of e)o[n]=c;return o},u={};function f(t,e){const o=r("k-layout");return s(),a(o,null,{default:_(()=>[...e[0]||(e[0]=[p("扩展内容",-1)])]),_:1})}const m=l(u,[["render",f]]),x=t=>{t.page({name:"扩展页面",path:"/custom-page",component:m})};export{x as default};
1
+ import{resolveComponent as r,createBlock as a,openBlock as s,withCtx as _,createTextVNode as p}from"vue";const d=(t,e)=>{const o=t.__vccOpts||t;for(const[n,c]of e)o[n]=c;return o},f={};function l(t,e){const o=r("k-card");return s(),a(o,null,{default:_(()=>[...e[0]||(e[0]=[p("扩展内容22",-1)])]),_:1})}const m=d(f,[["render",l]]),x=t=>{t.page({name:"扩展页面",path:"/custom-page",component:m})};export{x as default};
@@ -0,0 +1 @@
1
+ export declare const IS_DEV: boolean;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IS_DEV = void 0;
4
+ exports.IS_DEV = process.env.NODE_ENV === 'development';
@@ -0,0 +1,83 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare class GLBot {
3
+ private ctx;
4
+ private config;
5
+ static Config: Schema<Schemastery.ObjectS<{
6
+ wsServer: Schema<"客户端" | "服务端", "客户端" | "服务端">;
7
+ wsHost: Schema<string, string>;
8
+ wsPort: Schema<number, number>;
9
+ Token: Schema<string, string>;
10
+ serverName: Schema<string, string>;
11
+ joinMsg: Schema<string, string>;
12
+ event: Schema<number | readonly ("AsyncPlayerChatEvent" | "PlayerCommandPreprocessEvent" | "PlayerDeathEvent" | "PlayerJoinEvent" | "PlayerQuitEvent")[], number>;
13
+ maxReconnectCount: Schema<number, number>;
14
+ maxReconnectInterval: Schema<number, number>;
15
+ }> | Schemastery.ObjectS<{
16
+ rconEnable: Schema<boolean, boolean>;
17
+ rconServerHost: Schema<string, string>;
18
+ rconServerPort: Schema<number, number>;
19
+ rconPassword: Schema<string, string>;
20
+ alluser: Schema<boolean, boolean>;
21
+ superuser: Schema<string[], string[]>;
22
+ commonCmd: Schema<string[], string[]>;
23
+ cannotCmd: Schema<string[], string[]>;
24
+ }> | Schemastery.ObjectS<{
25
+ sendToChannel: Schema<string[], string[]>;
26
+ watchChannel: Schema<string[], string[]>;
27
+ sendprefix: Schema<string, string>;
28
+ cmdprefix: Schema<string, string>;
29
+ hideConnect: Schema<boolean, boolean>;
30
+ locale: Schema<"zh-CN" | "en-US", "zh-CN" | "en-US">;
31
+ }> | Schemastery.ObjectS<{
32
+ mcManagerUsername: Schema<string, string>;
33
+ mcManagerPassword: Schema<string, string>;
34
+ mcManagerKey: Schema<string, string>;
35
+ mcManagerHost: Schema<string, string>;
36
+ mcManagerWs: Schema<string, string>;
37
+ mcManagerMaxConnectWs: Schema<number, number>;
38
+ }>, {
39
+ wsServer: "客户端" | "服务端";
40
+ wsHost: string;
41
+ wsPort: number;
42
+ Token: string;
43
+ serverName: string;
44
+ joinMsg: string;
45
+ event: number;
46
+ maxReconnectCount: number;
47
+ maxReconnectInterval: number;
48
+ } & import("cosmokit").Dict & {
49
+ rconEnable: boolean;
50
+ rconServerHost: string;
51
+ rconServerPort: number;
52
+ rconPassword: string;
53
+ alluser: boolean;
54
+ superuser: string[];
55
+ commonCmd: string[];
56
+ cannotCmd: string[];
57
+ } & {
58
+ sendToChannel: string[];
59
+ watchChannel: string[];
60
+ sendprefix: string;
61
+ cmdprefix: string;
62
+ hideConnect: boolean;
63
+ locale: "zh-CN" | "en-US";
64
+ } & {
65
+ mcManagerUsername: string;
66
+ mcManagerPassword: string;
67
+ mcManagerKey: string;
68
+ mcManagerHost: string;
69
+ mcManagerWs: string;
70
+ mcManagerMaxConnectWs: number;
71
+ }>;
72
+ private mcSyncMsg;
73
+ private mcsManager;
74
+ constructor(ctx: Context, config: GLBotConfigType);
75
+ private initialize;
76
+ private globalCommand;
77
+ }
78
+ export declare class GLBotBase {
79
+ private ctx;
80
+ private config;
81
+ constructor(ctx: Context, config: GLBotConfigType);
82
+ }
83
+ export type GLBotConfigType = Schemastery.TypeS<typeof GLBot.Config>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GLBotBase = exports.GLBot = void 0;
7
+ const koishi_1 = require("koishi");
8
+ const constants_1 = require("../constants");
9
+ const mcsManager_1 = require("../mcsManager");
10
+ const queQiao_1 = __importDefault(require("../queQiao"));
11
+ const logger = new koishi_1.Logger('gl-bot');
12
+ class GLBot {
13
+ constructor(ctx, config) {
14
+ this.ctx = ctx;
15
+ this.config = config;
16
+ this.mcSyncMsg = new queQiao_1.default(ctx, config);
17
+ this.mcsManager = new mcsManager_1.MCManager(ctx, config);
18
+ this.initialize();
19
+ }
20
+ initialize() {
21
+ this.globalCommand();
22
+ }
23
+ globalCommand() {
24
+ this.ctx.on('message', session => {
25
+ if (constants_1.IS_DEV) {
26
+ // console.log(JSON.stringify(session, null, 2));
27
+ }
28
+ switch (session.content) {
29
+ case '环境变量':
30
+ session.send(`当前环境变量:${Object.entries(process.env)
31
+ .map(([k, v]) => `${k}: ${v}`)
32
+ .join('\n')}`);
33
+ break;
34
+ default:
35
+ break;
36
+ }
37
+ if (~session.content.indexOf('群群')) {
38
+ session.send(`群群似杂鱼!大杂鱼喵`);
39
+ }
40
+ });
41
+ }
42
+ }
43
+ exports.GLBot = GLBot;
44
+ GLBot.Config = koishi_1.Schema.intersect([queQiao_1.default.Config, mcsManager_1.MCManager.Config]);
45
+ class GLBotBase {
46
+ constructor(ctx, config) {
47
+ this.ctx = ctx;
48
+ this.config = config;
49
+ }
50
+ }
51
+ exports.GLBotBase = GLBotBase;
File without changes
package/lib/gl/type.js ADDED
File without changes
package/lib/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { Context, Schema } from "koishi";
1
+ import { GLBot } from './gl';
2
2
  export declare const name = "gl-bot";
3
- export interface Config {
4
- }
5
- export declare const Config: Schema<Config>;
6
- export declare function apply(ctx: Context): void;
3
+ export default GLBot;
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.name = void 0;
4
+ const gl_1 = require("./gl");
5
+ exports.name = 'gl-bot';
6
+ exports.default = gl_1.GLBot;
@@ -0,0 +1,25 @@
1
+ import { HTTP } from 'koishi';
2
+ import { ServiceInstanceConnectAuth, ServiceRemoteInstanceItem, ServiceRemoteItem, UserInfo } from './type';
3
+ export declare class MCSManagerAPI {
4
+ private http;
5
+ private baseUrl;
6
+ private authCookie?;
7
+ userInfo: UserInfo;
8
+ get requestHeaders(): {
9
+ cookie: string;
10
+ 'x-requested-with': string;
11
+ };
12
+ constructor(http: HTTP, baseUrl: string, authCookie?: string);
13
+ login(username: string, password: string): Promise<boolean>;
14
+ getUserInfo(): Promise<UserInfo>;
15
+ getServiceRemoteList(): Promise<ServiceRemoteItem[]>;
16
+ getServiceRemoteInstanceList(daemonId: string, options?: {
17
+ status?: string;
18
+ tag: string[];
19
+ instance_name?: string;
20
+ page?: number;
21
+ page_size?: number;
22
+ }): Promise<ServiceRemoteInstanceItem[]>;
23
+ getServiceInstanceConnectAuth(remoteUUID: string, instanceId: string): Promise<ServiceInstanceConnectAuth | null>;
24
+ restartRemoteInstance(daemonId: string, instanceId: string): Promise<HTTP.Response<any>>;
25
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCSManagerAPI = void 0;
4
+ class MCSManagerAPI {
5
+ get requestHeaders() {
6
+ return {
7
+ cookie: this.authCookie,
8
+ 'x-requested-with': 'XMLHttpRequest',
9
+ };
10
+ }
11
+ constructor(http, baseUrl, authCookie) {
12
+ this.http = http;
13
+ this.baseUrl = baseUrl;
14
+ this.authCookie = authCookie;
15
+ }
16
+ async login(username, password) {
17
+ const result = await this.http(`${this.baseUrl}/auth/login`, {
18
+ method: 'POST',
19
+ data: {
20
+ username,
21
+ password,
22
+ },
23
+ });
24
+ if (result.status === 200 && result.headers.get('set-cookie')) {
25
+ const cookieString = result.headers.get('set-cookie');
26
+ this.authCookie = extractCookiesWithRegex(cookieString);
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ async getUserInfo() {
32
+ const result = await this.http(`${this.baseUrl}/auth/`, {
33
+ headers: this.requestHeaders,
34
+ });
35
+ if (result.status === 200) {
36
+ this.userInfo = result.data.data;
37
+ return this.userInfo;
38
+ }
39
+ return null;
40
+ }
41
+ async getServiceRemoteList() {
42
+ return ((await this.http(`${this.baseUrl}/service/remote_services_list`, {
43
+ headers: this.requestHeaders,
44
+ params: {
45
+ token: this.userInfo.token,
46
+ },
47
+ })).data.data ?? []);
48
+ }
49
+ async getServiceRemoteInstanceList(daemonId, options) {
50
+ return ((await this.http(`${this.baseUrl}/service/remote_service_instances`, {
51
+ headers: this.requestHeaders,
52
+ params: {
53
+ daemonId,
54
+ page: options?.page || 1,
55
+ page_size: options?.page_size || 999,
56
+ status: options?.status || '',
57
+ instance_name: options?.instance_name || '',
58
+ tag: JSON.stringify(options?.tag || []),
59
+ token: this.userInfo.token,
60
+ },
61
+ })).data?.data?.data ?? []);
62
+ }
63
+ async getServiceInstanceConnectAuth(remoteUUID, instanceId) {
64
+ return ((await this.http(`${this.baseUrl}/protected_instance/stream_channel`, {
65
+ method: 'POST',
66
+ headers: this.requestHeaders,
67
+ params: {
68
+ remote_uuid: remoteUUID,
69
+ uuid: instanceId,
70
+ token: this.userInfo.token,
71
+ },
72
+ })).data.data ?? null);
73
+ }
74
+ async restartRemoteInstance(daemonId, instanceId) {
75
+ console.log({
76
+ daemonId,
77
+ uuid: instanceId,
78
+ token: this.userInfo.token,
79
+ });
80
+ return this.http(`${this.baseUrl}/protected_instance/restart`, {
81
+ headers: this.requestHeaders,
82
+ params: {
83
+ daemonId,
84
+ uuid: instanceId,
85
+ token: this.userInfo.token,
86
+ },
87
+ });
88
+ }
89
+ }
90
+ exports.MCSManagerAPI = MCSManagerAPI;
91
+ function extractCookiesWithRegex(cookieStr) {
92
+ return cookieStr
93
+ .match(/(\S+=\S+;)/g)
94
+ .filter(v => v !== 'path=/;')
95
+ .join(' ');
96
+ }
@@ -0,0 +1,14 @@
1
+ import { Context } from 'koishi';
2
+ import { GLBotConfigType } from '../gl';
3
+ import { MCBotResetCommand } from './commands/reset';
4
+ import { MCSManagerPanel } from './panel';
5
+ export declare class MCSManagerBot {
6
+ readonly ctx: Context;
7
+ readonly config: GLBotConfigType;
8
+ readonly panel: MCSManagerPanel;
9
+ constructor(ctx: Context, config: GLBotConfigType, panel: MCSManagerPanel);
10
+ help(): string[];
11
+ commands(): (typeof MCBotResetCommand)[];
12
+ initialize(): Promise<void>;
13
+ private registerCommands;
14
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCSManagerBot = void 0;
4
+ const reset_1 = require("./commands/reset");
5
+ class MCSManagerBot {
6
+ constructor(ctx, config, panel) {
7
+ this.ctx = ctx;
8
+ this.config = config;
9
+ this.panel = panel;
10
+ this.initialize();
11
+ }
12
+ help() {
13
+ return [
14
+ '服务器 管理指令:',
15
+ '/服务器 列表',
16
+ '/服务器 开启 <模糊名>',
17
+ '/服务器 关闭 <模糊名>',
18
+ '/服务器 重启 <模糊名>',
19
+ '/服务器 备份 <模糊名>',
20
+ ];
21
+ }
22
+ commands() {
23
+ return [reset_1.MCBotResetCommand];
24
+ }
25
+ async initialize() {
26
+ this.ctx.on('ready', async () => {
27
+ this.registerCommands();
28
+ });
29
+ }
30
+ registerCommands() {
31
+ for (const Command of this.commands()) {
32
+ new Command(this);
33
+ }
34
+ // this.ctx
35
+ // .command('/服务器 <action> [...name]')
36
+ // .option('debug', '-d')
37
+ // .action(({ options }, action, ...name) => {
38
+ // return `收到指令:${action} ${name.join(' ')},调试模式:${options.debug}`;
39
+ // });
40
+ }
41
+ }
42
+ exports.MCSManagerBot = MCSManagerBot;
@@ -0,0 +1,2 @@
1
+ export declare class MCBotCommandBase {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCBotCommandBase = void 0;
4
+ class MCBotCommandBase {
5
+ }
6
+ exports.MCBotCommandBase = MCBotCommandBase;
@@ -0,0 +1,7 @@
1
+ import { Context } from 'koishi';
2
+ import { GLBotConfigType } from '../../gl';
3
+ export declare class MCBotCommandBase {
4
+ readonly ctx: Context;
5
+ readonly config: GLBotConfigType;
6
+ constructor(ctx: Context, config: GLBotConfigType);
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCBotCommandBase = void 0;
4
+ const koishi_1 = require("koishi");
5
+ const logger = new koishi_1.Logger('mcsmanager-command');
6
+ class MCBotCommandBase {
7
+ constructor(ctx, config) {
8
+ this.ctx = ctx;
9
+ this.config = config;
10
+ // logger.info('注册 MCSManager 服务器管理指令...');
11
+ }
12
+ }
13
+ exports.MCBotCommandBase = MCBotCommandBase;
@@ -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 MCBotResetCommand {
9
+ private readonly bot;
10
+ constructor(bot: MCSManagerBot);
11
+ handle(session: Session<never, never, Context>, name: string): Promise<string>;
12
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCBotResetCommand = 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 MCBotResetCommand {
13
+ constructor(bot) {
14
+ this.bot = bot;
15
+ bot.ctx
16
+ .command('服务器 重启 <name...>')
17
+ .action(async ({ session }, _action, ...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
+ targetInstance.instance.restartInstance();
42
+ return `已向服务器实例 "${targetInstance.instance.cfg.config.nickname}" 发送重启操作`;
43
+ }
44
+ }
45
+ exports.MCBotResetCommand = MCBotResetCommand;
@@ -0,0 +1,18 @@
1
+ import { Schema } from 'koishi';
2
+ export declare class MCManagerConfig {
3
+ static Base: Schema<Schemastery.ObjectS<{
4
+ mcManagerUsername: Schema<string, string>;
5
+ mcManagerPassword: Schema<string, string>;
6
+ mcManagerKey: Schema<string, string>;
7
+ mcManagerHost: Schema<string, string>;
8
+ mcManagerWs: Schema<string, string>;
9
+ mcManagerMaxConnectWs: Schema<number, number>;
10
+ }>, Schemastery.ObjectT<{
11
+ mcManagerUsername: Schema<string, string>;
12
+ mcManagerPassword: Schema<string, string>;
13
+ mcManagerKey: Schema<string, string>;
14
+ mcManagerHost: Schema<string, string>;
15
+ mcManagerWs: Schema<string, string>;
16
+ mcManagerMaxConnectWs: Schema<number, number>;
17
+ }>>;
18
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCManagerConfig = void 0;
4
+ const koishi_1 = require("koishi");
5
+ class MCManagerConfig {
6
+ }
7
+ exports.MCManagerConfig = MCManagerConfig;
8
+ MCManagerConfig.Base = koishi_1.Schema.object({
9
+ mcManagerUsername: koishi_1.Schema.string().default('admin').description('用户名'),
10
+ mcManagerPassword: koishi_1.Schema.string()
11
+ .role('secret')
12
+ .default('admin')
13
+ .description('密码'),
14
+ mcManagerKey: koishi_1.Schema.string().role('secret').description('KEY'),
15
+ mcManagerHost: koishi_1.Schema.string()
16
+ .default('http://localhost:23333/api')
17
+ .description('地址'),
18
+ mcManagerWs: koishi_1.Schema.string()
19
+ .default('ws://localhost:24444')
20
+ .description('WebSocket 地址'),
21
+ mcManagerMaxConnectWs: koishi_1.Schema.number()
22
+ .default(20)
23
+ .description('最大连接实例数'),
24
+ }).description('MCSMANAGER 基础配置');
@@ -0,0 +1,8 @@
1
+ export declare enum RemoteInstanceStatusEnum {
2
+ STOPPED = 0,
3
+ RUNNING = 3
4
+ }
5
+ export declare const RemoteInstanceStatusName: {
6
+ 0: string;
7
+ 3: string;
8
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoteInstanceStatusName = exports.RemoteInstanceStatusEnum = void 0;
4
+ var RemoteInstanceStatusEnum;
5
+ (function (RemoteInstanceStatusEnum) {
6
+ RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["STOPPED"] = 0] = "STOPPED";
7
+ RemoteInstanceStatusEnum[RemoteInstanceStatusEnum["RUNNING"] = 3] = "RUNNING";
8
+ })(RemoteInstanceStatusEnum || (exports.RemoteInstanceStatusEnum = RemoteInstanceStatusEnum = {}));
9
+ exports.RemoteInstanceStatusName = {
10
+ [RemoteInstanceStatusEnum.STOPPED]: '已停止',
11
+ [RemoteInstanceStatusEnum.RUNNING]: '运行中',
12
+ };
@@ -0,0 +1,26 @@
1
+ import { Context, Schema } from 'koishi';
2
+ import { GLBotConfigType } from '../gl';
3
+ export declare class MCManager {
4
+ private readonly ctx;
5
+ private readonly config;
6
+ static Config: Schema<Schemastery.ObjectS<{
7
+ mcManagerUsername: Schema<string, string>;
8
+ mcManagerPassword: Schema<string, string>;
9
+ mcManagerKey: Schema<string, string>;
10
+ mcManagerHost: Schema<string, string>;
11
+ mcManagerWs: Schema<string, string>;
12
+ mcManagerMaxConnectWs: Schema<number, number>;
13
+ }>, {
14
+ mcManagerUsername: string;
15
+ mcManagerPassword: string;
16
+ mcManagerKey: string;
17
+ mcManagerHost: string;
18
+ mcManagerWs: string;
19
+ mcManagerMaxConnectWs: number;
20
+ } & import("cosmokit").Dict>;
21
+ private panel;
22
+ private bot;
23
+ constructor(ctx: Context, config: GLBotConfigType);
24
+ initialize(): Promise<void>;
25
+ }
26
+ export type MCManagerConfigType = typeof MCManager.Config;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCManager = void 0;
4
+ const koishi_1 = require("koishi");
5
+ const bot_1 = require("./bot");
6
+ const config_1 = require("./config");
7
+ const panel_1 = require("./panel");
8
+ class MCManager {
9
+ constructor(ctx, config) {
10
+ this.ctx = ctx;
11
+ this.config = config;
12
+ this.panel = new panel_1.MCSManagerPanel(ctx, config);
13
+ this.bot = new bot_1.MCSManagerBot(ctx, config, this.panel);
14
+ ctx.on('ready', this.initialize.bind(this));
15
+ }
16
+ async initialize() {
17
+ await this.panel.initialize();
18
+ }
19
+ }
20
+ exports.MCManager = MCManager;
21
+ MCManager.Config = koishi_1.Schema.intersect([config_1.MCManagerConfig.Base]);
@@ -0,0 +1,16 @@
1
+ import { Context } from 'koishi';
2
+ import { GLBotConfigType } from '../gl';
3
+ import { MCSManagerAPI } from './api';
4
+ import { MCSManagerPanel } from './panel';
5
+ import { ServiceRemoteInstanceItem, ServiceRemoteItem } from './type';
6
+ export declare class MCSManagerInstance {
7
+ private readonly ctx;
8
+ private readonly config;
9
+ private readonly api;
10
+ private readonly panel;
11
+ remote: ServiceRemoteItem;
12
+ cfg: ServiceRemoteInstanceItem;
13
+ isAuthenticated: boolean;
14
+ constructor(ctx: Context, config: GLBotConfigType, api: MCSManagerAPI, panel: MCSManagerPanel, remote: ServiceRemoteItem, cfg: ServiceRemoteInstanceItem);
15
+ restartInstance(): void;
16
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCSManagerInstance = void 0;
4
+ class MCSManagerInstance {
5
+ constructor(ctx, config, api, panel, remote, cfg) {
6
+ this.ctx = ctx;
7
+ this.config = config;
8
+ this.api = api;
9
+ this.panel = panel;
10
+ this.remote = remote;
11
+ this.cfg = cfg;
12
+ this.isAuthenticated = false;
13
+ }
14
+ restartInstance() {
15
+ this.api.restartRemoteInstance(this.remote.uuid, this.cfg.instanceUuid);
16
+ }
17
+ }
18
+ exports.MCSManagerInstance = MCSManagerInstance;
@@ -0,0 +1,24 @@
1
+ import { Context } from 'koishi';
2
+ import { GLBotConfigType } from '../gl';
3
+ import { MCSManagerAPI } from './api';
4
+ import { MCSManagerInstance } from './instance';
5
+ import { ServiceRemoteInstanceItem, ServiceRemoteItemCustom } from './type';
6
+ import { MCSManagerWebSocketIO } from './ws';
7
+ export declare class MCSManagerPanel {
8
+ readonly ctx: Context;
9
+ readonly config: GLBotConfigType;
10
+ private isInitialized;
11
+ api: MCSManagerAPI;
12
+ remotes: ServiceRemoteItemCustom[];
13
+ remoteConnectionsMap: Map<string, MCSManagerWebSocketIO>;
14
+ constructor(ctx: Context, config: GLBotConfigType);
15
+ initialize(): Promise<void>;
16
+ handleRemoteServices(): Promise<void>;
17
+ getAvailableRemoteInstance(): void;
18
+ createMCSManagerConnection(remote: ServiceRemoteItemCustom, instance: ServiceRemoteInstanceItem): Promise<MCSManagerWebSocketIO>;
19
+ searchInstanceByName(instanceName: string): Promise<{
20
+ remote: ServiceRemoteItemCustom;
21
+ instance: MCSManagerInstance;
22
+ sort: number;
23
+ }[]>;
24
+ }