Compare commits

...
12 Commits
32 changed files with 450 additions and 194 deletions
View File
+14 -12
View File
@@ -1,16 +1,17 @@
const mc = require('minecraft-protocol')
const { EventEmitter } = require('events')
require("events").EventEmitter.defaultMaxListeners = Infinity;
//require("events").EventEmitter.defaultMaxListeners = Infinity;
EventEmitter.defaultMaxListeners = Infinity
const util = require('util');
function createBot(options = {}, config) {
const bot = new EventEmitter()
const bot = new EventEmitter();
bot.options = {
// Set some default values in options
host: options.host ??= 'localhost',
username: options.username ??= 'Player',
hideErrors: options.hideErrors ??= true, // HACK: Hide errors by default as a lazy fix to console being spammed with them
};
bot.options = options
bot.options = options;
const ChatMessage = require('prismarine-chat')(bot.options.version);
// Create our client object, put it on the bot, and register some events
bot.on('init_client', client => {
@@ -24,10 +25,11 @@ function createBot(options = {}, config) {
bot.username = client.username
})
client.on('disconnect', (data) => {
bot.emit("disconnect", JSON.stringify(data.reason))
bot?.discord?.channel?.send(util.inspect(data.reason))
bot.emit("disconnect", data)
// bot.console.info(JSON.stringify(data))
// bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
}
})
client.on('end', reason => {
@@ -35,10 +37,10 @@ function createBot(options = {}, config) {
})
client.on('error', error => {
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
bot?.discord?.channel?.send(error.toString())
bot.console.warn(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
// bot?.discord?.channel?.send(error.toString())
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(error.toString()))
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(error.toString()))
}
})
@@ -48,10 +50,10 @@ function createBot(options = {}, config) {
client.on('kick_disconnect', (data) => {
bot.emit("kick_disconnect", data.reason)
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(data.reason))
bot.console?.warn(ChatMessage.fromNotch(`§8[§bClient Reconnect§8]§r `)?.toAnsi() + util.inspect(data.reason))
bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
}
})
@@ -60,7 +62,7 @@ function createBot(options = {}, config) {
});
})
const client = options.client ?? mc.createClient(options)
const client = options.client ?? new mc.createClient(options)
bot._client = client
bot.emit('init_client', client)
bot.bots = options.bots ?? [bot]
+6 -6
View File
@@ -15,17 +15,17 @@ module.exports = {
const servers = bot.bots.map(eachBot => eachBot.options.serverName);
for (const eachBot of bot.bots) {
if (args.slice(1).join(' ').toLowerCase() === 'all') {
eachBot.console.consoleServer = 'all'
bot.console.logs("Set the console server to all");
eachBot.console.server = 'all'
bot.console.info("Set the console server to all");
continue
}
const server = servers.find(server => server.toLowerCase().includes(args[1]))
if (!server) {
bot.console.logs("Invalid server");
bot.console.info("Invalid server");
return
}
bot.console.logs(`Set the console server to ` + server);
eachBot.console.consoleServer = server;
bot.console.info(`Set the console server to ` + server);
eachBot.console.server = server;
}
break
case 'customchat':
@@ -75,7 +75,7 @@ module.exports = {
if (bot.console.customChat.enabled) {
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.trusted} ${args.slice(3).join(' ')}`)
bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.trusted} ${args.slice(3).join(' ')}`);
}
break
default:
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
if (args[0] === "list") {
if (args[0]?.toLowerCase() === "list") {
const list = Object.keys(cows);
let content = [];
let color = true;
+13 -2
View File
@@ -40,7 +40,18 @@ module.exports = {
const source = context.source;
switch (args[0]?.toLowerCase()) {
case 'version':
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}-${botInfo.bot.buildstring.codename}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
if (botInfo.bot.buildstring.codename === '') {
if (bot.options.isSavage) {
bot.chat.message(`&9Friday &9Night &9Funkin &3Boyfriend &1Bot&8&r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}`)
setTimeout(() => {
bot.chat.message(`11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`)
}, 300)
} else {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
}
} else {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}-${botInfo.bot.buildstring.codename}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
}
break
case 'config':
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
@@ -275,7 +286,7 @@ module.exports = {
case "about":
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
text: `FNFBoyfriendBot is a open source kaboom bot created by Parker2991\nThe source can be found here ${botInfo.bot.source}`,
text: `FNFBoyfriendBot is a open source kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.bot.source}`,
color: "gray",
translate: "",
hoverEvent: {
+4 -11
View File
@@ -9,19 +9,12 @@ module.exports = {
usages: [
""
],
async execute (context) {
execute (context) {
const bot = context.bot;
// ik theres a better way to do but shut the fuck up about it
await bot.chat.message("killing process");
await bot.console.info("killing process");
await bot.discord.channel?.send("killing process");
await process.kill(0);
process.exit(69);
},
async discordExecute (context) {
discordExecute (context) {
const bot = context.bot;
await bot.chat.message("killing process");
await bot.console.info("killing process");
await bot.discord.channel?.send("killing process");
await process.exit(0);
process.exit(69);
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ module.exports = {
}
}
bot.bots.filter((eachBot) => {
if (eachBot.options.serverName === "Savage Friends" && eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom) {
if (eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom || eachBot.options.isCreayun && !eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom) {
eachBot.chat.message(`[${bot.options.serverName}] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} \u203a ${args.join(' ')}`)
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && !eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.tellraw("@a", component);
+1 -1
View File
@@ -1,6 +1,6 @@
module.exports = {
name: 'reload',
trustLevel: 0,
trustLevel: 3,
aliases: [
],
description: 'reloads commands',
+4 -4
View File
@@ -5,7 +5,7 @@ const fixansi = require('../util/ansi');
const CommandError = require('../util/command_error')
module.exports = {
name: 'website',
trustLevel: 0,
trustLevel: 1,
aliases: [
],
description: 'look up website data',
@@ -15,8 +15,8 @@ module.exports = {
execute (context) {
const bot = context.bot
const args = context.arguments;
if (args.join(' ').toLowerCase().startsWith("http://")) {
http.get(args.join(' '), (res) => {
if (args.slice(1).join(' ').toLowerCase().startsWith("http://")) {
http.get(args.slice(1).join(' '), (res) => {
const { statusCode } = res;
const contentType = res.headers['content-type'];
res.setEncoding('utf8');
@@ -33,7 +33,7 @@ module.exports = {
bot.chat.message(`&4${e.toString()}`);
});
} else {
https.get(args.join(' '), (res) => {
https.get(args.slice(1).join(' '), (res) => {
res.on('data', (d) => {
bot.tellraw("@a", { text: util.inspect(d.toString().substring(0, 32750)), color: "dark_green", })
// console.log(Object.keys(d.toString().length));
+19
View File
@@ -30,6 +30,25 @@
"+"
]
},
{
"name": [
{
"text": "Hydra",
"color": "dark_red"
}
],
"authors": [
"popbob/aaa"
],
"exclaimer": "",
"foundation": "nodejs/node-minecraft-protocol",
"prefixes": [
"+",
"$",
"h:",
"hydra:"
]
},
{
"name": [
{
+2
View File
@@ -25,6 +25,8 @@ core:
y: 0
z: 15
commandSetMessage: true
keys:
trusted: "trusted key here"
admin: "admin key here"
+1
View File
@@ -0,0 +1 @@
[]
+3 -3
View File
@@ -1,9 +1,9 @@
{
"bot": {
"buildstring": {
"version": "v6.0.0",
"build":"950",
"codename":"§#fe019aGraffiti §7Groovin"
"version": "v6.0.3",
"build":"1025",
"codename":""
},
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
}
View File
+2 -2
View File
@@ -27,9 +27,9 @@ const rl = readline.createInterface({
if (config.discord.enabled) discordClient.login(config.discord.token);
const bots = [];
for (const options of config.bots) {
const bot = createBot(options, config);
const bot = new createBot(options, config);
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);
bot.console.useReadlineInterface(rl);
bot.console.readlineInterface(rl);
}
+1
View File
@@ -1,6 +1,7 @@
const readline = require('readline');
function boot (bot, options, discordClient, config) {
bot.on("packet.login", (data) => {
if (bot.options.isCreayun) return
if (new Date().getDay() === 5) {
bot.chat.message('Gettin\' freaky on a friday night!');
} else {
+35 -14
View File
@@ -4,8 +4,7 @@ const ChipmunkModChatParser = require('../util/ChatParsers/ChipmunkMod');
const CreayunChatParser = require('../util/ChatParsers/Creayun');
const sayConsoleChatParser = require('../util/ChatParsers/sayConsole');
const VanillaChatParser = require("../util/ChatParsers/VanillaChat");
const nbt = require('prismarine-nbt');
const yfdCustomChatParser = require('../util/ChatParsers/yfdCustomChat')
const yfdCustomChatParser = require('../util/ChatParsers/yfdCustomChat');
function tryParse (json) {
try {
return JSON.parse(json)
@@ -19,7 +18,7 @@ function chat (bot, options, config) {
bot.on('registry_ready', registry => {
ChatMessage = loadPrismarineChat(registry)
})
if (options.isSavage) {
if (options.isSavage || options.isCreayun) {
bot.chatParsers = [CreayunChatParser, sayConsoleChatParser]
} else {
bot.chatParsers = [KaboomChatParser, ChipmunkModChatParser, VanillaChatParser, sayConsoleChatParser, yfdCustomChatParser]
@@ -32,23 +31,42 @@ function chat (bot, options, config) {
type: packet.type,
sender
})
const translateMessage = bot.getMessageAsPrismarine(message)?.toMotd()
const translateUsername = bot.getMessageAsPrismarine(sender)?.toMotd()
if (packet.type === 1) bot.emit('message', bot.getMessageAsPrismarine({translate:"chat.type.emote", with:[`${translateUsername}`,`${translateMessage}`]})?.toMotd())
if (packet.type === 2) bot.emit('message', bot.getMessageAsPrismarine({"translate":"commands.message.display.incoming","with":[`${translateUsername}`,`${translateMessage}`],"color":"gray","italic":true})?.toMotd())
if (packet.type === 3) bot.emit('message', bot.getMessageAsPrismarine({"translate":"commands.message.display.outgoing","with":[`${translateUsername}`,`${translateMessage}`],"color":"gray","italic":true})?.toMotd())
if (packet.type === 4) bot.emit('message', message);
if (packet.type === 5) bot.emit('message', bot.getMessageAsPrismarine({translate:"chat.type.announcement",color:'white', with:[`${translateUsername}`,`${translateMessage}`]})?.toMotd())
switch (packet.type) {
case 1:
bot.emit('message', { translate: "chat.type.emote", with: [ sender, message ]})
break
case 2:
bot.emit('message', { translate: "commands.message.display.incoming", with: [ sender, message], color: "gray", italic: true })
break
case 3:
bot.emit('message', { translate: "commands.message.display.outgoing", with: [ sender, message ], color: "gray", italic: true })
break
case 4:
bot.emit('message', message);
break
case 5:
bot.emit('message', { translate: 'chat.type.announcement', with: [ sender, message ]})
break
}
tryParsingMessage(message, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine })
})
bot.on('packet.player_chat', (packet, data) => {
const unsigned = tryParse(packet.unsignedChatContent)
// const unsigned = JSON.parse(loadPrismarineChat.processNbtMessage(nbt.comp(nbt.string(packet.unsignedChatContent))))
// const unsigned = loadPrismarineChat.processNbtMessage(tryParse(packet.unsignedChatContent))
bot.emit('player_chat', { plain: packet.plainMessage, unsigned, senderUuid: packet.senderUuid })
if (packet.type === 5) bot.emit('message', bot.getMessageAsPrismarine({ translate: "chat.type.announcement", with: [`${bot.players.find(player => player.uuid === packet.senderUuid).profile.name}`, `${packet.plainMessage}`]})?.toMotd())
if (packet.type !== 5) bot.emit("message", unsigned)
switch (packet.type) {
case 5:
bot.emit('message', { translate: "chat.type.announcement", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ]})
break
case 3:
bot.emit('message', { translate: "commands.message.display.outgoing", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ], color: "gray", italic: true })
break
case 2:
bot.emit('message', { translate: "commands.message.display.incoming", with: [ bot.players.find(player => player.uuid === packet.senderUuid).profile.name, packet.plainMessage ], color: "gray", italic: true })
break
default:
bot.emit('message', unsigned)
}
tryParsingMessage(unsigned, { senderUuid: packet.senderUuid, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine })
})
@@ -117,5 +135,8 @@ function chat (bot, options, config) {
})
}
}
bot.tellraw = (selector, message) => {
bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message))
}
}
module.exports = chat;
+11 -4
View File
@@ -11,9 +11,16 @@ function core (bot, options, config) {
const { start, end } = bot.core.area
if (!pos) return
if (bot.options.useChat ?? bot.options.isCreayun ?? bot.options.isSavage) return
// if (isNaN(pos.x + start.x)) bot.chat.command('world 3');
// console.log(isNaN(pos.x + start.x))
if (bot.options.useChat || bot.options.isCreayun || bot.options.isSavage) 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
*/
bot.chat.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)}'}`)
},
@@ -68,7 +75,7 @@ function core (bot, options, config) {
}
}
// if (bot.options.useChat ?? bot.options.isCreayun ?? bot.options.isSavage) return
if (bot.options.isSavage) return
if (bot.options.isSavage || bot.options.isCreayun) return
bot.on('move', () => {
// if (bot.options.isSavage) return
bot.core.move(bot.position)
+24 -14
View File
@@ -34,10 +34,9 @@ function command_manager (bot, options, config, discordClient) {
translate: "command.context.here"
}
])
//}
} else if (source?.sources?.console && !source?.sources?.discord) {
if (!command || !command.execute)
bot.console.warn(bot.getMessageAsPrismarine([
bot.console.warn([
{
translate: 'command.unknown.command',
color: "dark_red"
@@ -53,21 +52,20 @@ function command_manager (bot, options, config, discordClient) {
translate: "command.context.here",
color: "dark_red"
}
])?.toAnsi())
])
}
if (command?.trustLevel > 0) {
const event = bot?.discord?.message;
const event = bot.discord.message;
const roles = event?.member?.roles?.cache;
if (command?.trustLevel === 1 && !source?.sources?.discord) {
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 and admin or an owner hash" })
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) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!' })
}
if (command?.trustLevel === 2 && !source.sources.console) {
// bot.chat.message('trust level 2 does nothing currently'); placeholder code
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash" })
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' })
}
@@ -80,18 +78,18 @@ function command_manager (bot, options, config, discordClient) {
} else if (command?.trustLevel === 4 && !source.sources.console) {
throw new CommandError('This command can only be ran via console');
}
} if (!command?.discordExecute && command && source.sources.discord) {
}
if (!command?.discordExecute && command && source?.sources?.discord) {
throw new CommandError(`${command.name} command is not supported in discord!`)
} else if (command?.discordExecute && command && source.sources.discord) {
} else if (command?.discordExecute && command && source?.sources?.discord) {
return command.discordExecute({ bot, source, arguments: args, config, discordClient })
} else if (!command?.execute && command && !source.sources.discord) {
} else if (!command?.execute && command && !source?.sources?.discord) {
throw new CommandError(`${command.name} command is not supported in game!`)
} else if (command?.execute && command && !source.sources.discord) {
} else if (command?.execute && command && !source?.sources?.discord) {
return command?.execute({ bot, source, arguments: args, config, discordClient})
}
} catch (error) {
console.error(error.stack)
bot?.console?.filelogging(error.stack);
if (source?.sources?.discord && !source?.sources?.console) {
const Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.error}`)
@@ -103,9 +101,21 @@ function command_manager (bot, options, config, discordClient) {
]
})
} else if (!source?.sources?.discord && !source?.sources?.console) {
if (error instanceof CommandError)
bot.tellraw("@a", { text: error.message, color: "dark_red" })
else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
if (error instanceof CommandError) {
if (bot.options.isSavage || bot.options.isCreayun) {
bot.chat.message(`&4${error.message}`)
} else {
bot.tellraw("@a", { text: error.message, color: "dark_red" })
}
} else {
if (bot.options.isSavage || bot.options.isCreayun) {
bot.chat.message(`${bot.getMessageAsPrismarine({ translate: "command.failed", color: "dark_red" })?.toMotd().replaceAll('§','&')}`)
} else {
bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
}
}
// else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
//}
}
}
},
+69 -80
View File
@@ -1,93 +1,82 @@
const CommandSource = require('../util/command_source');
function CommandConsole (bot, options, config) {
const ChatMessage = require('prismarine-chat')(options.version);
let ratelimit = 0;
const prismarineChat = require('prismarine-chat')('1.20.2');
function Console (bot, options, config) {
let rateLimit = 0;
bot.console = {
readline: null,
consoleServer: 'all',
useReadlineInterface (rl) {
server: 'all',
readlineInterface (rl) {
this.readline = rl
rl.on('line', line => {
if (bot.options.serverName !== this.consoleServer && this.consoleServer !== 'all') return
if (line.startsWith(config.console.prefix)) {
return bot.commandManager.executeString(bot.console.source, line.substring(config.console.prefix.length))
} if (line.startsWith("")) {
return bot.commandManager.executeString(bot.console.source, `console say ${line.substring(0)}`)
rl.on('line', (args) => {
if (bot.options.serverName !== this.server && this.server !== 'all') return
if (args.startsWith(config.console.prefix)) {
return bot.commandManager.executeString(bot.console.source, args.substring(config.console.prefix.length))
} else if (args.startsWith("")) {
return bot.commandManager.executeString(bot.console.source, `console say ${args.substring(0)}`);
}
rl.on('close', () => {
this.readline = null;
})
})
rl.on('close', () => {
this.readline = null
})
log = function (...args) {
rl.output.write("\x1b[2K\r");
console.log(args.toString());
rl._refreshLine();
},
source: new CommandSource(bot.options.username, { console: true, discord: false }),
refreshLine (...args) {
this.readline.output.write("\x1b[2K\r");
console.log.apply(console, arguments);
this.readline._refreshLine();
},
log (message) {
this.refreshLine(bot.getMessageAsPrismarine(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §6logs§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
},
warn (error) {
this.refreshLine(prismarineChat.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §ewarn§8] §8[${options.serverName}§8] `)?.toAnsi() + error)
},
error (error) {
this.refreshLine(bot.getMessageAsPrismarine(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §4error§8] §8[${options.serverName}§8] `)?.toAnsi() + error)
},
info (message) {
this.refreshLine(prismarineChat.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §2info§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
},
customChat: {
enabled: false,
chat (message) {
const prefix = {
translate: '[%s] %s \u203a %s',
color:'dark_gray',
with: [
{
text: 'FNFBoyfriendBot Console',
color:'#00FFFF'
},
{
selector: `${bot.username}`, color:'#00FFFF',
clickEvent: { action: 'suggest_command', value: `${config.prefixes[0]}help` }
},
{
text: '',
extra: [`${message}`],
color:'white'
},
],
hoverEvent: { action:"show_text", value: 'FNF Sky is a fangirl but a simp for boyfriend confirmed??'},
clickEvent: 'https://doin-your.mom' ?
{ action: 'open_url', value: 'https://doin-your.mom' } : undefined,
}
bot.tellraw('@a', prefix)
}
}
}
bot.console.logs = function (message) {
log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §6logs§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
}
bot.console.info = function (message) {
log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §2info§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
}
bot.console.warn = function (message) {
console.log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §ewarn§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
}
bot.console.source = new CommandSource(bot.options.username, { console: true, discord: false });
bot.console.source.sendFeedback = message => {
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
if (!options.logging) return
bot.console.logs(ChatMessage.fromNotch('§8[§6Command§8] ')?.toAnsi() + ansi);
}
bot.console.error = function (message) {
console.log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §4error§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
}
bot.console.customChat = {
enabled: false,
chat (message) {
const prefix = {
translate: '[%s] %s \u203a %s',
color:'dark_gray',
with: [
{
text: 'FNFBoyfriendBot Console',
color:'#00FFFF'
},
{
selector: `${bot.username}`, color:'#00FFFF',
clickEvent: { action: 'suggest_command', value: '~help' }
},
{
text: '',
extra: [`${message}`],
color:'white'
},
],
hoverEvent: { action:"show_text", value: 'FNF Sky is a fangirl but a simp for boyfriend confirmed??'},
clickEvent: 'https://doin-your.mom' ?
{ action: 'open_url', value: 'https://doin-your.mom' } : undefined,
}
bot.tellraw('@a', prefix)
}
}
bot.on('message', message => {
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
const string = bot.getMessageAsPrismarine(message)?.toString(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
if (!options.logging) return
//ratelimit++
setInterval(() => {
// ratelimit--
ratelimit = 0
bot.on('message', (message) => {
rateLimit++
setTimeout(() => {
rateLimit--
}, 1000)
if (ratelimit > 300) {
// options.logging = false
if (!options.logging) return;
/* if (rateLimit > 100) {
return
}
bot.console.logs(`${ansi}`)
bot.console.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${string}`)
ratelimit++
}*/
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()}`);
})
}
module.exports = CommandConsole;
module.exports = Console;
+1 -5
View File
@@ -20,7 +20,7 @@ function discord(bot, options, config, discordClient) {
invite: config.discord.invite || undefined,
prefix: config.discord.prefix,
// presence: bot.discord.presence,
token: config.discord.token,
// token: config.discord.token,
}
discordClient.once('ready', (context) => {
bot.discord.channel = discordClient.channels.cache.get(options.channelId)
@@ -149,9 +149,5 @@ function discord(bot, options, config, discordClient) {
}
discordClient.on('messageCreate', messageCreate)
process.on("uncaughtException", (e) => {
// sendDiscordMessage("uncaught " + e.stack);
});
}
module.exports = discord;
+60
View File
@@ -0,0 +1,60 @@
const fs = require("fs");
const path = require("path");
const { createGzip } = require("zlib");
const readline = require('readline');
const { Console } = require("console");
function fileLogger(bot, options, message) {
const currentDate = new Date();
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
.toString()
.padStart(2, "0")}-${currentDate.getDate().toString().padStart(2, "0")}`;
const logFolder = path.join(__dirname, "../../logs");
const logFileName = "latest.log";
const logFilePath = path.join(logFolder, logFileName);
const logStream = fs.createWriteStream(logFilePath, { flags: "a" });
if (!fs.existsSync(path.join(__dirname, "../../logs"))) {
fs.mkdirSync(path.join(__dirname, "../../logs"))
}
try {
if (!fs.existsSync(logFolder)) {
fs.mkdirSync(logFolder);
}
} catch (e) {
console.error(`Unable to create log folder: ${e}`);
}
function compressFile(input, output) {
// if (!bot.Console.filelogging) return
const plainOutput = output.slice(0, -3);
fs.renameSync(input, plainOutput);
const gzip = createGzip();
fs.createReadStream(plainOutput)
.pipe(gzip)
.pipe(fs.createWriteStream(output + ".tmp"))
.once("finish", () => {
fs.unlinkSync(plainOutput);
fs.renameSync(output + ".tmp", output);
});
}
if (fs.existsSync(logFilePath)) {
const plainName = fs
.statSync(logFilePath)
.ctime.toISOString()
.split("T")[0];
let name = plainName;
let counter = 1;
let newFileName = path.join(logFolder, `${name}.log.gz`);
while (fs.existsSync(newFileName)) {
name = `${plainName}-${counter}`;
newFileName = path.join(logFolder, `${name}.log.gz`);
counter++;
}
compressFile(logFilePath, newFileName);
}
bot.console.fileLogger = function logging (message) {
logStream.write(message + "\n");
};
}
module.exports = fileLogger;
+57
View File
@@ -0,0 +1,57 @@
const fs = require('fs');
const path = require('path');
const jsonData = fs.readFileSync(path.join(__dirname, '../data/filter.json'));
function filterFunction (bot, options, config) {
bot.filter = {
list () {
try {
return JSON.parse(jsonData);
} catch (e) {
bot.chat.message(`&4${e.toString()}`);
}
},
add (player) {
try {
const filterList = JSON.parse(jsonData);
const addData = {
ignoreCase: false,
name: player
}
filterList.push(addData);
const data = JSON.stringify(filterList);
fs.writeFile(jsonData, data, (err) => {
if (err) throw err;
})
console.log(data);
} catch (e) {
bot.chat.message(`${e.toString()}`);
}
},
ignoreCase (player) {
try {
const filterList = JSON.parse(jsonData);
const addData = {
ignoreCase: true,
name: player
}
filterList.push(addData);
const data = JSON.stringify(filterList);
fs.writeFile(jsonData, data, (err) => {
if (err) throw err;
})
console.log(data);
} catch (e) {
bot.chat.message(`${e.toString()}`);
}
},
clear () {
try {
// fs.rmSync(path.join(__dirname, '../data/filter.json'));
fs.writeFileSync(jsonData, JSON.stringify([]));
} catch (e) {
bot.chat.message(`${e.toString()}`)
}
}
}
}
module.exports = filterFunction;
+16 -6
View File
@@ -18,11 +18,20 @@ function player_list (bot, options, config) {
}
})
bot.on('packet.player_remove', ({ players }) => {
// TODO: Add player removal (with validation)
for (const player of players) {
bot.players = bot.players.filter(entry => entry.uuid !== player)
}
bot.on('packet.player_remove', async ({players}) => { // players has uuids of the players
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude @a, @r, @s, @e, @p -aaa
bot.players.forEach(async player => {
if(!players.includes(player.uuid)) return
const a = player_completion.filter(_ => _.match == player.profile.name)
if(a.length >= 1) {
player.vanished = true
} else {
bot.players = bot.players.filter(_ => _.uuid != player.uuid)
}
})
})
function addPlayer (entry) {
@@ -35,7 +44,8 @@ function player_list (bot, options, config) {
gamemode: undefined,
listed: undefined,
latency: undefined,
displayName: undefined
displayName: undefined,
vanished: false
})
}
+3 -1
View File
@@ -58,8 +58,10 @@ function selfcare (bot, options, config) {
gameMode = packet.gameMode;
clientLock = packet.gameMode;
timer = setInterval(() => {
if (bot.options.isSavage && !bot.options.isKaboom) {
if (bot.options.isSavage && !bot.options.isKaboom && !bot.options.isCreayun) {
if (clientLock !== 4) bot._client.write("client_command", { actionId: 0 });
} else if (bot.options.isCreayun && !bot.options.isKaboom && !bot.options.isSavage) {
} else if (bot.options.isKaboom && !bot.options.isSavage) {
if (permissionLevel < 2) bot.chat.command('op @s[type=player]');
else if (gameMode !== 1) bot.chat.command('minecraft:gamemode creative');
+18
View File
@@ -0,0 +1,18 @@
module.exports = (bot) => {
// let aaa cook
bot.tab_complete = (str) => {
return new Promise((resolve) => {
bot._client.write('tab_complete', {
text: str, assumeCommand: false, sendBlockInSight: false
})
const tab_completeH = (packet) => {
bot._client.removeListener('tab_complete', tab_completeH)
resolve(packet.matches)
}
bot._client.once('tab_complete', tab_completeH)
})
}
}
+16 -16
View File
@@ -1,27 +1,27 @@
function ChipmunkMod (message, data, context, bot) {
try {
if (message === null || typeof message !== 'object') return
if (message.with?.length < 3 || (message.translate !== '[%s] %s › %s' && message.translate !== '%s %s › %s')) return
if (message === null || typeof message !== 'object') return
if (message.with?.length < 3 || (message.translate !== '[%s] %s › %s' && message.translate !== '%s %s › %s')) return
const senderComponent = message.with[1]
const contents = message.with[2]
let sender
const hoverEvent = senderComponent.hoverEvent
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent.contents.id
const senderComponent = message.with[1]
const contents = message.with[2]
let sender
const hoverEvent = senderComponent.hoverEvent
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent.contents.id
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.profile.name === stringUsername)
}
sender = data.players.find(player => player.profile.name === stringUsername)
}
if (!sender) return null
if (!sender) return null;
return { sender, contents, type: 'minecraft:chat', senderComponent }
return { sender, contents, type: 'minecraft:chat', senderComponent }
} catch(e) {
console.error(e)
console.error(e)
}
}
module.exports = ChipmunkMod
+5 -3
View File
@@ -1,14 +1,16 @@
const ChatMessage = require('prismarine-chat')('1.20.2');
const util = require('util');
function creayun (messageobj, data) {
let match;
let sender;
const stringify = message => new ChatMessage(message).toString()
const message = stringify(messageobj);
const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/;
const playerWithoutPrefix = /^(\S*?) » (.*?)$/
if (playerWithPrefix.test(message)) {
let match = message.match(playerWithPrefix)
const sender = data.players.find((player) => player.uuid === player.uuid)
if (!sender) return undefined
match = message.match(playerWithPrefix)
sender = data.players.find(player => player.profile.name === match[2])
if (!sender) return;
return { sender, contents: match[3], type: 'minecraft:chat'};
}
}
+55
View File
@@ -9,6 +9,61 @@ function ansi (message) {
"\x1B\[92m": "\x1B\[32m", // Green
"\x1B\[0m": "\x1B\[0m\x1B\[37m", // White
"\x1B\[97m": "\x1B\[0m\x1B\[37m", // White
"\x1B\[30m": "\x1B[30m", // black
"\x1B\[35m": "\x1B[35m", // purple
'\x1B[3m': "\x1B[23m", // italic
'\x1B[4m': "\x1B[24m", // underline
'\x1B[9m': "\x1B[29m", // strike through
'\x1B[6m': "\x1B[29m" // obfuscated
/*
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
Blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47
Default 39 49
Reset 0 0
ESC[1;34;{...}m Set graphics modes for cell, separated by semicolon (;).
ESC[0m reset all modes (styles and colors)
ESC[1m ESC[22m set bold mode.
ESC[2m ESC[22m set dim/faint mode.
ESC[3m ESC[23m set italic mode.
ESC[4m ESC[24m set underline mode.
ESC[5m ESC[25m set blinking mode
ESC[7m ESC[27m set inverse/reverse mode
ESC[8m ESC[28m set hidden/invisible mode
ESC[9m ESC[29m set strikethrough mode.
*/
/*
const defaultAnsiCodes = {
'§0': '\u001b[30m',
'§1': '\u001b[34m',
'§2': '\u001b[32m',
'§3': '\u001b[36m',
'§4': '\u001b[31m',
'§5': '\u001b[35m',
'§6': '\u001b[33m',
'§7': '\u001b[37m',
'§8': '\u001b[90m',
'§9': '\u001b[94m',
'§a': '\u001b[92m',
'§b': '\u001b[96m',
'§c': '\u001b[91m',
'§d': '\u001b[95m',
'§e': '\u001b[93m',
'§f': '\u001b[97m',
'§l': '\u001b[1m',
'§o': '\u001b[3m',
'§n': '\u001b[4m',
'§m': '\u001b[9m',
'§k': '\u001b[6m',
'§r': '\u001b[0m'
}
*/
};
let i = message;
+8 -8
View File
@@ -1,10 +1,10 @@
function usernameGen () {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
let username = '';
for (let i = 0; i < 10; i++ ) {
const randomIndex = Math.floor(Math.random() * characters.length);
username += characters[randomIndex];
}
return username;
}
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
let username = '';
for (let i = 0; i < 10; i++ ) {
const randomIndex = Math.floor(Math.random() * characters.length);
username += characters[randomIndex];
}
return username;
}
module.exports = usernameGen;