Merge branch 'main' of https://code.chipmunk.land/7cc5c4f330d47060/botvX
This commit is contained in:
commit
06b1e28490
46 changed files with 2338 additions and 345 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -150,4 +150,15 @@ dist
|
|||
.pnp.*
|
||||
|
||||
# Bot Settings
|
||||
settings.json
|
||||
settings.json
|
||||
|
||||
# Default secret file
|
||||
secret.json
|
||||
|
||||
# botvX user settings
|
||||
userPref/
|
||||
|
||||
# botvX log files
|
||||
UBotLogs/
|
||||
botvXLogs/
|
||||
logs/
|
||||
|
|
27
README.md
27
README.md
|
@ -1,27 +1,22 @@
|
|||
# botvX
|
||||
|
||||
## Что это такое?
|
||||
## What is it?
|
||||
|
||||
botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot:
|
||||
botvX is a Minecraft bot originally designed for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot:
|
||||
|
||||
- commands (obviously)
|
||||
- a self care system
|
||||
- a command core, to run commands quickly
|
||||
|
||||
## What does "botvX" mean?
|
||||
|
||||
"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version.
|
||||
|
||||
## What does "UBot" mean?
|
||||
|
||||
"UBot" just means "UBot", but is based on an older bot name "UnnamedBot". On some older versions, this bot did not have a proper name. "UnnamedBot" was introduced in version 4, which was shortened to just "UBot" around version 8.
|
||||
- a hashing system, to enable trusted users to securely run certain commands in chat
|
||||
|
||||
## How to install?
|
||||
|
||||
1. Download the latest release, or alternatively, download the latest development version using <code>git clone https://10.0.0.151:3000/7cc5c4f330d47060/botvX/</code>.
|
||||
2. Extract the files if necessary.
|
||||
3. Adjust the settings to fit your needs. Do not forget to also create a secrets file.
|
||||
4. Run ./launch.sh to start a bot launcher, which will reload the bot when the process closes.
|
||||
1. Install [Node.js](https://nodejs.org/) for your operating system.
|
||||
2. Download the latest release, or alternatively, download the latest development version using <code>git clone https://code.chipmunk.land/7cc5c4f330d47060/botvX/</code>.
|
||||
3. Extract the files if necessary.
|
||||
4. Run <code>npm install</code> in the bot's directory. If it doesn't work, try using the Node.js command prompt, or adding Node.js to your PATH.
|
||||
5. Copy <code>settings_example.json</code> to <code>settings.json</code> , and adjust the settings to fit your needs. Do not forget to also create a secrets file. An example secrets file is provided as <code>secret_example.json</code>. Do not forget, if you use the secrets template, to change the keys (the ones in there are public after all!).
|
||||
6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows) to start a bot launcher, which will reload the bot when the process closes. Alternatively, you can run <code>node index.js</code> to start the bot only once (it will still rejoin when kicked). If it displays an error saying Node is not a command, please make sure Node.js is on your PATH.
|
||||
|
||||
## Command list
|
||||
|
||||
|
@ -39,4 +34,6 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones
|
|||
| serverinfo | | Get system/bot info, similar to Kaboom's <code>serverinfo</code> command |
|
||||
| stop | | Restart bot |
|
||||
| template | | Used in development, does nothing |
|
||||
| verify | | Check the hashing system |
|
||||
| tpr | | Teleport to a random location |
|
||||
| verify | | Check the hashing system |
|
||||
|
||||
|
|
219
commands/about.js
Normal file
219
commands/about.js
Normal file
|
@ -0,0 +1,219 @@
|
|||
const os = require('os')
|
||||
const cp = require('child_process')
|
||||
const { getMessage, formatTime } = require('../util/lang.js')
|
||||
const fs = require('fs')
|
||||
const botVersion = require('../util/version.js')
|
||||
const version = require('../version.json')
|
||||
const index = require('../index.js')
|
||||
|
||||
const aboutBot = function (c) {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.author'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: version.botName,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: version.botAuthor,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
if (version.isPreRelease) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.about.preRelease'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
}
|
||||
c.reply({ text: '' })
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.sourceCode'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: version.sourceURL,
|
||||
color: c.colors.primary,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: version.sourceURL
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: {
|
||||
text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser')
|
||||
},
|
||||
value: { // Added twice for backwards compatibility
|
||||
text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser')
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
const os2 = function (o2, l) {
|
||||
switch (o2) {
|
||||
case 'win32':
|
||||
return `${os.version()}`
|
||||
case 'android':{
|
||||
try {
|
||||
const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
|
||||
return getMessage(l, 'command.about.serverInfo.os.android', [version])
|
||||
} catch (e) {
|
||||
return getMessage(l, 'command.about.serverInfo.os.android.noVersion')
|
||||
}
|
||||
}
|
||||
case 'linux':
|
||||
case 'freebsd':{
|
||||
if (fs.readdirSync('/etc').includes('os-release')) {
|
||||
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
|
||||
const osrelease2 = {}
|
||||
for (const item of osrelease) {
|
||||
if (!item.includes('=')) continue
|
||||
let osrvalue = item.split('=')[1]
|
||||
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
|
||||
osrelease2[item.split('=')[0]] = osrvalue
|
||||
}
|
||||
|
||||
if (osrelease2.PRETTY_NAME) {
|
||||
return getMessage(l, '%s', [osrelease2.PRETTY_NAME])
|
||||
} else {
|
||||
return getMessage(l, `command.about.serverInfo.os.${o2}`)
|
||||
}
|
||||
} else {
|
||||
return getMessage(l, `command.about.serverInfo.os.${o2}`)
|
||||
}
|
||||
}
|
||||
default:
|
||||
return o2
|
||||
}
|
||||
}
|
||||
|
||||
const aboutServer = function (c) {
|
||||
const displayInfo = function (name, infoFunc) {
|
||||
let thisItem
|
||||
try {
|
||||
thisItem = infoFunc()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
thisItem = 'Error! (check console)'
|
||||
}
|
||||
c.reply({
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, name),
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: thisItem,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Operating system
|
||||
displayInfo('command.about.serverInfo.os', () => {
|
||||
return os2(process.platform, c.lang)
|
||||
})
|
||||
|
||||
// Kernel version: os.release()
|
||||
displayInfo('command.about.serverInfo.kernelVer', () => {
|
||||
return os.release()
|
||||
})
|
||||
|
||||
// Processor
|
||||
if (os.cpus()[0]) {
|
||||
displayInfo('command.about.serverInfo.processor', () => {
|
||||
return os.cpus()[0].model
|
||||
})
|
||||
}
|
||||
|
||||
if (os.cpus()[0]) {
|
||||
// Processor architecture
|
||||
displayInfo('command.about.serverInfo.arch', () => {
|
||||
return os.machine()
|
||||
})
|
||||
}
|
||||
|
||||
// Username and UID
|
||||
displayInfo('command.about.serverInfo.osUsername', () => {
|
||||
return `${os.userInfo().username} (${os.userInfo().uid})`
|
||||
})
|
||||
|
||||
// Hostname
|
||||
displayInfo('command.about.serverInfo.hostName', () => {
|
||||
return os.hostname()
|
||||
})
|
||||
|
||||
// Current working directory
|
||||
displayInfo('command.about.serverInfo.workingDir', () => {
|
||||
return process.cwd()
|
||||
})
|
||||
|
||||
// Node.js® version
|
||||
displayInfo('command.about.serverInfo.nodeVersion', () => {
|
||||
return process.version
|
||||
})
|
||||
|
||||
// Bot uptime
|
||||
displayInfo('command.about.serverInfo.runTime', () => {
|
||||
return formatTime(process.uptime() * 1000, c.lang)
|
||||
})
|
||||
|
||||
// System uptime
|
||||
displayInfo('command.about.serverInfo.upTime', () => {
|
||||
return formatTime(os.uptime() * 1000, c.lang)
|
||||
})
|
||||
|
||||
if (process.platform === 'android') {
|
||||
// Device model
|
||||
displayInfo('command.about.serverInfo.os.android.model', () => {
|
||||
const brand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]
|
||||
const model = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]
|
||||
return `${brand} ${model}`
|
||||
})
|
||||
}
|
||||
|
||||
// Bot version
|
||||
displayInfo('command.about.serverInfo.botVer', () => {
|
||||
return botVersion
|
||||
})
|
||||
}
|
||||
|
||||
const displayServerList = function (c) {
|
||||
index.bot.forEach((item, i)=>{
|
||||
if (item.host.options && item.host.options.hidden) return
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.serverListItem'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: i.toString(),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: `${item.host.host}:${item.host.port}`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
execute: function (c) {
|
||||
if (c.args[0] === 'server') {
|
||||
aboutServer(c)
|
||||
} else if (c.args[0] === 'serverlist') {
|
||||
displayServerList(c)
|
||||
} else {
|
||||
aboutBot(c)
|
||||
}
|
||||
},
|
||||
aliases: ['info']
|
||||
}
|
7
commands/cb.js
Normal file
7
commands/cb.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
c.bot.ccq.push(c.args.join(' '))
|
||||
},
|
||||
consoleIndex: true,
|
||||
aliases: ['commandblock', 'cmdblock']
|
||||
}
|
90
commands/cloop.js
Normal file
90
commands/cloop.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
const subcmd = c.args.splice(0, 1)[0]
|
||||
switch (subcmd) {
|
||||
case 'add': {
|
||||
const rate = +(c.args.splice(0, 1)[0])
|
||||
const command = c.args.join(' ')
|
||||
if (rate < 20) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.cloop.error.tooShort')
|
||||
})
|
||||
}
|
||||
c.bot.addCloop(command, rate)
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.success.add'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: command,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: rate + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'remove': {
|
||||
const index = +c.args[0]
|
||||
c.bot.removeCloop(c.args[0])
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.success.remove'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: index + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'list':
|
||||
c.bot.cloops.forEach((item, i)=>{
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.list'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: i.toString(),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: item.command,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: item.rate + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
break
|
||||
case 'clear':
|
||||
c.bot.clearCloops()
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.cloop.success.clear'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
break
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}help cloop`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
},
|
||||
consoleIndex: true,
|
||||
level: 1
|
||||
}
|
11
commands/eval.js
Normal file
11
commands/eval.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const index = require('../index.js') // Not used in the code, but may be used by users of the command
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
try {
|
||||
console.log(eval(c.args.join(' ')))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
level: 3
|
||||
}
|
165
commands/help.js
Normal file
165
commands/help.js
Normal file
|
@ -0,0 +1,165 @@
|
|||
const fs = require('fs')
|
||||
const cmds = Object.create(null)
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
|
||||
const sortHelp = function sortHelp (c1, c2) {
|
||||
const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0
|
||||
const level2 = cmds[c2.with[0]].level ? cmds[c2.with[0]].level : 0
|
||||
return level1 - level2
|
||||
}
|
||||
|
||||
const bpl = fs.readdirSync('./commands')
|
||||
for (const plugin of bpl) {
|
||||
if (!plugin.endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const commandName = plugin.split('.js')[0]
|
||||
if (commandName !== 'help') {
|
||||
cmds[commandName] = require(`./${plugin}`)
|
||||
if (cmds[commandName].level === undefined) {
|
||||
cmds[commandName].level = 0
|
||||
}
|
||||
}
|
||||
} catch (e) { console.log(e) }
|
||||
}
|
||||
|
||||
const printHelp = (c) => {
|
||||
const commandList = []
|
||||
for (const i in cmds) {
|
||||
if (cmds[i].hidden) continue
|
||||
let cmdColor
|
||||
switch (cmds[i].level) {
|
||||
case 0:
|
||||
cmdColor = 'green'
|
||||
break
|
||||
case 1:
|
||||
cmdColor = 'red'
|
||||
break
|
||||
case 2:
|
||||
cmdColor = 'dark_red'
|
||||
break
|
||||
case 3:
|
||||
cmdColor = 'dark_red'
|
||||
break
|
||||
default:
|
||||
cmdColor = 'green'
|
||||
}
|
||||
commandList.push(
|
||||
{
|
||||
translate: '%s ',
|
||||
color: cmdColor,
|
||||
with: [
|
||||
i
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
c.reply({
|
||||
translate: '%s %s',
|
||||
with: [
|
||||
getMessage(c.lang, 'command.help.cmdList'),
|
||||
commandList.sort(sortHelp)
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
const printCmdHelp = (c) => {
|
||||
const cmd = c.args[0]
|
||||
if (!cmds[cmd]) {
|
||||
c.reply({ text: getMessage(c.lang, 'command.help.noCommand') })
|
||||
return
|
||||
}
|
||||
let usage = getMessage(c.lang, `command.${cmd}.usage`).split('||')
|
||||
let desc = getMessage(c.lang, `command.${cmd}.desc`)
|
||||
if (cmds[cmd].usage) {
|
||||
usage = cmds[cmd].usage.split('||')
|
||||
}
|
||||
if (cmds[cmd].desc) {
|
||||
desc = cmds[cmd].desc
|
||||
}
|
||||
if (cmds[cmd].alias) {
|
||||
console.log(cmds[cmds[cmd].alias])
|
||||
usage = getMessage(c.lang, `command.${cmds[cmd].alias}.usage`).split('||')
|
||||
desc = getMessage(c.lang, 'command.help.alias', [cmds[cmd].alias])
|
||||
if (cmds[cmds[cmd].alias].usage) {
|
||||
usage = cmds[cmds[cmd].alias].usage.split('||')
|
||||
}
|
||||
if (cmds[cmds[cmd].alias].desc) {
|
||||
desc = cmds[cmds[cmd].alias].desc
|
||||
}
|
||||
}
|
||||
for (const item of usage) {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.help.commandUsage'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: cmd,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: item,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.help.commandDesc'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: desc,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
const permsN = getMessage(c.lang, 'command.help.permsNormal')
|
||||
const permsT = getMessage(c.lang, 'command.help.permsTrusted')
|
||||
const permsO = getMessage(c.lang, 'command.help.permsOwner')
|
||||
const permsC = getMessage(c.lang, 'command.help.permsConsole')
|
||||
const rPerms = cmds[cmd].level ? cmds[cmd].level : 0
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.help.commandPerms'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: [permsN, permsT, permsO, permsC][rPerms],
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
if (c.args.length > 0) {
|
||||
printCmdHelp(c)
|
||||
} else {
|
||||
printHelp(c)
|
||||
}
|
||||
},
|
||||
aliases: [
|
||||
'heko' // Parker2991 request
|
||||
]
|
||||
}
|
||||
|
||||
cmds.help = module.exports // Placed after to ensure that the correct values are added to cmds
|
||||
if (cmds.help.level === undefined) {
|
||||
cmds.help.level = 0
|
||||
}
|
||||
|
||||
for (const i in cmds) {
|
||||
if (cmds[i].aliases) {
|
||||
for (const alias of cmds[commandName].aliases) {
|
||||
cmds[alias] = {
|
||||
alias: i,
|
||||
usage: cmds[i].usage,
|
||||
level: cmds[i].level,
|
||||
hidden: true,
|
||||
consoleIndex: cmds[i].consoleIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
commands/logoff.js
Normal file
7
commands/logoff.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
c.bot._client.end()
|
||||
},
|
||||
consoleIndex: true,
|
||||
level: 2
|
||||
}
|
44
commands/netmsg.js
Normal file
44
commands/netmsg.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
const { bot } = require('../index.js')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
if (c.bot.host && c.bot.host.options.hidden) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.netmsg.disabled'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
}
|
||||
const json = {
|
||||
translate: '[%s] %s: %s',
|
||||
with: [
|
||||
{
|
||||
translate: '%s:%s',
|
||||
with: [
|
||||
{
|
||||
text: c.host,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: c.port + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: c.username,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: c.args.join(' ')
|
||||
}
|
||||
],
|
||||
color: 'white'
|
||||
}
|
||||
bot.forEach(item => {
|
||||
if (item.host.options.hidden) return
|
||||
item.tellraw('@a', json)
|
||||
})
|
||||
}
|
||||
}
|
7
commands/refill.js
Normal file
7
commands/refill.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
c.bot.chat(c.bot.refillCoreCmd)
|
||||
},
|
||||
consoleIndex: true,
|
||||
aliases: ['refillcore', 'rc']
|
||||
}
|
7
commands/restart.js
Normal file
7
commands/restart.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
process.exit(0)
|
||||
},
|
||||
aliases: ['reboot'],
|
||||
level: 2
|
||||
}
|
8
commands/say.js
Normal file
8
commands/say.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
if (c.args[0].startsWith('/') && c.verify < 1) return
|
||||
c.bot.chat(c.args.join(' '))
|
||||
},
|
||||
consoleIndex: true,
|
||||
aliases: ['echo']
|
||||
}
|
88
commands/serverinfo.js
Executable file
88
commands/serverinfo.js
Executable file
|
@ -0,0 +1,88 @@
|
|||
const os = require('os')
|
||||
const cp = require('child_process')
|
||||
const { getMessage, formatTime } = require('../util/lang.js')
|
||||
const fs = require('fs')
|
||||
const botVersion = require('../util/version.js')
|
||||
|
||||
const gr = function (l, text, value, color) {
|
||||
if (!color) color = 'white'
|
||||
return {
|
||||
translate: '%s: %s',
|
||||
color: color.primary,
|
||||
with: [
|
||||
{
|
||||
text,
|
||||
color: color.secondary
|
||||
},
|
||||
{
|
||||
text: value,
|
||||
color: color.primary
|
||||
}
|
||||
],
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: {
|
||||
text: getMessage(l, 'copyText')
|
||||
},
|
||||
value: { // Added twice for backwards compatibility
|
||||
text: getMessage(l, 'copyText')
|
||||
}
|
||||
},
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const os2 = function (o2, l) {
|
||||
switch (o2) {
|
||||
case 'win32':
|
||||
return `${os.version()} (${os.release})`
|
||||
case 'android':
|
||||
return getMessage(l, 'command.serverinfo.os.android')
|
||||
case 'linux':
|
||||
return getMessage(l, 'command.serverinfo.os.linux', [os.release()])
|
||||
default:
|
||||
return o2
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
execute: function (c) {
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors))
|
||||
if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), formatTime(process.uptime() * 1000, c.lang), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), formatTime(os.uptime() * 1000, c.lang), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors))
|
||||
if (process.platform === 'linux' || process.platform === 'freebsd') {
|
||||
try {
|
||||
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
|
||||
const osrelease2 = {}
|
||||
for (const i in osrelease) {
|
||||
if (!osrelease[i].includes('=')) continue
|
||||
let osrvalue = osrelease[i].split('=')[1]
|
||||
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
|
||||
osrelease2[osrelease[i].split('=')[0]] = osrvalue
|
||||
}
|
||||
|
||||
if (osrelease2.PRETTY_NAME) {
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors))
|
||||
}
|
||||
} catch (e) {
|
||||
c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') })
|
||||
}
|
||||
} else if (process.platform === 'android') {
|
||||
const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors))
|
||||
const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]
|
||||
const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors))
|
||||
}
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors))
|
||||
}
|
||||
}
|
140
commands/settings.js
Normal file
140
commands/settings.js
Normal file
|
@ -0,0 +1,140 @@
|
|||
const { languages, getMessage } = require('../util/lang.js')
|
||||
const fs = require('fs')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
const subcmd = c.args.splice(0, 1)[0]
|
||||
switch (subcmd) {
|
||||
case 'set':{
|
||||
const allowedKeys = ['colorPrimary', 'colorSecondary', 'lang']
|
||||
const key = c.args.splice(0, 1)[0]
|
||||
if (!allowedKeys.includes(key)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidKey'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
}
|
||||
const value = c.args.join(' ')
|
||||
if (value === '' && key === 'lang') {
|
||||
// Show all valid languages to user
|
||||
for (const item of languages) {
|
||||
c.reply({
|
||||
translate: '%s (%s)',
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(item, 'language.name'),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: getMessage(item, 'language.region'),
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
translate: getMessage(item, 'command.settings.setLanguage'),
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}settings set lang ${item}`,
|
||||
color: c.colors.secondary
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
if (value === '') {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.mustProvideValue'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
}
|
||||
if (key === 'lang' && !languages.includes(value)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidLanguage'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
}
|
||||
c.prefs[key] = value
|
||||
|
||||
// Save to file
|
||||
fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs))
|
||||
|
||||
// Delete require cache
|
||||
for (const i in require.cache) {
|
||||
if (i.endsWith(`${c.uuid}.json`)) delete require.cache[i]
|
||||
}
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.saved'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'get':
|
||||
c.reply({
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: c.colors.primary,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: c.colors.secondary,
|
||||
color: c.colors.secondary
|
||||
}
|
||||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: '%s: %s (%s)',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.language'),
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: getMessage(c.lang, 'language.name'),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: getMessage(c.lang, 'language.region'),
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
break
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}help settings`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
7
commands/stop.js
Normal file
7
commands/stop.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
process.exit(1)
|
||||
},
|
||||
aliases: ['exit'],
|
||||
level: 2
|
||||
}
|
42
commands/template.js
Normal file
42
commands/template.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
// Blank template
|
||||
/*
|
||||
c.send(text, user?): Send text to all ("/tellraw @a")
|
||||
c.reply(text): Send text to command sender
|
||||
c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord)
|
||||
c.username: Username of sender
|
||||
c.nickname: Nickname of sender when applicable
|
||||
c.command: Command string
|
||||
c.args: Arguments of command (above without the first section, and split at every space)
|
||||
c.prefix: Prefix being used to send the command (when applicable)
|
||||
c.bot: Bot that received the command. Will be different type based on where it was received
|
||||
c.type: Type of bot receiving the command ("minecraft", "console", "discord")
|
||||
c.lang: The language the player has selected, or the default if none
|
||||
c.colors: The color palette the player has selected, or the default if none
|
||||
*/
|
||||
},
|
||||
/*
|
||||
Command description and usage have been moved to the message files. The format for a basic command is:
|
||||
"command.(name).usage": " <required> [optional]",
|
||||
"command.(name).desc": "Insert description here...",
|
||||
replacing (name) with the name of the new command.
|
||||
Some more complex commands may have messages of their own, which should be placed there too.
|
||||
First, insert the following line near the top of the command's file (not in the execute function):
|
||||
const { getMessage } = require('../../util/lang.js')
|
||||
Then, to get a specific message:
|
||||
getMessage(c.lang,"(message key)",[(arguments, in an array (optional))])
|
||||
For example, this will show the "about" command's redirection to "serverinfo":
|
||||
getMessage(c.lang,"command.about.serverinfo")
|
||||
The with array can be used to add information to a message. For example:
|
||||
getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"])
|
||||
shows the "help" command's formatting for command information, with some strings as items.
|
||||
That message would render as (in en-US):
|
||||
cmdusage - desc
|
||||
Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array.
|
||||
*/
|
||||
hidden: true, // To show the command on the help command list, remove this line (optional)
|
||||
consoleIndex: true, // When run from console, the second argument will be a bot ID (optional)
|
||||
aliases: ['example', 'testing'], // Other command names that will work the same (optional)
|
||||
level: 0 // Permission level required to run this command (optional)
|
||||
}
|
34
commands/test.js
Normal file
34
commands/test.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
const reply = function (name, item) {
|
||||
return {
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, `command.test.${name}`),
|
||||
color: c.colors.secondary
|
||||
},
|
||||
{
|
||||
text: item,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
c.reply(reply('uuid', c.uuid))
|
||||
c.reply(reply('username', c.username))
|
||||
c.reply(reply('nickname', c.nickname))
|
||||
c.reply(reply('command', c.command))
|
||||
c.reply(reply('msgType', c.msgType))
|
||||
c.reply(reply('prefix', c.prefix))
|
||||
c.reply(reply('args', c.args.join(', ')))
|
||||
c.reply(reply('verify', c.verify.toString()))
|
||||
c.reply(reply('host', c.host))
|
||||
c.reply(reply('port', c.port.toString()))
|
||||
c.reply(reply('lang', c.lang))
|
||||
c.reply(reply('colorPrimary', c.colors.primary))
|
||||
c.reply(reply('colorSecondary', c.colors.secondary))
|
||||
}
|
||||
}
|
43
commands/tpr.js
Executable file
43
commands/tpr.js
Executable file
|
@ -0,0 +1,43 @@
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: function (c) {
|
||||
let uuid
|
||||
if (c.type === 'console') {
|
||||
uuid = c.bot._client.uuid
|
||||
} else {
|
||||
uuid = c.uuid
|
||||
}
|
||||
const originalPos = {
|
||||
x: Math.floor(Math.random() * 2000000) - 1000000,
|
||||
y: 100,
|
||||
z: Math.floor(Math.random() * 2000000) - 1000000
|
||||
}
|
||||
c.reply(
|
||||
{
|
||||
translate: getMessage(c.lang, 'command.tpr.success'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: c.username,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: originalPos.x.toString(),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: originalPos.y.toString(),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: originalPos.z.toString(),
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
c.bot.ccq.push(`/essentials:tp ${uuid} ${originalPos.x}.0 ${originalPos.y} ${originalPos.z}.0`)
|
||||
},
|
||||
consoleIndex: true,
|
||||
aliases: ['rtp']
|
||||
}
|
21
commands/verify.js
Normal file
21
commands/verify.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
const permsN = getMessage(c.lang, 'command.help.permsNormal')
|
||||
const permsT = getMessage(c.lang, 'command.help.permsTrusted')
|
||||
const permsO = getMessage(c.lang, 'command.help.permsOwner')
|
||||
const permsC = getMessage(c.lang, 'command.help.permsConsole')
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.verify.success'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: [permsN, permsT, permsO, permsC][c.verify],
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
aliases: ['validate'],
|
||||
level: 1
|
||||
}
|
140
index.js
140
index.js
|
@ -1,80 +1,74 @@
|
|||
const m = require("minecraft-protocol")
|
||||
const settings = require("./settings.json")
|
||||
const generateUser = require("./util/usergen.js")
|
||||
const secret = require(settings.secret)
|
||||
const EventEmitter = require("node:events")
|
||||
const crypto = require("crypto")
|
||||
const fs=require("fs")
|
||||
const m = require('minecraft-protocol')
|
||||
const settings = require('./settings.json')
|
||||
const generateUser = require('./util/usergen.js')
|
||||
const EventEmitter = require('node:events')
|
||||
const fs = require('fs')
|
||||
|
||||
module.exports.bot=[];
|
||||
module.exports.bot = []
|
||||
|
||||
const botplug = []
|
||||
const bpl = fs.readdirSync('plugins')
|
||||
for (const plugin of bpl) {
|
||||
if (!plugin.endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
botplug.push(require(`./plugins/${plugin}`))
|
||||
} catch (e) { console.log(e) }
|
||||
}
|
||||
|
||||
const loadplug = (botno) => {
|
||||
const botplug = []
|
||||
const bpl = fs.readdirSync('plugins')
|
||||
for (const i in bpl) {
|
||||
if (!bpl[i].endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
botplug.push(require(`./plugins/${bpl[i]}`))
|
||||
} catch (e) { console.log(e) }
|
||||
}
|
||||
botplug.forEach((plug) => {
|
||||
try {
|
||||
if (botno !== undefined) {
|
||||
if (plug.loadBot) {
|
||||
plug.loadBot(module.exports.bot[botno])
|
||||
}
|
||||
} else {
|
||||
plug.load()
|
||||
}
|
||||
} catch (e) { console.log(e) }
|
||||
})
|
||||
}
|
||||
loadplug()
|
||||
|
||||
const createBot = function createBot(host,oldId){
|
||||
if(host.options.disabled){
|
||||
console.log(`Skipping server ${host.host}:${host.port}`)
|
||||
return;
|
||||
}
|
||||
const bot = new EventEmitter();
|
||||
bot._client = m.createClient({
|
||||
host: host.host,
|
||||
port: host.port ? host.port : 25565,
|
||||
username: generateUser(host.options.legalName),
|
||||
version: settings.version_mc
|
||||
})
|
||||
bot._client.on("success",()=>{
|
||||
})
|
||||
if(typeof oldId !== "undefined"){
|
||||
for(const i in module.exports.bot[oldId].interval){
|
||||
clearInterval(module.exports.bot[oldId].interval[i]);
|
||||
}
|
||||
delete module.exports.bot[oldId];
|
||||
bot.id=oldId;
|
||||
module.exports.bot[oldId]=bot;
|
||||
console.log("Re-creating bot "+bot.id)
|
||||
} else {
|
||||
bot.id=module.exports.bot.length;
|
||||
module.exports.bot.push(bot);
|
||||
console.log("Creating bot "+bot.id)
|
||||
}
|
||||
|
||||
bot.host=host;
|
||||
bot.interval={};
|
||||
|
||||
bot.info=(msg)=>{
|
||||
console.log(`[${bot.id}] [info] ${msg}`)
|
||||
}
|
||||
loadplug(bot.id);
|
||||
bot._client.on("error",(err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
botplug.forEach((plug) => {
|
||||
try {
|
||||
if (plug.load) {
|
||||
plug.load(module.exports.bot[botno])
|
||||
}
|
||||
} catch (e) { console.log(e) }
|
||||
})
|
||||
}
|
||||
|
||||
const createBot = function createBot (host, oldId) {
|
||||
if (host.options.disabled) {
|
||||
return
|
||||
}
|
||||
const bot = new EventEmitter()
|
||||
bot._client = m.createClient({
|
||||
host: host.host,
|
||||
port: host.port ? host.port : 25565,
|
||||
username: generateUser(host.options.legalName),
|
||||
version: host.version ? host.version : settings.version_mc
|
||||
})
|
||||
if (typeof oldId !== 'undefined') {
|
||||
for (const i in module.exports.bot[oldId].interval) {
|
||||
clearInterval(module.exports.bot[oldId].interval[i])
|
||||
}
|
||||
delete module.exports.bot[oldId]
|
||||
bot.id = oldId
|
||||
module.exports.bot[oldId] = bot
|
||||
} else {
|
||||
bot.id = module.exports.bot.length
|
||||
module.exports.bot.push(bot)
|
||||
}
|
||||
|
||||
for(const i in settings.servers){
|
||||
createBot(settings.servers[i]);
|
||||
bot.host = host
|
||||
bot.interval = {}
|
||||
|
||||
bot.info = (msg) => {
|
||||
console.log(`[${bot.id}] [info] ${msg}`)
|
||||
}
|
||||
|
||||
bot.displayChat = (type, msg) => {
|
||||
console.log(`[${bot.id}] [${type}] ${msg}`)
|
||||
}
|
||||
|
||||
loadplug(bot.id)
|
||||
bot._client.on('error', (err) => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
module.exports.createBot = createBot;
|
||||
|
||||
for (const server of settings.servers) {
|
||||
createBot(server)
|
||||
}
|
||||
|
||||
module.exports.createBot = createBot
|
||||
|
|
118
lang/en-US.json
Normal file
118
lang/en-US.json
Normal file
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"language.name": "English",
|
||||
"language.region": "United States",
|
||||
"time.week": " week ",
|
||||
"time.weekPlural": " weeks ",
|
||||
"time.day": " day ",
|
||||
"time.dayPlural": " days ",
|
||||
"time.hour": " hour ",
|
||||
"time.hourPlural": " hours ",
|
||||
"time.minute": " minute ",
|
||||
"time.minutePlural": " minutes ",
|
||||
"time.second": " second ",
|
||||
"time.secondPlural": " seconds ",
|
||||
"command.about.usage": "",
|
||||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
"command.cb.desc": "Run a command in a command block",
|
||||
"command.cloop.usage": " add <rate> <command>|| remove <index>|| list|| clear",
|
||||
"command.cloop.desc": "Manage command loops",
|
||||
"command.eval.usage": " <code>",
|
||||
"command.eval.desc": "Run JavaScript code",
|
||||
"command.help.usage": " [cmd]",
|
||||
"command.help.desc": "Shows command help",
|
||||
"command.logoff.usage": "",
|
||||
"command.logoff.desc": "Disconnect and reconnect the bot from a server",
|
||||
"command.netmsg.usage": " <message>",
|
||||
"command.netmsg.desc": "Send a message to all servers the bot is connected to",
|
||||
"command.refill.usage": "",
|
||||
"command.refill.desc": "Refill core",
|
||||
"command.say.usage": " <message>",
|
||||
"command.say.desc": "Sends a message to chat",
|
||||
"command.settings.usage": " get|| set <key> <value>",
|
||||
"command.settings.desc": "Set your user preferences",
|
||||
"command.stop.usage": "",
|
||||
"command.stop.desc": "Restart bot",
|
||||
"command.template.usage": " <required> [optional]",
|
||||
"command.template.desc": "Does nothing",
|
||||
"command.test.usage": " [args...]",
|
||||
"command.test.desc": "Chat parsing debugger command",
|
||||
"command.tpr.usage": "",
|
||||
"command.tpr.desc": "Teleport to a random location",
|
||||
"command.verify.usage": " [args...]",
|
||||
"command.verify.desc": "Check the hashing system",
|
||||
"command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones",
|
||||
"command.about.version": "Version %s",
|
||||
"command.about.preRelease": "This is a development version - there may be errors, and features may be changed or removed at any time. Please report any errors to the bot's developer.",
|
||||
"command.about.sourceCode": "Source code: %s",
|
||||
"command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser",
|
||||
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
|
||||
"command.cloop.error.subcommand": "Unknown subcommand, please do %s",
|
||||
"command.cloop.success.add": "Added command loop with command %s and rate %s",
|
||||
"command.cloop.success.remove": "Removed command loop %s",
|
||||
"command.cloop.success.clear": "Cleared all command loops",
|
||||
"command.cloop.list": "%s: Command: %s Rate: %s",
|
||||
"command.help.cmdList": "Commands:",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
"command.help.commandDesc": "Description - %s",
|
||||
"command.help.commandPerms": "Required permissions - %s",
|
||||
"command.help.permsNormal": "Normal",
|
||||
"command.help.permsTrusted": "Trusted",
|
||||
"command.help.permsOwner": "Owner",
|
||||
"command.help.permsConsole": "Console",
|
||||
"command.help.noCommand": "Command does not exist",
|
||||
"command.help.alias": "Alias to %s",
|
||||
"command.netmsg.disabled": "This command has been disabled on this server.",
|
||||
"command.settings.get.colorPrimary": "Primary color",
|
||||
"command.settings.get.colorSecondary": "Secondary color",
|
||||
"command.settings.get.language": "Language",
|
||||
"command.settings.setLanguage": "Run %s to set this as your language",
|
||||
"command.settings.error.invalidKey": "Invalid key",
|
||||
"command.settings.error.invalidLanguage": "Invalid language",
|
||||
"command.settings.error.mustProvideValue": "You must provide a value",
|
||||
"command.settings.saved": "Settings saved.",
|
||||
"command.test.uuid": "UUID",
|
||||
"command.test.username": "Username",
|
||||
"command.test.nickname": "Nickname",
|
||||
"command.test.command": "Command",
|
||||
"command.test.msgType": "Message type",
|
||||
"command.test.prefix": "Prefix",
|
||||
"command.test.args": "Arguments",
|
||||
"command.test.verify": "Permission level",
|
||||
"command.test.host": "Server host",
|
||||
"command.test.port": "Server port",
|
||||
"command.test.lang": "Language",
|
||||
"command.test.colorPrimary": "Primary color",
|
||||
"command.test.colorSecondary": "Secondary color",
|
||||
"command.about.serverInfo.os.android": "Android %s",
|
||||
"command.about.serverInfo.os.android.noVersion": "Android",
|
||||
"command.about.serverInfo.os.freebsd": "FreeBSD",
|
||||
"command.about.serverInfo.os.linux": "Linux",
|
||||
"command.about.serverInfo.os.macos": "macOS",
|
||||
"command.about.serverInfo.os.macos_old": "OS X",
|
||||
"command.about.serverInfo.os": "Operating system",
|
||||
"command.about.serverInfo.kernelVer": "Kernel version",
|
||||
"command.about.serverInfo.processor": "CPU",
|
||||
"command.about.serverInfo.arch": "Architecture",
|
||||
"command.about.serverInfo.osUsername": "Username",
|
||||
"command.about.serverInfo.hostName": "Hostname",
|
||||
"command.about.serverInfo.workingDir": "Working directory",
|
||||
"command.about.serverInfo.runTime": "Bot uptime",
|
||||
"command.about.serverInfo.upTime": "System uptime",
|
||||
"command.about.serverInfo.nodeVersion": "Node.js version",
|
||||
"command.about.serverInfo.osRelease": "Linux release",
|
||||
"command.about.serverInfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
|
||||
"command.about.serverInfo.os.android.version": "Android version",
|
||||
"command.about.serverInfo.os.android.model": "Device model",
|
||||
"command.about.serverInfo.botName": "Bot name",
|
||||
"command.about.serverInfo.botVer": "Bot version",
|
||||
"command.about.serverListItem": "Server %s - %s",
|
||||
"command.tpr.success": "Teleporting %s to %s, %s, %s",
|
||||
"command.verify.success": "Successfully verified with permission level %s",
|
||||
"command.error": "An error occured (check console for more info)",
|
||||
"command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.",
|
||||
"command.disallowed.perms.yourLevel": "Your permission level: %s",
|
||||
"command.disallowed.perms.cmdLevel": "Command requires: %s",
|
||||
"copyText": "Click to copy!"
|
||||
}
|
8
launch.cmd
Normal file
8
launch.cmd
Normal file
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
:botlaunch
|
||||
node index.js
|
||||
if %errorlevel%==1 (
|
||||
exit
|
||||
)
|
||||
timeout /nobreak /t 5 > nul
|
||||
goto botlaunch
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
while [ true ];
|
||||
do node index.js;
|
||||
if [ $? -eq 1 ]; then exit; fi
|
||||
sleep 6;
|
||||
done
|
42
package-lock.json
generated
42
package-lock.json
generated
|
@ -7,28 +7,28 @@
|
|||
"": {
|
||||
"name": "botv10",
|
||||
"version": "10.0.0",
|
||||
"license": "UNLICENSED",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minecraft-protocol": "^1.45.0",
|
||||
"prismarine-chat": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/msal-common": {
|
||||
"version": "14.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz",
|
||||
"integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==",
|
||||
"version": "14.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.1.tgz",
|
||||
"integrity": "sha512-2Q3tqNz/PZLfSr8BvcHZVpRRfSn4MjGSqjj9J+HlBsmbf1Uu4P0WeXnemjTJwwx9KrmplsrN3UkZ/LPOR720rw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/msal-node": {
|
||||
"version": "2.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz",
|
||||
"integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==",
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.13.0.tgz",
|
||||
"integrity": "sha512-DhP97ycs7qlCVzzzWGzJiwAFyFj5okno74E4FUZ61oCLfKh4IxA1kxirqzrWuYZWpBe9HVPL6GA4NvmlEOBN5Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@azure/msal-common": "14.14.0",
|
||||
"@azure/msal-common": "14.14.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"uuid": "^8.3.0"
|
||||
},
|
||||
|
@ -37,12 +37,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.14.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz",
|
||||
"integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==",
|
||||
"version": "22.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz",
|
||||
"integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
"undici-types": "~6.19.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/readable-stream": {
|
||||
|
@ -189,9 +189,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.5",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz",
|
||||
"integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==",
|
||||
"version": "4.3.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz",
|
||||
"integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
|
@ -427,9 +427,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/minecraft-data": {
|
||||
"version": "3.67.0",
|
||||
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz",
|
||||
"integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==",
|
||||
"version": "3.68.0",
|
||||
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.68.0.tgz",
|
||||
"integrity": "sha512-pNBTi39a1zbFpN9itwi0YSL3hqAsSw38D7pE9C6m+aURmXljpBlNTO+TkpZxxDv4KqqtNBOhmkj4x46IDW6R+Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/minecraft-folder-path": {
|
||||
|
@ -762,9 +762,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"version": "6.19.8",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "UNLICENSED",
|
||||
"license": "MIT",
|
||||
"description": ""
|
||||
}
|
||||
|
|
193
plugins/!chat.js
193
plugins/!chat.js
|
@ -99,3 +99,196 @@ module.exports={
|
|||
},
|
||||
parse
|
||||
}
|
||||
|
||||
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 messageTypes = [
|
||||
'',
|
||||
'chat.type.emote',
|
||||
'commands.message.display.incoming',
|
||||
'commands.message.display.outgoing',
|
||||
'',
|
||||
'chat.type.announcement',
|
||||
'chat.type.team.text',
|
||||
'chat.type.team.sent'
|
||||
]
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b._client.on('profileless_chat', (data) => {
|
||||
if (data.type === 4) {
|
||||
const json = parse1204(data.message)
|
||||
const parsed = parsePlain(json)
|
||||
const split = parsed.split(': ')
|
||||
const chatName = split.splice(0, 1)[0]
|
||||
const chatNameSplit = chatName.split(' ')
|
||||
const nickname = chatNameSplit[chatNameSplit.length - 1]
|
||||
const username = b.findRealName(chatName)
|
||||
const uuid = b.findUUID(username)
|
||||
b.emit('chat', {
|
||||
json,
|
||||
type: 'profileless',
|
||||
uuid,
|
||||
message: split.join(': '),
|
||||
nickname,
|
||||
username
|
||||
})
|
||||
} else if (data.type === 6 || data.type === 7) {
|
||||
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
|
||||
const nickname = b.findDisplayName(uuid)
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.target),
|
||||
parse1204(data.name),
|
||||
data.message
|
||||
]
|
||||
},
|
||||
type: 'profileless',
|
||||
uuid,
|
||||
message: parsePlain(data.message),
|
||||
nickname,
|
||||
username: parsePlain(parse1204(data.name))
|
||||
})
|
||||
} else {
|
||||
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
|
||||
const nickname = b.findDisplayName(uuid)
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.name),
|
||||
parse1204(data.message)
|
||||
]
|
||||
},
|
||||
type: 'profileless',
|
||||
uuid,
|
||||
message: parsePlain(parse1204(data.message)),
|
||||
nickname,
|
||||
username: parsePlain(parse1204(data.name))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
b._client.on('player_chat', (data) => {
|
||||
if (data.type === 4) {
|
||||
b.emit('chat', {
|
||||
json: parse1204(data.unsignedChatContent),
|
||||
type: 'player',
|
||||
uuid: data.senderUuid,
|
||||
message: data.plainMessage,
|
||||
nickname: parsePlain(parse1204(data.networkName)),
|
||||
username: b.findRealNameFromUUID(data.senderUuid)
|
||||
})
|
||||
} else if (data.type === 6 || data.type === 7) {
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: data.type === 2 ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.networkTargetName),
|
||||
parse1204(data.networkName),
|
||||
data.plainMessage
|
||||
]
|
||||
},
|
||||
type: 'player',
|
||||
uuid: data.senderUuid,
|
||||
message: parsePlain(data.plainMessage),
|
||||
nickname: parsePlain(parse1204(data.networkName)),
|
||||
username: b.findRealNameFromUUID(data.senderUuid)
|
||||
})
|
||||
} else {
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.networkName),
|
||||
data.plainMessage
|
||||
]
|
||||
},
|
||||
type: 'player',
|
||||
uuid: data.senderUuid,
|
||||
message: parsePlain(data.plainMessage),
|
||||
nickname: parsePlain(parse1204(data.networkName)),
|
||||
username: b.findRealNameFromUUID(data.senderUuid)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
b._client.on('system_chat', (data) => {
|
||||
const json = parse1204(data.content)
|
||||
const parsed = parsePlain(json)
|
||||
const split = parsed.split(': ')
|
||||
const chatName = split.splice(0, 1)[0]
|
||||
const chatNameSplit = chatName.split(' ')
|
||||
const nickname = chatNameSplit[chatNameSplit.length - 1]
|
||||
const username = b.findRealName(chatName)
|
||||
const uuid = b.findUUID(username)
|
||||
b.emit('chat', {
|
||||
json,
|
||||
type: 'system',
|
||||
uuid,
|
||||
message: split.join(': '),
|
||||
nickname,
|
||||
username
|
||||
})
|
||||
})
|
||||
|
||||
b._client.on('chat', (data) => { // Legacy chat for versions <1.19
|
||||
const json = parse1204(data.message)
|
||||
const parsed = parsePlain(json)
|
||||
let chatName
|
||||
let nickname
|
||||
let username
|
||||
let message
|
||||
let uuid
|
||||
if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat
|
||||
if (json.with && json.with.length >= 2) {
|
||||
message = parsePlain(json.with[1])
|
||||
username = parsePlain(json.with[0])
|
||||
}
|
||||
uuid = b.findUUID(username)
|
||||
} else { // Servers with Extras chat, such as Kaboom
|
||||
const split = parsed.split(': ')
|
||||
chatName = split.splice(0, 1)[0]
|
||||
const chatNameSplit = chatName.split(' ')
|
||||
nickname = chatNameSplit[chatNameSplit.length - 1]
|
||||
username = b.findRealName(chatName)
|
||||
uuid = b.findUUID(username)
|
||||
message = split.join(': ')
|
||||
}
|
||||
if (data.uuid) uuid = data.uuid
|
||||
b.emit('chat', {
|
||||
json,
|
||||
type: 'legacy',
|
||||
uuid,
|
||||
message,
|
||||
nickname,
|
||||
username
|
||||
})
|
||||
})
|
||||
|
||||
b.on('chat', (data) => {
|
||||
const msgConsole = parseConsole(data.json)
|
||||
const msgPlain = parsePlain(data.json)
|
||||
if (settings.logJSONmessages) console.log(data.json)
|
||||
if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
32
plugins/chatlog.js
Executable file
32
plugins/chatlog.js
Executable file
|
@ -0,0 +1,32 @@
|
|||
const chatlog = require('../util/chatlog.js')
|
||||
const fs = require('fs')
|
||||
const settings = require('../settings.json')
|
||||
|
||||
const checkLog = () => {
|
||||
if (settings.disableLogging) return
|
||||
try {
|
||||
if (!fs.readdirSync('.').includes('logs')) fs.mkdirSync('logs')
|
||||
const dateToday = new Date(Date.now())
|
||||
const dateTomorrow = new Date(Date.now() + 86400000)
|
||||
const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`
|
||||
const filenameTomorrow = `${dateTomorrow.getUTCMonth() + 1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}`
|
||||
if (!fs.readdirSync('./logs').includes(filenameToday)) fs.mkdirSync(`logs/${filenameToday}`)
|
||||
if (!fs.readdirSync('./logs').includes(filenameTomorrow)) fs.mkdirSync(`logs/${filenameTomorrow}`) // Create tomorrow's log directory early
|
||||
} catch (e) {
|
||||
console.log(e) // Prevents some crashes when disk space is full or when the permissions are incorrect
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(checkLog, 3600000) // Runs once every hour,
|
||||
checkLog() // and at bot startup.
|
||||
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.on('plainchat', (msg, type) => {
|
||||
if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`)
|
||||
})
|
||||
b.on('command', (name, uuid, text) => {
|
||||
if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,26 +1,23 @@
|
|||
module.exports={
|
||||
load:()=>{
|
||||
|
||||
},
|
||||
loadBot:(b)=>{
|
||||
b.cloops=[];
|
||||
b.addCloop=function (command, rate){
|
||||
b.cloops.push({
|
||||
command,
|
||||
rate,
|
||||
interval: setInterval(()=>{b.ccq.push(command)},rate)
|
||||
})
|
||||
b.ccq.push(command)
|
||||
}
|
||||
b.removeCloop=function (index){
|
||||
clearInterval(b.cloops[index].interval)
|
||||
b.cloops.splice(index,1)
|
||||
}
|
||||
b.clearCloops=function (){
|
||||
for(const i in b.cloops){
|
||||
clearInterval(b.cloops[i].interval)
|
||||
}
|
||||
b.cloops=[];
|
||||
}
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.cloops = []
|
||||
b.addCloop = function (command, rate) {
|
||||
b.cloops.push({
|
||||
command,
|
||||
rate,
|
||||
interval: setInterval(() => { b.ccq.push(command) }, rate)
|
||||
})
|
||||
b.ccq.push(command)
|
||||
}
|
||||
}
|
||||
b.removeCloop = function (index) {
|
||||
clearInterval(b.cloops[index].interval)
|
||||
b.cloops.splice(index, 1)
|
||||
}
|
||||
b.clearCloops = function () {
|
||||
for (const cloop of b.cloops) {
|
||||
clearInterval(cloop.interval)
|
||||
}
|
||||
b.cloops = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,156 +1,65 @@
|
|||
const fs=require("fs");
|
||||
const Command=require("../util/Command.js");
|
||||
const hashcheck=require("../util/hashcheck.js");
|
||||
const settings = require("../settings.json");
|
||||
const getMessage = require('../util/lang.js');
|
||||
let cmds=Object.create(null);
|
||||
const sortHelp=function sortHelp(c1, c2){
|
||||
const level1 = cmds[c1.with[1]].level?cmds[c1.with[1]].level:0;
|
||||
const level2 = cmds[c2.with[1]].level?cmds[c2.with[1]].level:0;
|
||||
return level1 - level2
|
||||
const Command = require('../util/Command.js')
|
||||
const hashcheck = require('../util/hashcheck.js')
|
||||
const settings = require('../settings.json')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
const cmds = require('../util/commands.js')
|
||||
const fs = require('fs')
|
||||
|
||||
if (!fs.readdirSync('.').includes('userPref')) fs.mkdirSync('userPref')
|
||||
|
||||
const loadSettings = function (uuid) {
|
||||
try {
|
||||
return require(`../userPref/${uuid}.json`)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
module.exports={
|
||||
load:()=>{
|
||||
module.exports.loadCMD();
|
||||
},
|
||||
loadBot:(b)=>{
|
||||
b.prefix=settings.prefix;
|
||||
b.lastCmd=0;
|
||||
b.runCommand=(name, uuid, text, prefix)=>{
|
||||
if(uuid=="00000000-0000-0000-0000-000000000000") return;
|
||||
if(Date.now()-b.lastCmd<=1000) return;
|
||||
b.lastCmd=Date.now();
|
||||
const cmd=text.split(" ");
|
||||
let lang=settings.defaultLang;
|
||||
let verify=hashcheck(cmd);
|
||||
if(verify>0){
|
||||
text=cmd.slice(0,cmd.length-1).join(" ");
|
||||
}
|
||||
if(cmds[cmd[0].toLowerCase()]){
|
||||
const command = cmds[cmd[0].toLowerCase()];
|
||||
if(command.level!==undefined && command.level>verify){
|
||||
b.tellraw(uuid,{
|
||||
text:getMessage(lang,"command.disallowed.perms")
|
||||
});
|
||||
b.tellraw(uuid,{
|
||||
text:getMessage(lang,"command.disallowed.perms.yourLevel",[verify+""])
|
||||
});
|
||||
b.tellraw(uuid,{
|
||||
text:getMessage(lang,"command.disallowed.perms.cmdLevel",[command.level+""])
|
||||
});
|
||||
return;
|
||||
}
|
||||
try{
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify))
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
b.tellraw(uuid,{
|
||||
text:getMessage(lang,"command.error"),
|
||||
color: "red",
|
||||
hoverEvent:{
|
||||
action: "show_text",
|
||||
value:{
|
||||
"text": e.stack
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.prefix = settings.prefix
|
||||
b.lastCmd = 0
|
||||
b.runCommand = (name, nickname, uuid, text, msgType, prefix) => {
|
||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||
if (Date.now() - b.lastCmd <= 1000) return
|
||||
const userSettings = loadSettings(uuid)
|
||||
b.lastCmd = Date.now()
|
||||
const cmd = text.split(' ')
|
||||
const lang = settings.defaultLang
|
||||
const verify = hashcheck(cmd)
|
||||
if (verify > 0) {
|
||||
text = cmd.slice(0, cmd.length - 1).join(' ')
|
||||
}
|
||||
b.emit('command', name, uuid, text, prefix)
|
||||
if (cmds[cmd[0].toLowerCase()]) {
|
||||
const command = cmds[cmd[0].toLowerCase()]
|
||||
if (command.level !== undefined && command.level > verify) {
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(lang, 'command.disallowed.perms')
|
||||
})
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + ''])
|
||||
})
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + ''])
|
||||
})
|
||||
return
|
||||
}
|
||||
b.printHelp=(uuid,prefix,lang)=>{
|
||||
let commandList=[];
|
||||
for(const i in cmds){
|
||||
if(cmds[i].hidden) continue;
|
||||
let cmdColor;
|
||||
switch (cmds[i].level){
|
||||
case 0:
|
||||
cmdColor = "green";
|
||||
break;
|
||||
case 1:
|
||||
cmdColor = "red";
|
||||
break;
|
||||
case 2:
|
||||
cmdColor = "dark_red";
|
||||
break;
|
||||
case 3:
|
||||
cmdColor = "dark_gray";
|
||||
break;
|
||||
default:
|
||||
cmdColor = "gray";
|
||||
}
|
||||
commandList.push(
|
||||
{
|
||||
translate: "%s%s ",
|
||||
color: cmdColor,
|
||||
with: [
|
||||
prefix,
|
||||
i
|
||||
]
|
||||
}
|
||||
)
|
||||
try {
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(lang, 'command.error'),
|
||||
color: 'red',
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
text: e.stack
|
||||
}
|
||||
}
|
||||
b.tellraw(uuid,{
|
||||
translate: "%s: %s",
|
||||
with: [
|
||||
getMessage(lang,"command.help.cmdList"),
|
||||
commandList.sort(sortHelp)
|
||||
]
|
||||
})
|
||||
})
|
||||
}
|
||||
b.printCmdHelp=(uuid,cmd,lang)=>{
|
||||
if(!cmds[cmd]){
|
||||
b.tellraw(uuid,{text:getMessage(lang,"command.help.noCommand")});
|
||||
return;
|
||||
}
|
||||
let usage=getMessage(lang,`command.${cmd}.usage`).split("||");
|
||||
let desc=getMessage(lang,`command.${cmd}.desc`);
|
||||
if(cmds[cmd].usage){
|
||||
usage=cmds[cmd].usage.split("||");
|
||||
}
|
||||
if(cmds[cmd].desc){
|
||||
desc=cmds[cmd].desc;
|
||||
}
|
||||
//b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])});
|
||||
for(const i in usage){
|
||||
b.tellraw(uuid,{text:getMessage(lang,"command.help.commandUsage",[cmd,usage[i]])});
|
||||
}
|
||||
b.tellraw(uuid,{text:getMessage(lang,"command.help.commandDesc",[desc])});
|
||||
const permsN=getMessage(lang,"command.help.permsNormal");
|
||||
const permsT=getMessage(lang,"command.help.permsTrusted");
|
||||
const permsO=getMessage(lang,"command.help.permsOwner");
|
||||
const permsC=getMessage(lang,"command.help.permsConsole");
|
||||
const rPerms=cmds[cmd].level?cmds[cmd].level:0;
|
||||
b.tellraw(uuid,{text:getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]])});
|
||||
}
|
||||
},
|
||||
loadCMD:()=>{
|
||||
const botplug = []
|
||||
const bpl = fs.readdirSync('./plugins/commands')
|
||||
for (const i in bpl) {
|
||||
if (!bpl[i].endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
commandName=bpl[i].split(".js")[0];
|
||||
cmds[commandName]=require(`./commands/${bpl[i]}`);
|
||||
if(cmds[commandName].level === undefined){
|
||||
cmds[commandName].level = 0;
|
||||
}
|
||||
console.log("Loaded command "+commandName);
|
||||
if(cmds[commandName].aliases){
|
||||
for(const j in cmds[commandName].aliases){
|
||||
cmds[cmds[commandName].aliases[j]]={
|
||||
execute:cmds[commandName].execute,
|
||||
desc:"Alias to "+commandName,
|
||||
usage:cmds[commandName].usage,
|
||||
level:cmds[commandName].level,
|
||||
hidden:true,
|
||||
consoleIndex:cmds[commandName].consoleIndex
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (e) { console.log(e); }
|
||||
}
|
||||
},
|
||||
cmds
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,3 +104,130 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const uuidToInt = require('../util/uuidtoint.js')
|
||||
const cs = {
|
||||
x: 4,
|
||||
y: 6,
|
||||
z: 4
|
||||
}
|
||||
module.exports = {
|
||||
load: function (b) {
|
||||
b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 150000)
|
||||
b.ccq = []
|
||||
b.blocknoX = 0
|
||||
b.blocknoZ = 0
|
||||
b.ccStarted = false
|
||||
b.blocknoY = 0
|
||||
b.pos = { x: 0, y: 0, z: 0 }
|
||||
|
||||
b.refillCoreCmd = `/fill ~ 55 ~ ~${cs.x - 1} ${54 + cs.y} ~${cs.z - 1} command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`
|
||||
|
||||
b.advanceccq = function () {
|
||||
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
||||
b._client.write('update_command_block', {
|
||||
command: '/',
|
||||
location: {
|
||||
x: b.commandPos.x + b.blocknoX,
|
||||
y: b.commandPos.y + b.blocknoY,
|
||||
z: b.commandPos.z + b.blocknoZ
|
||||
},
|
||||
mode: 2,
|
||||
flags: 1
|
||||
})
|
||||
b._client.write('update_command_block', {
|
||||
command: b.ccq[0].substr(0, 32767),
|
||||
location: {
|
||||
x: b.commandPos.x + b.blocknoX,
|
||||
y: b.commandPos.y + b.blocknoY,
|
||||
z: b.commandPos.z + b.blocknoZ
|
||||
},
|
||||
mode: 2,
|
||||
flags: 5
|
||||
})
|
||||
b.blocknoX++
|
||||
if (b.blocknoX === cs.x) {
|
||||
b.blocknoY++
|
||||
b.blocknoX = 0
|
||||
if (b.blocknoY === cs.y) {
|
||||
b.blocknoZ++
|
||||
b.blocknoY = 0
|
||||
if (b.blocknoZ === cs.z) {
|
||||
b.blocknoZ = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
b.ccq.splice(0, 1)
|
||||
}
|
||||
|
||||
b._client.on('login', () => {
|
||||
b._client.write('settings', {
|
||||
locale: 'ru_RU',
|
||||
viewDistance: 4,
|
||||
chatFlags: 0, // Enable full chat functionality
|
||||
chatColors: true,
|
||||
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
|
||||
mainHand: 1 // Right hand
|
||||
})
|
||||
b.add_sc_task('cc', () => {
|
||||
b.chat(b.refillCoreCmd)
|
||||
}, true)
|
||||
b.add_sc_task('cc_size', () => {
|
||||
b.chat('/gamerule commandModificationBlockLimit 32768')
|
||||
})
|
||||
})
|
||||
b.on('ccstart', () => {
|
||||
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000)
|
||||
b.ccStarted = true
|
||||
})
|
||||
b.on('chat', (data) => {
|
||||
if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') ||
|
||||
data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) {
|
||||
if (!b.ccStarted) {
|
||||
b.emit('ccstart')
|
||||
}
|
||||
b.sc_tasks.cc.failed = 0
|
||||
b.sc_tasks.cc_size.failed = 0
|
||||
} else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) {
|
||||
b.sc_tasks.cc_size.failed = 1
|
||||
}
|
||||
})
|
||||
b._client.on('position', function (a) {
|
||||
if (!b.ccStarted) {
|
||||
b.original_pos = { x: a.x, y: a.y, z: a.z }
|
||||
b.pos = { x: a.x, y: a.y, z: a.z }
|
||||
} else {
|
||||
b.pos = { x: a.x, y: a.y, z: a.z }
|
||||
if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) {
|
||||
b.original_pos = { x: a.x, y: a.y, z: a.z }
|
||||
b.sc_tasks.cc.failed = 1
|
||||
}
|
||||
}
|
||||
b.commandPos = {
|
||||
x: Math.floor(a.x),
|
||||
z: Math.floor(a.z),
|
||||
y: 55
|
||||
}
|
||||
b._client.write('teleport_confirm', { teleportId: a.teleportId })
|
||||
})
|
||||
|
||||
b.tellraw = (uuid, message) => {
|
||||
let finalname = ''
|
||||
if (uuid === '@a') {
|
||||
finalname = '@a'
|
||||
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
|
||||
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
|
||||
} else {
|
||||
finalname = uuid
|
||||
}
|
||||
let tellrawCommand
|
||||
if (b.host.options.isVanilla) {
|
||||
tellrawCommand = 'tellraw'
|
||||
} else {
|
||||
tellrawCommand = 'minecraft:tellraw'
|
||||
}
|
||||
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,49 +1,67 @@
|
|||
const parse = require("../util/chatparse.js")
|
||||
const parse1204 = require("../util/chatparse_1204.js")
|
||||
module.exports={
|
||||
load:()=>{
|
||||
},
|
||||
loadBot:(b)=>{
|
||||
b.players={};
|
||||
b._client.on("player_info",(data)=>{
|
||||
console.log
|
||||
let buffer2={};
|
||||
for(const i in data.data){
|
||||
let uuid;
|
||||
if(data.data[i].uuid){
|
||||
uuid=data.data[i].uuid
|
||||
} else if(data.data[i].UUID){
|
||||
uuid=data.data[i].UUID
|
||||
}
|
||||
if(data.data[i].player && data.data[i].player.name!==undefined){
|
||||
buffer2[uuid]={realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1]}
|
||||
} else if(data.data[i].name!==undefined){
|
||||
buffer2[uuid]={realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1]}
|
||||
} else if(data.data[i].displayName!==undefined){
|
||||
buffer2[uuid]={displayName: parse(parse1204(data.data[i].displayName))[1]}
|
||||
}
|
||||
}
|
||||
for(const uuid in buffer2){
|
||||
if(!b.players[uuid]) b.players[uuid]={displayName:"",realName:""};
|
||||
if(buffer2[uuid].displayName) b.players[uuid].displayName=buffer2[uuid].displayName;
|
||||
if(buffer2[uuid].realName) b.players[uuid].realName=buffer2[uuid].realName;
|
||||
}
|
||||
})
|
||||
b.findUUID=(name)=>{
|
||||
for(const i in b.players){
|
||||
if(b.players[i].realName==name){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return "00000000-0000-0000-0000-000000000000"
|
||||
const parse = require('../util/chatparse_plain')
|
||||
const parseNBT = require('../util/parseNBT')
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.players = {}
|
||||
b._client.on('player_info', (data) => {
|
||||
const buffer2 = {}
|
||||
for (const player of data.data) {
|
||||
let uuid
|
||||
if (player.uuid) {
|
||||
uuid = player.uuid
|
||||
} else if (player.UUID) {
|
||||
uuid = player.UUID
|
||||
}
|
||||
b.findRealName=(name)=>{
|
||||
for(const i in b.players){
|
||||
if(b.players[i].displayName==name){
|
||||
return b.players[i].realName
|
||||
}
|
||||
}
|
||||
return "Geometrical Dominator"
|
||||
let displayName
|
||||
if (player.displayName !== undefined) {
|
||||
displayName = player.displayName
|
||||
} else {
|
||||
displayName = '{"text":"[[[[ No display name ]]]]"}'
|
||||
}
|
||||
if (player.player && player.player.name !== undefined) {
|
||||
buffer2[uuid] = { realName: player.player.name, displayName: parse(parseNBT(displayName)) }
|
||||
} else if (player.name !== undefined) {
|
||||
buffer2[uuid] = { realName: player.name, displayName: parse(parseNBT(displayName)) }
|
||||
} else if (player.displayName !== undefined) {
|
||||
buffer2[uuid] = { displayName: parse(parseNBT(displayName)) }
|
||||
}
|
||||
}
|
||||
for (const uuid in buffer2) {
|
||||
if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' }
|
||||
if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName
|
||||
if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName
|
||||
}
|
||||
})
|
||||
b.findUUID = (name) => {
|
||||
for (const i in b.players) {
|
||||
if (b.players[i].realName === name) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return '00000000-0000-0000-0000-000000000000'
|
||||
}
|
||||
}
|
||||
b.findRealName = (name) => {
|
||||
for (const i in b.players) {
|
||||
if (b.players[i].displayName === name) {
|
||||
return b.players[i].realName
|
||||
}
|
||||
}
|
||||
return '[[[[ no name ]]]]'
|
||||
}
|
||||
b.findRealNameFromUUID = (name) => {
|
||||
if (b.players[name]) {
|
||||
return b.players[name].realName
|
||||
} else {
|
||||
return '[[[[ no name ]]]]'
|
||||
}
|
||||
}
|
||||
b.findDisplayName = (name) => {
|
||||
if (b.players[name]) {
|
||||
const displayName = b.players[name].displayName.split(' ')
|
||||
return displayName[displayName.length - 1]
|
||||
} else {
|
||||
return '[[[[ No display name ]]]]'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
85
plugins/selfcare.js
Executable file
85
plugins/selfcare.js
Executable file
|
@ -0,0 +1,85 @@
|
|||
class SCTask {
|
||||
constructor (failTask, startFailed = false) {
|
||||
/*
|
||||
* failed: Whether to run this task
|
||||
* failTask: Command to run when failed is true
|
||||
*/
|
||||
this.failed = startFailed
|
||||
this.failTask = failTask
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
b.sc_tasks = {}
|
||||
b.selfcareRun = 0
|
||||
b.interval.sc = setInterval(() => {
|
||||
if (Date.now() - b.selfcareRun <= 600) {
|
||||
return
|
||||
}
|
||||
for (const i in b.sc_tasks) {
|
||||
if (b.sc_tasks[i].failed) {
|
||||
b.sc_tasks[i].failTask()
|
||||
}
|
||||
}
|
||||
b.selfcareRun = Date.now()
|
||||
}, 40)
|
||||
b.add_sc_task = (name, failTask, startFailed) => {
|
||||
b.sc_tasks[name] = new SCTask(failTask, startFailed)
|
||||
}
|
||||
|
||||
// Self care tasks
|
||||
|
||||
// Operator
|
||||
b.add_sc_task('op', () => {
|
||||
b.chat('/op @s[type=player]')
|
||||
})
|
||||
b._client.on('login', (p) => {
|
||||
b.entityId = p.entityId
|
||||
})
|
||||
b._client.on('entity_status', (p) => {
|
||||
if (p.entityId === b.entityId && p.entityStatus === 24) {
|
||||
b.sc_tasks.op.failed = 1
|
||||
} else if (p.entityId === b.entityId && p.entityStatus === 28) {
|
||||
b.sc_tasks.op.failed = 0
|
||||
}
|
||||
})
|
||||
|
||||
// CommandSpy
|
||||
if (!b.host.options.isVanilla) {
|
||||
b.add_sc_task('cspy', () => {
|
||||
b.chat('/cspy on')
|
||||
}, true)
|
||||
b.on('plainchat', (msg) => {
|
||||
if (msg === 'Successfully disabled CommandSpy') {
|
||||
b.sc_tasks.cspy.failed = 1
|
||||
} else if (msg === 'Successfully enabled CommandSpy') {
|
||||
b.sc_tasks.cspy.failed = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Gamemode
|
||||
b.add_sc_task('gamemode', () => {
|
||||
b.chat('/minecraft:gamemode creative')
|
||||
})
|
||||
b._client.on('game_state_change', (p) => {
|
||||
if (p.reason === 3 && p.gameMode !== 1) {
|
||||
b.sc_tasks.gamemode.failed = 1
|
||||
} else if (p.reason === 3 && p.gameMode === 1) {
|
||||
b.sc_tasks.gamemode.failed = 0
|
||||
}
|
||||
})
|
||||
|
||||
// Respawning after dying
|
||||
b.add_sc_task('respawn', () => {
|
||||
b._client.write('client_command', { actionId: 0 }) // Simulates respawning
|
||||
b.sc_tasks.respawn.failed = 0
|
||||
})
|
||||
b.on('chat', (data) => {
|
||||
if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options') ||
|
||||
data.json.translate === 'Chat disabled in client options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'Chat disabled in client options')) {
|
||||
b.sc_tasks.respawn.failed = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
module.exports={
|
||||
load:()=>{
|
||||
|
||||
},
|
||||
loadBot:(b)=>{
|
||||
|
||||
module.exports = {
|
||||
load: (b) => {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
secret_example.json
Normal file
6
secret_example.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"keyTrusted": "Insert trusted level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)",
|
||||
"keyOwner": "Insert owner level key here... (PLEASE CHANGE THIS, THIS KEY IS PUBLIC)",
|
||||
"onlineEmail": "email@example.com",
|
||||
"onlinePass": "password"
|
||||
}
|
23
settings_example.json
Executable file
23
settings_example.json
Executable file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"secret":"/path/to/secrets/file/secret.json",
|
||||
"version_mc": "1.20.4",
|
||||
"defaultLang": "en-US",
|
||||
"terminalMode": "blackTerminal_24bit",
|
||||
"colors": {
|
||||
"primary": "#FFCCEE",
|
||||
"secondary": "#FF99DD"
|
||||
},
|
||||
"prefix":[
|
||||
"bot:",
|
||||
"\""
|
||||
],
|
||||
"servers":[
|
||||
{
|
||||
"host": "kaboom.pw",
|
||||
"port": 25565,
|
||||
"options":{
|
||||
"name": "kaboom"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
17
util/chatlog.js
Normal file
17
util/chatlog.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const fs = require('fs')
|
||||
const settings = require('../settings.json')
|
||||
|
||||
module.exports = function (fileName, item) {
|
||||
if (settings.disableLogging) return
|
||||
const dateToday = new Date(Date.now())
|
||||
const UTCYears = dateToday.getUTCFullYear()
|
||||
const UTCMonths = dateToday.getUTCMonth() + 1
|
||||
const UTCDays = dateToday.getUTCDate()
|
||||
const UTCHours = dateToday.getUTCHours()
|
||||
const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2, '0')
|
||||
const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2, '0')
|
||||
const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3, '0')
|
||||
const filenameToday = `${UTCMonths}-${UTCDays}-${UTCYears}`
|
||||
const logDate = `${UTCMonths}/${UTCDays}/${UTCYears} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}`
|
||||
fs.appendFileSync(`logs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`)
|
||||
}
|
106
util/chatparse_console.js
Normal file
106
util/chatparse_console.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
const settings = require('../settings.json')
|
||||
const lang = require('./mc_lang.js')
|
||||
const _consoleColors = require('./consolecolors.json')
|
||||
|
||||
let consoleColors
|
||||
let consoleColors24
|
||||
if (_consoleColors[settings.terminalMode]) {
|
||||
consoleColors = _consoleColors[settings.terminalMode].fourBit
|
||||
consoleColors24 = _consoleColors[settings.terminalMode].twentyFourBit
|
||||
} else {
|
||||
consoleColors = _consoleColors.none.fourBit
|
||||
consoleColors24 = _consoleColors.none.twentyFourBit
|
||||
}
|
||||
|
||||
const hexColorParser = (color) => {
|
||||
if (!consoleColors24.enabled || consoleColors24.bit !== 24) { // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet
|
||||
return ''
|
||||
}
|
||||
let out = '\x1B[0;'
|
||||
const redChannel = Number(`0x${color.slice(1, 3)}`)
|
||||
const greenChannel = Number(`0x${color.slice(3, 5)}`)
|
||||
const blueChannel = Number(`0x${color.slice(5, 7)}`)
|
||||
if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) {
|
||||
out += '48;2;220;220;220;'
|
||||
} else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) {
|
||||
out += '48;2;0;0;0;'
|
||||
}
|
||||
return out + `38;2;${redChannel};${greenChannel};${blueChannel}m`
|
||||
}
|
||||
|
||||
const processColor = (col, rcol) => {
|
||||
let out
|
||||
if (col === 'reset') {
|
||||
out = rcol
|
||||
} else if (col.startsWith('#')) {
|
||||
out = hexColorParser(col)
|
||||
} else {
|
||||
out = consoleColors[col]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
|
||||
if (l >= 4) {
|
||||
return ''
|
||||
}
|
||||
let data
|
||||
if (typeof _data === 'string') {
|
||||
data = { text: _data, color: 'reset' }
|
||||
} else if (typeof _data === 'number') {
|
||||
data = { text: _data + '', color: 'reset' }
|
||||
} else if (_data.constructor === Array) {
|
||||
data = { extra: _data, color: 'reset' }
|
||||
} else {
|
||||
data = _data
|
||||
}
|
||||
if (data['']) {
|
||||
data.text = data['']
|
||||
if (!data.color) data.color = 'reset'
|
||||
}
|
||||
|
||||
let out = ''
|
||||
if (data.color) {
|
||||
out += processColor(data.color, resetColor)
|
||||
} else {
|
||||
out += resetColor
|
||||
}
|
||||
if (data.text) {
|
||||
let _text = data.text
|
||||
if (typeof _text === 'number') {
|
||||
_text = _text.toString()
|
||||
}
|
||||
out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '')
|
||||
}
|
||||
if (data.translate) {
|
||||
let trans = data.translate.replaceAll('%%', '\ud900\ud801').replaceAll('\x1b', '').replaceAll('\x0e', '')
|
||||
if (lang[trans] !== undefined) {
|
||||
trans = lang[trans].replace(/%%/g, '\ue123')
|
||||
}
|
||||
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'))
|
||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
||||
})
|
||||
}
|
||||
out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s')
|
||||
}
|
||||
if (data.extra) {
|
||||
for (const item of data.extra) {
|
||||
const parsed = parse(item, l, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||
out += parsed
|
||||
}
|
||||
}
|
||||
out += resetColor
|
||||
return out
|
||||
}
|
||||
const parse2 = function (_data, l, resetColor) {
|
||||
try {
|
||||
return parse(_data)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return `\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ${JSON.stringify(_data)}`
|
||||
}
|
||||
}
|
||||
module.exports = parse2
|
55
util/chatparse_plain.js
Normal file
55
util/chatparse_plain.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
const lang = require('./mc_lang.js')
|
||||
const parse = function (_data, l = 0) {
|
||||
if (l >= 4) {
|
||||
return ''
|
||||
}
|
||||
let data
|
||||
if (typeof _data === 'string') {
|
||||
data = { text: _data }
|
||||
} else if (typeof _data === 'number') {
|
||||
data = { text: _data + '' }
|
||||
} else if (_data.constructor === Array) {
|
||||
data = { extra: _data }
|
||||
} else {
|
||||
data = _data
|
||||
}
|
||||
let out = ''
|
||||
if (data['']) {
|
||||
data.text = data['']
|
||||
}
|
||||
if (data.text) {
|
||||
let _text = data.text
|
||||
if (typeof _text === 'number') {
|
||||
_text = _text.toString()
|
||||
}
|
||||
out += _text
|
||||
}
|
||||
if (data.translate) {
|
||||
let trans = data.translate.replace(/%%/g, '\ue123')
|
||||
if (lang[trans] !== undefined) {
|
||||
trans = lang[trans].replace(/%%/g, '\ue123')
|
||||
}
|
||||
for (const i in data.with) {
|
||||
const j2 = parse(data.with[i], l + 1)
|
||||
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
||||
}
|
||||
out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s')
|
||||
}
|
||||
if (data.extra) {
|
||||
for (const item of data.extra) {
|
||||
const parsed = parse(item, l)
|
||||
out += parsed
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
const parse2 = function (_data, l) {
|
||||
try {
|
||||
return parse(_data)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return `An error occured while parsing a message. See console for more information. JSON that caused the error: ${JSON.stringify(_data)}`
|
||||
}
|
||||
}
|
||||
module.exports = parse2
|
28
util/commands.js
Normal file
28
util/commands.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs')
|
||||
const cmds = Object.create(null)
|
||||
const bpl = fs.readdirSync('./commands')
|
||||
for (const plugin of bpl) {
|
||||
if (!plugin.endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const commandName = plugin.split('.js')[0]
|
||||
cmds[commandName] = require(`../commands/${plugin}`)
|
||||
if (cmds[commandName].level === undefined) {
|
||||
cmds[commandName].level = 0
|
||||
}
|
||||
if (cmds[commandName].aliases) {
|
||||
for (const alias of cmds[commandName].aliases) {
|
||||
cmds[alias] = {
|
||||
execute: cmds[commandName].execute,
|
||||
alias: commandName,
|
||||
usage: cmds[commandName].usage,
|
||||
level: cmds[commandName].level,
|
||||
hidden: true,
|
||||
consoleIndex: cmds[commandName].consoleIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) { console.log(e) }
|
||||
}
|
||||
module.exports = cmds
|
182
util/consolecolors.json
Normal file
182
util/consolecolors.json
Normal file
|
@ -0,0 +1,182 @@
|
|||
{
|
||||
"blackTerminal_24bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;38;2;170;0;0m",
|
||||
"red": "\u001B[0;38;2;255;85;85m",
|
||||
"dark_green": "\u001B[0;38;2;0;170;0m",
|
||||
"green": "\u001B[0;38;2;85;255;85m",
|
||||
"gold": "\u001B[0;38;2;255;170;0m",
|
||||
"yellow": "\u001B[0;38;2;255;255;85m",
|
||||
"dark_blue": "\u001B[0;38;2;0;0;170m",
|
||||
"blue": "\u001B[0;38;2;85;85;255m",
|
||||
"dark_purple": "\u001B[0;38;2;170;0;170m",
|
||||
"light_purple": "\u001B[0;38;2;255;85;255m",
|
||||
"dark_aqua": "\u001B[0;38;2;0;170;170m",
|
||||
"aqua": "\u001B[0;38;2;85;255;255m",
|
||||
"black": "\u001B[0;48;2;220;220;220;38;2;0;0;0m",
|
||||
"gray": "\u001B[0;38;2;170;170;170m",
|
||||
"dark_gray": "\u001B[0;38;2;85;85;85m",
|
||||
"white": "\u001B[0;38;2;255;255;255m",
|
||||
"reset": "\u001B[0;38;2;255;255;255m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 24,
|
||||
"lightMode": false
|
||||
}
|
||||
},
|
||||
"whiteTerminal_24bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;38;2;170;0;0m",
|
||||
"red": "\u001B[0;38;2;255;85;85m",
|
||||
"dark_green": "\u001B[0;38;2;0;170;0m",
|
||||
"green": "\u001B[0;48;2;20;20;20;38;2;85;255;85m",
|
||||
"gold": "\u001B[0;38;2;255;170;0m",
|
||||
"yellow": "\u001B[0;48;2;20;20;20;38;2;255;255;85m",
|
||||
"dark_blue": "\u001B[0;38;2;0;0;170m",
|
||||
"blue": "\u001B[0;38;2;85;85;255m",
|
||||
"dark_purple": "\u001B[0;38;2;170;0;170m",
|
||||
"light_purple": "\u001B[0;38;2;255;85;255m",
|
||||
"dark_aqua": "\u001B[0;38;2;0;170;170m",
|
||||
"aqua": "\u001B[0;48;2;20;20;20;38;2;85;255;255m",
|
||||
"black": "\u001B[0;38;2;0;0;0m",
|
||||
"gray": "\u001B[0;38;2;170;170;170m",
|
||||
"dark_gray": "\u001B[0;38;2;85;85;85m",
|
||||
"white": "\u001B[0;48;2;20;20;20;38;2;255;255;255m",
|
||||
"reset": "\u001B[0;48;2;20;20;20;38;2;255;255;255m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 24,
|
||||
"lightMode": true
|
||||
}
|
||||
},
|
||||
"blackTerminal_8bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;38;5;1m",
|
||||
"red": "\u001B[0;38;5;9m",
|
||||
"dark_green": "\u001B[0;38;5;2m",
|
||||
"green": "\u001B[0;38;5;10m",
|
||||
"gold": "\u001B[0;38;5;3m",
|
||||
"yellow": "\u001B[0;38;5;11m",
|
||||
"dark_blue": "\u001B[0;38;5;4m",
|
||||
"blue": "\u001B[0;38;5;12m",
|
||||
"dark_purple": "\u001B[0;38;5;5m",
|
||||
"light_purple": "\u001B[0;38;5;13m",
|
||||
"dark_aqua": "\u001B[0;38;5;6m",
|
||||
"aqua": "\u001B[0;38;5;14m",
|
||||
"black": "\u001B[0;48;5;15;38;5;0m",
|
||||
"gray": "\u001B[0;38;5;7m",
|
||||
"dark_gray": "\u001B[0;38;5;8m",
|
||||
"white": "\u001B[0;38;5;15m",
|
||||
"reset": "\u001B[0;38;5;15m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 8,
|
||||
"lightMode": false
|
||||
}
|
||||
},
|
||||
"whiteTerminal_8bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;38;5;1m",
|
||||
"red": "\u001B[0;38;5;9m",
|
||||
"dark_green": "\u001B[0;38;5;2m",
|
||||
"green": "\u001B[0;48;5;0;38;5;10m",
|
||||
"gold": "\u001B[0;38;5;3m",
|
||||
"yellow": "\u001B[0;48;5;0;38;5;11m",
|
||||
"dark_blue": "\u001B[0;38;5;4m",
|
||||
"blue": "\u001B[0;38;5;12m",
|
||||
"dark_purple": "\u001B[0;38;5;5m",
|
||||
"light_purple": "\u001B[0;38;5;13m",
|
||||
"dark_aqua": "\u001B[0;38;5;6m",
|
||||
"aqua": "\u001B[0;48;5;0;38;5;14m",
|
||||
"black": "\u001B[0;38;5;0m",
|
||||
"gray": "\u001B[0;38;5;7m",
|
||||
"dark_gray": "\u001B[0;38;5;8m",
|
||||
"white": "\u001B[0;48;5;0;38;5;15m",
|
||||
"reset": "\u001B[0;48;5;0;38;5;15m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 8,
|
||||
"lightMode": true
|
||||
}
|
||||
},
|
||||
"blackTerminal_4bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;31m",
|
||||
"red": "\u001B[0;1;31m",
|
||||
"dark_green": "\u001B[0;32m",
|
||||
"green": "\u001B[0;1;32m",
|
||||
"gold": "\u001B[0;33m",
|
||||
"yellow": "\u001B[0;1;33m",
|
||||
"dark_blue": "\u001B[0;34m",
|
||||
"blue": "\u001B[0;1;34m",
|
||||
"dark_purple": "\u001B[0;35m",
|
||||
"light_purple": "\u001B[0;1;35m",
|
||||
"dark_aqua": "\u001B[0;36m",
|
||||
"aqua": "\u001B[0;1;36m",
|
||||
"black": "\u001B[0;1;47;30m",
|
||||
"gray": "\u001B[0;37m",
|
||||
"dark_gray": "\u001B[0;1;30m",
|
||||
"white": "\u001B[0;1;37m",
|
||||
"reset": "\u001B[0;1;37m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 4,
|
||||
"lightMode": false
|
||||
}
|
||||
},
|
||||
"whiteTerminal_4bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;31m",
|
||||
"red": "\u001B[0;1;31m",
|
||||
"dark_green": "\u001B[0;32m",
|
||||
"green": "\u001B[0;40;1;32m",
|
||||
"gold": "\u001B[0;33m",
|
||||
"yellow": "\u001B[0;40;1;33m",
|
||||
"dark_blue": "\u001B[0;34m",
|
||||
"blue": "\u001B[0;1;34m",
|
||||
"dark_purple": "\u001B[0;35m",
|
||||
"light_purple": "\u001B[0;1;35m",
|
||||
"dark_aqua": "\u001B[0;36m",
|
||||
"aqua": "\u001B[0;40;1;36m",
|
||||
"black": "\u001B[0;30m",
|
||||
"gray": "\u001B[0;37m",
|
||||
"dark_gray": "\u001B[0;1;30m",
|
||||
"white": "\u001B[0;40;1;37m",
|
||||
"reset": "\u001B[0;40;1;37m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 4,
|
||||
"lightMode": true
|
||||
}
|
||||
},
|
||||
"none":{
|
||||
"fourBit":{
|
||||
"dark_red": "",
|
||||
"red": "",
|
||||
"dark_green": "",
|
||||
"green": "",
|
||||
"gold": "",
|
||||
"yellow": "",
|
||||
"dark_blue": "",
|
||||
"blue": "",
|
||||
"dark_purple": "",
|
||||
"light_purple": "",
|
||||
"dark_aqua": "",
|
||||
"aqua": "",
|
||||
"black": "",
|
||||
"gray": "",
|
||||
"dark_gray": "",
|
||||
"white": "",
|
||||
"reset": ""
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,14 @@
|
|||
{
|
||||
"time.week": " week ",
|
||||
"time.weekPlural": " weeks ",
|
||||
"time.day": " day ",
|
||||
"time.dayPlural": " days ",
|
||||
"time.hour": " hour ",
|
||||
"time.hourPlural": " hours ",
|
||||
"time.minute": " minute ",
|
||||
"time.minutePlural": " minutes ",
|
||||
"time.second": " second ",
|
||||
"time.secondPlural": " seconds ",
|
||||
"command.about.usage": "",
|
||||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
|
@ -23,17 +33,23 @@
|
|||
"command.stop.desc": "Restart bot",
|
||||
"command.template.usage": " <required> [optional]",
|
||||
"command.template.desc": "Does nothing",
|
||||
"command.tpr.desc": "Teleport to a random location",
|
||||
"command.tpr.usage": "",
|
||||
"command.verify.usage": " [args...]",
|
||||
"command.verify.desc": "Check the hashing system",
|
||||
"command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db",
|
||||
"command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones",
|
||||
"command.about.version": "Version %s",
|
||||
"command.about.preRelease": "This is prerelease software - there may be errors, and features may be changed or removed at any time.",
|
||||
"command.about.sourceCode": "Source code: %s",
|
||||
"command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser",
|
||||
"command.about.serverinfo": "To view system information, run the command %s.",
|
||||
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
|
||||
"command.cloop.error.subcommand": "Unknown subcommand, please do %s",
|
||||
"command.cloop.success.add": "Added command loop with command %s and rate %s",
|
||||
"command.cloop.success.remove": "Removed command loop %s",
|
||||
"command.cloop.success.clear": "Cleared all command loops",
|
||||
"command.cloop.list": "%s: Command: %s Rate: %s",
|
||||
"command.help.cmdList": "Commands",
|
||||
"command.help.cmdList": "Commands:",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
"command.help.commandDesc": "Description - %s",
|
||||
|
@ -45,7 +61,7 @@
|
|||
"command.help.noCommand": "Command does not exist",
|
||||
"command.serverinfo.os.android": "Android",
|
||||
"command.serverinfo.os.freebsd": "FreeBSD",
|
||||
"command.serverinfo.os.linux": "Linux",
|
||||
"command.serverinfo.os.linux": "Linux %s",
|
||||
"command.serverinfo.os.macos": "macOS",
|
||||
"command.serverinfo.os.macos_old": "OS X",
|
||||
"command.serverinfo.os": "Operating system",
|
||||
|
@ -63,9 +79,11 @@
|
|||
"command.serverinfo.os.android.model": "Device model",
|
||||
"command.serverinfo.botName": "Bot name",
|
||||
"command.serverinfo.botVer": "Bot version",
|
||||
"command.tpr.success": "Teleporting %s to %s, %s, %s",
|
||||
"command.verify.success": "Successfully verified with permission level %s",
|
||||
"command.error": "An error occured (check console for more info)",
|
||||
"command.disallowed.perms": "You do not have permission to run this command. If you do have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system.",
|
||||
"command.disallowed.perms.yourLevel": "Your permission level: %s",
|
||||
"command.disallowed.perms.cmdLevel": "Command requires: %s",
|
||||
"copyText": "Click to copy!"
|
||||
}
|
||||
}
|
||||
|
|
89
util/lang/en-UW.json
Normal file
89
util/lang/en-UW.json
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"time.week": " week ",
|
||||
"time.weekPlural": " weeks ",
|
||||
"time.day": " day ",
|
||||
"time.dayPlural": " days ",
|
||||
"time.hour": " houw ",
|
||||
"time.hourPlural": " houws ",
|
||||
"time.minute": " minyute ",
|
||||
"time.minutePlural": " minyutes ",
|
||||
"time.second": " second ",
|
||||
"time.secondPlural": " seconds ",
|
||||
"command.about.usage": "",
|
||||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
"command.cb.desc": "Wun a command in a command bwock",
|
||||
"command.cloop.usage": " add <wate> <command>|| remove <index>|| list|| clear",
|
||||
"command.cloop.desc": "Manage command woops",
|
||||
"command.eval.usage": " <code>",
|
||||
"command.eval.desc": "Wun JavaScwipt code",
|
||||
"command.help.usage": " [cmd]",
|
||||
"command.help.desc": "Shows command hewp",
|
||||
"command.logoff.usage": "",
|
||||
"command.logoff.desc": "Disconnyect and weconnyect the bot fwom a sewvew",
|
||||
"command.netmsg.usage": " <message>",
|
||||
"command.netmsg.desc": "Send a message to aww sewvews the bot is connyected to",
|
||||
"command.refill.usage": "",
|
||||
"command.refill.desc": "Wefiww cowe",
|
||||
"command.say.usage": " <message>",
|
||||
"command.say.desc": "Sends a message to chat",
|
||||
"command.serverinfo.usage": "",
|
||||
"command.serverinfo.desc": "Get system/bot info",
|
||||
"command.stop.usage": "",
|
||||
"command.stop.desc": "Westawt bot",
|
||||
"command.template.usage": " <wequiwed> [optionyaw]",
|
||||
"command.template.desc": "Does nyothing",
|
||||
"command.tpr.desc": "Tewepowt to a wandom wocation",
|
||||
"command.tpr.usage": "",
|
||||
"command.verify.usage": " [awgs...]",
|
||||
"command.verify.desc": "Check the hashing system",
|
||||
"command.about.author": "%s - a Minyecwaft bot made by %s",
|
||||
"command.about.version": "Vewsion %s",
|
||||
"command.about.preRelease": "This is pwewewease softwawe - thewe may be ewwows, and featuwes may be changed ow wemoved at any time.",
|
||||
"command.about.sourceCode": "Souwce code: %s",
|
||||
"command.about.sourceCode.openInBrowser": "Cwick to open the souwce code wink in youw defauwt bwowsew",
|
||||
"command.about.serverinfo": "To view system infowmation, wun the command %s.",
|
||||
"command.cloop.error.tooShort": "Command woops must have a wate above 20ms.",
|
||||
"command.cloop.error.subcommand": "Unknyown subcommand, pwease do %s",
|
||||
"command.cloop.success.add": "Added command woop with command %s and wate %s",
|
||||
"command.cloop.success.remove": "Wemoved command woop %s",
|
||||
"command.cloop.success.clear": "Cweawed aww command woops",
|
||||
"command.cloop.list": "%s: Command: %s Wate: %s",
|
||||
"command.help.cmdList": "Commands:",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
"command.help.commandDesc": "Descwiption - %s",
|
||||
"command.help.commandPerms": "Wequiwed pewmissions - %s",
|
||||
"command.help.permsNormal": "Nyowmaw",
|
||||
"command.help.permsTrusted": "Twusted",
|
||||
"command.help.permsOwner": "Ownyew",
|
||||
"command.help.permsConsole": "Consowe",
|
||||
"command.help.noCommand": "Command does nyot exist",
|
||||
"command.serverinfo.os.android": "Andwoid",
|
||||
"command.serverinfo.os.freebsd": "FweeBSD",
|
||||
"command.serverinfo.os.linux": "Winyux %s",
|
||||
"command.serverinfo.os.macos": "macOS",
|
||||
"command.serverinfo.os.macos_old": "OS X",
|
||||
"command.serverinfo.os": "Opewating system",
|
||||
"command.serverinfo.processor": "CPU",
|
||||
"command.serverinfo.arch": "Awchitectuwe",
|
||||
"command.serverinfo.osUsername": "Usewnyame",
|
||||
"command.serverinfo.hostName": "Hostnyame",
|
||||
"command.serverinfo.workingDir": "Wowking diwectowy",
|
||||
"command.serverinfo.runTime": "Bot uptime",
|
||||
"command.serverinfo.upTime": "System uptime",
|
||||
"command.serverinfo.nodeVersion": "Nyode.js vewsion",
|
||||
"command.serverinfo.osRelease": "Winyux wewease",
|
||||
"command.serverinfo.osRelease.missing": "/etc/os-release does nyot exist. Infowmation may be wimited.",
|
||||
"command.serverinfo.os.android.version": "Andwoid vewsion",
|
||||
"command.serverinfo.os.android.model": "Device modew",
|
||||
"command.serverinfo.botName": "Bot nyame",
|
||||
"command.serverinfo.botVer": "Bot vewsion",
|
||||
"command.tpr.success": "Tewepowting %s to %s, %s, %s",
|
||||
"command.verify.success": "Successfuwwy vewified with pewmission wevew %s",
|
||||
"command.error": "An ewwow occuwed (check consowe fow mowe info)",
|
||||
"command.disallowed.perms": "You do nyot have pewmission to wun this command. If you do have pewmission, pwease make suwe you put the command hash at the end, ow wan the command thwough youw cwient's hashing system.",
|
||||
"command.disallowed.perms.yourLevel": "Youw pewmission wevew: %s",
|
||||
"command.disallowed.perms.cmdLevel": "Command wequiwes: %s",
|
||||
"copyText": "Cwick to copy!"
|
||||
}
|
6
util/mc_lang.js
Normal file
6
util/mc_lang.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
const _lang = require('minecraft-data')('1.20.2').language
|
||||
const lang = Object.create(null) // Without constructor function
|
||||
for (const i in _lang) {
|
||||
lang[i] = _lang[i]
|
||||
}
|
||||
module.exports = lang
|
11
util/parseNBT.js
Normal file
11
util/parseNBT.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const { processNbtMessage } = require('prismarine-chat')
|
||||
const parse = function (data) {
|
||||
if (typeof data.type === 'string') {
|
||||
return JSON.parse(processNbtMessage(data))
|
||||
} else if (typeof data === 'string') {
|
||||
return JSON.parse(data)
|
||||
} else {
|
||||
return data
|
||||
}
|
||||
}
|
||||
module.exports = parse
|
20
util/version.js
Normal file
20
util/version.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const version = require('../version.json')
|
||||
const cp = require('child_process')
|
||||
|
||||
let botVersion = version.botVersion
|
||||
let gitCommit
|
||||
let gitBranch
|
||||
|
||||
try {
|
||||
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]
|
||||
gitBranch = cp.execSync('git rev-parse --abbrev-ref HEAD').toString('UTF-8').split('\n')[0]
|
||||
} catch (e) {
|
||||
gitCommit = false
|
||||
gitBranch = false
|
||||
}
|
||||
|
||||
if (gitCommit) {
|
||||
botVersion += ` (${gitCommit} - ${gitBranch})`
|
||||
}
|
||||
|
||||
module.exports = botVersion
|
|
@ -1,3 +1,7 @@
|
|||
{
|
||||
"bot": "10.0.0-beta.1"
|
||||
"botName": "botvX Dev",
|
||||
"botVersion": "10.0.0",
|
||||
"botAuthor": "a5a06d596f15c7db",
|
||||
"isPreRelease": true,
|
||||
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX"
|
||||
}
|
Loading…
Reference in a new issue