From 1fd50ab7fad3a3454112cfa95a2167dc64633cca Mon Sep 17 00:00:00 2001 From: Parker2991 Date: Tue, 25 Feb 2025 19:53:19 +0000 Subject: [PATCH] v7.0.2, build: 2100 --- package-lock.json | 202 +++++++++++++++++++++++++++++++ package.json | 1 + src/commands/public/echo.js | 6 +- src/data/info.json | 6 +- src/index.js | 19 ++- src/modules/boot.js | 3 - src/modules/chat.js | 2 +- src/modules/command_core.js | 14 +-- src/modules/console.js | 4 +- src/modules/discord.js | 6 +- src/modules/matrix.js | 86 +++++++++++++ src/modules/selfcare.js | 2 - src/modules/team.js | 61 ---------- src/util/command_manager_util.js | 1 - src/util/loadModules.js | 6 +- 15 files changed, 321 insertions(+), 98 deletions(-) create mode 100644 src/modules/matrix.js delete mode 100644 src/modules/team.js diff --git a/package-lock.json b/package-lock.json index ce68063..4c0a1b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "discord.js": "^14.17.3", "js-yaml": "^4.1.0", + "matrix-js-sdk": "^36.2.0", "minecraft-data": "^3.83.1", "minecraft-protocol": "^1.54.0", "prismarine-chat": "^1.10.1", @@ -38,6 +39,18 @@ "node": ">=16" } }, + "node_modules/@babel/runtime": { + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.9.tgz", + "integrity": "sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg==", + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@discordjs/builders": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.10.0.tgz", @@ -174,6 +187,21 @@ "url": "https://github.com/discordjs/discord.js?sponsor" } }, + "node_modules/@matrix-org/matrix-sdk-crypto-wasm": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-13.0.0.tgz", + "integrity": "sha512-2gtpjnxL42sdJAgkwitpMMI4cw7Gcjf5sW0MXoe+OAlXPlxIzyM+06F5JJ8ENvBeHkuV2RqtFIRrh8i90HLsMw==", + "license": "Apache-2.0", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@matrix-org/olm": { + "version": "3.2.15", + "resolved": "https://registry.npmjs.org/@matrix-org/olm/-/olm-3.2.15.tgz", + "integrity": "sha512-S7lOrndAK9/8qOtaTq/WhttJC/o4GAzdfK0MUPpo8ApzsJEC0QjtwrkC3KBXdFP1cD1MXi/mlKR7aaoVMKgs6Q==", + "license": "Apache-2.0" + }, "node_modules/@sapphire/async-queue": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", @@ -207,6 +235,12 @@ "npm": ">=7.0.0" } }, + "node_modules/@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.10.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz", @@ -235,6 +269,12 @@ "safe-buffer": "~5.1.1" } }, + "node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "license": "MIT" + }, "node_modules/@types/ws": { "version": "8.5.14", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.14.tgz", @@ -304,6 +344,12 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/another-json": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/another-json/-/another-json-0.2.0.tgz", + "integrity": "sha512-/Ndrl68UQLhnCdsAzEXLMFuOR546o2qbYRqCglaNHbjXrwG1ayTcdwr3zkSGOGtGXDyR5X9nCFfnyG2AFJIsqg==", + "license": "Apache-2.0" + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -331,6 +377,12 @@ "follow-redirects": "^1.14.0" } }, + "node_modules/base-x": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.0.tgz", + "integrity": "sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ==", + "license": "MIT" + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -351,6 +403,15 @@ ], "license": "MIT" }, + "node_modules/bs58": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz", + "integrity": "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==", + "license": "MIT", + "dependencies": { + "base-x": "^5.0.0" + } + }, "node_modules/buffer": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", @@ -420,6 +481,15 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "license": "MIT" }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", @@ -666,6 +736,15 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/jwt-decode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -739,6 +818,19 @@ "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==", "license": "MIT" }, + "node_modules/loglevel": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.2.tgz", + "integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + }, + "funding": { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/loglevel" + } + }, "node_modules/macaddress": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.3.tgz", @@ -751,6 +843,61 @@ "integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==", "license": "MIT" }, + "node_modules/matrix-events-sdk": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz", + "integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA==", + "license": "Apache-2.0" + }, + "node_modules/matrix-js-sdk": { + "version": "36.2.0", + "resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-36.2.0.tgz", + "integrity": "sha512-pP44qfqLA9tiJjx5YjxBPPkUmNsA2G0nb04ZUTuPbtQFmfK5cEQgIpvoCq69oqU6aulufeYpxJmd9yNffOvF9g==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.12.5", + "@matrix-org/matrix-sdk-crypto-wasm": "^13.0.0", + "@matrix-org/olm": "3.2.15", + "another-json": "^0.2.0", + "bs58": "^6.0.0", + "content-type": "^1.0.4", + "jwt-decode": "^4.0.0", + "loglevel": "^1.7.1", + "matrix-events-sdk": "0.0.1", + "matrix-widget-api": "^1.10.0", + "oidc-client-ts": "^3.0.1", + "p-retry": "4", + "sdp-transform": "^2.14.1", + "unhomoglyph": "^1.0.6", + "uuid": "11" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/matrix-js-sdk/node_modules/uuid": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, + "node_modules/matrix-widget-api": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/matrix-widget-api/-/matrix-widget-api-1.13.1.tgz", + "integrity": "sha512-mkOHUVzaN018TCbObfGOSaMW2GoUxOfcxNNlTVx5/HeMk3OSQPQM0C9oEME5Liiv/dBUoSrEB64V8wF7e/gb1w==", + "license": "Apache-2.0", + "dependencies": { + "@types/events": "^3.0.0", + "events": "^3.2.0" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -887,6 +1034,31 @@ "asn1": "0.2.3" } }, + "node_modules/oidc-client-ts": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/oidc-client-ts/-/oidc-client-ts-3.1.0.tgz", + "integrity": "sha512-IDopEXjiwjkmJLYZo6BTlvwOtnlSniWZkKZoXforC/oLZHC9wkIxd25Kwtmo5yKFMMVcsp3JY6bhcNJqdYk8+g==", + "license": "Apache-2.0", + "dependencies": { + "jwt-decode": "^4.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "license": "MIT", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/prismarine-auth": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.6.0.tgz", @@ -1061,6 +1233,12 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "license": "MIT" + }, "node_modules/ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -1070,12 +1248,30 @@ "node": ">=0.12" } }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "license": "MIT" }, + "node_modules/sdp-transform": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.15.0.tgz", + "integrity": "sha512-KrOH82c/W+GYQ0LHqtr3caRpM3ITglq3ljGUIb8LTki7ByacJZ9z+piSGiwZDsRyhQbYBOBJgr2k6X4BZXi3Kw==", + "license": "MIT", + "bin": { + "sdp-verify": "checker.js" + } + }, "node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -1160,6 +1356,12 @@ "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", "license": "MIT" }, + "node_modules/unhomoglyph": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/unhomoglyph/-/unhomoglyph-1.0.6.tgz", + "integrity": "sha512-7uvcWI3hWshSADBu4JpnyYbTVc7YlhF5GDW/oPD5AxIxl34k4wXR3WDkPnzLxkN32LiTCTKMQLtKVZiwki3zGg==", + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index e8c8045..292e480 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "dependencies": { "discord.js": "^14.17.3", "js-yaml": "^4.1.0", + "matrix-js-sdk": "^36.2.0", "minecraft-data": "^3.83.1", "minecraft-protocol": "^1.54.0", "prismarine-chat": "^1.10.1", diff --git a/src/commands/public/echo.js b/src/commands/public/echo.js index 9dd8f31..fbcec24 100644 --- a/src/commands/public/echo.js +++ b/src/commands/public/echo.js @@ -19,7 +19,11 @@ module.exports = { discordExecute (context) { const bot = context.bot; const args = context.arguments; - bot.discord.message.channel.send(args.join(' ')); + if (args.includes("@everyone") || args.includes("@here")) { + bot.discord.message.reply("go fuck yourself"); + } else { + bot.discord.message.channel.send(args.join(' ')); + } // bot.chat.send(args.join(' ')); } } diff --git a/src/data/info.json b/src/data/info.json index 5c66aa9..01d2c7d 100644 --- a/src/data/info.json +++ b/src/data/info.json @@ -1,8 +1,8 @@ { "buildstring": { - "build": "2055", - "codename": "", - "version": "v7.0.1", + "build": "2100", + "codename": "§bPit Stop", + "version": "v7.0.3", "url":"https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot" } } diff --git a/src/index.js b/src/index.js index d97c382..55fd262 100644 --- a/src/index.js +++ b/src/index.js @@ -7,10 +7,9 @@ const { Client, GatewayIntentBits } = require('discord.js'); const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits; const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] }); const CommandSource = require('./util/command_source'); +const matrix = require('matrix-js-sdk'); console.log('Starting FNFBoyfriendBot'); -process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c'); - if (fs.existsSync(path.join(__dirname, "../config.yml")) === false) { console.warn("Config not found creating config from the default config"); @@ -32,6 +31,17 @@ const rl = readline.createInterface({ }) if (config.discord.enabled) discordClient.login(config.discord.token); + +const mxClient = matrix.createClient({ + baseUrl: config.matrix.host, + accessToken: config.matrix.token, + userId: config.matrix.id +}); + +if (config.matrix.enabled) mxClient.startClient(); + + + const bots = []; let bot; @@ -39,7 +49,7 @@ for (const options of config.bots) { bot = new createBot(options, config); bots.push(bot); bot.bots = bots; - require('./util/loadModules')(bot, options, config, discordClient); + require('./util/loadModules')(bot, options, config, discordClient, mxClient); bot.console.readlineInterface(rl); } @@ -59,7 +69,8 @@ discordClient.on('messageCreate', (message) => { } }, { discord: true, - console: false + console: false, + matrix: false }, false, message); bot.commandManager.executeString(source, message.content.substring(prefix.length)); diff --git a/src/modules/boot.js b/src/modules/boot.js index a0a20a2..4970813 100644 --- a/src/modules/boot.js +++ b/src/modules/boot.js @@ -17,9 +17,6 @@ function inject (context) { process.exit(5); }); - setInterval(() => { - process.stdout.write(`\x1b]2; FNFBoyfriendBot | Time: ${new Date().toLocaleString("en-US",{timeZone: "America/CHICAGO"})} | \x1b\x5c`) - }, 1000) } module.exports = { diff --git a/src/modules/chat.js b/src/modules/chat.js index 258b7a9..3ea9534 100644 --- a/src/modules/chat.js +++ b/src/modules/chat.js @@ -21,7 +21,7 @@ function inject (context) { bot.on('registry_ready', registry => { ChatMessage = loadPrismarineChat(registry) }) - if (options.isSavage || options.isCreayun) { + if (options.mode === "savageFriends" || options.mode === "creayun") { bot.chatParsers = [CreayunChatParser, sayConsoleChatParser] } else { bot.chatParsers = [KaboomChatParser, ChipmunkModChatParser, VanillaChatParser, sayConsoleChatParser, yfdCustomChatParser] diff --git a/src/modules/command_core.js b/src/modules/command_core.js index 81c4e0d..dd31249 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -25,15 +25,7 @@ function inject (context) { if (!pos) return if (bot.options.mode === "creayun" || bot.options.mode === "savageFriends") return; - if (isNaN(pos.x + start.x)) { - bot.chat.command('spawn'); - return - } - /*^^^ - for checking is the core pos is null and if so - it will not refill core until the pos is not NaN - instead of tping to a set cords cuz fuck you im not doing that - */ + const command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy` bot.chat.command(`${command}`) }, @@ -45,10 +37,6 @@ function inject (context) { if (!pos) return; if (bot.options.mode === "creayun" || bot.options.mode === "savageFriends") return; - if (isNaN(pos.x + pos.x)) { - bot.chat.command('spawn'); - return - } const command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy` diff --git a/src/modules/console.js b/src/modules/console.js index 928f221..2435fea 100644 --- a/src/modules/console.js +++ b/src/modules/console.js @@ -49,8 +49,8 @@ function inject (context) { bot.on('message', (message) => { if (!options.logging) return; - //if (bot.getMessageAsPrismarine(message)?.toString().includes("https://www.innersloth.com/games/among-us/ › amogus")) return; -// if (ratelimit > 10) return + + if (ratelimit > 10) return bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi()); bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`); ratelimit++ diff --git a/src/modules/discord.js b/src/modules/discord.js index 53c7190..71acd79 100644 --- a/src/modules/discord.js +++ b/src/modules/discord.js @@ -73,11 +73,9 @@ function inject (context) { }, { discord: true, console: false - }, false, message) + }, false, message); -// bot.sendFeedback = message => { - sendComponent(message) -// } + sendComponent(message); bot.commandManager.executeString(source, message.content.substring(config.discord.prefix.length)) return diff --git a/src/modules/matrix.js b/src/modules/matrix.js new file mode 100644 index 0000000..b1f34ac --- /dev/null +++ b/src/modules/matrix.js @@ -0,0 +1,86 @@ +const CommandSource = require('../util/command_source'); + +function inject (context) { + const matrixClient = context.mxClient; + const config = context.config; + const bot = context.bot; + const options = context.options; + if (!config.matrix.enabled) return; + + require('matrix-js-sdk/lib/logger').logger.disableAll(); + + bot.matrix = { + client: matrixClient, + invite: JSON.stringify(config.matrix.invite), + }; + + let matrixQueue = []; + + setInterval(async () => { + try { + if (matrixQueue.length === 0) return; + const content = { body: matrixQueue.join('\n'), msgtype: "m.text" }; + await bot.matrix.client.sendEvent(bot.options.roomId, 'm.room.message', content, ''); + } catch (e) { + bot?.console?.warn(e.stack); + } + matrixQueue = []; + }, 5000); + + function sendChatMessage (message) { + matrixQueue.push(message); + } + + bot.on('message', (data) => { + const message = bot.getMessageAsPrismarine(data)?.toString(); + sendChatMessage(message) + }); + + let start = Date.now(); + + bot.matrix.client.on('Room.timeline', (event, room, toStartOfTimeline) => { + if (event.getRoomId() !== bot.options.roomId || event.getType() !== 'm.room.message' || event.getTs() < start || event.sender.userId === bot.matrix.client.getUserId()) return; + + if (event.getContent().body.startsWith('/')) { + bot.core.run(event.getContent().body.substring('/'.length)); + return; + } + + const tag = [{ + translate: "[%s] %s \u203a ", + color: "dark_gray", + with: [ + { + translate: "%s%s%s %s", + with: [ + { text: "FNF", color: "blue" }, + { text: "Boyfriend", color: "dark_aqua" }, + { text: "Bot", color: "dark_blue" }, + { text: "Matrix", color: "green" }, + ], + clickEvent: config.matrix.invite ? { + action: "open_url", + value: bot.matrix.invite + } : undefined, + hoverEvent: { + action: "show_text", + contents: "Click to join the matrix!" + } + }, + { text: event.sender.rawDisplayName }, + ] + }] + + bot.tellraw("@a", [ tag, event.getContent().body ]); + }); +} + +module.exports = { + data: { + enabled: true, + name: "matrix", + type: "logging" + }, + inject +}; + diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index 873617a..88b1846 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -28,8 +28,6 @@ function inject (context) { else if (stringMessage === "Please, register to the server with the command: /register ") register = true; else if (stringMessage === "This user isn't registered!") register = true; else if (stringMessage === "Successfully registered!") register = false; -// else if (stringMessage === "You already have registered this username!") register = false; - else if (stringMessage === "You're already logged in!") register = false; else if (stringMessage === "Successful login!") register = false; diff --git a/src/modules/team.js b/src/modules/team.js deleted file mode 100644 index 604e0a7..0000000 --- a/src/modules/team.js +++ /dev/null @@ -1,61 +0,0 @@ -const sleep = require('../util/sleep'); - -function inject (context) { - const bot = context.bot; - const options = context.options; - const config = context.config; - - if (options.mode !== "kaboom" || config.team.enabled === false) return; - bot.on("packet.login", async () => { - if (options.mode === "kaboom") { - await sleep(100); - bot.chat.command(`minecraft:team add ${config.team.name}`); - await sleep(100); - bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`); - } - }) - - bot.on("packet.teams", async (data) => { -// if (options.isSavage || options.isCreayun) return; - try { - if (data.team === config.team.name) { - data?.players?.map(async (player) => { - if (player !== bot.options.username) { - await sleep(100); - bot.core.run(`minecraft:team empty ${config.team.name}`); - await sleep(100); - bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`); - // this removes players who are not the bot - } - }); - - if (data.mode == 1) { - // this is checking if the team has been deleted - bot.core.run(`minecraft:team add ${config.team.name}`); - await sleep(100); - bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`); - } if (data.name !== JSON.stringify(config.team.displayName)) { - // this checks if the team displayName matches the one set in the config - bot.core.run(`minecraft:team modify ${config.team.name} displayName ${JSON.stringify(config.team.displayName)}`); - } if (data.prefix !== JSON.stringify(config.team.prefix)) { - // this checks if the team prefix matches the one set in the config - bot.core.run(`minecraft:team modify ${config.team.name} prefix ${JSON.stringify(config.team.prefix)}`); - } if (data.suffix !== JSON.stringify(config.team.suffix)) { - // this checks if the team suffix matches the one set in the config - bot.core.run(`minecraft:team modify ${config.team.name} suffix ${JSON.stringify(config.team.suffix)}`) - } - } - } catch (e) { - console.log(e.stack) - } - }) -} - -module.exports = { - data: { - enabled: true, - name: "teams", - type: "extras" - }, - inject -} diff --git a/src/util/command_manager_util.js b/src/util/command_manager_util.js index 1f74103..8da5774 100644 --- a/src/util/command_manager_util.js +++ b/src/util/command_manager_util.js @@ -2,7 +2,6 @@ const CommandError = require('./command_error'); module.exports = (bot, command, args, source) => { const event = bot.discord.message; const roles = event?.member?.roles?.cache; - switch (command?.data?.trustLevel) { case 0: // do nothing since trust level 0 is public diff --git a/src/util/loadModules.js b/src/util/loadModules.js index d8dbd04..6c48741 100644 --- a/src/util/loadModules.js +++ b/src/util/loadModules.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -async function loadModules (bot, options, config, discordClient) { +async function loadModules (bot, options, config, discordClient, mxClient) { bot.modules = []; for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) { try { @@ -9,12 +9,12 @@ async function loadModules (bot, options, config, discordClient) { if (module.data.enabled === false) { bot.modules.push(module); } else { - module.inject({ bot, options, config, discordClient }); + module.inject({ bot, options, config, discordClient, mxClient }); bot.modules.push(module); } } if (filename.endsWith(".mjs")) { const module = await import(path.join(__dirname, '../modules', filename)); - module.default({ bot, options, config, discordClient }); + module.default({ bot, options, config, discordClient, mxClient }); } } catch (error) { console.error(`Failed to load module ${filename} due to error`);