mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2025-12-27 03:05:21 +09:00
.
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const {BaseControllerPlugin} = require('@clusterio/controller');
|
const {BaseControllerPlugin} = require('@clusterio/controller');
|
||||||
const {InstanceActionEvent} = require('./info.js');
|
const {InstanceActionEvent} = require('./info.js');
|
||||||
const {ChatEvent} = require("./message.js");
|
|
||||||
|
|
||||||
const MAX_DISCORD_MESSAGE_LENGTH = 1950;
|
const MAX_DISCORD_MESSAGE_LENGTH = 1950;
|
||||||
const MIN_CONFIDENCE_SCORE = 10.0;
|
const MIN_CONFIDENCE_SCORE = 10.0;
|
||||||
@@ -185,7 +184,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}`);
|
||||||
this.controller.sendTo({ instanceId: this.instance.id }, new ChatEvent(this.controller.name, `[color=255,255,255]\`${nrc_username}\`: ${result}[/color]`));
|
return `[color=255,255,255]\`${nrc_username}\`: ${result}[/color]`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
info.js
2
info.js
@@ -2,7 +2,7 @@
|
|||||||
const lib = require('@clusterio/lib');
|
const lib = require('@clusterio/lib');
|
||||||
|
|
||||||
class InstanceActionEvent {
|
class InstanceActionEvent {
|
||||||
static type = 'event';
|
static type = 'requests';
|
||||||
static src = 'instance';
|
static src = 'instance';
|
||||||
static dst = 'controller';
|
static dst = 'controller';
|
||||||
static plugin = 'ClusterChatSync';
|
static plugin = 'ClusterChatSync';
|
||||||
|
|||||||
26
message.js
26
message.js
@@ -1,26 +0,0 @@
|
|||||||
const { Type } = require("@sinclair/typebox");
|
|
||||||
|
|
||||||
class ChatEvent {
|
|
||||||
static type = "event";
|
|
||||||
static src = ["control", "instance"];
|
|
||||||
static dst = "instance";
|
|
||||||
static plugin = "global_chat";
|
|
||||||
static permission = null;
|
|
||||||
|
|
||||||
static jsonSchema = Type.Object({
|
|
||||||
"instanceName": Type.String(),
|
|
||||||
"content": Type.String(),
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(instanceName, content) {
|
|
||||||
this.instanceName = instanceName;
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
static fromJSON(json) {
|
|
||||||
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