mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2026-11-15 15:34:52 +09:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c56f2f03de | ||
|
|
984613de7d | ||
|
|
5461422397 | ||
|
|
3b223191da | ||
|
|
4f6c380859 |
No files matched your search
@@ -42,7 +42,7 @@ export const MAX_INBOUND_LENGTH = 400;
|
|||||||
|
|
||||||
// Factorio renders these, so a Discord user could spoof a colour, an item link,
|
// Factorio renders these, so a Discord user could spoof a colour, an item link,
|
||||||
// or a fake speaker line. Whitelist the real tags rather than matching \[.*\],
|
// or a fake speaker line. Whitelist the real tags rather than matching \[.*\],
|
||||||
// which would also eat innocent text like "array[0]" or "[lol]".
|
// which would also eat innocent text like 'array[0]' or '[lol]'.
|
||||||
const RICH_TEXT_RE = new RegExp(
|
const RICH_TEXT_RE = new RegExp(
|
||||||
String.raw`\[/?(?:color|font|item|entity|technology|recipe|fluid|tile|virtual-signal`
|
String.raw`\[/?(?:color|font|item|entity|technology|recipe|fluid|tile|virtual-signal`
|
||||||
+ String.raw`|gps|img|specialisation|achievement|train|planet|space-location|quality)(?:=[^\]]*)?\]`,
|
+ String.raw`|gps|img|specialisation|achievement|train|planet|space-location|quality)(?:=[^\]]*)?\]`,
|
||||||
@@ -104,7 +104,6 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
name: 'chat_relay',
|
name: 'chat_relay',
|
||||||
title: 'Chat Relay',
|
title: 'Chat Relay',
|
||||||
description: 'Bidirectional chat relay between Factorio and Discord.',
|
description: 'Bidirectional chat relay between Factorio and Discord.',
|
||||||
webEntrypoint: './web',
|
|
||||||
instanceEntrypoint: 'dist/node/instance.js',
|
instanceEntrypoint: 'dist/node/instance.js',
|
||||||
controllerEntrypoint: 'dist/node/controller.js',
|
controllerEntrypoint: 'dist/node/controller.js',
|
||||||
controllerConfigFields: {
|
controllerConfigFields: {
|
||||||
@@ -133,4 +132,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
ChatEvent,
|
ChatEvent,
|
||||||
ChatFromDiscordEvent,
|
ChatFromDiscordEvent,
|
||||||
],
|
],
|
||||||
|
features: [
|
||||||
|
'ScriptCommands',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
+2
-2
@@ -81,11 +81,11 @@ export default async function(context: InstancePluginContext) {
|
|||||||
const message_content = message_index === -1 ? '' : message.slice(message_index + 1).trim();
|
const message_content = message_index === -1 ? '' : message.slice(message_index + 1).trim();
|
||||||
|
|
||||||
queue.push({datetime: dt, message: `**\`${message_username}\`**: ${message_content}`});
|
queue.push({datetime: dt, message: `**\`${message_username}\`**: ${message_content}`});
|
||||||
} else if (action === 'JOIN' || action === 'LEAVE' || action === 'KICK' || action === 'BAN' || action === 'UNBANNED') {
|
} else if (action === 'JOIN' || action === 'LEAVE' || action === 'KICK') {
|
||||||
const message_index = message.indexOf(' ');
|
const message_index = message.indexOf(' ');
|
||||||
const message_username = message_index === -1 ? message : message.slice(0, message_index);
|
const message_username = message_index === -1 ? message : message.slice(0, message_index);
|
||||||
const message_content = message_index === -1 ? '' : message.slice(message_index + 1).trim();
|
const message_content = message_index === -1 ? '' : message.slice(message_index + 1).trim();
|
||||||
const player_count = instance.playersOnline.size + (action === 'JOIN' ? 0 : -1);
|
const player_count = instance.playersOnline.size + (action === 'LEAVE' ? -1 : 0);
|
||||||
|
|
||||||
queue.push({datetime: dt, message: `**\`${message_username}\`** ${message_content} (${player_count})`});
|
queue.push({datetime: dt, message: `**\`${message_username}\`** ${message_content} (${player_count})`});
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@phidias0303/chat_relay",
|
"name": "@phidias0303/chat_relay",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"description": "Chat relay of Discord and Factorio, seperate channel",
|
"description": "Chat relay of Discord and Factorio, seperate channel",
|
||||||
"author": "PHIDIAS <phidias@aperx.org>",
|
"author": "PHIDIAS <phidias@aperx.org>",
|
||||||
"license": "MIT",
|
"license": "Apache 2.0",
|
||||||
"homepage": "https://github.com/PHIDIAS0303/chat_relay#readme",
|
"homepage": "https://github.com/PHIDIAS0303/chat_relay#readme",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -22,18 +22,18 @@
|
|||||||
],
|
],
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --mode production",
|
"prepare": "tsc --build && vite build",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"@clusterio/controller": "workspace:^",
|
||||||
"@clusterio/lib": "workspace:^"
|
"@clusterio/lib": "workspace:^"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@clusterio/controller": "workspace:^",
|
||||||
"@clusterio/lib": "workspace:^",
|
"@clusterio/lib": "workspace:^",
|
||||||
"@clusterio/web_ui": "workspace:^",
|
"@clusterio/web_ui": "workspace:^",
|
||||||
"webpack": "catalog:",
|
"vite": "catalog:"
|
||||||
"webpack-cli": "catalog:",
|
|
||||||
"webpack-merge": "catalog:"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.27.0",
|
"discord.js": "^14.27.0",
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
{"path": "../../packages/lib/tsconfig.browser.json"},
|
{"path": "../../packages/lib/tsconfig.browser.json"},
|
||||||
{"path": "../../packages/web_ui/tsconfig.browser.json"}
|
{"path": "../../packages/web_ui/tsconfig.browser.json"}
|
||||||
],
|
],
|
||||||
"include": ["web/**/*.tsx", "web/**/*.ts", "index.ts", "package.json"]
|
"include": ["index.ts", "package.json"]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { defineConfig } from "vite";
|
||||||
|
import { clusterioPlugin } from "@clusterio/web_ui/vite.mjs";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [clusterioPlugin()],
|
||||||
|
});
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import {type WebPluginContext} from '@clusterio/web_ui';
|
|
||||||
|
|
||||||
export default async function loadWebPlugin(context: WebPluginContext) {
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const path = require('path');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const {merge} = require('webpack-merge');
|
|
||||||
const common = require('@clusterio/web_ui/webpack.common');
|
|
||||||
|
|
||||||
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
|
||||||
context: __dirname,
|
|
||||||
entry: './web/index.tsx',
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, 'dist', 'web'),
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.container.ModuleFederationPlugin({
|
|
||||||
name: 'chat_relay',
|
|
||||||
library: {type: 'var', name: 'plugin_chat_relay'},
|
|
||||||
exposes: {
|
|
||||||
'./': './index.ts',
|
|
||||||
'./package.json': './package.json',
|
|
||||||
'./web': './web/index.tsx',
|
|
||||||
},
|
|
||||||
shared: {
|
|
||||||
'@clusterio/lib': {import: false},
|
|
||||||
'@clusterio/web_ui': {import: false},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
Reference in new issue
Block a user