mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2025-12-27 03:05:21 +09:00
.
This commit is contained in:
@@ -3,6 +3,7 @@ const Discord = require('discord.js');
|
|||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const {BaseControllerPlugin} = require('@clusterio/controller');
|
const {BaseControllerPlugin} = require('@clusterio/controller');
|
||||||
const {InstanceActionEvent} = require('./info.js');
|
const {InstanceActionEvent} = require('./info.js');
|
||||||
|
import { ChatEvent } from "./messages";
|
||||||
|
|
||||||
const MAX_DISCORD_MESSAGE_LENGTH = 1950;
|
const MAX_DISCORD_MESSAGE_LENGTH = 1950;
|
||||||
const MIN_CONFIDENCE_SCORE = 10.0;
|
const MIN_CONFIDENCE_SCORE = 10.0;
|
||||||
@@ -182,7 +183,7 @@ class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
|
|
||||||
if (result && result.action) {
|
if (result && result.action) {
|
||||||
await this.sendMessage(request, `**\`${nrc_username}\`**: ${result.passage}`);
|
await this.sendMessage(request, `**\`${nrc_username}\`**: ${result.passage}`);
|
||||||
return `[color=255,255,255]\`${nrc_username}\`: ${result}[/color]`;
|
this.instance.sendTo({ instanceId: this.instance.id }, new ChatEvent(this.instance.name, `[color=255,255,255]\`${nrc_username}\`: ${result}[/color]`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
message.ts
Normal file
24
message.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Type, Static } from "@sinclair/typebox";
|
||||||
|
export class ChatEvent {
|
||||||
|
declare ["constructor"]: typeof ChatEvent;
|
||||||
|
static type = "event" as const;
|
||||||
|
static src = ["control", "instance"] as const;
|
||||||
|
static dst = "instance" as const;
|
||||||
|
static plugin = "global_chat" as const;
|
||||||
|
static permission = null;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public instanceName: string,
|
||||||
|
public content: string,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static jsonSchema = Type.Object({
|
||||||
|
"instanceName": Type.String(),
|
||||||
|
"content": Type.String(),
|
||||||
|
});
|
||||||
|
|
||||||
|
static fromJSON(json: Static<typeof ChatEvent.jsonSchema>) {
|
||||||
|
return new this(json.instanceName, json.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user