proxy preview + hash check change

This commit is contained in:
ChomeNS 2022-11-16 18:09:37 +07:00
parent 66bf765f8c
commit 9f8b4f6bd8
36 changed files with 149 additions and 51 deletions

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Sudo everyone on Ayunboom!',
trusted: 1,
usage: '<hash> <c:|command>',
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`);
} else {
throw new Error('Invalid hash');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the bot\'s username and UUID',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the UUID to your clipboard', color: 'green'}]}}]);
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -6,8 +6,8 @@ module.exports = {
description: 'Changes the bot\'s visibility',
usage: '<hash> <true|false>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
if (args[1] === 'true') {
bot.visibility = true;
bot.chat('/essentials:vanish disable');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'RecycleBot bruhify but actionbar',
usage: '<message>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.bruhifyText = args.join(' ');
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Executes a command in the command core',
usage: '<command>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.core.run(args.join(' '));
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the bot\'s changelog',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'Changelogs:', color: 'green'}]);
changelog.forEach((message, number) => {
number += 1;

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Clears the chat',
usage: '[specific] <player>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === 'specific') {
bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}]);
return;

View file

@ -4,7 +4,7 @@ module.exports = {
alias: ['ccq'],
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (bot.queue[0]) {
bot.queue = [];
}

View file

@ -65,10 +65,10 @@ module.exports = {
'<hash> <list>',
],
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (!bot.cloops) bot.cloops = [];
if (args[0] === bot.hash) {
if (args[0] === hash) {
if (args[1] === 'add' && args[3]) {
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval');
add(args.slice(3).join(' '), args[2], bot);

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Moo',
usage: '<cow|list> <message>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0]==='list') {
const listed = Object.keys(cows);

View file

@ -15,8 +15,8 @@ module.exports = {
description: 'Crashes the server',
usage: '<hash>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
crash(bot);
} else {
throw new Error('Invalid hash');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the bot\'s creator',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]);
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Shows the discord invite',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [
{
text: 'The Discord invite is ',

View file

@ -5,9 +5,9 @@ module.exports = {
description: 'Lags Eaglercraft and crashes it',
usage: '<on|off> <hash>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[1] === 'on') {
if (args[0] === bot.hash) {
if (args[0] === hash) {
bot.eaglercrashstarted = true;
bot.eaglercrash = setInterval(async function() {
if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0');
@ -18,7 +18,7 @@ module.exports = {
}
}
if (args[1] === 'off') {
if (args[0] === bot.hash) {
if (args[0] === hash) {
clearInterval(bot.eaglercrash);
bot.eaglercrashstarted = false;
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]');

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Says a message',
usage: '<message>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.chat(args.join(' '));
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Ends the bot\'s client',
usage: '<hash>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.end('end command');
} else {
throw new Error('Invalid hash');

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Summon any entity!',
usage: '[specific] <player>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
// eslint-disable-next-line no-unused-vars
const mcData = require('minecraft-data')(bot.version);

View file

@ -15,7 +15,7 @@ module.exports = {
'<reset>',
'<server (eval server)> <code>',
],
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === 'run') {
try {
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Execute command bypassed',
usage: '<hash> <command>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' '));
} else {
throw new Error('Invalid hash');

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Gamemode everyone',
usage: '<hash> <gamemode>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`);
} else {
throw new Error('Invalid hash');

View file

@ -8,7 +8,7 @@ module.exports = {
description: 'Shows the help',
usage: '[command]',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const generalCommands = [];
const trustedCommands = [];
const ownerCommands = [];

View file

@ -143,7 +143,7 @@ module.exports = {
'<nowplaying>',
'<queue>',
],
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
switch (args[0]) {
case 'play':
play(bot, args.slice(1));

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Broadcasts a message to all of the servers that the bot is connected',
usage: '<message>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const component = [
{
text: '[',

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Resets the bot\'s command core',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.core.loopPlace();
},
discordExecute: function(bot) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Randomly teleports the player',
usage: '',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`;
bot.tellraw('@a', [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]);
bot.core.run(`essentials:teleport ${sender} ${rtppos}`);

View file

@ -7,8 +7,8 @@ module.exports = {
description: 'Eval command without vm2',
trusted: 2,
usage: '<ownerhash> <code>',
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.ownerHash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === ownerhash) {
try {
bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
} catch (err) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Tests if the bot is working',
usage: '',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [
{
text: `Username: ${username},`,

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the time',
usage: '<timezone>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const timezone = args.join(' ');
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
const component = [{text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}];

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Teleport everyone',
usage: '<hash> <player>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`);
} else {
throw new Error('Invalid hash');

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the bot\'s uptime',
usage: '',
trusted: 0,
execute: function(bot) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]);
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Working Urban Dictionary',
usage: '<word>',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
urban.autocompleteExtra(args[0], (error, results) => {
if (error) {
bot.tellraw('@a', [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]);

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
usage: '',
trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0]) {
const playername = args.join(' ');
const player = bot.playersAddedPlayers[playername];

View file

@ -5,10 +5,10 @@ module.exports = {
alias: [],
usage: '<hash>',
trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.hash) {
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === hash) {
bot.tellraw('@a', {text: 'Valid hash', color: 'green'});
} else if (args[0] === bot.ownerHash) {
} else if (args[0] === ownerhash) {
bot.tellraw('@a', {text: 'Valid OwnerHash', color: 'green'});
} else {
bot.tellraw('@a', {text: 'Invalid hash', color: 'red'});

View file

@ -11,7 +11,7 @@ function inject(bot, dcclient, config) {
bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir));
};
bot.command_handler.reload();
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc) {
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash) {
bot.command_handler.reload();
let raw;
let command;
@ -28,7 +28,7 @@ function inject(bot, dcclient, config) {
if (typeof command.discordExecute === 'undefined') throw new Error('This command is not yet supported on discord!');
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config);
} else {
command.execute(bot, username, usernameraw, sender, prefix, args, config);
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash);
}
} catch (e) {
if (prefix === config.discord.prefix) {
@ -42,10 +42,10 @@ function inject(bot, dcclient, config) {
}
}
};
bot.command_handler.run = function(username, usernameraw, message, sender, channeldc) {
bot.command_handler.run = function(username, usernameraw, message, sender, channeldc, hash, ownerhash) {
for (const prefix of config.prefixes) {
if (!message.startsWith(prefix)) continue;
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc);
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash);
}
};
bot.on('message', async (_username, _message, _sender) => {
@ -57,7 +57,7 @@ function inject(bot, dcclient, config) {
if (!bot.getplayerusername[sender]) username = usernameraw;
else username = bot.getplayerusername[sender];
const message = _message.replace(/* /§r/g */ /§[a-f0-9rlonmk]/g, '')/* .replace(/§/g, '')*/;
bot.command_handler.run(username, usernameraw, message, sender);
bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash);
} catch (e) {
bot.console.error(e);
}

View file

@ -105,6 +105,9 @@ function inject(bot, _dcclient, config, rl) {
bot.username,
'*' + line.substring(1),
bot.uuid,
null,
'h',
'o',
);
}
bot.tellraw('@a', [

95
plugins/proxy.js Normal file
View file

@ -0,0 +1,95 @@
/* eslint-disable require-jsdoc */
const mc = require('minecraft-protocol');
function inject(bot, dcclient, config) {
config.servers.forEach((server, index) => {
if (server.host !== bot.options.host) return;
const {MessageBuilder} = require('prismarine-chat')(bot.version);
const version = bot.version;
const srv = mc.createServer({
'online-mode': false,
'port': 25566 + index,
'keepAlive': false,
version,
});
srv.on('login', function(client) {
bot.console.info(`[Proxy] ${client.username} connected to proxy`);
let endedClient = false;
let endedTarget = false;
const targetClient = mc.createClient({
username: client.username,
host: bot.options.host,
version,
});
targetClient.on('packet', (data, meta) => {
if (!endedClient &&
meta.state === mc.states.PLAY &&
client.state === mc.states.PLAY
) client.write(meta.name, data);
});
targetClient.on('error', () => {});
targetClient.on('end', () => {
targetClient.end();
endedTarget = true;
});
client.on('end', function() {
endedClient = true;
targetClient.end();
bot.console.info(`[Proxy] ${client.username} ended`);
});
client.on('error', function() {
endedClient = true;
bot.console.info(`[Proxy] ${client.username} got error`);
});
client.on('packet', (data, meta) => {
if (meta.name === 'chat' && !data.message?.startsWith('/')) {
if (data.message.startsWith('.')) {
return bot.command_handler.run(
client.username,
client.username,
'*' + data.message.substring(1),
client.uuid,
null,
'h',
'o',
);
}
bot.tellraw('@a', {
color: 'dark_gray',
translate: '[%s] [%s] %s \u203a %s',
with: [
{
text: 'Chat',
color: 'gray',
},
{
text: 'Proxy',
color: 'gray',
},
{
text: client.username,
color: 'green',
},
MessageBuilder.fromString('&7' + data.message),
],
});
return;
}
targetClient.write(meta.name, data);
});
bot.on('end', () => srv.close());
});
});
};
module.exports = {inject};