Compare commits

...

7 commits

15 changed files with 73 additions and 44 deletions

View file

@ -112,7 +112,7 @@ const aboutServer = function (c) {
text: thisItem,
color: c.colors.primary,
clickEvent: {
action: "copy_to_clipboard",
action: 'copy_to_clipboard',
value: thisItem
},
hoverEvent: {
@ -201,10 +201,10 @@ const aboutServer = function (c) {
}
const displayServerList = function (c) {
index.bot.forEach((item, i)=>{
index.bot.forEach((item, i) => {
if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return
let message = 'command.about.serverListItem';
if(c.bot.id == i) message = 'command.about.serverListItem.thisServer'
let message = 'command.about.serverListItem'
if (c.bot.id == i) message = 'command.about.serverListItem.thisServer'
c.reply({
translate: getMessage(c.lang, message),
color: c.colors.secondary,
@ -217,7 +217,7 @@ const displayServerList = function (c) {
text: `${item.host.host}:${item.host.port}`,
color: c.colors.primary,
clickEvent: {
action: "copy_to_clipboard",
action: 'copy_to_clipboard',
value: `${item.host.host}:${item.host.port}`
},
hoverEvent: {
@ -240,9 +240,9 @@ const displayServerList = function (c) {
module.exports = {
execute: function (c) {
let subcmd = c.args[0]
if(subcmd === "servers") subcmd = "serverlist"
if(c.cmdName === "serverinfo") subcmd = "server"
if(c.cmdName === "serverlist" || c.cmdName === "servers") subcmd = "serverlist"
if (subcmd === 'servers') subcmd = 'serverlist'
if (c.cmdName === 'serverinfo') subcmd = 'server'
if (c.cmdName === 'serverlist' || c.cmdName === 'servers') subcmd = 'serverlist'
if (subcmd === 'server') {
aboutServer(c)
} else if (subcmd === 'serverlist') {

View file

@ -44,7 +44,7 @@ module.exports = {
break
}
case 'list':
c.bot.cloops.forEach((item, i)=>{
c.bot.cloops.forEach((item, i) => {
c.reply({
translate: getMessage(c.lang, 'command.cloop.list'),
color: c.colors.secondary,

View file

@ -66,7 +66,7 @@ const printHelp = (c) => {
const printCmdHelp = (c) => {
const cmd = c.args[0]
if (!cmds[cmd]) {
if (!cmds[cmd] || (cmds[cmd].hidden && c.type !== 'console')) {
c.reply({ text: getMessage(c.lang, 'command.help.noCommand') })
return
}

View file

@ -4,9 +4,9 @@ module.exports = {
execute: (c) => {
let host = c.host
let port = c.port
if(c.bot.host.options && c.bot.host.options.hidden){
host = "localhost" // Makes hidden servers appear as localhost
port = "25565"
if (c.bot.host.options && c.bot.host.options.hidden) {
host = 'localhost' // Makes hidden servers appear as localhost
port = '25565'
}
const json = {
translate: '[%s] %s: %s',
@ -14,12 +14,12 @@ module.exports = {
{
text: c.serverName,
hoverEvent: {
action: "show_text",
action: 'show_text',
value: {
translate: '%s: %s:%s',
with: [
{
text: getMessage(c.lang, "command.netmsg.serverAddress"),
text: getMessage(c.lang, 'command.netmsg.serverAddress'),
color: c.colors.primary
},
{
@ -47,6 +47,7 @@ module.exports = {
color: 'white'
}
bot.forEach(item => {
if (item.host.options && item.host.options.netmsgIncomingDisabled && c.type !== 'console') return
item.tellraw('@a', json)
})
}

View file

@ -1,14 +1,22 @@
const { languages, getMessage } = require('../util/lang.js')
const fs = require('fs')
const settings = require('../settings.json')
module.exports = {
execute: (c) => {
if(c.type == "console"){
if (c.type == 'console') {
c.reply({
text: getMessage(c.lang, 'command.settings.disabled.console'),
color: c.colors.secondary
})
return
}
if (settings.userSettingsDisabled) {
c.reply({
text: getMessage(c.lang, 'command.settings.disabled.global'),
color: c.colors.secondary
})
return
}
const subcmd = c.args.splice(0, 1)[0]
switch (subcmd) {
case 'set':{

View file

@ -14,7 +14,7 @@ module.exports = {
text: item,
color: c.colors.primary,
clickEvent: {
action: "copy_to_clipboard",
action: 'copy_to_clipboard',
value: item
},
hoverEvent: {

View file

@ -1,14 +1,14 @@
const fs = require('fs')
if (!fs.readdirSync('.').includes('settings.json')) {
console.log("Settings file is missing, using defaults.")
fs.copyFileSync("settings_example.json", "settings.json")
console.log('Settings file is missing, using defaults.')
fs.copyFileSync('settings_example.json', 'settings.json')
}
if (!fs.readdirSync('.').includes('secret.json')) {
console.log("Secrets file is missing, using defaults.")
fs.copyFileSync("secret_example.json", "secret.json")
console.log("Please change the hashing keys in the secrets file.")
console.log('Secrets file is missing, using defaults.')
fs.copyFileSync('secret_example.json', 'secret.json')
console.log('Please change the hashing keys in the secrets file.')
}
const m = require('minecraft-protocol')

View file

@ -11,6 +11,7 @@
"time.minutePlural": " minutes ",
"time.second": " second ",
"time.secondPlural": " seconds ",
"chat.antiSpamTriggered": "Anti-spam has been triggered for this server.",
"command.about.usage": "",
"command.about.desc": "About the bot",
"command.cb.usage": " <command>",

View file

@ -2,6 +2,7 @@ const settings = require('../settings.json')
const parsePlain = require('../util/chatparse_plain.js')
const parseConsole = require('../util/chatparse_console.js')
const parse1204 = require('../util/parseNBT.js')
const { getMessage } = require('../util/lang.js')
const convertChatStyleItem = (item) => {
let output={};
for(const i in item){
@ -26,9 +27,14 @@ const convertChatTypeItem = (item) => {
}
module.exports = {
load: (b) => {
b.messageTypes = [];
b._client.on("registry_data",(data)=>{
if(data.codec.value['minecraft:chat_type']){
b.messageCount = 0;
b.chatDisabledUntil = 0;
b.interval.antiSpam = setInterval(()=>{
b.messageCount = 0;
}, 4000)
b.messageTypes = []
b._client.on('registry_data', (data) => {
if (data.codec.value['minecraft:chat_type']) {
b.messageTypes = data.codec.value['minecraft:chat_type']
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value;
nbtItems.forEach((item, i) => {
@ -163,6 +169,13 @@ module.exports = {
})
b.on('chat', (data) => {
b.messageCount++;
if(Date.now() < b.chatDisabledUntil) return
if(b.messageCount >= 100){
b.info(getMessage(settings.defaultLang, "chat.antiSpamTriggered"))
b.chatDisabledUntil = Date.now() + 30000
return
}
const msgConsole = parseConsole(data.json)
const msgPlain = parsePlain(data.json)
if (settings.logJSONmessages) console.log(data.json)
@ -170,14 +183,6 @@ module.exports = {
if (msgPlain.startsWith('Command set: ')) return
b.emit('plainchat', msgPlain, data.type)
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
const fullCommand = data.message
for (const prefix of b.prefix) {
if (fullCommand.startsWith(prefix)) {
const command = fullCommand.slice(prefix.length)
b.runCommand(data.username, data.nickname, data.uuid, command, data.type, prefix)
}
}
})
}
}

View file

@ -5,11 +5,15 @@ const { getMessage } = require('../util/lang.js')
const cmds = require('../util/commands.js')
const fs = require('fs')
if (!fs.readdirSync('.').includes('userPref')) fs.mkdirSync('userPref')
if (!fs.readdirSync('.').includes('userPref') && !settings.userSettingsDisabled) fs.mkdirSync('userPref')
const loadSettings = function (uuid) {
try {
return require(`../userPref/${uuid}.json`)
if(settings.userSettingsDisabled){
return {}
} else {
return require(`../userPref/${uuid}.json`)
}
} catch (e) {
return {}
}
@ -18,6 +22,15 @@ module.exports = {
load: (b) => {
b.prefix = settings.prefix
b.lastCmd = 0
b.on('chat', (data) => {
const fullCommand = data.message
for (const prefix of b.prefix) {
if (fullCommand.startsWith(prefix)) {
const command = fullCommand.slice(prefix.length)
b.runCommand(data.username, data.nickname, data.uuid, command, data.type, prefix)
}
}
})
b.runCommand = (name, nickname, uuid, text, msgType, prefix) => {
if (uuid === '00000000-0000-0000-0000-000000000000') return
if (Date.now() - b.lastCmd <= 1000) return

View file

@ -58,7 +58,7 @@ module.exports = {
})
}
// Gamemode
// Gamemode / end portal bug
b.add_sc_task('gamemode', () => {
b.chat('/minecraft:gamemode creative')
})
@ -67,6 +67,8 @@ module.exports = {
b.sc_tasks.gamemode.failed = 1
} else if (p.reason === 3 && p.gameMode === 1) {
b.sc_tasks.gamemode.failed = 0
} else if (p.reason === 4){
b.sc_tasks.respawn.failed = 1
}
})

View file

@ -1,5 +1,4 @@
{
"secret":"/path/to/secrets/file/secret.json",
"version_mc": "1.20.4",
"defaultLang": "en-US",
"terminalMode": "blackTerminal_24bit",

View file

@ -75,7 +75,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
if (lang[trans] !== undefined) {
trans = lang[trans].replace(/%%/g, '\ue123')
}
if(data.with){
if (data.with) {
data.with.forEach((item, i) => {
const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))

View file

@ -21,8 +21,8 @@ const getMessage = function (l, msg, with2) {
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
message = languages['en-US'][message].replace(/%%/g, '\ue123')
}
if (with2){
with2.forEach((withItem, i)=>{
if (with2) {
with2.forEach((withItem, i) => {
message = message.replace(/%s/, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
message = message.replaceAll(`%${+i + 1}$s`, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
})

View file

@ -32,12 +32,12 @@ const rsg = function (count) {
}
const rsgLegal = function (count) {
let output = ''
if(Math.random()>0.5){
output += "uwu_"
if (Math.random() > 0.5) {
output += 'uwu_'
} else {
output += "owo_"
output += 'owo_'
}
output += crypto.randomBytes(count).toString("hex")
output += crypto.randomBytes(count).toString('hex')
return output
}
module.exports = function (legal) {