71 unstaged files
This commit is contained in:
parent
f5b85902b6
commit
3e31b2f4f3
61 changed files with 1495 additions and 919 deletions
42
README.md
42
README.md
|
@ -1,3 +1,43 @@
|
|||
# botvX
|
||||
|
||||
# Go to [chipmunk](https://code.chipmunk.land/7cc5c4f330d47060/botvX)
|
||||
## What is it?
|
||||
|
||||
botvX 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:
|
||||
|
||||
- commands (obviously)
|
||||
- a self care system
|
||||
- a command core, to run commands quickly
|
||||
- a hashing system, to enable trusted users to securely run certain commands in chat
|
||||
|
||||
## 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.
|
||||
|
||||
## How to install?
|
||||
|
||||
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
|
||||
|
||||
| Name | Usage | Description |
|
||||
|-|-|-|
|
||||
| about | | About the bot |
|
||||
| cb | \<command\> | Run a command in a command block |
|
||||
| cloop | add <rate> <command>, remove <index>, list, clear | Manage command loops |
|
||||
| eval | \<code\> | Run JavaScript code (must run through console)|
|
||||
| help | [cmd] | Shows command help |
|
||||
| logoff | | Disconnect and reconnect the bot from a server |
|
||||
| netmsg | \<message\> | Send a message to all servers the bot is connected to |
|
||||
| refill | | Refill core |
|
||||
| say | \<message\> | Sends a message to chat |
|
||||
| serverinfo | | Get system/bot info, similar to Kaboom's <code>serverinfo</code> command |
|
||||
| stop | | Restart bot |
|
||||
| template | | Used in development, does nothing |
|
||||
| tpr | | Teleport to a random location |
|
||||
| verify | | Check the hashing system |
|
||||
|
||||
|
|
190
commands/about.js
Normal file
190
commands/about.js
Normal file
|
@ -0,0 +1,190 @@
|
|||
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 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()} (${os.release})`
|
||||
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) {
|
||||
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 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) {
|
||||
return getMessage(l, '%s %s', [osrelease2.PRETTY_NAME, os.release()])
|
||||
} else {
|
||||
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
|
||||
}
|
||||
} else {
|
||||
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
|
||||
}
|
||||
}
|
||||
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)
|
||||
})
|
||||
|
||||
// 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
|
||||
})
|
||||
}
|
||||
module.exports = {
|
||||
execute: function (c) {
|
||||
if (c.args[0] === 'server') {
|
||||
aboutServer(c)
|
||||
} else {
|
||||
aboutBot(c)
|
||||
}
|
||||
},
|
||||
aliases: ['info']
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
const getMessage = require('../../util/lang.js')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
const subcmd = c.args.splice(0, 1)[0]
|
|
@ -1,4 +1,4 @@
|
|||
const index = require('../../index.js') // Not used in the code, but may be used by users of the command
|
||||
const index = require('../index.js') // Not used in the code, but may be used by users of the command
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
try {
|
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 i in bpl) { // Built-in loadCMD to the help command, to prevent circular require
|
||||
if (!bpl[i].endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const commandName = bpl[i].split('.js')[0]
|
||||
if (commandName !== 'help') {
|
||||
cmds[commandName] = require(`./${bpl[i]}`)
|
||||
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 i in usage) {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.help.commandUsage'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: cmd,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: usage[i],
|
||||
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 j in cmds[i].aliases) {
|
||||
cmds[cmds[i].aliases[j]] = {
|
||||
alias: i,
|
||||
usage: cmds[i].usage,
|
||||
level: cmds[i].level,
|
||||
hidden: true,
|
||||
consoleIndex: cmds[i].consoleIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,14 @@
|
|||
const { bot } = require('../../index.js')
|
||||
const { bot } = require('../index.js')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
if(c.bot.host && c.bot.host.options.netmsgDisabled){
|
||||
c.reply({
|
||||
text: getMessage(c.lang, "command.netmsg.disabled"),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
}
|
||||
const json = {
|
||||
translate: '[%s] %s: %s',
|
||||
with: [
|
||||
|
@ -29,6 +37,7 @@ module.exports = {
|
|||
color: 'white'
|
||||
}
|
||||
for (const i in bot) {
|
||||
if(bot[i].host.options.netmsgDisabled) continue
|
||||
bot[i].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']
|
||||
}
|
|
@ -2,6 +2,6 @@ module.exports = {
|
|||
execute: (c) => {
|
||||
process.exit(0)
|
||||
},
|
||||
aliases: ['restart', 'exit'],
|
||||
aliases: ['reboot'],
|
||||
level: 2
|
||||
}
|
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 i in languages){
|
||||
c.reply({
|
||||
translate: "%s (%s)",
|
||||
color: c.colors.secondary,
|
||||
with:[
|
||||
{
|
||||
text: getMessage(languages[i], 'language.name'),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: getMessage(languages[i], 'language.region'),
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
hoverEvent:{
|
||||
action: "show_text",
|
||||
value: {
|
||||
translate: getMessage(languages[i], 'command.settings.setLanguage'),
|
||||
with:[
|
||||
{
|
||||
text: `${c.prefix}settings set lang ${languages[i]}`,
|
||||
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.secondary,
|
||||
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.secondary,
|
||||
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.secondary,
|
||||
with:[
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.language'),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
|
@ -23,7 +23,7 @@ module.exports = {
|
|||
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')
|
||||
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":
|
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
|
||||
}
|
22
index.js
22
index.js
|
@ -19,21 +19,15 @@ const loadplug = (botno) => {
|
|||
}
|
||||
botplug.forEach((plug) => {
|
||||
try {
|
||||
if (botno !== undefined) {
|
||||
if (plug.loadBot) {
|
||||
plug.loadBot(module.exports.bot[botno])
|
||||
}
|
||||
} else {
|
||||
plug.load()
|
||||
if (plug.load) {
|
||||
plug.load(module.exports.bot[botno])
|
||||
}
|
||||
} 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()
|
||||
|
@ -41,9 +35,7 @@ const createBot = function createBot (host, oldId) {
|
|||
host: host.host,
|
||||
port: host.port ? host.port : 25565,
|
||||
username: generateUser(host.options.legalName),
|
||||
version: settings.version_mc
|
||||
})
|
||||
bot._client.on('success', () => {
|
||||
version: host.version ? host.version : settings.version_mc
|
||||
})
|
||||
if (typeof oldId !== 'undefined') {
|
||||
for (const i in module.exports.bot[oldId].interval) {
|
||||
|
@ -52,11 +44,9 @@ const createBot = function createBot (host, oldId) {
|
|||
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
|
||||
|
@ -65,6 +55,11 @@ const createBot = function createBot (host, oldId) {
|
|||
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)
|
||||
|
@ -74,4 +69,5 @@ const createBot = function createBot (host, oldId) {
|
|||
for (const i in settings.servers) {
|
||||
createBot(settings.servers[i])
|
||||
}
|
||||
|
||||
module.exports.createBot = createBot
|
||||
|
|
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
|
26
package-lock.json
generated
26
package-lock.json
generated
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "botv10",
|
||||
"version": "10.0.0",
|
||||
"version": "10.0.0-beta-2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "botv10",
|
||||
"version": "10.0.0",
|
||||
"license": "UNLICENSED",
|
||||
"version": "10.0.0-beta-2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minecraft-protocol": "^1.45.0",
|
||||
"prismarine-chat": "^1.10.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.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz",
|
||||
"integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
"undici-types": "~6.13.0"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
|
@ -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.13.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
|
||||
"integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
"prismarine-chat": "^1.10.0"
|
||||
},
|
||||
"name": "botv10",
|
||||
"version": "10.0.0",
|
||||
"version": "10.0.0-beta-2",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "UNLICENSED",
|
||||
"license": "MIT",
|
||||
"description": ""
|
||||
}
|
||||
|
|
115
plugins/!chat.js
115
plugins/!chat.js
|
@ -1,35 +1,49 @@
|
|||
const console2 = require('./console.js')
|
||||
const parse = require('../util/chatparse.js')
|
||||
const parse1204 = require('../util/chatparse_1204.js')
|
||||
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: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b._client.on('profileless_chat', (data) => {
|
||||
if (data.type === 4) {
|
||||
const json = parse1204(data.message)
|
||||
const parsed = parse(json)[1]
|
||||
const parsed = parsePlain(json)
|
||||
const split = parsed.split(': ')
|
||||
const chatName = split.splice(0, 1)[0]
|
||||
const username = b.findRealName(chatName)
|
||||
const uuid = b.findUUID(username)
|
||||
b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username })
|
||||
} else if (data.type === 6 || data.type === 7) {
|
||||
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: data.senderUuid,
|
||||
message: parsePlain(data.message),
|
||||
username: parsePlain(parse1204(data.name))
|
||||
})
|
||||
} else {
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: data.type === 2 ? 'gray' : 'reset',
|
||||
color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.name),
|
||||
parse1204(data.message)
|
||||
|
@ -37,20 +51,36 @@ module.exports = {
|
|||
},
|
||||
type: 'profileless',
|
||||
uuid: '00000000-0000-0000-0000-000000000000',
|
||||
message: parse(parse1204(data.message))[1],
|
||||
username: parse(parse1204(data.name))[1]
|
||||
message: parsePlain(parse1204(data.message)),
|
||||
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, username: parse(parse1204(data.networkName))[1] })
|
||||
} else {
|
||||
b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) })
|
||||
} 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),
|
||||
username: parsePlain(parse1204(data.networkName))
|
||||
})
|
||||
} else {
|
||||
b.emit('chat', {
|
||||
json: {
|
||||
translate: messageTypes[data.type],
|
||||
color: (data.type === 2 || data.type === 3) ? 'gray' : 'reset',
|
||||
with: [
|
||||
parse1204(data.networkName),
|
||||
data.plainMessage
|
||||
|
@ -58,37 +88,55 @@ module.exports = {
|
|||
},
|
||||
type: 'player',
|
||||
uuid: data.senderUuid,
|
||||
message: parse(data.plainMessage)[1],
|
||||
username: parse(parse1204(data.networkName))[1]
|
||||
message: parsePlain(data.plainMessage),
|
||||
username: parsePlain(parse1204(data.networkName))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
b._client.on('system_chat', (data) => {
|
||||
const json = parse1204(data.content)
|
||||
const parsed = parse(json)[1]
|
||||
const parsed = parsePlain(json)
|
||||
const split = parsed.split(': ')
|
||||
const chatName = split.splice(0, 1)[0]
|
||||
const username = b.findRealName(chatName)
|
||||
const uuid = b.findUUID(username)
|
||||
b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username })
|
||||
})
|
||||
|
||||
b._client.on('chat', (data) => { // Legacy chat
|
||||
const json = parse1204(data.message)
|
||||
const parsed = parse(json)[1]
|
||||
const split = parsed.split(': ')
|
||||
const chatName = split.splice(0, 1)[0]
|
||||
const username = b.findRealName(chatName)
|
||||
const uuid = b.findUUID(username)
|
||||
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username })
|
||||
const parsed = parsePlain(json)
|
||||
let chatName
|
||||
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(': ')
|
||||
message = split.join(': ')
|
||||
uuid = b.findUUID(username)
|
||||
chatName = split.splice(0, 1)[0]
|
||||
username = b.findRealName(chatName)
|
||||
}
|
||||
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username })
|
||||
})
|
||||
b.on('chat', (data) => {
|
||||
const msg = parse(data.json)
|
||||
if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return
|
||||
if (msg[1].startsWith('Command set: ')) return
|
||||
b.emit('plainchat', msg[1])
|
||||
console2.write(`[${b.id}] [${data.type}] ` + msg[0])
|
||||
const fullCommand = data.message
|
||||
|
||||
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)
|
||||
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
|
||||
|
||||
const fullCommand = data.message
|
||||
for (const i in b.prefix) {
|
||||
if (fullCommand.startsWith(b.prefix[i])) {
|
||||
const command = fullCommand.slice(b.prefix[i].length)
|
||||
|
@ -96,6 +144,5 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
parse
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b.cloops = []
|
||||
b.addCloop = function (command, rate) {
|
||||
b.cloops.push({
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
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')
|
||||
const 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 { 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) => {
|
||||
load: (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
|
||||
const userSettings = loadSettings(uuid);
|
||||
b.lastCmd = Date.now()
|
||||
const cmd = text.split(' ')
|
||||
const lang = settings.defaultLang
|
||||
|
@ -41,7 +44,7 @@ module.exports = {
|
|||
return
|
||||
}
|
||||
try {
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify))
|
||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify, userSettings))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
b.tellraw(uuid, {
|
||||
|
@ -57,130 +60,5 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
}
|
||||
b.printHelp = (uuid, prefix, lang) => {
|
||||
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_gray'
|
||||
break
|
||||
default:
|
||||
cmdColor = 'gray'
|
||||
}
|
||||
commandList.push(
|
||||
{
|
||||
translate: '%s%s ',
|
||||
color: cmdColor,
|
||||
with: [
|
||||
prefix,
|
||||
i
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
b.tellraw(uuid, {
|
||||
translate: '%s: %s',
|
||||
with: [
|
||||
getMessage(lang, 'command.help.cmdList'),
|
||||
commandList.sort(sortHelp)
|
||||
]
|
||||
})
|
||||
}
|
||||
b.printCmdHelp = (uuid, cmd, lang, color) => {
|
||||
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, {
|
||||
translate: getMessage(lang, 'command.help.commandUsage'),
|
||||
color: color.secondary,
|
||||
with: [
|
||||
{
|
||||
text: cmd,
|
||||
color: color.primary
|
||||
},
|
||||
{
|
||||
text: usage[i],
|
||||
color: color.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
b.tellraw(uuid, {
|
||||
translate: getMessage(lang, 'command.help.commandDesc'),
|
||||
color: color.secondary,
|
||||
with: [
|
||||
{
|
||||
text: desc,
|
||||
color: color.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
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, {
|
||||
translate: getMessage(lang, 'command.help.commandPerms'),
|
||||
color: color.secondary,
|
||||
with: [
|
||||
{
|
||||
text: [permsN, permsT, permsO, permsC][rPerms],
|
||||
color: color.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
},
|
||||
loadCMD: () => {
|
||||
const bpl = fs.readdirSync('./plugins/commands')
|
||||
for (const i in bpl) {
|
||||
if (!bpl[i].endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
const uuidToInt = require('../util/uuidtoint.js')
|
||||
const cs = {
|
||||
x: 4,
|
||||
y: 6,
|
||||
z: 4
|
||||
}
|
||||
module.exports = {
|
||||
cs: 4,
|
||||
cs_v: 6,
|
||||
load: function () {
|
||||
|
||||
},
|
||||
loadBot: function (b) {
|
||||
b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000)
|
||||
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 = 0
|
||||
b.ccStarted = false
|
||||
b.blocknoY = 0
|
||||
b.pos = { x: 0, y: 0, z: 0, correct: 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: b.ccq[0],
|
||||
location: {
|
||||
x: b.commandPos.x1 + b.blocknoX,
|
||||
y: b.commandPos.y1 + b.blocknoY,
|
||||
z: b.commandPos.z1 + b.blocknoZ
|
||||
x: b.commandPos.x + b.blocknoX,
|
||||
y: b.commandPos.y + b.blocknoY,
|
||||
z: b.commandPos.z + b.blocknoZ
|
||||
},
|
||||
mode: 2,
|
||||
flags: 1
|
||||
|
@ -29,21 +31,21 @@ module.exports = {
|
|||
b._client.write('update_command_block', {
|
||||
command: b.ccq[0],
|
||||
location: {
|
||||
x: b.commandPos.x1 + b.blocknoX,
|
||||
y: b.commandPos.y1 + b.blocknoY,
|
||||
z: b.commandPos.z1 + b.blocknoZ
|
||||
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 === module.exports.cs) {
|
||||
if (b.blocknoX === cs.x) {
|
||||
b.blocknoY++
|
||||
b.blocknoX = 0
|
||||
if (b.blocknoY === module.exports.cs_v) {
|
||||
if (b.blocknoY === cs.y) {
|
||||
b.blocknoZ++
|
||||
b.blocknoY = 0
|
||||
if (b.blocknoZ === module.exports.cs) {
|
||||
if (b.blocknoZ === cs.z) {
|
||||
b.blocknoZ = 0
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +53,14 @@ module.exports = {
|
|||
}
|
||||
b.ccq.splice(0, 1)
|
||||
}
|
||||
|
||||
b._client.on('login', () => {
|
||||
b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true)
|
||||
b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true)
|
||||
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, 3) }, 1000) // 1 Second and 3 Milliseconds
|
||||
|
@ -74,23 +81,22 @@ module.exports = {
|
|||
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, correct: 1 }
|
||||
b.pos = { x: a.x, y: a.y, z: a.z }
|
||||
} else {
|
||||
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
|
||||
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.pos.correct = 0
|
||||
b.sc_tasks.cc.failed = 1
|
||||
}
|
||||
}
|
||||
|
||||
b.commandPos = {
|
||||
x1: Math.floor(a.x),
|
||||
z1: Math.floor(a.z),
|
||||
y1: 55
|
||||
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') {
|
||||
|
@ -100,7 +106,13 @@ module.exports = {
|
|||
} else {
|
||||
finalname = uuid
|
||||
}
|
||||
b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`)
|
||||
let tellrawCommand
|
||||
if (b.host.options.isVanilla) {
|
||||
tellrawCommand = 'tellraw'
|
||||
} else {
|
||||
tellrawCommand = 'minecraft:tellraw'
|
||||
}
|
||||
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
const version = require('../../version.json')
|
||||
const settings = require('../../settings.json')
|
||||
const getMessage = require('../../util/lang.js')
|
||||
const cp = require('child_process')
|
||||
module.exports = {
|
||||
execute: function (c) {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.author'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: settings.name,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
c.reply({ text: '' })
|
||||
const botVersion = version.bot
|
||||
let gitCommit
|
||||
try {
|
||||
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]
|
||||
} catch (e) {
|
||||
gitCommit = false
|
||||
}
|
||||
if (gitCommit) {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.version'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
[
|
||||
{
|
||||
text: botVersion,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
translate: ' (%s)',
|
||||
color: 'white',
|
||||
with: [
|
||||
{
|
||||
text: gitCommit,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
})
|
||||
} else {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.version'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: botVersion,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
c.reply({ text: '' })
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.serverinfo'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
translate: '"%s"',
|
||||
color: 'white',
|
||||
with: [
|
||||
{
|
||||
text: 'serverinfo',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
aliases: ['info']
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
if (c.args.length > 0) {
|
||||
c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors)
|
||||
} else {
|
||||
c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors)
|
||||
}
|
||||
},
|
||||
aliases: [
|
||||
'heko' // Parker2991 request
|
||||
]
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}')
|
||||
},
|
||||
consoleIndex: true,
|
||||
aliases: ['refillcore', 'rc']
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
const os = require('os')
|
||||
const cp = require('child_process')
|
||||
const settings = require('../../settings.json')
|
||||
const timeformat = require('../../util/timeformat.js')
|
||||
const version = require('../../version.json')
|
||||
const getMessage = require('../../util/lang.js')
|
||||
const fs = require('fs')
|
||||
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')
|
||||
}
|
||||
},
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const os2 = function (o2, l) {
|
||||
switch (o2) {
|
||||
case 'win32':
|
||||
return os.version()
|
||||
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'), timeformat(process.uptime() * 1000), c.colors))
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), timeformat(os.uptime() * 1000), 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.botName'), settings.name, c.colors))
|
||||
let botVersion = version.bot
|
||||
let gitCommit
|
||||
try {
|
||||
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]
|
||||
} catch (e) {
|
||||
gitCommit = false
|
||||
}
|
||||
if (gitCommit) {
|
||||
botVersion += ` (${gitCommit})`
|
||||
}
|
||||
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors))
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
module.exports = {
|
||||
execute: (c) => {
|
||||
c.reply({
|
||||
text: c.verify + ''
|
||||
})
|
||||
c.reply({
|
||||
text: c.command
|
||||
})
|
||||
},
|
||||
level: 1
|
||||
}
|
|
@ -1,8 +1,39 @@
|
|||
const readln = require('readline')
|
||||
const index = require('../index.js')
|
||||
const ConsoleCommand = require('../util/ConsoleCommand.js')
|
||||
const newercommands = require('./command.js').cmds
|
||||
let rl
|
||||
const cmds = require('../util/commands.js')
|
||||
const rl = readln.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
prompt: '\x1b[0m> '
|
||||
})
|
||||
rl.on('line', (l) => {
|
||||
try {
|
||||
if (cmds[l.split(' ')[0].toLowerCase()]) {
|
||||
if (cmds[l.split(' ')[0].toLowerCase()].consoleIndex) {
|
||||
const tmpcmd = l.split(' ')
|
||||
const index2 = tmpcmd.splice(1, 1)[0]
|
||||
if (index2 === '*') {
|
||||
for (let i = 0; i < index.bot.length; i++) {
|
||||
const cmd = new ConsoleCommand(tmpcmd.join(' '), i)
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2)
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new ConsoleCommand(l, -2)
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
rl.prompt(false)
|
||||
})
|
||||
rl.prompt()
|
||||
|
||||
function consoleWrite (text) {
|
||||
readln.cursorTo(process.stdout, 0)
|
||||
readln.clearLine(process.stdout, 0)
|
||||
|
@ -10,44 +41,12 @@ function consoleWrite (text) {
|
|||
rl.prompt(true)
|
||||
}
|
||||
module.exports = {
|
||||
load: () => {
|
||||
rl = readln.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
prompt: '\x1b[0m\x1b[38;5;15m> '
|
||||
})
|
||||
rl.on('line', (l) => {
|
||||
try {
|
||||
if (newercommands[l.split(' ')[0].toLowerCase()]) {
|
||||
if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) {
|
||||
const tmpcmd = l.split(' ')
|
||||
const index2 = tmpcmd.splice(1, 1)[0]
|
||||
if (index2 === '*') {
|
||||
for (let i = 0; i < index.bot.length; i++) {
|
||||
const cmd = new ConsoleCommand(tmpcmd.join(' '), i)
|
||||
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2)
|
||||
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new ConsoleCommand(l, -2)
|
||||
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
rl.prompt(false)
|
||||
})
|
||||
rl.prompt()
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b.info = (msg) => {
|
||||
consoleWrite(`[${b.id}] [info] ${msg}`)
|
||||
}
|
||||
},
|
||||
rl,
|
||||
write: consoleWrite
|
||||
b.displayChat = (type, msg) => {
|
||||
consoleWrite(`[${b.id}] [${type}] ${msg}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b._client.on('login', () => {
|
||||
b.interval.chatQueue = setInterval(() => {
|
||||
if (b.chatqueue.length !== 0) {
|
||||
b._client.chat(b.chatqueue[0])
|
||||
b.chatqueue.splice(0, 1)
|
||||
}
|
||||
}, 150)
|
||||
}, 100)
|
||||
})
|
||||
b.chatqueue = []
|
||||
b.chat = function chat (msg) {
|
||||
if (msg.length === 0) return
|
||||
msg.match(/.{1,250}/g).forEach(element => {
|
||||
msg.match(/.{1,255}/g).forEach(element => {
|
||||
b.chatqueue.push(element)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
const parse = require('../util/chatparse.js')
|
||||
const parse1204 = require('../util/chatparse_1204.js')
|
||||
const parse = require('../util/chatparse_plain')
|
||||
const parseNBT = require('../util/parseNBT')
|
||||
module.exports = {
|
||||
load: () => {
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b.players = {}
|
||||
b._client.on('player_info', (data) => {
|
||||
const buffer2 = {}
|
||||
|
@ -14,12 +12,18 @@ module.exports = {
|
|||
} else if (data.data[i].UUID) {
|
||||
uuid = data.data[i].UUID
|
||||
}
|
||||
let displayName
|
||||
if (data.data[i].displayName !== undefined) {
|
||||
displayName = data.data[i].displayName
|
||||
} else {
|
||||
displayName = '{"text":"[[[[ No display name ]]]]"}'
|
||||
}
|
||||
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] }
|
||||
buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parseNBT(displayName)) }
|
||||
} else if (data.data[i].name !== undefined) {
|
||||
buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] }
|
||||
buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) }
|
||||
} else if (data.data[i].displayName !== undefined) {
|
||||
buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] }
|
||||
buffer2[uuid] = { displayName: displayName.plain }
|
||||
}
|
||||
}
|
||||
for (const uuid in buffer2) {
|
||||
|
@ -42,7 +46,7 @@ module.exports = {
|
|||
return b.players[i].realName
|
||||
}
|
||||
}
|
||||
return 'Geometrical Dominator'
|
||||
return '[[[[ no name ]]]]'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
const index = require('../index.js')
|
||||
module.exports = {
|
||||
load: () => {
|
||||
},
|
||||
loadBot: (b) => {
|
||||
load: (b) => {
|
||||
b._client.on('end', () => {
|
||||
b.info('bot ' + b.id + ' disconnected')
|
||||
b.info(`Bot ${b.id} disconnected`)
|
||||
for (const i in b.interval) {
|
||||
clearInterval(b.interval[i])
|
||||
}
|
||||
setTimeout(() => {
|
||||
b.info('Re-connecting bot ' + b.id)
|
||||
b.info(`Re-connecting bot ${b.id}`)
|
||||
index.createBot(b.host, b.id)
|
||||
}, 5000)
|
||||
})
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
class SCTask {
|
||||
constructor (failTask, chatCommand, startFailed = false) {
|
||||
/*
|
||||
* failed: Whether to run this task
|
||||
* failTask: Command to run when failed is true
|
||||
* chatCommand: Whether to run failTask in chat rather than in command block
|
||||
*/
|
||||
this.failed = startFailed
|
||||
this.failTask = failTask
|
||||
this.chatCommand = chatCommand
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
b.sc_tasks = {}
|
||||
b.interval.sc = setInterval(() => {
|
||||
for (const i in b.sc_tasks) {
|
||||
if (b.sc_tasks[i].failed) {
|
||||
if (b.sc_tasks[i].chatCommand) {
|
||||
b.chat(b.sc_tasks[i].failTask)
|
||||
} else {
|
||||
b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
b.add_sc_task = (name, failTask, chatCommand, startFailed) => {
|
||||
b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
b.add_sc_task('cspy', '/cspy on', true, 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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
b.add_sc_task('gamemode', '/minecraft:gamemode creative', true)
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
b.add_sc_task('op', '/op @s[type=player]', true)
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
84
plugins/selfcare.js
Executable file
84
plugins/selfcare.js
Executable file
|
@ -0,0 +1,84 @@
|
|||
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')) {
|
||||
b.sc_tasks.respawn.failed = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
module.exports = {
|
||||
load: () => {
|
||||
|
||||
},
|
||||
loadBot: (b) => {
|
||||
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"
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"secret":"./settings_s.json",
|
||||
"name": "Minecraft Bot",
|
||||
"secret":"/path/to/secrets/file/secret.json",
|
||||
"version_mc": "1.20.4",
|
||||
"defaultLang": "en-US",
|
||||
"terminalMode": "blackTerminal_24bit",
|
||||
"colors": {
|
||||
"primary": "#FFCCEE",
|
||||
"secondary": "#FF99DD"
|
|
@ -1,7 +1,7 @@
|
|||
// HOW TO WRITE CLASS JS
|
||||
const settings = require('../settings.json')
|
||||
class Command {
|
||||
constructor (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) {
|
||||
constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) {
|
||||
this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) }
|
||||
this.reply = text => bot.tellraw(uuid, text)
|
||||
this.uuid = uuid
|
||||
|
@ -16,8 +16,26 @@ class Command {
|
|||
this.verify = verify
|
||||
this.host = bot.host.host
|
||||
this.port = bot.host.port
|
||||
this.lang = lang
|
||||
this.colors = settings.colors
|
||||
// this.lang = lang
|
||||
this.prefs = prefs
|
||||
if(prefs.lang){
|
||||
this.lang = prefs.lang
|
||||
} else {
|
||||
this.lang = settings.defaultLang
|
||||
}
|
||||
|
||||
let _colors = {}
|
||||
if(prefs.colorPrimary){
|
||||
_colors.primary = prefs.colorPrimary
|
||||
} else {
|
||||
_colors.primary = settings.colors.primary
|
||||
}
|
||||
if(prefs.colorSecondary){
|
||||
_colors.secondary = prefs.colorSecondary
|
||||
} else {
|
||||
_colors.secondary = settings.colors.secondary
|
||||
}
|
||||
this.colors = _colors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +1,19 @@
|
|||
// HOW TO WRITE CLASS JS
|
||||
const index = require('../index.js')
|
||||
const { cmds } = require('../plugins/command.js')
|
||||
const parse = require('../util/chatparse.js')
|
||||
const parse = require('../util/chatparse_console.js')
|
||||
const settings = require('../settings.json')
|
||||
const getMessage = require('../util/lang.js')
|
||||
const lang = settings.defaultLang
|
||||
class ConsoleCommand {
|
||||
constructor (cmd, index2) {
|
||||
this.send = () => {} // not needed for console
|
||||
this.reply = text => process.stdout.write(parse(text)[0] + '\n')
|
||||
this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console
|
||||
this.reply = text => process.stdout.write(parse(text) + '\n')
|
||||
this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console
|
||||
this.username = 'Owner'
|
||||
this.nickname = 'Console'
|
||||
this.command = cmd
|
||||
this.prefix = '' // prefix does not exist at console
|
||||
this.bot = index2 >= 0
|
||||
? index.bot[index2]
|
||||
: {
|
||||
printHelp: () => {
|
||||
const helpCmds = []
|
||||
for (const i in cmds) {
|
||||
// if(cmds[i].hidden) continue;
|
||||
helpCmds.push(i)
|
||||
}
|
||||
console.log(getMessage(lang, 'command.help.cmdList', [helpCmds.join(' ')]))
|
||||
},
|
||||
printCmdHelp: (uuid, cmd) => {
|
||||
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
|
||||
}
|
||||
for (const i in usage) {
|
||||
console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]]))
|
||||
}
|
||||
console.log(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
|
||||
console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]]))
|
||||
}
|
||||
} // bot does not exist at console
|
||||
: {}
|
||||
this.type = 'console'
|
||||
this.index = index2
|
||||
this.args = cmd.split(' ').slice(1)
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
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]
|
||||
}
|
||||
const consoleColors = {
|
||||
dark_red: '\x1B[0m\x1B[38;2;170;0;0m',
|
||||
red: '\x1B[0m\x1B[38;2;255;85;85m',
|
||||
dark_green: '\x1B[0m\x1B[38;2;0;170;0m',
|
||||
green: '\x1B[0m\x1B[38;2;85;255;85m',
|
||||
gold: '\x1B[0m\x1B[38;2;255;170;0m',
|
||||
yellow: '\x1B[0m\x1B[38;2;255;255;85m',
|
||||
dark_blue: '\x1B[0m\x1B[38;2;0;0;170m',
|
||||
blue: '\x1B[0m\x1B[38;2;85;85;255m',
|
||||
dark_purple: '\x1B[0m\x1B[38;2;170;0;170m',
|
||||
light_purple: '\x1B[0m\x1B[38;2;255;85;255m',
|
||||
dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m',
|
||||
aqua: '\x1B[0m\x1B[38;2;85;255;255m',
|
||||
black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m',
|
||||
gray: '\x1B[0m\x1B[38;2;170;170;170m',
|
||||
dark_gray: '\x1B[0m\x1B[38;2;85;85;85m',
|
||||
white: '\x1B[0m\x1B[38;2;255;255;255m',
|
||||
reset: '\x1B[0m\x1B[38;2;255;255;255m'
|
||||
}
|
||||
const hexColorParser = (color) => {
|
||||
let out = '\x1B[0m'
|
||||
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 (redChannel < 96 && greenChannel < 96 && blueChannel < 96) {
|
||||
out += '\x1B[48;2;220;220;220m'
|
||||
}
|
||||
return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m`
|
||||
}
|
||||
const processColor = (col, rcol) => {
|
||||
const out = ['', '']
|
||||
if (col === 'reset') {
|
||||
out[0] = rcol[0]
|
||||
} else if (col.startsWith('#')) {
|
||||
out[0] = hexColorParser(col)
|
||||
} else {
|
||||
out[0] = consoleColors[col]
|
||||
}
|
||||
return out
|
||||
}
|
||||
const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) {
|
||||
if (l >= 12) {
|
||||
return ['', '', '']
|
||||
}
|
||||
let data
|
||||
if (typeof _data === 'string') {
|
||||
data = { text: _data, color: 'reset' }
|
||||
} else if (typeof _data === 'number') {
|
||||
data = { text: _data + '', color: 'reset' }
|
||||
} else {
|
||||
data = _data
|
||||
}
|
||||
let nkt = false
|
||||
const out = ['', '', ''] // console plain minecraft
|
||||
if (data['']) {
|
||||
data.text = data['']
|
||||
nkt = true
|
||||
}
|
||||
if (data.color) {
|
||||
if (data.color === 'reset') {
|
||||
out[0] += resetColor[0]
|
||||
} else if (data.color.startsWith('#')) {
|
||||
out[0] += hexColorParser(data.color)
|
||||
} else {
|
||||
out[0] += consoleColors[data.color]
|
||||
}
|
||||
} else {
|
||||
out[0] += resetColor[0]
|
||||
}
|
||||
if (data.text) {
|
||||
let _text = data.text
|
||||
if (typeof _text === 'number') {
|
||||
_text = _text.toString()
|
||||
}
|
||||
if (nkt) {
|
||||
out[0] += resetColor[0]
|
||||
out[2] += resetColor[1]
|
||||
}
|
||||
out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format
|
||||
out[1] += _text
|
||||
out[2] += _text
|
||||
}
|
||||
if (data.translate) {
|
||||
let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format
|
||||
let trans2 = data.translate.replace(/%%/g, '\ue123')
|
||||
let trans3 = data.translate.replace(/%%/g, '\ue123')
|
||||
if (lang[trans] !== undefined) {
|
||||
trans = lang[trans].replace(/%%/g, '\ue123')
|
||||
trans2 = lang[trans2].replace(/%%/g, '\ue123')
|
||||
trans3 = lang[trans3].replace(/%%/g, '\ue123')
|
||||
}
|
||||
for (const i in data.with) {
|
||||
const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||
trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
}
|
||||
out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
}
|
||||
if (data.extra) {
|
||||
for (const i in data.extra) {
|
||||
const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||
out[0] += parsed[0]
|
||||
out[1] += parsed[1]
|
||||
out[2] += parsed[2]
|
||||
}
|
||||
}
|
||||
out[0] += resetColor[0]
|
||||
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),
|
||||
'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data),
|
||||
'§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data)
|
||||
]
|
||||
}
|
||||
}
|
||||
module.exports = parse2
|
104
util/chatparse_console.js
Normal file
104
util/chatparse_console.js
Normal file
|
@ -0,0 +1,104 @@
|
|||
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', '') // Remove escape codes and [SO] from console format
|
||||
}
|
||||
if (data.translate) {
|
||||
let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format
|
||||
if (lang[trans] !== undefined) {
|
||||
trans = lang[trans].replace(/%%/g, '\ue123')
|
||||
}
|
||||
for (const i in data.with) {
|
||||
const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||
trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
}
|
||||
out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
}
|
||||
if (data.extra) {
|
||||
for (const i in data.extra) {
|
||||
const parsed = parse(data.extra[i], 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.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||
}
|
||||
out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
}
|
||||
if (data.extra) {
|
||||
for (const i in data.extra) {
|
||||
const parsed = parse(data.extra[i], 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 i in bpl) {
|
||||
if (!bpl[i].endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const commandName = bpl[i].split('.js')[0]
|
||||
cmds[commandName] = require(`../commands/${bpl[i]}`)
|
||||
if (cmds[commandName].level === undefined) {
|
||||
cmds[commandName].level = 0
|
||||
}
|
||||
if (cmds[commandName].aliases) {
|
||||
for (const j in cmds[commandName].aliases) {
|
||||
cmds[cmds[commandName].aliases[j]] = {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ module.exports = function (cmd) {
|
|||
const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ')
|
||||
const _dateString = Date.now().toString()
|
||||
const dateString = _dateString.slice(0, _dateString.length - 4)
|
||||
const hashTrusted = 'babyboom:' + secret.keyTrusted + ':' + cmdWithoutHash + ':' + dateString
|
||||
const hashOwner = 'babyboom:' + secret.keyOwner + ':' + cmdWithoutHash + ':' + dateString
|
||||
const hashTrusted = `babyboom:${secret.keyTrusted}:${cmdWithoutHash}:${dateString}`
|
||||
const hashOwner = `babyboom:${secret.keyOwner}:${cmdWithoutHash}:${dateString}`
|
||||
const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex')
|
||||
const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex')
|
||||
if (cmd[cmd.length - 1] === validhashT) {
|
||||
|
|
42
util/lang.js
42
util/lang.js
|
@ -1,5 +1,6 @@
|
|||
const fs = require('fs')
|
||||
const languages = {}
|
||||
|
||||
const loadplug = (botno) => {
|
||||
const bpl = fs.readdirSync('util/lang')
|
||||
for (const i in bpl) {
|
||||
|
@ -12,11 +13,12 @@ const loadplug = (botno) => {
|
|||
}
|
||||
}
|
||||
loadplug()
|
||||
module.exports = function (l, msg, with2) {
|
||||
|
||||
const getMessage = function (l, msg, with2) {
|
||||
let message = msg.replace(/%%/g, '\ue123')
|
||||
if (languages[l][message] !== undefined) {
|
||||
if (languages[l] && languages[l][message] !== undefined) {
|
||||
message = languages[l][message].replace(/%%/g, '\ue123')
|
||||
} else if (languages['en-US'][message] !== undefined) {
|
||||
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
|
||||
message = languages['en-US'][message].replace(/%%/g, '\ue123')
|
||||
}
|
||||
for (const i in with2) {
|
||||
|
@ -25,3 +27,37 @@ module.exports = function (l, msg, with2) {
|
|||
}
|
||||
return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
languages: Object.keys(languages),
|
||||
getMessage,
|
||||
formatTime: function (time, language) {
|
||||
let finalString = ''
|
||||
const seconds = Math.floor(time / 1000) % 60
|
||||
const minutes = Math.floor(time / 60000) % 60
|
||||
const hours = Math.floor(time / 3600000) % 24
|
||||
const days = Math.floor(time / 86400000) % 7
|
||||
const weeks = Math.floor(time / 604800000)
|
||||
if (weeks !== 0) {
|
||||
finalString += weeks
|
||||
finalString += `${weeks === 1 ? getMessage(language, 'time.week') : getMessage(language, 'time.weekPlural')}`
|
||||
}
|
||||
if (days !== 0) {
|
||||
finalString += days
|
||||
finalString += `${days === 1 ? getMessage(language, 'time.day') : getMessage(language, 'time.dayPlural')}`
|
||||
}
|
||||
if (hours !== 0) {
|
||||
finalString += hours
|
||||
finalString += `${hours === 1 ? getMessage(language, 'time.hour') : getMessage(language, 'time.hourPlural')}`
|
||||
}
|
||||
if (minutes !== 0) {
|
||||
finalString += minutes
|
||||
finalString += `${minutes === 1 ? getMessage(language, 'time.minute') : getMessage(language, 'time.minutePlural')}`
|
||||
}
|
||||
if (seconds !== 0) {
|
||||
finalString += seconds
|
||||
finalString += `${seconds === 1 ? getMessage(language, 'time.second') : getMessage(language, 'time.secondPlural')}`
|
||||
}
|
||||
return finalString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
{
|
||||
"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>",
|
||||
|
@ -17,24 +29,26 @@
|
|||
"command.refill.desc": "Refill core",
|
||||
"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": "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.serverinfo": "To view system information, run the command %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.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",
|
||||
|
@ -44,29 +58,41 @@
|
|||
"command.help.permsOwner": "Owner",
|
||||
"command.help.permsConsole": "Console",
|
||||
"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.macos": "macOS",
|
||||
"command.serverinfo.os.macos_old": "OS X",
|
||||
"command.serverinfo.os": "Operating system",
|
||||
"command.serverinfo.processor": "CPU",
|
||||
"command.serverinfo.arch": "Architecture",
|
||||
"command.serverinfo.osUsername": "Username",
|
||||
"command.serverinfo.hostName": "Hostname",
|
||||
"command.serverinfo.workingDir": "Working directory",
|
||||
"command.serverinfo.runTime": "Bot uptime",
|
||||
"command.serverinfo.upTime": "System uptime",
|
||||
"command.serverinfo.nodeVersion": "Node.js version",
|
||||
"command.serverinfo.osRelease": "Linux release",
|
||||
"command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
|
||||
"command.serverinfo.os.android.version": "Android version",
|
||||
"command.serverinfo.os.android.model": "Device model",
|
||||
"command.serverinfo.botName": "Bot name",
|
||||
"command.serverinfo.botVer": "Bot version",
|
||||
"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.about.serverInfo.os.android": "Android %s",
|
||||
"command.about.serverInfo.os.android.noVersion": "Android",
|
||||
"command.about.serverInfo.os.freebsd": "FreeBSD %s",
|
||||
"command.about.serverInfo.os.linux": "Linux %s",
|
||||
"command.about.serverInfo.os.macos": "macOS",
|
||||
"command.about.serverInfo.os.macos_old": "OS X",
|
||||
"command.about.serverInfo.os": "Operating system",
|
||||
"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.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!"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
{
|
||||
"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.verify.usage": " [awgs...]",
|
||||
"command.verify.desc": "Check the hashing system",
|
||||
"command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db",
|
||||
"command.about.version": "Vewsion %s",
|
||||
"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 Rate: %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",
|
||||
"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.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
|
|
@ -1,17 +0,0 @@
|
|||
const settings = require('../settings.json')
|
||||
module.exports = function (text) {
|
||||
return JSON.stringify({
|
||||
translate: '[%s] %s',
|
||||
color: '#FFAAFF',
|
||||
with: [
|
||||
{
|
||||
text: settings.name,
|
||||
color: 'light_purple'
|
||||
},
|
||||
{
|
||||
text,
|
||||
color: 'white'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
module.exports = function (time) {
|
||||
let finalString = ''
|
||||
const seconds = Math.floor(time / 1000) % 60
|
||||
const minutes = Math.floor(time / 60000) % 60
|
||||
const hours = Math.floor(time / 3600000) % 24
|
||||
const days = Math.floor(time / 86400000) % 7
|
||||
const weeks = Math.floor(time / 604800000)
|
||||
if (weeks !== 0) {
|
||||
finalString += `${weeks} week${weeks === 1 ? '' : 's'} `
|
||||
}
|
||||
if (days !== 0) {
|
||||
finalString += `${days} day${days === 1 ? '' : 's'} `
|
||||
}
|
||||
if (hours !== 0) {
|
||||
finalString += `${hours} hour${hours === 1 ? '' : 's'} `
|
||||
}
|
||||
if (minutes !== 0) {
|
||||
finalString += `${minutes} minute${minutes === 1 ? '' : 's'} `
|
||||
}
|
||||
if (seconds !== 0) {
|
||||
finalString += `${seconds} second${seconds === 1 ? '' : 's'} `
|
||||
}
|
||||
return finalString
|
||||
}
|
|
@ -1,15 +1,31 @@
|
|||
const rsg = function (count) {
|
||||
let output = ''
|
||||
for (let i = 0; i < count; i++) {
|
||||
let rng = Math.floor(Math.random() * 16) + 1
|
||||
if (rng === 7) rng = 17 // No bells
|
||||
if (rng === 10) rng = 18 // No line feeds
|
||||
if (rng === 11) rng = 19 // No vertical tabulations
|
||||
if (rng === 12) rng = 20 // No form feed
|
||||
if (rng === 13) rng = 21 // No carriage returns
|
||||
if (rng === 14) rng = 22 // No shift out
|
||||
if (rng === 15) rng = 23 // No shift in
|
||||
output += String.fromCharCode(rng)
|
||||
const type = Math.floor(Math.random() * 6)
|
||||
switch (type) {
|
||||
case 0:
|
||||
output += ' '
|
||||
break
|
||||
case 1:
|
||||
output += '§§'
|
||||
break
|
||||
case 2:
|
||||
output += '§ '
|
||||
break
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:{ // Make this case more likely
|
||||
let rng = Math.floor(Math.random() * 16) + 1
|
||||
if (rng === 7) rng = 17 // No bells
|
||||
if (rng === 10) rng = 18 // No line feeds
|
||||
if (rng === 11) rng = 19 // No vertical tabulations
|
||||
if (rng === 12) rng = 20 // No form feed
|
||||
if (rng === 13) rng = 21 // No carriage returns
|
||||
if (rng === 14) rng = 22 // No shift out
|
||||
if (rng === 15) rng = 23 // No shift in
|
||||
output += `§${String.fromCharCode(rng)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
@ -17,6 +33,6 @@ module.exports = function (legal) {
|
|||
if (legal) {
|
||||
return Math.floor(Math.random() * 1000000).toString()
|
||||
} else {
|
||||
return ' \xa7' + rsg(6) + ' ' + rsg(4)
|
||||
return rsg(6 + Math.floor(Math.random() * 3))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = function (uuid) {
|
||||
const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g)
|
||||
const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return `0x${a}` }).match(/.{1,10}/g)
|
||||
const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0]
|
||||
return numUUID
|
||||
}
|
||||
|
|
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-beta.2",
|
||||
"botAuthor": "a5a06d596f15c7db",
|
||||
"isPreRelease": true,
|
||||
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue