mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2025-12-27 11:05:22 +09:00
.
This commit is contained in:
29
message.js
29
message.js
@@ -1,33 +1,26 @@
|
|||||||
// import { Type, Static } from "@sinclair/typebox";
|
const { Type } = require("@sinclair/typebox");
|
||||||
const {Type, Static} = require("@sinclair/typebox");
|
|
||||||
|
|
||||||
export class ChatEvent {
|
class ChatEvent {
|
||||||
// declare ["constructor"]: typeof ChatEvent;
|
|
||||||
// as const
|
|
||||||
static type = "event";
|
static type = "event";
|
||||||
// as const
|
|
||||||
static src = ["control", "instance"];
|
static src = ["control", "instance"];
|
||||||
// as const
|
|
||||||
static dst = "instance";
|
static dst = "instance";
|
||||||
// as const
|
|
||||||
static plugin = "global_chat";
|
static plugin = "global_chat";
|
||||||
static permission = null;
|
static permission = null;
|
||||||
|
|
||||||
/*
|
|
||||||
constructor(
|
|
||||||
public instanceName: string,
|
|
||||||
public content: string,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static jsonSchema = Type.Object({
|
static jsonSchema = Type.Object({
|
||||||
"instanceName": Type.String(),
|
"instanceName": Type.String(),
|
||||||
"content": Type.String(),
|
"content": Type.String(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// json: Static<typeof ChatEvent.jsonSchema>
|
constructor(instanceName, content) {
|
||||||
|
this.instanceName = instanceName;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
static fromJSON(json) {
|
static fromJSON(json) {
|
||||||
return new this(json.instanceName, json.content);
|
return new ChatEvent(json.instanceName, json.content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If you need to use this class in other files
|
||||||
|
module.exports = { ChatEvent };
|
||||||
|
|||||||
Reference in New Issue
Block a user