Compare commits
7 commits
e4dffbaad9
...
49485b1040
Author | SHA1 | Date | |
---|---|---|---|
49485b1040 | |||
0147badad3 | |||
cb4aa5a818 | |||
f6b2365ccd | |||
314cfc9f85 | |||
831ed85c00 | |||
2e19b33053 |
15 changed files with 73 additions and 44 deletions
|
@ -112,7 +112,7 @@ const aboutServer = function (c) {
|
||||||
text: thisItem,
|
text: thisItem,
|
||||||
color: c.colors.primary,
|
color: c.colors.primary,
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: "copy_to_clipboard",
|
action: 'copy_to_clipboard',
|
||||||
value: thisItem
|
value: thisItem
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
|
@ -203,7 +203,7 @@ const aboutServer = function (c) {
|
||||||
const displayServerList = 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
|
if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return
|
||||||
let message = 'command.about.serverListItem';
|
let message = 'command.about.serverListItem'
|
||||||
if (c.bot.id == i) message = 'command.about.serverListItem.thisServer'
|
if (c.bot.id == i) message = 'command.about.serverListItem.thisServer'
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: getMessage(c.lang, message),
|
translate: getMessage(c.lang, message),
|
||||||
|
@ -217,7 +217,7 @@ const displayServerList = function (c) {
|
||||||
text: `${item.host.host}:${item.host.port}`,
|
text: `${item.host.host}:${item.host.port}`,
|
||||||
color: c.colors.primary,
|
color: c.colors.primary,
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: "copy_to_clipboard",
|
action: 'copy_to_clipboard',
|
||||||
value: `${item.host.host}:${item.host.port}`
|
value: `${item.host.host}:${item.host.port}`
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
|
@ -240,9 +240,9 @@ const displayServerList = function (c) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
execute: function (c) {
|
execute: function (c) {
|
||||||
let subcmd = c.args[0]
|
let subcmd = c.args[0]
|
||||||
if(subcmd === "servers") subcmd = "serverlist"
|
if (subcmd === 'servers') subcmd = 'serverlist'
|
||||||
if(c.cmdName === "serverinfo") subcmd = "server"
|
if (c.cmdName === 'serverinfo') subcmd = 'server'
|
||||||
if(c.cmdName === "serverlist" || c.cmdName === "servers") subcmd = "serverlist"
|
if (c.cmdName === 'serverlist' || c.cmdName === 'servers') subcmd = 'serverlist'
|
||||||
if (subcmd === 'server') {
|
if (subcmd === 'server') {
|
||||||
aboutServer(c)
|
aboutServer(c)
|
||||||
} else if (subcmd === 'serverlist') {
|
} else if (subcmd === 'serverlist') {
|
||||||
|
|
|
@ -66,7 +66,7 @@ const printHelp = (c) => {
|
||||||
|
|
||||||
const printCmdHelp = (c) => {
|
const printCmdHelp = (c) => {
|
||||||
const cmd = c.args[0]
|
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') })
|
c.reply({ text: getMessage(c.lang, 'command.help.noCommand') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ module.exports = {
|
||||||
let host = c.host
|
let host = c.host
|
||||||
let port = c.port
|
let port = c.port
|
||||||
if (c.bot.host.options && c.bot.host.options.hidden) {
|
if (c.bot.host.options && c.bot.host.options.hidden) {
|
||||||
host = "localhost" // Makes hidden servers appear as localhost
|
host = 'localhost' // Makes hidden servers appear as localhost
|
||||||
port = "25565"
|
port = '25565'
|
||||||
}
|
}
|
||||||
const json = {
|
const json = {
|
||||||
translate: '[%s] %s: %s',
|
translate: '[%s] %s: %s',
|
||||||
|
@ -14,12 +14,12 @@ module.exports = {
|
||||||
{
|
{
|
||||||
text: c.serverName,
|
text: c.serverName,
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: "show_text",
|
action: 'show_text',
|
||||||
value: {
|
value: {
|
||||||
translate: '%s: %s:%s',
|
translate: '%s: %s:%s',
|
||||||
with: [
|
with: [
|
||||||
{
|
{
|
||||||
text: getMessage(c.lang, "command.netmsg.serverAddress"),
|
text: getMessage(c.lang, 'command.netmsg.serverAddress'),
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ module.exports = {
|
||||||
color: 'white'
|
color: 'white'
|
||||||
}
|
}
|
||||||
bot.forEach(item => {
|
bot.forEach(item => {
|
||||||
|
if (item.host.options && item.host.options.netmsgIncomingDisabled && c.type !== 'console') return
|
||||||
item.tellraw('@a', json)
|
item.tellraw('@a', json)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
const { languages, getMessage } = require('../util/lang.js')
|
const { languages, getMessage } = require('../util/lang.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const settings = require('../settings.json')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
execute: (c) => {
|
execute: (c) => {
|
||||||
if(c.type == "console"){
|
if (c.type == 'console') {
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.settings.disabled.console'),
|
text: getMessage(c.lang, 'command.settings.disabled.console'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
})
|
||||||
return
|
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]
|
const subcmd = c.args.splice(0, 1)[0]
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case 'set':{
|
case 'set':{
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
||||||
text: item,
|
text: item,
|
||||||
color: c.colors.primary,
|
color: c.colors.primary,
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: "copy_to_clipboard",
|
action: 'copy_to_clipboard',
|
||||||
value: item
|
value: item
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
|
|
10
index.js
10
index.js
|
@ -1,14 +1,14 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
if (!fs.readdirSync('.').includes('settings.json')) {
|
if (!fs.readdirSync('.').includes('settings.json')) {
|
||||||
console.log("Settings file is missing, using defaults.")
|
console.log('Settings file is missing, using defaults.')
|
||||||
fs.copyFileSync("settings_example.json", "settings.json")
|
fs.copyFileSync('settings_example.json', 'settings.json')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.readdirSync('.').includes('secret.json')) {
|
if (!fs.readdirSync('.').includes('secret.json')) {
|
||||||
console.log("Secrets file is missing, using defaults.")
|
console.log('Secrets file is missing, using defaults.')
|
||||||
fs.copyFileSync("secret_example.json", "secret.json")
|
fs.copyFileSync('secret_example.json', 'secret.json')
|
||||||
console.log("Please change the hashing keys in the secrets file.")
|
console.log('Please change the hashing keys in the secrets file.')
|
||||||
}
|
}
|
||||||
|
|
||||||
const m = require('minecraft-protocol')
|
const m = require('minecraft-protocol')
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"time.minutePlural": " minutes ",
|
"time.minutePlural": " minutes ",
|
||||||
"time.second": " second ",
|
"time.second": " second ",
|
||||||
"time.secondPlural": " seconds ",
|
"time.secondPlural": " seconds ",
|
||||||
|
"chat.antiSpamTriggered": "Anti-spam has been triggered for this server.",
|
||||||
"command.about.usage": "",
|
"command.about.usage": "",
|
||||||
"command.about.desc": "About the bot",
|
"command.about.desc": "About the bot",
|
||||||
"command.cb.usage": " <command>",
|
"command.cb.usage": " <command>",
|
||||||
|
|
|
@ -2,6 +2,7 @@ const settings = require('../settings.json')
|
||||||
const parsePlain = require('../util/chatparse_plain.js')
|
const parsePlain = require('../util/chatparse_plain.js')
|
||||||
const parseConsole = require('../util/chatparse_console.js')
|
const parseConsole = require('../util/chatparse_console.js')
|
||||||
const parse1204 = require('../util/parseNBT.js')
|
const parse1204 = require('../util/parseNBT.js')
|
||||||
|
const { getMessage } = require('../util/lang.js')
|
||||||
const convertChatStyleItem = (item) => {
|
const convertChatStyleItem = (item) => {
|
||||||
let output={};
|
let output={};
|
||||||
for(const i in item){
|
for(const i in item){
|
||||||
|
@ -26,8 +27,13 @@ const convertChatTypeItem = (item) => {
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
load: (b) => {
|
load: (b) => {
|
||||||
b.messageTypes = [];
|
b.messageCount = 0;
|
||||||
b._client.on("registry_data",(data)=>{
|
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']) {
|
if (data.codec.value['minecraft:chat_type']) {
|
||||||
b.messageTypes = 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;
|
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value;
|
||||||
|
@ -163,6 +169,13 @@ module.exports = {
|
||||||
})
|
})
|
||||||
|
|
||||||
b.on('chat', (data) => {
|
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 msgConsole = parseConsole(data.json)
|
||||||
const msgPlain = parsePlain(data.json)
|
const msgPlain = parsePlain(data.json)
|
||||||
if (settings.logJSONmessages) console.log(data.json)
|
if (settings.logJSONmessages) console.log(data.json)
|
||||||
|
@ -170,14 +183,6 @@ module.exports = {
|
||||||
if (msgPlain.startsWith('Command set: ')) return
|
if (msgPlain.startsWith('Command set: ')) return
|
||||||
b.emit('plainchat', msgPlain, data.type)
|
b.emit('plainchat', msgPlain, data.type)
|
||||||
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,15 @@ const { getMessage } = require('../util/lang.js')
|
||||||
const cmds = require('../util/commands.js')
|
const cmds = require('../util/commands.js')
|
||||||
const fs = require('fs')
|
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) {
|
const loadSettings = function (uuid) {
|
||||||
try {
|
try {
|
||||||
|
if(settings.userSettingsDisabled){
|
||||||
|
return {}
|
||||||
|
} else {
|
||||||
return require(`../userPref/${uuid}.json`)
|
return require(`../userPref/${uuid}.json`)
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +22,15 @@ module.exports = {
|
||||||
load: (b) => {
|
load: (b) => {
|
||||||
b.prefix = settings.prefix
|
b.prefix = settings.prefix
|
||||||
b.lastCmd = 0
|
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) => {
|
b.runCommand = (name, nickname, uuid, text, msgType, prefix) => {
|
||||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||||
if (Date.now() - b.lastCmd <= 1000) return
|
if (Date.now() - b.lastCmd <= 1000) return
|
||||||
|
|
|
@ -58,7 +58,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamemode
|
// Gamemode / end portal bug
|
||||||
b.add_sc_task('gamemode', () => {
|
b.add_sc_task('gamemode', () => {
|
||||||
b.chat('/minecraft:gamemode creative')
|
b.chat('/minecraft:gamemode creative')
|
||||||
})
|
})
|
||||||
|
@ -67,6 +67,8 @@ module.exports = {
|
||||||
b.sc_tasks.gamemode.failed = 1
|
b.sc_tasks.gamemode.failed = 1
|
||||||
} else if (p.reason === 3 && p.gameMode === 1) {
|
} else if (p.reason === 3 && p.gameMode === 1) {
|
||||||
b.sc_tasks.gamemode.failed = 0
|
b.sc_tasks.gamemode.failed = 0
|
||||||
|
} else if (p.reason === 4){
|
||||||
|
b.sc_tasks.respawn.failed = 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"secret":"/path/to/secrets/file/secret.json",
|
|
||||||
"version_mc": "1.20.4",
|
"version_mc": "1.20.4",
|
||||||
"defaultLang": "en-US",
|
"defaultLang": "en-US",
|
||||||
"terminalMode": "blackTerminal_24bit",
|
"terminalMode": "blackTerminal_24bit",
|
||||||
|
|
|
@ -33,11 +33,11 @@ const rsg = function (count) {
|
||||||
const rsgLegal = function (count) {
|
const rsgLegal = function (count) {
|
||||||
let output = ''
|
let output = ''
|
||||||
if (Math.random() > 0.5) {
|
if (Math.random() > 0.5) {
|
||||||
output += "uwu_"
|
output += 'uwu_'
|
||||||
} else {
|
} else {
|
||||||
output += "owo_"
|
output += 'owo_'
|
||||||
}
|
}
|
||||||
output += crypto.randomBytes(count).toString("hex")
|
output += crypto.randomBytes(count).toString('hex')
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
module.exports = function (legal) {
|
module.exports = function (legal) {
|
||||||
|
|
Loading…
Reference in a new issue