From e75576a488ab8890de399f78ac2bc3c3cd47ba78 Mon Sep 17 00:00:00 2001 From: Parker2991 Date: Wed, 9 Oct 2024 12:12:54 -0400 Subject: [PATCH] finished filter and made the bot send vanish in chat instead of core. v6.0.5, Build: 1050 --- .gitignore | 2 + src/commands/console.js | 3 +- src/commands/filter.js | 32 ++++------ src/commands/help.js | 16 +++-- src/commands/info.js | 2 +- src/commands/list.js | 17 +++--- src/commands/mcserver.js | 26 +++++++- src/commands/netmsg.js | 2 +- src/commands/rtp.js | 4 +- src/commands/validate.js | 15 ----- src/data/default_config.yml | 2 - src/data/filter.json | 2 +- src/data/info.json | 4 +- src/modules/command_core.js | 2 +- src/modules/command_manager.js | 2 +- src/modules/filter.js | 105 ++++++++++++++++++++++++++++---- src/modules/selfcare.js | 2 +- src/output.txt | 7 +++ src/util/ChatParsers/Creayun.js | 2 +- src/util/usernameGen.js | 2 - 20 files changed, 172 insertions(+), 77 deletions(-) create mode 100644 src/output.txt diff --git a/.gitignore b/.gitignore index 52dfd74..0dc32a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ config.yml src/modules/exploits.js logs/* src/data/filter.json +data/filter.json prototyping-crap + diff --git a/src/commands/console.js b/src/commands/console.js index c895bf7..af37ebb 100644 --- a/src/commands/console.js +++ b/src/commands/console.js @@ -60,6 +60,7 @@ module.exports = { bot.console.customChat.chat(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(' ')}`) } else if (!bot.console.customChat.enabled) { bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(' ')}`) +// bot.chat.message(`${config.prefixes[0]}${args.slice(2)} ${args.slice(3).shift()}${bot.validation.trusted}`) } break case "admin": @@ -67,7 +68,7 @@ module.exports = { if (bot.console.customChat.enabled) { bot.console.customChat.chat(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`) } else if (!bot.console.customChat.enabled) { - bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`) +// bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`) } break case "trusted": diff --git a/src/commands/filter.js b/src/commands/filter.js index 0323b21..33cdb13 100644 --- a/src/commands/filter.js +++ b/src/commands/filter.js @@ -22,37 +22,23 @@ module.exports = { const args = context.arguments; const config = context.config; let component = []; + if (bot.options.isCreayun || bot.options.isSavage) throw new CommandError('this command is meant for kaboom.pw and its clones') if (!args && !args[0] && !args[1] && !args[2] && !args[3] && !args[4]) return switch (args[1]?.toLowerCase()) { case 'list': // bot.tellraw(`@a`, JSON.stringify(bot.filter.list().length)); if (bot.filter.list().length === 0) { component.push({ - translate: '%s%s %s%s%s', - color: 'blue', + translate: '%s: (%s)', + color: 'dark_gray', with: [ { text: 'Players', color: 'dark_blue' }, - { text: ':', color: 'dark_blue' }, - { text: '(', color: 'blue' }, { text: JSON.stringify(bot.filter.list().length), color: 'gold' }, - { text: ')', color: 'blue' }, ] }) } else { let i = 0; let listComponent = [] - /*component.push({ - translate: '%s%s %s%s%s\n %s', - color: 'blue', - with: [ - { text: 'Players', color: 'dark_blue' }, - { text: ':', color: 'dark_blue' }, - { text: '(', color: 'blue' }, - { text: JSON.stringify(bot.filter.list().length), color: 'gold' }, - { text: ')', color: 'blue' }, - - ] - })*/ for (const players of bot.filter.list()) { listComponent.push({ translate: '%s \u203a %s', @@ -69,14 +55,18 @@ module.exports = { listComponent.pop() component.push({ - translate: 'Players (%s):', - color: 'dark_blue', - with: [ { text: `${bot.filter.list().length}`, color: 'gold' } ] + translate: '%s: (%s)', + color: 'dark_gray', + with: [ + { text: 'Players', color: 'dark_blue' }, + { text: `${bot.filter.list().length}`, color: 'gold' } + ] }) component.push('\n') component.push(listComponent) - bot.tellraw("@a", component) +// bot.tellraw("@a", component) } + bot.tellraw("@a", component) break; case "--regex": case "-r": diff --git a/src/commands/help.js b/src/commands/help.js index 73d33e0..55aabfa 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -111,11 +111,19 @@ module.exports = { commandComponent.push("\n"); commandComponent.push(usagesComponent); for (const aliases of command.aliases) { - if (args[0] === command.name) { - bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, commandComponent) + if (args[0]?.toLowerCase() === command.name) { + if (bot.options.isSavage) { + bot.chat.message(`${bot.getMessageAsPrismarine(commandComponent)?.toMotd().replaceAll('§','&')}`); + } else { + bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, commandComponent) + } return; - } if (args[0] === aliases) { - bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, commandComponent) + } if (args[0]?.toLowerCase() === aliases) { + if (bot.options.isSavage) { + bot.chat.message(`${bot.getMessageAsPrismarine(commandComponent)?.toMotd().replaceAll('§','&')}`) + } else { + bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, commandComponent) + } return } } diff --git a/src/commands/info.js b/src/commands/info.js index 838e503..2c812d0 100644 --- a/src/commands/info.js +++ b/src/commands/info.js @@ -270,7 +270,7 @@ module.exports = { color: "light_purple" }, { - text: "aaa - FBot, SnifferBot, Xbot\n", + text: "aaa - FBot, SnifferBot, Xbot, Hydra\n", color: "gold", }, { diff --git a/src/commands/list.js b/src/commands/list.js index 1894888..10505bf 100644 --- a/src/commands/list.js +++ b/src/commands/list.js @@ -15,8 +15,8 @@ module.exports = { const component = [] for (const player of players) { component.push({ - translate: `%s \u203a %s [%s %s %s %s %s]`, - color: 'blue', + translate: `%s \u203a %s [%s: %s %s %s: %s]`, + color: 'dark_gray', with: [ player.displayName ?? player.profile.name, { @@ -34,10 +34,10 @@ module.exports = { }] } }, - { text: `Ping:`, color: 'dark_blue' }, + { text: `Ping`, color: 'dark_blue' }, { text: `${player.latency}`, color: 'gold' }, - { text: '/', color: 'dark_aqua' }, - { text: `Gamemode:`, color: 'dark_blue' }, + { text: '/', color: 'dark_gray' }, + { text: `Gamemode`, color: 'dark_blue' }, { text: `${player.gamemode}`, color: 'gold' }, ] }) @@ -53,10 +53,11 @@ module.exports = { }, 300) } else if (bot.options.isKaboom) { bot.tellraw(`@a[name="${source.player.profile.name}"]`, [ - { text: `Players: `, color:'gray' }, - { text: '(' , color: 'gray' }, + { text: `Players`, color: 'dark_blue' }, + { text: ': ', color: 'dark_gray' }, + { text: '(' , color: 'dark_gray' }, { text: `${JSON.stringify(bot.players.length)}`, color: 'gold' }, - { text: ')\n', color: 'gray' }, + { text: ')\n', color: 'dark_gray' }, component ]) } diff --git a/src/commands/mcserver.js b/src/commands/mcserver.js index 7f4e885..3d2b9cd 100644 --- a/src/commands/mcserver.js +++ b/src/commands/mcserver.js @@ -18,10 +18,32 @@ module.exports = { const discordClient = context.discordClient; const args = context.arguments; const source = context.source; + let component = []; try { const [host, port] = args[0].split(':') const server = await mc.ping({ host, port: Number(port ?? 25565) }) - bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [ + component.push({ + translate: '%s %s %s:%s\n%s %s %s / %s\n%s %s %s\n%s %s %s', + color: 'dark_gray', + with: [ + { text: 'Ip', color: 'dark_blue' }, + { text: '\u203a' }, + { text: `${host}`, color: 'dark_blue' }, + { text: `${Number(port ?? 25565)}`, color: 'gold' }, + { text: 'Players', color: 'dark_blue' }, + { text: '\u203a' }, + { text: `${server.players.online}`, color: 'gold' }, + { text: `${server.players.max}`, color: 'gold' }, + { text: 'Version', color: 'dark_blue' }, + { text: '\u203a' }, + { text: `${server.version.name}`, color: 'blue' }, + { text: 'Motd', color: 'dark_blue' }, + { text: '\u203a' }, + server.description + ] + }) + bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, component); +/* bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [ { text: `Ip \u203a ${host}:${Number(port ?? 25565)}\n`, color: 'gray', @@ -62,7 +84,7 @@ module.exports = { color: 'gray', }, server.description, - ]) + ])*/ } catch (e) { bot.chat.message(`${e.toString()}`) } diff --git a/src/commands/netmsg.js b/src/commands/netmsg.js index 9d2d1dc..83fed27 100644 --- a/src/commands/netmsg.js +++ b/src/commands/netmsg.js @@ -1,7 +1,7 @@ const CommandError = require('../util/command_error.js') module.exports = { name: 'netmsg', - trustLevel: 1, + trustLevel: 0, aliases: [ ], diff --git a/src/commands/rtp.js b/src/commands/rtp.js index a7022d9..4aea9f5 100644 --- a/src/commands/rtp.js +++ b/src/commands/rtp.js @@ -14,11 +14,11 @@ module.exports = { // if (!source.player) return if (bot.options.isKaboom) { x = between(-30_000_000, 30_000_000) - y = between(-30_000_000, 30_000_000) + y = 100 z = between(-30_000_000, 30_000_000) } else if (bot.options.isSavage) { x = between(-4096, 4096); - y = between(-4096, 4096); + y = 100 z = between(-4096, 4096); } // bot.tellraw("@a", `Randomly Teleported: ${sender.profile.name} to x:${x} y:${y} z:${z} `) diff --git a/src/commands/validate.js b/src/commands/validate.js index ed6509a..a2a7765 100644 --- a/src/commands/validate.js +++ b/src/commands/validate.js @@ -13,20 +13,6 @@ module.exports = { const bot = context.bot; const args = context.arguments; const source = context.source; -/* if (args[0] === bot.validation.trusted) { - if (bot.options.isSavage) { - bot.chat.message('&2Valid Trusted hash'); - } else { - bot.tellraw(`@a`, { text: "Valid Trusted hash", color: "dark_green" }); - } - } - if (args[0] === bot.validation.owner) { - if (bot.options.isSavage) { - bot.chat.message("&2Valid Owner hash"); - } else { - bot.tellraw(`@a`, { text: "Valid Owner hash", color: "dark_green" }); - } - }*/ if (args[0] === bot.validation.trusted) { bot.chat.message('&2Valid Trusted hash'); } @@ -42,7 +28,6 @@ module.exports = { const event = bot?.discord?.message const roles = event?.member?.roles?.cache const source = context.source; - console.log(Object.keys(bot.discord.message.member.user.username)); if (roles?.some(role => role.name === `${config.discord.roles.trusted}`)) { bot.discord.message.reply('Valid trusted user') bot.chat.message(`Valid trusted user [${bot.discord.message.member.user.username}]`) diff --git a/src/data/default_config.yml b/src/data/default_config.yml index 4217a99..ddaf832 100644 --- a/src/data/default_config.yml +++ b/src/data/default_config.yml @@ -1,5 +1,3 @@ -# FNFBoyfriendBot v6.0.0-alpha config - prefixes: - "!" - "fnfbfbot!" diff --git a/src/data/filter.json b/src/data/filter.json index e854bf2..0637a08 100644 --- a/src/data/filter.json +++ b/src/data/filter.json @@ -1 +1 @@ -[{"ignoreCase":false,"regexed":false,"name":"e"},{"ignoreCase":false,"regexed":false,"name":"sladkjf"},{"ignoreCase":true,"regexed":true,"name":"amogus"}] \ No newline at end of file +[] \ No newline at end of file diff --git a/src/data/info.json b/src/data/info.json index a23dc97..f3f974b 100644 --- a/src/data/info.json +++ b/src/data/info.json @@ -1,8 +1,8 @@ { "bot": { "buildstring": { - "version": "v6.0.4", - "build":"1035", + "version": "v6.0.5", + "build":"1050", "codename":"" }, "source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/" diff --git a/src/modules/command_core.js b/src/modules/command_core.js index 4fece23..6b56466 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -67,7 +67,7 @@ function core (bot, options, config) { const location = bot.core.currentBlock() if (!location) return if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) { - bot.chat.command(`${command?.substring(0, 256)}`) + return } else { bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 }) bot.core.incrementCurrentBlock() diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index 7a542ae..fe4a8fc 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -58,7 +58,7 @@ function command_manager (bot, options, config, discordClient) { const event = bot.discord.message; const roles = event?.member?.roles?.cache; if (command?.trustLevel === 1 && !source?.sources?.discord) { - const hash = args[0] +// const hash = args[0] if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash" }) if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' }) } else if (command?.trustLevel === 1 && source?.sources.discord) { diff --git a/src/modules/filter.js b/src/modules/filter.js index a5c0aa4..5cd9d6b 100644 --- a/src/modules/filter.js +++ b/src/modules/filter.js @@ -1,9 +1,8 @@ -//const json = require('../data/filter.json'); const fs = require('fs'); const path = require('path'); -//const json = fs.readFileSync(path.join(__dirname, '../data/filter.json')); function filter (bot, options, config, discordClient) { if (options.isSavage || options.isCreayun) return; + // filter v5 (not to be confused with the bot version) bot.filter = { list () { try { @@ -12,33 +11,117 @@ function filter (bot, options, config, discordClient) { console.log(e.stack) } }, + add (ignoreCase, regexed, player) { var data = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json'))); var arrayadd = { ignoreCase: ignoreCase, regexed: regexed, name: player } data.push(arrayadd); fs.writeFileSync(path.join(__dirname, '../data/filter.json'), JSON.stringify(data)) + this.doAll(); }, + remove (index) { var data = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json'))); data.splice(index, 1); fs.writeFileSync(path.join(__dirname, '../data/filter.json'), JSON.stringify(data)); }, + clear () { var data = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json'))); data = []; fs.writeFileSync(path.join(__dirname, '../data/filter.json'), JSON.stringify(data)) }, - gamemodeCheck () { - - }, - joinMsg () { - - }, - check () { + doAll () { + for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) { + if (filteredPlayers.ignoreCase) { + check = bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()) + } else if (filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name); + check = bot.players.find((players) => regex.test(players.profile.name)) + } else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name.toLowerCase()); + check = bot.players.find((players) => regex.test(players.profile.name.toLowerCase())) + } else { + check = bot.players.find((players) => players.profile.name === filteredPlayers.name) + } + } + if (!check) return; + bot.core.run(`execute run gamemode adventure @a[name="${check?.profile?.name}"]`) + bot.core.run(`execute run deop @a[name="${check?.profile?.name}"]`); + bot.core.run(`essentials:mute ${check?.uuid} 10y`); } } + bot.on('message', (message) => { + try { + const stringMessage = bot.getMessageAsPrismarine(message)?.toString() + for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) { + if (filteredPlayers.ignoreCase) { + if (!bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase())) return; + else if (bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).gamemode !== 2) { + bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).profile.name}"]`); + } else if (stringMessage.includes('op')) { + setTimeout(() => { + bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).profile.name}"]`) + }, 10); + } + } else if (filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name); + if (!bot.players.find((players) => regex.test(players.profile.name))) return; + else if (bot.players.find((players) => regex.test(players.profile.name)).gamemode !== 2) { + bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => regex.test(players.profile.name)).profile.name}"]`); + } else if (stringMessage.includes('op')) { + setTimeout(() => { + bot.core.run(`execute run deop @a[name="${bot.players.find((players) => regex.test(players.profile.name)).profile.name}"]`); + }, 10) + } + } else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name.toLowerCase()); + if (!bot.players.find((players) => regex.test(players.profile.name.toLowerCase()))) return; + else if (bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).gamemode !== 2) { + bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).profile.name}"]`); + } else if (stringMessage.includes('op')) { + setTimeout(() => { + bot.core.run(`execute run deop @a[name="${bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).profile.name}"]`); + }, 10) + } + } else { + if (!bot.players.find((players) => players.profile.name === filteredPlayers.name)) return; + else if (bot.players.find((players) => players.profile.name === filteredPlayers.name).gamemode !== 2) { + bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => players.profile.name === filteredPlayers.name).profile.name}"]`); + } else if (stringMessage.includes('op')) { + setTimeout(() => { + bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayers.name).profile.name}"]`); + }, 10) + } + } + } + } catch (e) { + bot.console.warn(e.stack); + } + }) + + bot.on('parsed_message', (message) => { + const stringMessage = bot.getMessageAsPrismarine(message)?.toString(); + for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) { + if (filteredPlayers.ignoreCase) { + check = bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()) + } else if (filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name); + check = bot.players.find((players) => regex.test(players.profile.name)) + } else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) { + let regex = new RegExp(filteredPlayers.name.toLowerCase()); + check = bot.players.find((players) => regex.test(players.profile.name.toLowerCase())) + } else { + check = bot.players.find((players) => players.profile.name === filteredPlayers.name) + } + } + if (bot.filter.list().length === 0) return; + if (!check) return; + if (!bot.players) return; + if (message.sender.profile.name === check?.profile?.name) { + bot.core.run(`essentials:mute ${check?.uuid} 10y`); + } + }) } module.exports = filter; -// let e = new RegExp('Parker.*'); bot.players.find((a) => e.test(a.profile.name)) - diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index d05db11..1913598 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -95,7 +95,7 @@ You already have registered this username! else if (username) bot.chat.command(`username ${bot.options.username}`) else if (nickname) bot.chat.command(`nick off`) else if (!prefix) bot.chat.command(`prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`); - else if (!vanished) bot.core.run(`vanish ${bot.options.username} on`); + else if (!vanished) bot.chat.command(`essentials:vanish on`); else if (unmuted) bot.core.run(`essentials:mute ${bot.uuid}`); else if (!god) bot.core.run(`god ${bot.options.username} enable`); else if (!teleportToggle) bot.core.run(`tptoggle ${bot.options.username} disable`); diff --git a/src/output.txt b/src/output.txt new file mode 100644 index 0000000..b11c395 --- /dev/null +++ b/src/output.txt @@ -0,0 +1,7 @@ + 27 util/ChatParsers/ChipmunkMod.js + 25 util/ChatParsers/Creayun.js + 41 util/ChatParsers/Kaboom.js + 23 util/ChatParsers/VanillaChat.js + 26 util/ChatParsers/sayConsole.js + 25 util/ChatParsers/yfdCustomChat.js + 167 total diff --git a/src/util/ChatParsers/Creayun.js b/src/util/ChatParsers/Creayun.js index e00244e..d363319 100644 --- a/src/util/ChatParsers/Creayun.js +++ b/src/util/ChatParsers/Creayun.js @@ -17,7 +17,7 @@ function creayun (messageobj, data) { // console.log(data.players.find(player => player.profile.name === match[2])) sender = data.players.find(player => player.profile.name === match[2]) // sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName)) - if (!sender) return; +// if (!sender) return; // console.log(sender) return { sender, contents: match[3], type: 'minecraft:chat'}; } diff --git a/src/util/usernameGen.js b/src/util/usernameGen.js index ed5f169..fb2f2aa 100644 --- a/src/util/usernameGen.js +++ b/src/util/usernameGen.js @@ -1,7 +1,5 @@ function usernameGen (bot, config) { // const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; - const unicode = "▄".codePointAt(0).toString(16); - const unicodeGen = "\\u" + "0000".substring(0, 4 - unicode.length) + unicode; if (bot.options.isSavage || bot.options.isCreayun && !bot.options.isKaboom) { characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; } else {