w
This commit is contained in:
parent
9ac84ac04f
commit
372f8887c7
10 changed files with 89 additions and 90 deletions
|
@ -6,14 +6,14 @@ import chatlog from '../util/chatlog.js'
|
|||
|
||||
const execute = (c) => {
|
||||
const payload = c.args.join(' ')
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog(`eval`, `${c.host}:${c.port} ${c.username} (${c.uuid}) Payload: ${payload}`)
|
||||
let result;
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog('eval', `${c.host}:${c.port} ${c.username} (${c.uuid}) Payload: ${payload}`)
|
||||
let result
|
||||
try {
|
||||
result = inspect(eval(payload))
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog(`eval`, `${c.host}:${c.port} ${c.username} (${c.uuid}) Result: ${result}`)
|
||||
} catch (e){
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog('eval', `${c.host}:${c.port} ${c.username} (${c.uuid}) Result: ${result}`)
|
||||
} catch (e) {
|
||||
result = inspect(e)
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog(`eval`, `${c.host}:${c.port} ${c.username} (${c.uuid}) Error: ${inspect(e)}`)
|
||||
if (!settings.disableLogging && !settings.disableEvalLogging) chatlog('eval', `${c.host}:${c.port} ${c.username} (${c.uuid}) Error: ${inspect(e)}`)
|
||||
}
|
||||
if (c.type === 'console') {
|
||||
console.log(result)
|
||||
|
|
|
@ -7,13 +7,13 @@ const execute = (c) => {
|
|||
switch (subcmd) {
|
||||
case 'add': {
|
||||
const command = c.args.join(' ')
|
||||
let playerName;
|
||||
let uuid;
|
||||
let playerName
|
||||
let uuid
|
||||
console.log(command)
|
||||
if (!/[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}/.test(command)) {
|
||||
playerName = command
|
||||
uuid = c.bot.findUUID(playerName)
|
||||
if(uuid == "00000000-0000-0000-0000-000000000000"){
|
||||
if (uuid == '00000000-0000-0000-0000-000000000000') {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.filter.error.notFound')
|
||||
})
|
||||
|
@ -23,7 +23,7 @@ const execute = (c) => {
|
|||
playerName = c.bot.findRealNameFromUUID(command)
|
||||
uuid = command
|
||||
}
|
||||
if(!c.bot.isFiltered(command)){
|
||||
if (!c.bot.isFiltered(command)) {
|
||||
playerName = c.bot.findRealNameFromUUID(command)
|
||||
c.bot.addFilter(uuid, playerName)
|
||||
} else {
|
||||
|
@ -81,7 +81,7 @@ const execute = (c) => {
|
|||
})
|
||||
break
|
||||
case 'clear':
|
||||
//c.bot.clearCloops()
|
||||
// c.bot.clearCloops()
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'Not implemented')
|
||||
})
|
||||
|
@ -101,6 +101,6 @@ const execute = (c) => {
|
|||
}
|
||||
|
||||
const level = 0
|
||||
const aliases = ["blacklist"]
|
||||
const aliases = ['blacklist']
|
||||
const consoleIndex = true
|
||||
export { execute, level, consoleIndex }
|
||||
|
|
|
@ -4,45 +4,45 @@ import { getMessage } from '../util/lang.js'
|
|||
Please do not get mad at me because your bot also has this (or a similar) command.
|
||||
*/
|
||||
const execute = (c) => {
|
||||
if(c.args[0] == "set"){
|
||||
const scale = Math.min(Math.max(+c.args[1],0.0625),16)
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.scale.set'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: c.args[1],
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
c.bot.ccq.push(`attribute ${c.uuid} scale base set ${scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} gravity base set ${0.08 * scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} movement_speed base set ${0.1 * scale}`) // Very close to 0.1 normally, so we just round
|
||||
c.bot.ccq.push(`attribute ${c.uuid} step_height base set ${0.6 * scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} jump_strength base set ${0.42 * scale}`) // Very close to 0.42 normally, so we just round
|
||||
} else if(c.args[0] == "reset"){
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.scale.reset'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
c.bot.ccq.push(`attribute ${c.uuid} scale base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} gravity base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} movement_speed base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} step_height base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} jump_strength base reset`)
|
||||
} else {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}help scale`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
if (c.args[0] == 'set') {
|
||||
const scale = Math.min(Math.max(+c.args[1], 0.0625), 16)
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.scale.set'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: c.args[1],
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
c.bot.ccq.push(`attribute ${c.uuid} scale base set ${scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} gravity base set ${0.08 * scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} movement_speed base set ${0.1 * scale}`) // Very close to 0.1 normally, so we just round
|
||||
c.bot.ccq.push(`attribute ${c.uuid} step_height base set ${0.6 * scale}`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} jump_strength base set ${0.42 * scale}`) // Very close to 0.42 normally, so we just round
|
||||
} else if (c.args[0] == 'reset') {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.scale.reset'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
c.bot.ccq.push(`attribute ${c.uuid} scale base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} gravity base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} movement_speed base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} step_height base reset`)
|
||||
c.bot.ccq.push(`attribute ${c.uuid} jump_strength base reset`)
|
||||
} else {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}help scale`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
const aliases = ['size'] // Other command names that will work the same (optional)
|
||||
export { execute, aliases }
|
||||
|
|
2
index.js
2
index.js
|
@ -43,7 +43,7 @@ const createBot = function createBot (host, oldId) {
|
|||
}
|
||||
|
||||
bot._client = createClient(options)
|
||||
|
||||
|
||||
bot.info = (msg) => {
|
||||
console.log(`[${bot.id}] [info] ${msg}`)
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ export default {
|
|||
'command.filter.desc': 'Manage filtered players',
|
||||
'command.help.usage': ' [cmd]',
|
||||
'command.help.desc': 'Shows command help',
|
||||
// 'command.kick.usage': ' (syntax not finalized)',
|
||||
// 'command.kick.desc': 'Kick a player',
|
||||
// 'command.kick.usage': ' (syntax not finalized)',
|
||||
// 'command.kick.desc': 'Kick a player',
|
||||
'command.logoff.usage': '',
|
||||
'command.logoff.desc': 'Disconnect and reconnect the bot from a server',
|
||||
'command.netmsg.usage': ' <message>',
|
||||
|
@ -142,5 +142,5 @@ export default {
|
|||
'command.disabled.local': 'This command has been disabled on this server.',
|
||||
'command.disabled.console': 'This command cannot be run from the console.',
|
||||
'command.disabled.nonConsole': 'This command must be run from the console.',
|
||||
copyText: 'Click to copy this item to your clipboard',
|
||||
copyText: 'Click to copy this item to your clipboard'
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@ const rl = createInterface({
|
|||
prompt: '\x1b[0m> '
|
||||
})
|
||||
rl.on('line', (l) => {
|
||||
const args = l.split(' ');
|
||||
const cmdName = args[0].toLowerCase();
|
||||
const args = l.split(' ')
|
||||
const cmdName = args[0].toLowerCase()
|
||||
|
||||
try {
|
||||
const cmd = cmds[cmdName];
|
||||
const cmd = cmds[cmdName]
|
||||
if (!cmd) {
|
||||
rl.prompt(false);
|
||||
return;
|
||||
rl.prompt(false)
|
||||
return
|
||||
}
|
||||
|
||||
if (cmd.consoleIndex) {
|
||||
const index2 = args.splice(1, 1)[0];
|
||||
const index2 = args.splice(1, 1)[0]
|
||||
if (index2 === '*') {
|
||||
for (let i = 0; i < bots.length; i++) {
|
||||
const context = new Command(uuid, user, nick, args.join(' '), 'console', 'console', 'console', '', bots[i])
|
||||
|
@ -55,7 +55,7 @@ rl.on('line', (l) => {
|
|||
console.log(e)
|
||||
}
|
||||
|
||||
rl.prompt(false);
|
||||
rl.prompt(false)
|
||||
})
|
||||
rl.prompt()
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import uuidToInt from '../util/uuidtoint.js'
|
||||
export default function load (b) {
|
||||
b.filteredPlayers = [];
|
||||
b.filteredPlayers = []
|
||||
|
||||
b.interval.deopFiltered = setInterval(()=>{
|
||||
b.interval.deopFiltered = setInterval(() => {
|
||||
b.filteredPlayers.forEach(item => {
|
||||
if(b.players[item.uuid] && b.players[item.uuid].here){
|
||||
if (b.players[item.uuid] && b.players[item.uuid].here) {
|
||||
b.ccq.push(`/deop @a[nbt={UUID:[I;${uuidToInt(item.uuid)}]}]`)
|
||||
b.ccq.push(`/gamemode spectator @a[nbt={UUID:[I;${uuidToInt(item.uuid)}]}]`)
|
||||
}
|
||||
})
|
||||
}, 50)
|
||||
|
||||
|
||||
b.addFilter = function (uuid, username) {
|
||||
b.filteredPlayers.push({
|
||||
username,
|
||||
|
@ -19,30 +18,30 @@ export default function load (b) {
|
|||
})
|
||||
}
|
||||
b.removeFilter = function (string) {
|
||||
let index=-1;
|
||||
let index = -1
|
||||
if (/[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}/.test(string)) { // Uuid code
|
||||
b.filteredPlayers.forEach((item,index2)=>{
|
||||
if(item.uuid == string){
|
||||
b.filteredPlayers.forEach((item, index2) => {
|
||||
if (item.uuid == string) {
|
||||
console.log(index2)
|
||||
index=index2
|
||||
index = index2
|
||||
}
|
||||
})
|
||||
} else { // Uuid code
|
||||
b.filteredPlayers.forEach((item,index2)=>{
|
||||
if(item.username == string){
|
||||
b.filteredPlayers.forEach((item, index2) => {
|
||||
if (item.username == string) {
|
||||
console.log(index2)
|
||||
index=index2
|
||||
index = index2
|
||||
}
|
||||
})
|
||||
}
|
||||
if(index==-1) return
|
||||
if (index == -1) return
|
||||
b.filteredPlayers.splice(index, 1)
|
||||
}
|
||||
b.isFiltered = function (string) {
|
||||
let playerIsFiltered=false
|
||||
b.filteredPlayers.forEach((item)=>{
|
||||
if(item.uuid == string){
|
||||
playerIsFiltered=true
|
||||
let playerIsFiltered = false
|
||||
b.filteredPlayers.forEach((item) => {
|
||||
if (item.uuid == string) {
|
||||
playerIsFiltered = true
|
||||
}
|
||||
})
|
||||
return playerIsFiltered
|
||||
|
|
|
@ -3,9 +3,9 @@ import parseNBT from '../util/parseNBT.js'
|
|||
|
||||
export default function load (b) {
|
||||
b.players = {}
|
||||
b._client.on("player_remove",(data)=>{
|
||||
for(const item of data.players){
|
||||
b.players[item].here=false
|
||||
b._client.on('player_remove', (data) => {
|
||||
for (const item of data.players) {
|
||||
b.players[item].here = false
|
||||
b.emit('playerquit', item)
|
||||
}
|
||||
})
|
||||
|
@ -34,7 +34,7 @@ export default function load (b) {
|
|||
}
|
||||
for (const uuid in buffer2) {
|
||||
if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' }
|
||||
b.players[uuid].here=true
|
||||
b.players[uuid].here = true
|
||||
let displayName = ''
|
||||
let realName = ''
|
||||
if (buffer2[uuid].displayName) {
|
||||
|
|
|
@ -8,7 +8,7 @@ export default function (cmd, uuid) {
|
|||
const hashTrusted = `babyboom:${settings.keyTrusted}:${uuid}:${cmdWithoutHash}:${dateString}`
|
||||
const hashOwner = `babyboom:${settings.keyOwner}:${uuid}:${cmdWithoutHash}:${dateString}`
|
||||
|
||||
const hashPart = cmd[cmd.length - 1];
|
||||
const hashPart = cmd[cmd.length - 1]
|
||||
const validhashT = createHash('sha256').update(hashTrusted).digest('hex')
|
||||
const validhashO = createHash('sha256').update(hashOwner).digest('hex')
|
||||
if (hashPart === validhashT) return 1
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
const THRESHOLD = 1000; // KiB = 1024; KB = 1000
|
||||
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
||||
const THRESHOLD = 1000 // KiB = 1024; KB = 1000
|
||||
|
||||
export default function memoryconvert (bytes) {
|
||||
for (let i = 0; i < UNITS.length; i++) {
|
||||
const last = i === (UNITS.length - 1);
|
||||
const max = THRESHOLD ** (i + 1);
|
||||
if (!last && bytes >= max) continue;
|
||||
const last = i === (UNITS.length - 1)
|
||||
const max = THRESHOLD ** (i + 1)
|
||||
if (!last && bytes >= max) continue
|
||||
|
||||
const divisor = THRESHOLD ** i;
|
||||
const unit = UNITS[i];
|
||||
const divisor = THRESHOLD ** i
|
||||
const unit = UNITS[i]
|
||||
|
||||
const div = bytes / divisor;
|
||||
const div = bytes / divisor
|
||||
return `${+div.toFixed(2)} ${unit}`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue