mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-11-29 13:45:38 -05:00
refractured the base and added some shit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import optionss from './options';
|
||||
|
||||
import { chat } from './modules/chat';
|
||||
import { commandHandler } from './modules/commandHandler';
|
||||
import { Console } from './modules/console';
|
||||
import { memUsage } from './modules/memUsage';
|
||||
import { players } from './modules/players';
|
||||
import { registry } from './modules/registry';
|
||||
import { selfcare } from './modules/selfcare';
|
||||
import { tabComplete } from './modules/tabComplete';
|
||||
import { position } from './modules/position';
|
||||
import { core } from './modules/core';
|
||||
import { reconnect } from './modules/reconnect';
|
||||
import { commandManager } from './modules/commandManager';
|
||||
|
||||
export default class FNFBoyfriendBot extends EventEmitter {
|
||||
public _client: any
|
||||
public bots: any;
|
||||
public chat: any;
|
||||
public core: any;
|
||||
public console: any;
|
||||
public entityId: number;
|
||||
public modules: any;
|
||||
public options: any;
|
||||
public players: any;
|
||||
public position: any;
|
||||
public reconnectDelay: any;
|
||||
public registry: any;
|
||||
public selfcare: any;
|
||||
public tabcomplete: any;
|
||||
constructor (options: any, config: any) {
|
||||
super();
|
||||
const defaultOptions = new optionss()
|
||||
this.options = {
|
||||
host: options.host ??= defaultOptions.host,
|
||||
port: options.port ??= defaultOptions.port,
|
||||
username: options.username ??= defaultOptions.username,
|
||||
version: options.version ??= defaultOptions.version,
|
||||
hideErrors: options.hideErrors ??= defaultOptions.hideErrors,
|
||||
scInterval: options.scInterval ??= defaultOptions.scInterval,
|
||||
reconnectDelay: options.reconnectDelay ?? defaultOptions.reconnectDelay
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
new chat({ bot: this, config });
|
||||
new Console({ bot: this, config });
|
||||
new players({ bot: this, config });
|
||||
new registry({ bot: this, config });
|
||||
new selfcare({ bot: this, config });
|
||||
new tabComplete({ bot: this, config });
|
||||
new memUsage({ bot: this, config });
|
||||
new reconnect({ bot: this, config });
|
||||
new position({ bot: this, config });
|
||||
new core({ bot: this, config });
|
||||
new commandHandler({ bot: this, config })
|
||||
}
|
||||
}
|
||||
+5
-21
@@ -1,26 +1,10 @@
|
||||
import mc from "minecraft-protocol";
|
||||
import { EventEmitter } from "events";
|
||||
import FNFBoyfriendBot from "./FNFBoyfriendBot";
|
||||
|
||||
export class createBot {
|
||||
bot: any;
|
||||
bots: any;
|
||||
debugEnabled: any;
|
||||
console: any;
|
||||
|
||||
constructor (options: any) {
|
||||
this.bot = new EventEmitter();
|
||||
|
||||
const bot = this.bot;
|
||||
|
||||
bot.options = {
|
||||
host: (options.host ??= "localhost"),
|
||||
username: (options.username ??= "Player"),
|
||||
version: (options.version ??= "1.21.8"),
|
||||
hideErrors: (options.hideErrors ??= true),
|
||||
scInterval: (options.scInterval ??= 1000)
|
||||
}
|
||||
|
||||
bot.options = options;
|
||||
export class createBot extends FNFBoyfriendBot {
|
||||
constructor (options: any, config: any) {
|
||||
super(options, config);
|
||||
const bot = this;
|
||||
|
||||
bot.on("init_client", (client: any) => {
|
||||
client?.on('packet', (data: any, meta: any) => {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export class source {
|
||||
public player: any;
|
||||
public uuid: any;
|
||||
public prefix: any;
|
||||
|
||||
constructor (player: any, uuid: any, prefix: any) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
constructor(player, sources, ChatType) {
|
||||
this.player = player;
|
||||
this.sources = sources;
|
||||
this.ChatType = ChatType;
|
||||
this.player.trustLevel = 0;
|
||||
}
|
||||
}
|
||||
module.exports = CommandSource;
|
||||
*/
|
||||
@@ -0,0 +1,38 @@
|
||||
import translations from '../../resources/translations.json';
|
||||
|
||||
export default function format (
|
||||
bot: any,
|
||||
time: any,
|
||||
dayName: any,
|
||||
month: any,
|
||||
dayNumber: any,
|
||||
year: any,
|
||||
type: any,
|
||||
server: any,
|
||||
message: any,
|
||||
) {
|
||||
let component = [
|
||||
{
|
||||
translate: translations["console.format.text"],
|
||||
color: "light_purple",
|
||||
with: [
|
||||
{ text: `${time}`, color: "blue" },
|
||||
{
|
||||
translate: translations["console.format.date"],
|
||||
color: "aqua",
|
||||
with: [
|
||||
dayName,
|
||||
month,
|
||||
dayNumber,
|
||||
year
|
||||
]
|
||||
},
|
||||
type,
|
||||
{ text: `${server}`, color: "aqua" },
|
||||
]
|
||||
|
||||
},
|
||||
bot.getMessageAsPrismarine(message)?.toAnsi()
|
||||
]
|
||||
return component;
|
||||
}
|
||||
+6
-9
@@ -1,10 +1,9 @@
|
||||
import fs from "fs";;
|
||||
import path from "path";
|
||||
import readline from 'readline'
|
||||
import fs from "fs";
|
||||
import path from "path"
|
||||
import readline from 'readline';
|
||||
import { createBot } from "./bot";
|
||||
import { parseToml } from './util/parseToml';
|
||||
import loadModules from './util/loadModules';
|
||||
import version from './data/version.json'
|
||||
import version from './resources/version.json';
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
@@ -23,10 +22,8 @@ const config = parseToml('./config.toml');
|
||||
const bots = [];
|
||||
|
||||
for (const options of config.bots) {
|
||||
const bot = new createBot(options);
|
||||
bot.debugEnabled = debugEnabled;
|
||||
let bot = new createBot(options, config);
|
||||
bots.push(bot);
|
||||
bot.bots = bots;
|
||||
loadModules(bot, config, rl);
|
||||
bot?.console?.interface(rl);
|
||||
bot.console.interface(rl)
|
||||
}
|
||||
+8
-6
@@ -26,7 +26,7 @@ function parseChatType (chatTypes: any, type: any, sender: any, target: any, mes
|
||||
return json
|
||||
}
|
||||
|
||||
export default class chat {
|
||||
export class chat {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
@@ -42,7 +42,8 @@ export default class chat {
|
||||
chatTypes = packet.entries
|
||||
})
|
||||
|
||||
bot.chatParsers = [kaboom, chipmunkmod]
|
||||
bot.chatParsers = [kaboom, chipmunkmod];
|
||||
|
||||
/* if (options.mode === "savageFriends") {
|
||||
bot.chatParsers = [creayun];
|
||||
} else {
|
||||
@@ -79,14 +80,14 @@ export default class chat {
|
||||
message: unsigned
|
||||
})
|
||||
|
||||
if (bot.debugEnabled) bot.emit("player", unsigned)
|
||||
|
||||
parseMessage(unsigned, {
|
||||
senderUuid: packet.senderUuid,
|
||||
players: bot.players,
|
||||
getMessageAsPrismarine: bot.getMessageAsPrismarine,
|
||||
chatType: "minecraft:player_chat"
|
||||
});
|
||||
|
||||
if (bot.debugEnabled) bot.emit("player", unsigned)
|
||||
});
|
||||
|
||||
bot.on("packet.system_chat", (packet: any) => {
|
||||
@@ -127,6 +128,7 @@ export default class chat {
|
||||
}
|
||||
|
||||
if (!parsed) return;
|
||||
|
||||
bot.emit("parsed_message", parsed);
|
||||
} catch (e: unknown) {
|
||||
console.log(e);
|
||||
@@ -153,7 +155,7 @@ export default class chat {
|
||||
bot._client.write("chat_message", {
|
||||
message: message?.substring(0, 256)?.replaceAll("§", "&"),
|
||||
timestamp: BigInt(Date.now()),
|
||||
// salt: 0n,
|
||||
salt: 0n,
|
||||
offset: 0,
|
||||
acknowledged: bitset,
|
||||
});
|
||||
@@ -163,7 +165,7 @@ export default class chat {
|
||||
bot._client.write("chat_command", {
|
||||
command: command?.substring(0, 256)?.replaceAll("§", "&"),
|
||||
timestamp: BigInt(Date.now()),
|
||||
// salt: 0n,
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export default class commandHandler {
|
||||
import { source } from '../command/source';
|
||||
|
||||
export class commandHandler {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
@@ -8,19 +10,17 @@ export default class commandHandler {
|
||||
try {
|
||||
const prefixes = config.prefixes;
|
||||
const message = packet.contents;
|
||||
const color = message.color;
|
||||
let text;
|
||||
if (message.extra) text = message.extra[0];
|
||||
else text = message.text;
|
||||
|
||||
//console.log(message)
|
||||
// console.log(bot.getMessageAsPrismarine(message))
|
||||
//const e = bot.getMessageAsPrismarine(message)?.toMotd();
|
||||
//console.log(e)
|
||||
const plainMessage = bot.getMessageAsPrismarine(message)?.toString();
|
||||
|
||||
for (const prefix of prefixes) {
|
||||
if (!plainMessage.startsWith(prefix)) return;
|
||||
const command = plainMessage.substring(prefix.length);
|
||||
const getPrefix = plainMessage.split(command)[0];
|
||||
bot.core.run(command)
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
if (e instanceof Error) bot.console.info(e.stack)
|
||||
}
|
||||
//console.log(packet)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export class commandManager {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
|
||||
}
|
||||
}
|
||||
+15
-5
@@ -1,9 +1,10 @@
|
||||
export default class Console {
|
||||
import translations from '../resources/translations.json';
|
||||
import format from '../data/console/format';
|
||||
export class Console {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
|
||||
let host = `${options.host}:${options.port}`;
|
||||
|
||||
bot.console = {
|
||||
@@ -15,6 +16,7 @@ export default class Console {
|
||||
this.readline = rl;
|
||||
|
||||
rl.on("line", (args: any) => {
|
||||
console.log(args)
|
||||
if (options.serverName !== this.server && this.server !== "all") return;
|
||||
|
||||
if (args.startsWith(config.console.prefix)) {
|
||||
@@ -36,9 +38,17 @@ export default class Console {
|
||||
},
|
||||
|
||||
prefix(type: any, server: any, message: any) {
|
||||
let time = new Date().toLocaleTimeString("en-US", { timeZone: config.console.timezone });
|
||||
let date = new Date().toLocaleDateString("en-US", { timeZone: config.console.timezone })
|
||||
return bot.getMessageAsPrismarine(`§8[§1${time} §3${date} ${type}§8] §8[§b${server}§8]§r `)?.toAnsi() + bot.getMessageAsPrismarine(message)?.toAnsi()
|
||||
// i read the firefox docs to see how to get elements of date seperately if that makes any sense
|
||||
const timeZone = config.console.timeZone
|
||||
const dayName = new Date().toLocaleDateString('en-US', { weekday: 'long', timeZone });
|
||||
const dayNumber = new Date().toLocaleDateString('en-US', { day: 'numeric', timeZone });
|
||||
const month = new Date().toLocaleDateString('en-US', { month: 'long', timeZone });
|
||||
const year = new Date().toLocaleDateString('en-US', { year: 'numeric', timeZone });
|
||||
//const date = format(translations['console.format.date'], `${dayName}`, `${month}`, `${dayNumber}`, `${year}`);
|
||||
const time = new Date().toLocaleTimeString("en-US", { timeZone });
|
||||
const consoleFormat = format(bot, time, dayName, month, dayNumber, year, type, server, message);
|
||||
|
||||
return bot.getMessageAsPrismarine(consoleFormat)?.toAnsi()
|
||||
},
|
||||
|
||||
log(message: any) {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// i may or may not have used v4's command core for a base here
|
||||
|
||||
export class core {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
|
||||
bot.core = {
|
||||
area: {
|
||||
start: options.core?.area.start ?? { x: 0, y: 0, z: 0 },
|
||||
end: options.core?.area.end ?? { x: 15, y: 0, z: 15 }
|
||||
},
|
||||
position: null,
|
||||
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
||||
|
||||
refill () {
|
||||
const pos = bot.core.position
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
if (!pos) return
|
||||
|
||||
bot.chat.command(`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`)
|
||||
},
|
||||
|
||||
move (pos = bot.position) {
|
||||
bot.core.position = {
|
||||
x: Math.floor(pos.x / 16) * 16,
|
||||
y: 0,
|
||||
z: Math.floor(pos.z / 16) * 16
|
||||
}
|
||||
bot.core.refill()
|
||||
},
|
||||
|
||||
currentBlock () {
|
||||
const relativePosition = bot.core.currentBlockRelative
|
||||
const corePosition = bot.core.position
|
||||
if (!corePosition) return null
|
||||
return { x: relativePosition.x + corePosition.x, y: relativePosition.y + corePosition.y, z: relativePosition.z + corePosition.z }
|
||||
},
|
||||
|
||||
incrementCurrentBlock () {
|
||||
const relativePosition = bot.core.currentBlockRelative
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
relativePosition.x++
|
||||
|
||||
if (relativePosition.x > end.x) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.z++
|
||||
}
|
||||
|
||||
if (relativePosition.z > end.z) {
|
||||
relativePosition.z = start.z
|
||||
relativePosition.y++
|
||||
}
|
||||
|
||||
if (relativePosition.y > end.y) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.y = start.y
|
||||
relativePosition.z = start.z
|
||||
}
|
||||
},
|
||||
|
||||
run (command: any) {
|
||||
const location = bot.core.currentBlock()
|
||||
if (!location) return
|
||||
|
||||
bot._client.write('update_command_block', { command, location, mode: 1, flags: 0b100 })
|
||||
|
||||
bot.core.incrementCurrentBlock()
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('move', () => {
|
||||
bot.core.move(bot.position)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { connect } from 'socket.io-client';
|
||||
import version from '../data/version.json';
|
||||
|
||||
export default class debugBridge {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
|
||||
if (!bot.debugEnabled) return;
|
||||
|
||||
bot.debugBridge = {
|
||||
client: connect(config.debug.host)
|
||||
}
|
||||
// `Starting FNFBoyfriendBot ${version.codename} ${version.version} Build: ${version.build}`
|
||||
const client = bot.debugBridge.client;
|
||||
|
||||
client.on('connect', (socket: any) => {
|
||||
bot.console.info('Connected to Debug Bridge');
|
||||
|
||||
bot.emit('version', { version: version.version, codename: version.codename, build: version.build })
|
||||
|
||||
bot.on('disguised', (data: any) => socket.emit('diguised', data));
|
||||
|
||||
bot.on('player', (data: any) => socket.emit('player', data));
|
||||
|
||||
bot.on('system', (data: any) => socket.emit('system', data));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import v8 from 'v8';
|
||||
const { heap_size_limit } = v8.getHeapStatistics();
|
||||
|
||||
export class memUsage {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
|
||||
setInterval(() => {
|
||||
let mbDivide = 1048576;
|
||||
bot.console.info(`[Heap Memory] ${Math.floor(process.memoryUsage().heapUsed / mbDivide)} MB / ${Math.floor(process.memoryUsage().heapTotal / mbDivide)} MB`);
|
||||
bot.console.info(`[Process Memory] ${Math.floor(process.memoryUsage.rss() / mbDivide)} MB / ${Math.floor(heap_size_limit / mbDivide - 192)} MB`);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
setInterval(() => {
|
||||
let osMemUsed = Math.floor((totalmem() / mbDivide) - freemem() / mbDivide)
|
||||
console.log(`Heap mem: ${Math.floor(heapUsed / mbDivide)} MB / ${Math.floor(heapTotal / mbDivide)} MB`);
|
||||
console.log(`Process mem: ${Math.floor(rss / mbDivide)} MB / ${Math.floor(heap_size_limit) / mbDivide} MB`);
|
||||
console.log(`OS mem: ${osMemUsed} MB / ${Math.floor(totalmem() / mbDivide)} MB`)
|
||||
}, 1000)
|
||||
*/
|
||||
@@ -2,7 +2,7 @@ const convertNbtComponentToJson = require("../util/convertNbtComponentToJson");
|
||||
const entityUUID = require('../util/entityUUID');
|
||||
|
||||
// taken from FNFBoyfriendBot v8.0.0
|
||||
export default class playerList {
|
||||
export class players {
|
||||
constructor(context: any) {
|
||||
const bot = context.bot;
|
||||
bot.players = [];
|
||||
@@ -25,7 +25,7 @@ export default class playerList {
|
||||
bot.on("packet.player_remove", async ({ players }: { players: any }) => {
|
||||
// players has uuids of the players
|
||||
let player_completion = (
|
||||
await bot.tab_complete("scoreboard players add ")
|
||||
await bot.tabcomplete("scoreboard players add ")
|
||||
).filter((_: any) => _.tooltip == undefined); // exclude @a, @r, @s, @e, @p -aaa
|
||||
bot.players.forEach(async (player: any) => {
|
||||
if (!players.includes(player.uuid)) return;
|
||||
@@ -0,0 +1,20 @@
|
||||
export class position {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
|
||||
bot.position = null;
|
||||
|
||||
bot.on('packet.position', (packet: any) => {
|
||||
bot.position = {
|
||||
x: packet.x,
|
||||
y: packet.y,
|
||||
z: packet.z
|
||||
}
|
||||
bot._client.write("teleport_confirm", { teleportId: packet.teleportId });
|
||||
|
||||
bot.emit("move");
|
||||
});
|
||||
|
||||
bot.on('end', () => bot.position = null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import mc from 'minecraft-protocol';
|
||||
|
||||
export class reconnect {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
bot.reconnectDelay = options.reconnectDelay;
|
||||
let client;
|
||||
|
||||
bot.on('end', () => {
|
||||
setTimeout(() => {
|
||||
client = options.client ?? mc.createClient(options);
|
||||
bot._client = client;
|
||||
bot.emit("init_client", bot._client);
|
||||
}, bot.reconnectDelay);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bot.on("end", () => {
|
||||
setTimeout(() => {
|
||||
if (options.usernameGen) {
|
||||
client =
|
||||
options.client ??
|
||||
mc.createClient(options, (options.username = usernameGen()));
|
||||
} else {
|
||||
client = options.client ?? mc.createClient(options);
|
||||
}
|
||||
bot._client = client;
|
||||
bot.emit("init_client", bot._client);
|
||||
}, bot.reconnectDelay);
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = reconnect;
|
||||
|
||||
*/
|
||||
+8
-12
@@ -1,20 +1,16 @@
|
||||
import createRegistry from 'prismarine-registry';
|
||||
import language from '../resources/language.json';
|
||||
|
||||
export default class registry {
|
||||
export class registry {
|
||||
constructor(context: any) {
|
||||
const bot = context.bot;
|
||||
bot.once("packet.login", (packet: any) => {
|
||||
bot.registry = createRegistry(bot._client.version);
|
||||
// bot.registry.language = require("../data/language.json");
|
||||
bot.emit("registry_ready", bot.registry);
|
||||
});
|
||||
|
||||
bot.registry = createRegistry(bot.options.version);
|
||||
bot.registry.language = language;
|
||||
bot.emit("registry_ready", bot.registry);
|
||||
|
||||
/* bot.on('packet.registry_data', async (packet: ant) => {
|
||||
await sleep(1000)
|
||||
if (bot.loggedIn) {
|
||||
bot.registry.loadDimensionCodec(packet)
|
||||
}
|
||||
})*/
|
||||
bot.on('packet.registry_data', (packet: any) => {
|
||||
bot.registry.loadDimensionCodec(packet)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
export default class selfcare {
|
||||
export class selfcare {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// taken from FNFBoyfriendBot v8.0.0
|
||||
|
||||
export default class tabComplete {
|
||||
export class tabComplete {
|
||||
constructor(context: any) {
|
||||
const bot = context.bot;
|
||||
// let aaa cook
|
||||
bot.tab_complete = (str: any) => {
|
||||
bot.tabcomplete = (str: any) => {
|
||||
return new Promise((resolve) => {
|
||||
bot._client.write("tab_complete", {
|
||||
text: str,
|
||||
@@ -0,0 +1,12 @@
|
||||
import { usernameGen } from './util/usernameGen';
|
||||
|
||||
export default class options {
|
||||
public host: string = "localhost"
|
||||
public port: number = 25565;
|
||||
public username = usernameGen();
|
||||
public serverName: string = "localhost";
|
||||
public hideErrors: boolean = true;
|
||||
public scInterval: number = 1000;
|
||||
public version: '1.21.8';
|
||||
public reconnectDelay: number = 3000
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"console.format.date": "%s, %s %s, %s",
|
||||
"console.format.text": "[%s %s %s] [%s] "
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"build": "5000",
|
||||
"codename": "§cReimu",
|
||||
"codename": "§5Madoka",
|
||||
"version": "v9.0.0-alpha"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export default async function loadModules (bot: any, config: any, rl: any) {
|
||||
bot.modules = []
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../modules'))) {
|
||||
try {
|
||||
if (filename.endsWith(".ts") || filename.endsWith(".js")) {
|
||||
const module = await import(path.join(__dirname, '../modules/', filename))
|
||||
const modules = module.default;
|
||||
bot.modules.push(modules)
|
||||
new modules({ bot, config })
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error(`Failed to load module ${filename} due to error`);
|
||||
console.error(`\x1b[31m${error.stack}\x1b[0m`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bot.debugEnabled) console.info(`Loaded ${bot.modules.length} Modules`);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export function usernameGen() {
|
||||
const characters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
let username = "";
|
||||
for (let i = 0; i < 3 + Math.floor(Math.random() * 14); i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
username += characters[randomIndex];
|
||||
}
|
||||
return username;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
const io = require('socket.io-client');
|
||||
|
||||
const client = io.connect('http://localhost:8080');
|
||||
|
||||
client.on('connect', () => {
|
||||
client.emit('meow', ':3')
|
||||
})
|
||||
@@ -1,23 +0,0 @@
|
||||
const io = require('socket.io');
|
||||
let port = 8080;
|
||||
// should i even have this here?
|
||||
const server = new io.Server(8080);
|
||||
console.log('server started');
|
||||
|
||||
server.on('connection', (socket) => {
|
||||
socket.on('player', (data) => {
|
||||
console.log(data)
|
||||
});
|
||||
|
||||
socket.on('disguised', (data) => {
|
||||
console.log(data)
|
||||
});
|
||||
|
||||
socket.on('system', (data) => {
|
||||
console.log(data)
|
||||
});
|
||||
|
||||
/* socket.on('meow', (data) => {
|
||||
console.log(data)
|
||||
})*/
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
const v8 = require('v8');
|
||||
const { totalmem, freemem } = require('os');
|
||||
const { heap_size_limit } = v8.getHeapStatistics();
|
||||
const { heapUsed, heapTotal, rss } = process.memoryUsage();
|
||||
let mbDivide = 1048576;
|
||||
setInterval(() => {
|
||||
let osMemUsed = Math.floor((totalmem() / mbDivide) - freemem() / mbDivide)
|
||||
console.log(`Heap mem: ${Math.floor(heapUsed / mbDivide)} MB / ${Math.floor(heapTotal / mbDivide)} MB`);
|
||||
console.log(`Process mem: ${Math.floor(rss / mbDivide)} MB / ${Math.floor(heap_size_limit / mbDivide - 192)} MB`);
|
||||
console.log(`OS mem: ${osMemUsed} MB / ${Math.floor(totalmem() / mbDivide)} MB`)
|
||||
}, 1000)
|
||||
Generated
+1
-202
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "FNFBoyfriendBot-Reimu",
|
||||
"name": "FNFBoyfriendBot-Madoka",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@@ -9,7 +9,6 @@
|
||||
"prismarine-chat": "^1.12.0",
|
||||
"prismarine-registry": "^1.11.0",
|
||||
"smol-toml": "^1.5.2",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"yaml": "^2.8.2"
|
||||
},
|
||||
@@ -46,15 +45,6 @@
|
||||
"integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/cors": {
|
||||
"version": "2.8.19",
|
||||
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz",
|
||||
"integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.10.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.2.tgz",
|
||||
@@ -110,19 +100,6 @@
|
||||
"node": ">=6.5"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/aes-js": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz",
|
||||
@@ -180,15 +157,6 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/base64id": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
|
||||
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^4.5.0 || >= 5.9"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
|
||||
@@ -237,28 +205,6 @@
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cors": {
|
||||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
@@ -297,26 +243,6 @@
|
||||
"integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/engine.io": {
|
||||
"version": "6.6.4",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz",
|
||||
"integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/node": ">=10.0.0",
|
||||
"accepts": "~1.3.4",
|
||||
"base64id": "2.0.0",
|
||||
"cookie": "~0.7.2",
|
||||
"cors": "~2.8.5",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.17.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client": {
|
||||
"version": "6.6.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.3.tgz",
|
||||
@@ -356,23 +282,6 @@
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
@@ -552,27 +461,6 @@
|
||||
"integrity": "sha512-vGBKTA+jwM4KgjGZ+S/8/Mkj9rWzePyGY6jManXPGhiWu63RYwW8dKPyk5koP+8qNVhPhHgFa1y/MJ4wrjsNrg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/minecraft-data": {
|
||||
"version": "3.101.0",
|
||||
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.101.0.tgz",
|
||||
@@ -659,15 +547,6 @@
|
||||
"url": "https://nearley.js.org/#give-to-nearley"
|
||||
}
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
@@ -697,15 +576,6 @@
|
||||
"asn1": "0.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prismarine-auth": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-2.7.0.tgz",
|
||||
@@ -937,51 +807,6 @@
|
||||
"url": "https://github.com/sponsors/cyyynthia"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io": {
|
||||
"version": "4.8.1",
|
||||
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
|
||||
"integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.4",
|
||||
"base64id": "~2.0.0",
|
||||
"cors": "~2.8.5",
|
||||
"debug": "~4.3.2",
|
||||
"engine.io": "~6.6.0",
|
||||
"socket.io-adapter": "~2.5.2",
|
||||
"socket.io-parser": "~4.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-adapter": {
|
||||
"version": "2.5.5",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
|
||||
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "~4.3.4",
|
||||
"ws": "~8.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-adapter/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-client": {
|
||||
"version": "4.8.1",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.1.tgz",
|
||||
@@ -1044,23 +869,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
||||
@@ -1109,15 +917,6 @@
|
||||
"macaddress": "^0.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"prismarine-chat": "^1.12.0",
|
||||
"prismarine-registry": "^1.11.0",
|
||||
"smol-toml": "^1.5.2",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"yaml": "^2.8.2"
|
||||
},
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@
|
||||
"moduleDetection": "force",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"strictPropertyInitialization": false,
|
||||
},
|
||||
"exclude": ["./debug-bridge", "./build"]
|
||||
"exclude": ["./build", "./memoryTest.js"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user