hacky porting

This commit is contained in:
Chipmunk 2024-02-12 21:54:29 -05:00
parent ebde071dae
commit 716257c45f
16 changed files with 145 additions and 155 deletions

View file

@ -1,10 +1,10 @@
const name = 'destroy'
const description = 'destroy'
const usage = '{prefix}destroy'
const usages = ['destroy']
const aliases = ['destroy']
const enabled = true
const permLevel = 1
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
let i = 0
@ -14,4 +14,4 @@ function execute (bot, cmd, entity, args, handler) {
}, 1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,17 +0,0 @@
const name = 'dragonfard'
const description = 'slash summon ender dragon'
const usage = '{prefix}dragonfard'
const aliases = ['dragonfard']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
let i = 0
setInterval(() => {
bot.core.run(`/execute at @e run setblock ~ 1 ~${i++} command_block{Command:'summon ender_dragon ~ ~ ~ {Health:0}',auto:1} destroy`)
if (i > 50) { i = 0 }
}, 1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,22 +0,0 @@
const name = 'fard2'
const description = 'CustomName'
const usage = '{prefix}fard2'
const aliases = ['fard2']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
let cmd1 = 'title @a title "'
let prevCmd1 = ''
while ((cmd1.length + 1) < 32767) {
prevCmd1 = cmd1
cmd1 += 'e'
}
prevCmd1 += '"'
bot.core.run(prevCmd1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,14 +0,0 @@
const name = 'fard4'
const description = 'data modify storage'
const usage = '{prefix}fard4'
const aliases = ['fard4']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
bot.core.run('/data modify storage e e set value [e,e,e,e,e]')
setTimeout(() => bot.cloops.push({ command: '/data modify storage e e append from storage e e[]', interval: 1 }), 69)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -14,15 +14,15 @@ const permLevel = 0
const fs = require('fs')
const path = require('path')
const https = require('https')
const tmp = require('tmp')
function execute (bot, cmd, player, args, handler) {
const subCmd = args.shift()
let filepath, tmpobj, file, files, primary, msg, split
let filepath, file, files, primary, msg, split
switch (subCmd) {
case 'play':
filepath = args.join(' ').replace(/\xa7.?/g, '')
/*
if (/https?:\/\//.test(filepath)) {
https.get(filepath, (res) => {
// Open file in local filesystem
@ -42,6 +42,7 @@ function execute (bot, cmd, player, args, handler) {
// });
return
}
*/
filepath = path.join('music', filepath)
// if (!filepath.endsWith('.mid')) { filepath += '.mid' }

View file

@ -1,18 +0,0 @@
const name = 'net'
const description = 'Runs a command as each bot.'
const usage = '{prefix}netcb <command...>'
const aliases = ['net']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const command = args.shift()
if (handler.info(command).name === name) { return bot.core.run(`/tellraw @a ${JSON.stringify({ text: 'You may not run net using net.', color: bot.colors.error })}`) }
bot.getBots().forEach((bot) => {
handler.execute(bot, command, player, args.slice(0))
})
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'play'
const description = 'Runs a command in the command core'
const usage = '{prefix}cb <command...>'
const aliases = ['cb']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'scare'
const description = 'i am have clien lag help me pls'
const usage = '{prefix}scare'
const aliases = ['scare']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
bot.cloops.push({ command: `scare ${args.join(' ')}`, interval: 1 })
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,19 +0,0 @@
const name = 'translate'
const description = 'Translates text.'
const usages = ['<language> <text>']
const aliases = ['translate']
const enabled = true
const permLevel = 0
const { Translate } = require('translate')
async function execute (bot, cmd, player, args, handler) {
const language = args.shift()
const text = args.join(' ').replace(/§.?/g, '')
bot.core.run(`minecraft:tellraw @a ${JSON.stringify(
{ text: JSON.stringify(await Translate(text, language)), color: bot.colors.primary }
)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -12,31 +12,30 @@ const fs = require('fs')
const path = require('path')
const moment = require('moment')
let filepath = path.join('logs', moment().format('YYYY-MM-DD') + '.log')
const logDir = 'logs'
if (!fs.existsSync(logDir)) fs.mkdirSync(logDir)
let filepath = path.join(logDir, moment().format('YYYY-MM-DD'))
if (fs.existsSync(filepath)) {
const suspath = filepath + '-'
const pathWithSeparator = filepath + '-'
let i = 0
while (fs.existsSync(filepath)) {
filepath = suspath + (i++)
filepath = pathWithSeparator + (i++)
}
}
filepath += '.log'
fs.writeFileSync(filepath, '')
const servers = [
'kaboom.pw:25565:kaboom',
's.veast.network:25565:kaboom',
'play.cyclenet.eu:25560:kaboom',
// 'legunepw.apexmc.co:25565:kaboom',
'ssandcat.aternos.me:25565:vanilla'
// 'kittyandhawk.ddns.net:25565:vanilla'
'chipmunk.land:25565:kaboom'
]
const bots = createBots(servers, {
username: ' ',
username: 'MusicBot',
prefix: "'",
colors: { primary: 'green', secondary: 'dark_green', error: 'red' },
version: '1.17.1',
randomizeUsername: true,
version: '1.20.4',
randomizeUsername: false,
autoReconnect: true
// 'online-mode': { enabled: false, username: 'removed lol', password: null }
})

View file

@ -1,6 +0,0 @@
const sus = require('./bot')
const servers = ['kaboom.pw:25565:kaboom', '']
sus.createBots(servers, {
username: ' '
}).forEach((bot) => bot.on('login', () => bot.chatQueue.push('i accidentally deleted index.js and lost console code lol')))

View file

@ -89,7 +89,7 @@
},
"_ChipMC_": {
"first": "2022-03-11T21:15:24.931Z",
"last": "2022-03-22T03:26:08.097Z"
"last": "2024-02-12T03:43:21.153Z"
},
"Dinutil§玃§封§<E5B081>": {
"first": "2022-03-11T21:15:24.931Z",
@ -49854,5 +49854,73 @@
"§a6jKKksNm9hi3": {
"first": "2022-03-22T03:26:07.918Z",
"last": "2022-03-22T03:26:08.097Z"
},
"§7§6§n§k§b§lHBot": {
"first": "2024-02-12T02:49:06.330Z",
"last": "2024-02-12T02:59:03.100Z"
},
"iHxOL3uXYfwpPPDO": {
"first": "2024-02-12T02:49:06.332Z",
"last": "2024-02-12T02:57:54.091Z"
},
"1bhBPyAq8": {
"first": "2024-02-12T02:49:06.333Z",
"last": "2024-02-12T03:16:51.738Z"
},
"§c§3§3§5§b§lHBot": {
"first": "2024-02-12T03:00:18.499Z",
"last": "2024-02-12T03:00:18.500Z"
},
"Z9CcyAPHspfvUiwO": {
"first": "2024-02-12T03:00:18.500Z",
"last": "2024-02-12T03:00:18.500Z"
},
"SBot_zlfIjtU": {
"first": "2024-02-12T03:03:21.257Z",
"last": "2024-02-12T03:03:21.258Z"
},
"MiBF1qnFN": {
"first": "2024-02-12T03:03:21.258Z",
"last": "2024-02-12T03:07:00.476Z"
},
"첎绗粉앳䢳蹷酑嶏": {
"first": "2024-02-12T03:03:21.258Z",
"last": "2024-02-12T03:03:21.258Z"
},
"Thorioum": {
"first": "2024-02-12T03:03:21.258Z",
"last": "2024-02-12T03:05:13.445Z"
},
"bruhmoment": {
"first": "2024-02-12T03:03:21.258Z",
"last": "2024-02-12T03:04:32.184Z"
},
"SBot_aE0Rh03": {
"first": "2024-02-12T03:05:13.444Z",
"last": "2024-02-12T03:05:13.570Z"
},
"㣵㥗瀭氷徭㎪愆풞૰ώ⦇␤먼♑羥": {
"first": "2024-02-12T03:05:13.445Z",
"last": "2024-02-12T03:05:13.445Z"
},
"WhyMustUDoDis": {
"first": "2024-02-12T03:05:13.445Z",
"last": "2024-02-12T03:05:13.614Z"
},
"SBot_DAJhfMD": {
"first": "2024-02-12T03:06:57.922Z",
"last": "2024-02-12T03:06:58.511Z"
},
"謹䵣♯쟗ꩣ뗲뵨㦫": {
"first": "2024-02-12T03:06:58.511Z",
"last": "2024-02-12T03:06:59.304Z"
},
"§9§3§1§9§b§lHBot": {
"first": "2024-02-12T03:12:45.902Z",
"last": "2024-02-12T03:43:21.153Z"
},
"4nr6OfyCxS": {
"first": "2024-02-12T03:12:45.905Z",
"last": "2024-02-12T03:18:07.937Z"
}
}

View file

@ -44,7 +44,7 @@ function client (bot, client) {
if (packet.health <= 0) { bot._client.write('client_command', { payload: 0 }) }
})
bot._client.on('declare_commands', () => bot.chat.queue.push(bot.brand === 'kaboom' ? '/op @s[type=player]' : '/trigger opme')) // assumes that the vanilla server has an 'opme' trigger
// bot._client.on('declare_commands', () => bot.chat.queue.push(bot.brand === 'kaboom' ? '/op @s[type=player]' : '/trigger opme')) // assumes that the vanilla server has an 'opme' trigger
}
module.exports = { bot, client }

View file

@ -1,16 +1,49 @@
const parseText = require('./../util/text_parser.js')
const nbt = require('prismarine-nbt')
function bot (bot) {
bot.chat = {
queue: [],
patterns: []
patterns: [],
message (message) {
const acc = 0
const bitset = Buffer.allocUnsafe(3)
bitset[0] = acc & 0xFF
bitset[1] = (acc >> 8) & 0xFF
bitset[2] = (acc >> 16) & 0xFF
bot._client.write('chat_message', {
message,
timestamp: BigInt(Date.now()),
salt: 0n,
offset: 0,
acknowledged: bitset
})
},
command (command) {
bot._client.write('chat_command', {
command,
timestamp: BigInt(Date.now()),
salt: 0n,
argumentSignatures: [],
signedPreview: false,
messageCount: 0,
acknowledged: Buffer.alloc(3),
previousMessages: []
})
}
}
setInterval(() => {
if (!bot.loggedIn) { return }
const message = bot.chat.queue.shift()
if (message != null) {
bot._client.write('chat', { message })
if (message[0] === '/') bot.chat.command(message.substring(1))
else bot.chat.message(message)
}
}, 200)
@ -28,10 +61,10 @@ function bot (bot) {
const player = bot.players[packet.sender]
const message = msg.split('> ')[1]
bot.emit('message', player, message)
} else if (msg.match(/.* .*§r: §.*/g)) {
} else if (msg.match(/.* .*§r:§r §.*/g)) {
if (packet.sender === '00000000-0000-0000-0000-000000000000') return
const player = bot.players[packet.sender]
const message = msg.split('§r: ')[1].substr(2)
const message = msg.split('§r:§r ')[1].substring(2)
bot.emit('message', player, message)
} else if (msg.match(/§.*§b: \/.*/g)) {
let username = msg.split('§b: ')[0]
@ -45,10 +78,21 @@ function bot (bot) {
}
function client (bot, client) {
client.on('chat', (packet) => {
if (JSON.parse(packet.message)?.translate === 'advMode.setCommand.success') return
client.on('profileless_chat', (packet) => {
const message = parseText(nbt.simplify(packet.message))
bot.emit('chat', message, packet)
})
const message = parseText(packet.message)
client.on('player_chat', (packet) => {
const message = packet.unsignedChatContent ? parseText(nbt.simplify(packet.unsignedChatContent)) : packet.plainMessage
bot.emit('chat', message, { sender: packet.senderUuid })
})
client.on('system_chat', (packet) => {
const json = nbt.simplify(packet.content)
if (json?.translate === 'advMode.setCommand.success') return
const message = parseText(json)
bot.emit('chat', message, packet)
})
}

View file

@ -1,16 +1,16 @@
const ffmpeg = require('fluent-ffmpeg')
const tmp = require('tmp')
// const tmp = require('tmp')
const fs = require('fs')
const path = require('path')
const canvas = require('canvas')
// const canvas = require('canvas')
const colorsys = require('colorsys')
const { randomUUID } = require('crypto')
const nbt = require('prismarine-nbt')
const SNBT = require('../util/snbt.js')
const toNBTUUID = require('./../util/uuid-to-nbt-uuid.js')
const cnv = canvas.createCanvas(256, 144)
const ctx = cnv.getContext('2d')
// const cnv = canvas.createCanvas(256, 144)
// const ctx = cnv.getContext('2d')
function inject (bot) {
const video = {

View file

@ -50,9 +50,7 @@ const ansimap = {
* @param {string} json_string - A text component string, such as the chat packet's 'message' property.
* @returns {object} Parsed message in { raw, clean, ansi } form.
*/
function parseText (jsonString) {
const json = JSON.parse(jsonString)
function parseText (json) {
let raw = parseJson(json, { color: 'reset' })
if (raw.startsWith('§r')) {
raw = raw.substring(2)
@ -92,6 +90,8 @@ function parseJson (json, parent) {
if (json.obfuscated) raw += '§k'
if (json.text) {
raw += json.text
} else if (json['']) {
raw += json['']
}
if (json.translate) { // I checked with the native minecraft code. This is how Minecraft does the matching and group indexing. -hhhzzzsss
if (language[json.translate]) {