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,
|
||||
color: c.colors.primary,
|
||||
clickEvent: {
|
||||
action: "copy_to_clipboard",
|
||||
action: 'copy_to_clipboard',
|
||||
value: thisItem
|
||||
},
|
||||
hoverEvent: {
|
||||
|
@ -203,7 +203,7 @@ const aboutServer = function (c) {
|
|||
const displayServerList = function (c) {
|
||||
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';
|
||||
let message = 'command.about.serverListItem'
|
||||
if (c.bot.id == i) message = 'command.about.serverListItem.thisServer'
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, message),
|
||||
|
@ -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') {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ module.exports = {
|
|||
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"
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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':{
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
|||
text: item,
|
||||
color: c.colors.primary,
|
||||
clickEvent: {
|
||||
action: "copy_to_clipboard",
|
||||
action: 'copy_to_clipboard',
|
||||
value: item
|
||||
},
|
||||
hoverEvent: {
|
||||
|
|
10
index.js
10
index.js
|
@ -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')
|
||||
|
|
|
@ -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>",
|
||||
|
|
|
@ -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,8 +27,13 @@ const convertChatTypeItem = (item) => {
|
|||
}
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.messageTypes = [];
|
||||
b._client.on("registry_data",(data)=>{
|
||||
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;
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
"secret":"/path/to/secrets/file/secret.json",
|
||||
"version_mc": "1.20.4",
|
||||
"defaultLang": "en-US",
|
||||
"terminalMode": "blackTerminal_24bit",
|
||||
|
|
|
@ -33,11 +33,11 @@ const rsg = function (count) {
|
|||
const rsgLegal = function (count) {
|
||||
let output = ''
|
||||
if (Math.random() > 0.5) {
|
||||
output += "uwu_"
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue