mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2026-11-23 16:03:13 +09:00
Update index.ts
This commit is contained in:
1 parent
ddb14e644e
commit
aaf1b34072
1 file changed
+6
-11
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user