Update index.ts

This commit is contained in:
phidias authored and GitHub committed 2026-10-12 14:55:02 +09:00
1 parent ddb14e644e
commit aaf1b34072
1 file changed
+6 -11
+6 -11
View File
@@ -1,4 +1,5 @@
import type * as lib from '@clusterio/lib'; import type * as lib from '@clusterio/lib';
import type {Instance, InstancePluginContext} from '@clusterio/host';
import {Type, Static} from '@sinclair/typebox'; import {Type, Static} from '@sinclair/typebox';
export class ChatEvent { export class ChatEvent {
@@ -10,20 +11,14 @@ export class ChatEvent {
static permission = null; static permission = null;
constructor( constructor(
public instanceName: string, public instance: Instance,
public action: string, public action: string,
public content: string, public content: string,
) { ) {}
}
static jsonSchema = Type.Object({ static async fromContext(context: InstancePluginContext) {
'instanceName': Type.String(), const instance = context.instance;
'action': Type.String(), return new InstancePlugin(context.instance, context.instanceName, context.action, context.content);
'content': Type.String(),
});
static fromJSON(json: Static<typeof ChatEvent.jsonSchema>) {
return new this(json.instanceName, json.action, json.content);
} }
} }