Merge branch 'main' of code.chipmunk.land:7cc5c4f330d47060/botv12
This commit is contained in:
commit
502a82fd30
54 changed files with 924 additions and 564 deletions
.gitignoreREADME.md
chatParsers
chat_cmm.jschat_cmm_mcp.jschat_extras_profileless.jschat_player.jschat_system.jschat_vanilla_legacy.js
commands
about.jscb.jscloop.jseval.jshelp.jslogoff.jsnetmsg.jsrefill.jsrestart.jssay.jsstop.jstemplate.jstest.jstpr.jsvalidate.js
index.jslang
package-lock.jsonpackage.jsonplugins
chatlog.jscloop.jscommand.jscommandblock.jsconsole.jserrorh.jshelloworld.jsplayer.jsrejoin.jsselfcare.jsserverChat.js
settings_example.jssettings_example.jsonutil
Command.jschatlog.jschatparse_console.jscommands.jsconsolecolors.jsonhashcheck.jslang.jsmemoryconvert.jsusergen.jsuuidtoint.jsversion.js
version.jsversion.json
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -151,11 +151,12 @@ dist
|
|||
|
||||
# Bot Settings
|
||||
settings.json
|
||||
settings.js
|
||||
|
||||
# Default secret file
|
||||
# Legacy secret file for version 10
|
||||
secret.json
|
||||
|
||||
# botvX user settings
|
||||
# botvX / owobot user settings
|
||||
userPref/
|
||||
|
||||
# botvX log files
|
||||
|
|
|
@ -19,7 +19,7 @@ If you find any exploits, security issues, etc in the code, please send me an is
|
|||
2. Download the latest release, or alternatively, download the latest development version using `git clone https://code.chipmunk.land/7cc5c4f330d47060/botv12`.
|
||||
3. Extract the files if necessary.
|
||||
4. Run `npm install` 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 the reference configuration from [the old repository](https://code.chipmunk.land/7cc5c4f330d47060/owobot) to `settings.json`, and adjust the settings to fit your needs.
|
||||
5. Copy the reference configuration (`settings_example.js` in the root) to `settings.js`, and adjust the settings to fit your needs. The secrets are also contained in this file as well.
|
||||
6. Run ./launch.sh (macOS, Linux, FreeBSD) or ./launch.cmd (Windows). This will start a bot launcher, which will restart the bot when the process closes. Alternatively, you can run `node index.js` 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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
|
||||
const priority = 0
|
||||
const parse = (data, b) => {
|
||||
|
@ -44,4 +44,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
|
||||
const priority = 0
|
||||
const parse = (data, b) => {
|
||||
|
@ -24,4 +24,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
|
||||
const priority = 1
|
||||
const parse = (data, b) => {
|
||||
|
@ -28,4 +28,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -16,4 +16,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
|
||||
const priority = 2
|
||||
const parse = (data, b) => {
|
||||
|
@ -37,4 +37,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
|
||||
const priority = 1
|
||||
const parse = (data, b) => {
|
||||
|
@ -30,4 +30,4 @@ const parse = (data, b) => {
|
|||
parsed: false
|
||||
}
|
||||
}
|
||||
export { priority, parse }
|
||||
export { priority, parse }
|
||||
|
|
|
@ -2,11 +2,10 @@ import os from 'node:os'
|
|||
import { execSync } from 'child_process'
|
||||
import { getMessage, formatTime } from '../util/lang.js'
|
||||
import memoryconvert from '../util/memoryconvert.js'
|
||||
import { readdirSync, readFileSync } from "node:fs"
|
||||
import { default as botVersion } from "../util/version.js"
|
||||
import { default as version } from "../version.json" with { type: "json" }
|
||||
import { bots } from "../index.js"
|
||||
|
||||
import { readdirSync, readFileSync } from 'node:fs'
|
||||
import botVersion from '../util/version.js'
|
||||
import version from '../version.js'
|
||||
import { bots } from '../index.js'
|
||||
|
||||
const aboutBot = function (c) {
|
||||
c.reply({
|
||||
|
@ -284,4 +283,4 @@ const execute = function (c) {
|
|||
}
|
||||
}
|
||||
const aliases = ['info', 'serverlist', 'servers', 'serverinfo', 'specs']
|
||||
export { execute, aliases }
|
||||
export { execute, aliases }
|
||||
|
|
6
commands/cb.js
Executable file
6
commands/cb.js
Executable file
|
@ -0,0 +1,6 @@
|
|||
const execute = (c) => {
|
||||
c.bot.ccq.push(c.args.join(' '))
|
||||
}
|
||||
const consoleIndex = true
|
||||
const aliases = ['commandblock', 'cmdblock']
|
||||
export { execute, consoleIndex, aliases }
|
91
commands/cloop.js
Executable file
91
commands/cloop.js
Executable file
|
@ -0,0 +1,91 @@
|
|||
import { getMessage } from '../util/lang.js'
|
||||
const execute = (c) => {
|
||||
let subcmd
|
||||
if (c.args.length >= 1) subcmd = c.args.splice(0, 1)[0].toLowerCase()
|
||||
switch (subcmd) {
|
||||
case 'add': {
|
||||
const rate = +(c.args.splice(0, 1)[0])
|
||||
const command = c.args.join(' ')
|
||||
if (rate < 20) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.cloop.error.tooShort')
|
||||
})
|
||||
}
|
||||
c.bot.addCloop(command, rate)
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.success.add'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: command,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: rate + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'remove': {
|
||||
const index = +c.args[0]
|
||||
c.bot.removeCloop(c.args[0])
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.success.remove'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: index + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'list':
|
||||
c.bot.cloops.forEach((item, i) => {
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.list'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: i.toString(),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: item.command,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: item.rate + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
break
|
||||
case 'clear':
|
||||
c.bot.clearCloops()
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.cloop.success.clear'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
break
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}help cloop`,
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
const consoleIndex = true
|
||||
const level = 1
|
||||
|
||||
export { execute, consoleIndex, level }
|
|
@ -1,16 +1,7 @@
|
|||
import * as index from "../index.js" // Not used in the code, but may be used by users of the command
|
||||
import * as index from '../index.js' // Not used in the code, but may be used by users of the command
|
||||
import { getMessage } from '../util/lang.js'
|
||||
|
||||
const execute = (c) => {
|
||||
if(c.verify != 2){
|
||||
c.reply({
|
||||
text: getMessage(c.lang, "command.disallowed.perms.short")
|
||||
})
|
||||
c.reply({
|
||||
text: getMessage(c.lang, "command.disabled.nonConsole")
|
||||
})
|
||||
return
|
||||
}
|
||||
const item = eval(c.args.join(' '))
|
||||
if (c.type === 'console') {
|
||||
console.log(item)
|
||||
|
@ -48,4 +39,3 @@ const execute = (c) => {
|
|||
}
|
||||
const level = 2
|
||||
export { execute, level }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import cmds from "../util/commands.js"
|
||||
import cmds from '../util/commands.js'
|
||||
import { getMessage } from '../util/lang.js'
|
||||
|
||||
const sortHelp = function sortHelp (c1, c2) {
|
||||
|
@ -171,12 +171,12 @@ const printCmdHelp = (c) => {
|
|||
}
|
||||
]
|
||||
})
|
||||
if(cmds[cmd].aliases){
|
||||
const aliasList = [];
|
||||
for(const item of cmds[cmd].aliases){
|
||||
if(aliasList.length>0){
|
||||
if (cmds[cmd].aliases) {
|
||||
const aliasList = []
|
||||
for (const item of cmds[cmd].aliases) {
|
||||
if (aliasList.length > 0) {
|
||||
aliasList.push({
|
||||
text: ", ",
|
||||
text: ', ',
|
||||
color: c.colors.secondary
|
||||
})
|
||||
}
|
||||
|
@ -224,7 +224,6 @@ const printCmdHelp = (c) => {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
const execute = (c) => {
|
||||
if (c.args.length > 0) {
|
||||
printCmdHelp(c)
|
||||
|
@ -236,4 +235,3 @@ const aliases = [
|
|||
'heko' // Parker2991 request
|
||||
]
|
||||
export { execute, aliases }
|
||||
|
||||
|
|
7
commands/logoff.js
Executable file
7
commands/logoff.js
Executable file
|
@ -0,0 +1,7 @@
|
|||
const execute = (c) => {
|
||||
c.bot._client.end()
|
||||
}
|
||||
const consoleIndex = true
|
||||
const level = 2
|
||||
|
||||
export { execute, consoleIndex, level }
|
57
commands/netmsg.js
Executable file
57
commands/netmsg.js
Executable file
|
@ -0,0 +1,57 @@
|
|||
import { bots } from '../index.js'
|
||||
import { getMessage } from '../util/lang.js'
|
||||
|
||||
const execute = (c) => {
|
||||
let host = c.host
|
||||
let port = c.port
|
||||
if (c.bot.host.options && c.bot.host.options.hidden) {
|
||||
host = 'localhost' // Makes hidden servers appear as localhost
|
||||
port = '25565'
|
||||
} else if (c.bot.host.options && c.bot.host.options.displayAsIPv6) {
|
||||
host = `[${host}]`
|
||||
}
|
||||
const json = {
|
||||
translate: '[%s] %s: %s',
|
||||
with: [
|
||||
{
|
||||
text: c.serverName,
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
translate: '%s: %s:%s',
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.netmsg.serverAddress'),
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: host,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: port + '',
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
color: c.colors.secondary
|
||||
}
|
||||
},
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: c.username,
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: c.args.join(' ').slice(0, 512)
|
||||
}
|
||||
],
|
||||
color: c.colors.tertiary
|
||||
}
|
||||
bots.forEach(item => {
|
||||
if (item.host.options && item.host.options.netmsgIncomingDisabled && c.type !== 'console') return
|
||||
item.tellraw('@a', json)
|
||||
})
|
||||
}
|
||||
|
||||
export { execute }
|
7
commands/refill.js
Executable file
7
commands/refill.js
Executable file
|
@ -0,0 +1,7 @@
|
|||
const execute = (c) => {
|
||||
c.bot.chat(c.bot.refillCoreCmd)
|
||||
}
|
||||
const consoleIndex = true
|
||||
const aliases = ['refillcore', 'rc']
|
||||
|
||||
export { execute, consoleIndex, aliases }
|
7
commands/restart.js
Executable file
7
commands/restart.js
Executable file
|
@ -0,0 +1,7 @@
|
|||
const execute = (c) => {
|
||||
process.exit(0)
|
||||
}
|
||||
const aliases = ['reboot']
|
||||
const level = 2
|
||||
|
||||
export { execute, aliases, level }
|
|
@ -1,5 +1,5 @@
|
|||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import { default as version } from "../version.json" with { type: "json" }
|
||||
import settings from '../settings.js'
|
||||
import version from '../version.js'
|
||||
const execute = (c) => {
|
||||
if (c.verify < 1) {
|
||||
c.bot.tellraw('@a', {
|
||||
|
@ -38,4 +38,4 @@ const execute = (c) => {
|
|||
}
|
||||
const consoleIndex = true
|
||||
const aliases = ['echo']
|
||||
export { execute, consoleIndex, aliases }
|
||||
export { execute, consoleIndex, aliases }
|
||||
|
|
7
commands/stop.js
Executable file
7
commands/stop.js
Executable file
|
@ -0,0 +1,7 @@
|
|||
const execute = (c) => {
|
||||
process.exit(1)
|
||||
}
|
||||
const aliases = ['exit']
|
||||
const level = 2
|
||||
|
||||
export { execute, aliases, level }
|
41
commands/template.js
Executable file
41
commands/template.js
Executable file
|
@ -0,0 +1,41 @@
|
|||
const execute = (c) => {
|
||||
// Blank template
|
||||
/*
|
||||
c.send(text, user?): Send text to all ("/tellraw @a")
|
||||
c.reply(text): Send text to command sender
|
||||
c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord)
|
||||
c.username: Username of sender
|
||||
c.nickname: Nickname of sender when applicable
|
||||
c.command: Command string
|
||||
c.args: Arguments of command (above without the first section, and split at every space)
|
||||
c.prefix: Prefix being used to send the command (when applicable)
|
||||
c.bot: Bot that received the command. Will be different type based on where it was received
|
||||
c.type: Type of bot receiving the command ("minecraft", "console", "discord")
|
||||
c.lang: The language the player has selected, or the default if none
|
||||
c.colors: The color palette the player has selected, or the default if none
|
||||
*/
|
||||
}
|
||||
/*
|
||||
Command description and usage have been moved to the message files. The format for a basic command is:
|
||||
"command.(name).usage": " <required> [optional]",
|
||||
"command.(name).desc": "Insert description here...",
|
||||
replacing (name) with the name of the new command.
|
||||
Some more complex commands may have messages of their own, which should be placed there too.
|
||||
First, insert the following line near the top of the command's file (not in the execute function):
|
||||
const { getMessage } = require('../../util/lang.js')
|
||||
Then, to get a specific message:
|
||||
getMessage(c.lang,"(message key)",[(arguments, in an array (optional))])
|
||||
For example, this will show the "about" command's redirection to "serverinfo":
|
||||
getMessage(c.lang,"command.about.serverinfo")
|
||||
The with array can be used to add information to a message. For example:
|
||||
getMessage(lang,"command.help.commandInfo",["cmd","usage","desc"])
|
||||
shows the "help" command's formatting for command information, with some strings as items.
|
||||
That message would render as (in en-US):
|
||||
cmdusage - desc
|
||||
Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array.
|
||||
*/
|
||||
const hidden = true // To show the command on the help command list, remove this line (optional)
|
||||
const consoleIndex = true // When run from console, the second argument will be a bot ID (optional)
|
||||
const aliases = ['example'] // Other command names that will work the same (optional)
|
||||
const level = 0 // Permission level required to run this command (optional)
|
||||
export { execute, hidden, consoleIndex, aliases, level } // Only export the items that were included in your command
|
|
@ -34,16 +34,20 @@ const execute = (c) => {
|
|||
c.reply(reply('uuid', c.uuid))
|
||||
c.reply(reply('username', c.username))
|
||||
c.reply(reply('nickname', c.nickname))
|
||||
c.reply(reply('command', c.command.slice(0,1024)))
|
||||
c.reply(reply('command', c.command.slice(0, 1024)))
|
||||
c.reply(reply('msgType', c.msgType))
|
||||
c.reply(reply('msgSubtype', c.msgSubtype))
|
||||
c.reply(reply('prefix', c.prefix))
|
||||
c.reply(reply('args', c.args.join(', ').slice(0,1024)))
|
||||
c.reply(reply('args', c.args.join(', ').slice(0, 1024)))
|
||||
c.reply(reply('verify', c.verify.toString()))
|
||||
c.reply(reply('host', c.host))
|
||||
c.reply(reply('port', c.port.toString()))
|
||||
c.reply(reply('lang', c.lang))
|
||||
c.reply(reply('colorPrimary', c.colors.primary))
|
||||
c.reply(reply('colorSecondary', c.colors.secondary))
|
||||
c.reply(reply('colorTertiary', c.colors.tertiary))
|
||||
c.reply(reply('colorWarning', c.colors.warning))
|
||||
c.reply(reply('colorError', c.colors.error))
|
||||
c.reply(reply('colorFatalError', c.colors.fatalError))
|
||||
}
|
||||
export { execute }
|
||||
export { execute }
|
||||
|
|
44
commands/tpr.js
Executable file
44
commands/tpr.js
Executable file
|
@ -0,0 +1,44 @@
|
|||
import { getMessage } from '../util/lang.js'
|
||||
|
||||
const 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`)
|
||||
}
|
||||
const consoleIndex = true
|
||||
const aliases = ['rtp']
|
||||
|
||||
export { execute, consoleIndex, aliases }
|
21
commands/validate.js
Executable file
21
commands/validate.js
Executable file
|
@ -0,0 +1,21 @@
|
|||
import { getMessage } from '../util/lang.js'
|
||||
|
||||
const 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')
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.verify.success'),
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
text: [permsN, permsT, permsO][c.verify],
|
||||
color: c.colors.primary
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
const aliases = ['verify']
|
||||
const level = 1
|
||||
|
||||
export { execute, aliases, level }
|
20
index.js
20
index.js
|
@ -1,20 +1,20 @@
|
|||
import { createClient } from "minecraft-protocol";
|
||||
import { default as settings } from './settings.json' with {type: "json"}
|
||||
import { createClient } from 'minecraft-protocol'
|
||||
import settings from './settings.js'
|
||||
import generateUser from './util/usergen.js'
|
||||
import EventEmitter from 'node:events'
|
||||
import { readdirSync } from "node:fs";
|
||||
import { readdirSync } from 'node:fs'
|
||||
|
||||
const bots = [];
|
||||
const bots = []
|
||||
|
||||
const plugins = [];
|
||||
const plugins = []
|
||||
const bpl = readdirSync('plugins')
|
||||
for (const plugin of bpl) {
|
||||
if (!plugin.endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
import(`./plugins/${plugin}`).then((pluginItem)=>{
|
||||
for(const bot of bots){
|
||||
import(`./plugins/${plugin}`).then((pluginItem) => {
|
||||
for (const bot of bots) {
|
||||
pluginItem.default(bot)
|
||||
}
|
||||
plugins.push(pluginItem.default) // For rejoining
|
||||
|
@ -24,10 +24,10 @@ for (const plugin of bpl) {
|
|||
|
||||
const createBot = function createBot (host, oldId) {
|
||||
const bot = new EventEmitter()
|
||||
|
||||
|
||||
bot.host = host
|
||||
bot.interval = {}
|
||||
|
||||
|
||||
bot._client = createClient({
|
||||
host: host.host,
|
||||
port: host.port ? host.port : 25565,
|
||||
|
@ -54,7 +54,7 @@ const createBot = function createBot (host, oldId) {
|
|||
delete bots[oldId]
|
||||
bot.id = oldId
|
||||
bots[oldId] = bot
|
||||
for(const pluginItem of plugins){
|
||||
for (const pluginItem of plugins) {
|
||||
pluginItem(bot)
|
||||
}
|
||||
} else {
|
||||
|
|
131
lang/en-US.js
Normal file
131
lang/en-US.js
Normal file
|
@ -0,0 +1,131 @@
|
|||
export default {
|
||||
'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 ',
|
||||
'chat.antiSpamTriggered': 'Anti-spam has been triggered for this server.',
|
||||
'command.about.usage': '',
|
||||
'command.about.desc': 'About the bot',
|
||||
'command.cb.usage': ' <command>',
|
||||
'command.cb.desc': 'Run a command in a command block',
|
||||
'command.cloop.usage': ' add <rate> <command>|| remove <index>|| list|| clear',
|
||||
'command.cloop.desc': 'Manage command loops',
|
||||
'command.eval.usage': ' <code>',
|
||||
'command.eval.desc': 'Run JavaScript code',
|
||||
'command.help.usage': ' [cmd]',
|
||||
'command.help.desc': 'Shows command help',
|
||||
'command.logoff.usage': '',
|
||||
'command.logoff.desc': 'Disconnect and reconnect the bot from a server',
|
||||
'command.netmsg.usage': ' <message>',
|
||||
'command.netmsg.desc': 'Send a message to all servers the bot is connected to',
|
||||
'command.refill.usage': '',
|
||||
'command.refill.desc': 'Refill core',
|
||||
'command.say.usage': ' <message>',
|
||||
'command.say.desc': 'Sends a message to chat',
|
||||
'command.restart.usage': '',
|
||||
'command.restart.desc': 'Restart bot',
|
||||
'command.stop.usage': '',
|
||||
'command.stop.desc': 'Stop bot',
|
||||
'command.template.usage': ' <required> [optional]',
|
||||
'command.template.desc': 'Does nothing',
|
||||
'command.test.usage': ' [args...]',
|
||||
'command.test.desc': 'Chat parsing debugger command',
|
||||
'command.tpr.usage': '',
|
||||
'command.tpr.desc': 'Teleport to a random location',
|
||||
'command.validate.usage': ' [args...]',
|
||||
'command.validate.desc': 'Check the hashing system',
|
||||
'command.about.author': '%s - a Minecraft bot made by %s for Kaboom and clones',
|
||||
'command.about.version': 'Version %s',
|
||||
'command.about.preRelease': "This is a development version - there may be errors, and features may be changed or removed at any time. Please report any errors to the bot's developer.",
|
||||
'command.about.sourceCode': 'Source code: %s',
|
||||
'command.about.license': 'This bot is free and open-source software and is available under the terms of the MIT license.',
|
||||
'command.about.subcommands': "This command has subcommands to find out more about this bot - try running the commands \"servers\" for a list of Minecraft servers the bot is connected to, or \"serverinfo\" for technical specifications of the bot's server.",
|
||||
'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.eval.output': 'Output',
|
||||
'command.help.cmdList': 'Commands',
|
||||
'command.help.commandInfo': '%s%s - %s',
|
||||
'command.help.commandUsage': 'Usage - %s%s',
|
||||
'command.help.commandDesc': 'Description - %s',
|
||||
'command.help.commandPerms': 'Required permissions - %s',
|
||||
'command.help.commandUsage.lf': 'Usage - %s%s\n',
|
||||
'command.help.commandDesc.lf': 'Description - %s\n',
|
||||
'command.help.commandPerms.lf': 'Required permissions - %s\n',
|
||||
'command.help.commandAliases': 'Aliases - %s',
|
||||
'command.help.runCommand': 'Click to run command',
|
||||
'command.help.permsNormal': 'Public',
|
||||
'command.help.permsTrusted': 'Trusted',
|
||||
'command.help.permsOwner': 'Owner',
|
||||
'command.help.noCommand': 'Command does not exist',
|
||||
'command.help.alias': 'Alias to %s',
|
||||
'command.help.copyAlias': 'Click to copy this alias to your clipboard',
|
||||
'command.netmsg.serverAddress': 'Server Address',
|
||||
'command.test.uuid': 'UUID',
|
||||
'command.test.username': 'Username',
|
||||
'command.test.nickname': 'Nickname',
|
||||
'command.test.command': 'Command',
|
||||
'command.test.msgType': 'Message type',
|
||||
'command.test.msgSubtype': 'Message subtype',
|
||||
'command.test.prefix': 'Prefix',
|
||||
'command.test.args': 'Arguments',
|
||||
'command.test.verify': 'Permission level',
|
||||
'command.test.host': 'Server host',
|
||||
'command.test.port': 'Server port',
|
||||
'command.test.lang': 'Language',
|
||||
'command.test.colorPrimary': 'Primary color',
|
||||
'command.test.colorSecondary': 'Secondary color',
|
||||
'command.test.colorTertiary': 'Tertiary color',
|
||||
'command.test.colorWarning': 'Warning color',
|
||||
'command.test.colorError': 'Error color',
|
||||
'command.test.colorFatalError': 'Fatal error color',
|
||||
'command.about.serverInfo.os.android': 'Android %s',
|
||||
'command.about.serverInfo.os.android.noVersion': 'Android',
|
||||
'command.about.serverInfo.os.freebsd': 'FreeBSD',
|
||||
'command.about.serverInfo.os.linux': 'Linux',
|
||||
'command.about.serverInfo.os.macos': 'macOS',
|
||||
'command.about.serverInfo.os.macos_old': 'OS X',
|
||||
'command.about.serverInfo.os': 'Operating system',
|
||||
'command.about.serverInfo.kernelVer': 'Kernel version',
|
||||
'command.about.serverInfo.processor': 'CPU',
|
||||
'command.about.serverInfo.arch': 'Architecture',
|
||||
'command.about.serverInfo.totalMem': 'Total memory',
|
||||
'command.about.serverInfo.freeMem': 'Free memory',
|
||||
'command.about.serverInfo.usedMem': 'Used memory',
|
||||
'command.about.serverInfo.osUsername': 'Username',
|
||||
'command.about.serverInfo.hostName': 'Hostname',
|
||||
'command.about.serverInfo.workingDir': 'Working directory',
|
||||
'command.about.serverInfo.runTime': 'Bot uptime',
|
||||
'command.about.serverInfo.upTime': 'System uptime',
|
||||
'command.about.serverInfo.nodeVersion': 'Node.js version',
|
||||
'command.about.serverInfo.osRelease': 'Linux release',
|
||||
'command.about.serverInfo.osRelease.missing': '/etc/os-release does not exist. Information may be limited.',
|
||||
'command.about.serverInfo.os.android.version': 'Android version',
|
||||
'command.about.serverInfo.os.android.model': 'Device model',
|
||||
'command.about.serverInfo.botName': 'Bot name',
|
||||
'command.about.serverInfo.botVer': 'Bot version',
|
||||
'command.about.serverListItem': 'Server %s - %s',
|
||||
'command.about.serverListItem.thisServer': 'Server %s - %s (this server)',
|
||||
'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.short': 'You do not have permission to run this command.',
|
||||
'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 the hashing system of your client or proxy.',
|
||||
'command.disallowed.perms.yourLevel': 'Your permission level: %s',
|
||||
'command.disallowed.perms.cmdLevel': 'Command requires: %s',
|
||||
'command.disabled.generic': 'This command has been disabled.',
|
||||
'command.disabled.local': 'This command has been disabled on this server.',
|
||||
'command.disabled.console': 'This command cannot be run from the console.',
|
||||
'command.disabled.nonConsole': 'This command must be run from the console.',
|
||||
copyText: 'Click to copy this item to your clipboard'
|
||||
}
|
138
lang/en-US.json
138
lang/en-US.json
|
@ -1,138 +0,0 @@
|
|||
{
|
||||
"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 ",
|
||||
"chat.antiSpamTriggered": "Anti-spam has been triggered for this server.",
|
||||
"command.about.usage": "",
|
||||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
"command.cb.desc": "Run a command in a command block",
|
||||
"command.cloop.usage": " add <rate> <command>|| remove <index>|| list|| clear",
|
||||
"command.cloop.desc": "Manage command loops",
|
||||
"command.eval.usage": " <code>",
|
||||
"command.eval.desc": "Run JavaScript code",
|
||||
"command.help.usage": " [cmd]",
|
||||
"command.help.desc": "Shows command help",
|
||||
"command.logoff.usage": "",
|
||||
"command.logoff.desc": "Disconnect and reconnect the bot from a server",
|
||||
"command.netmsg.usage": " <message>",
|
||||
"command.netmsg.desc": "Send a message to all servers the bot is connected to",
|
||||
"command.refill.usage": "",
|
||||
"command.refill.desc": "Refill core",
|
||||
"command.say.usage": " <message>",
|
||||
"command.say.desc": "Sends a message to chat",
|
||||
"command.restart.usage": "",
|
||||
"command.restart.desc": "Restart bot",
|
||||
"command.stop.usage": "",
|
||||
"command.stop.desc": "Stop bot",
|
||||
"command.template.usage": " <required> [optional]",
|
||||
"command.template.desc": "Does nothing",
|
||||
"command.test.usage": " [args...]",
|
||||
"command.test.desc": "Chat parsing debugger command",
|
||||
"command.tpr.usage": "",
|
||||
"command.tpr.desc": "Teleport to a random location",
|
||||
"command.validate.usage": " [args...]",
|
||||
"command.validate.desc": "Check the hashing system",
|
||||
"command.about.author": "%s - a Minecraft bot made by %s for Kaboom and clones",
|
||||
"command.about.version": "Version %s",
|
||||
"command.about.preRelease": "This is a development version - there may be errors, and features may be changed or removed at any time. Please report any errors to the bot's developer.",
|
||||
"command.about.sourceCode": "Source code: %s",
|
||||
"command.about.license": "This bot is free and open-source software and is available under the terms of the MIT license.",
|
||||
"command.about.subcommands": "This command has subcommands to find out more about this bot - try running the commands \"servers\" for a list of Minecraft servers the bot is connected to, or \"serverinfo\" for technical specifications of the bot's server.",
|
||||
"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.eval.output": "Output",
|
||||
"command.help.cmdList": "Commands",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
"command.help.commandDesc": "Description - %s",
|
||||
"command.help.commandPerms": "Required permissions - %s",
|
||||
"command.help.commandUsage.lf": "Usage - %s%s\n",
|
||||
"command.help.commandDesc.lf": "Description - %s\n",
|
||||
"command.help.commandPerms.lf": "Required permissions - %s\n",
|
||||
"command.help.commandAliases": "Aliases - %s",
|
||||
"command.help.runCommand": "Click to run command",
|
||||
"command.help.permsNormal": "Public",
|
||||
"command.help.permsTrusted": "Trusted",
|
||||
"command.help.permsOwner": "Owner",
|
||||
"command.help.noCommand": "Command does not exist",
|
||||
"command.help.alias": "Alias to %s",
|
||||
"command.help.copyAlias": "Click to copy this alias to your clipboard",
|
||||
"command.netmsg.serverAddress": "Server Address",
|
||||
"command.test.uuid": "UUID",
|
||||
"command.test.username": "Username",
|
||||
"command.test.nickname": "Nickname",
|
||||
"command.test.command": "Command",
|
||||
"command.test.msgType": "Message type",
|
||||
"command.test.msgSubtype": "Message subtype",
|
||||
"command.test.prefix": "Prefix",
|
||||
"command.test.args": "Arguments",
|
||||
"command.test.verify": "Permission level",
|
||||
"command.test.host": "Server host",
|
||||
"command.test.port": "Server port",
|
||||
"command.test.lang": "Language",
|
||||
"command.test.colorPrimary": "Primary color",
|
||||
"command.test.colorSecondary": "Secondary color",
|
||||
"command.about.serverInfo.os.android": "Android %s",
|
||||
"command.about.serverInfo.os.android.noVersion": "Android",
|
||||
"command.about.serverInfo.os.freebsd": "FreeBSD",
|
||||
"command.about.serverInfo.os.linux": "Linux",
|
||||
"command.about.serverInfo.os.macos": "macOS",
|
||||
"command.about.serverInfo.os.macos_old": "OS X",
|
||||
"command.about.serverInfo.os": "Operating system",
|
||||
"command.about.serverInfo.kernelVer": "Kernel version",
|
||||
"command.about.serverInfo.processor": "CPU",
|
||||
"command.about.serverInfo.arch": "Architecture",
|
||||
"command.about.serverInfo.totalMem": "Total memory",
|
||||
"command.about.serverInfo.freeMem": "Free memory",
|
||||
"command.about.serverInfo.usedMem": "Used memory",
|
||||
"command.about.serverInfo.osUsername": "Username",
|
||||
"command.about.serverInfo.hostName": "Hostname",
|
||||
"command.about.serverInfo.workingDir": "Working directory",
|
||||
"command.about.serverInfo.runTime": "Bot uptime",
|
||||
"command.about.serverInfo.upTime": "System uptime",
|
||||
"command.about.serverInfo.nodeVersion": "Node.js version",
|
||||
"command.about.serverInfo.osRelease": "Linux release",
|
||||
"command.about.serverInfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
|
||||
"command.about.serverInfo.os.android.version": "Android version",
|
||||
"command.about.serverInfo.os.android.model": "Device model",
|
||||
"command.about.serverInfo.botName": "Bot name",
|
||||
"command.about.serverInfo.botVer": "Bot version",
|
||||
"command.about.serverListItem": "Server %s - %s",
|
||||
"command.about.serverListItem.thisServer": "Server %s - %s (this server)",
|
||||
"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.short": "You do not have permission to run this command.",
|
||||
"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 the hashing system of your client or proxy.",
|
||||
"command.disallowed.perms.yourLevel": "Your permission level: %s",
|
||||
"command.disallowed.perms.cmdLevel": "Command requires: %s",
|
||||
"command.disabled.generic": "This command has been disabled.",
|
||||
"command.disabled.local": "This command has been disabled on this server.",
|
||||
"command.disabled.console": "This command cannot be run from the console.",
|
||||
"command.disabled.nonConsole": "This command must be run from the console.",
|
||||
"feature.deprecated": "%s will be removed in the future.",
|
||||
"feature.deprecated.replace": "%s will be replaced with %s in the future.",
|
||||
"feature.deprecated.merge": "%s will be merged with %s in the future.",
|
||||
"feature.removed": "%s has been removed.",
|
||||
"feature.removed.replace": "%s has been replaced with %s.",
|
||||
"feature.removed.merge": "%s has been merged with %s.",
|
||||
"feature.removed.plural": "%s have been removed.",
|
||||
"feature.removed.replace.plural": "%s have been replaced with %s.",
|
||||
"feature.removed.merge.plural": "%s have been merged with %s.",
|
||||
"copyText": "Click to copy this item to your clipboard"
|
||||
}
|
16
package-lock.json
generated
16
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "botv12",
|
||||
"version": "12.0.0-alpha.1",
|
||||
"version": "12.0.0-alpha.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "botv12",
|
||||
"version": "12.0.0-alpha.1",
|
||||
"version": "12.0.0-alpha.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minecraft-protocol": "^1.49.0"
|
||||
|
@ -22,9 +22,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@azure/msal-node": {
|
||||
"version": "2.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.0.tgz",
|
||||
"integrity": "sha512-oww0oJTOOvPKTVXqVyxfcFVjExQKYEkKR5KM0cTG3jnzt6u/MRMx8XaK49L/bxV35r9sCHQFjNlEShad9qGSYA==",
|
||||
"version": "2.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.2.tgz",
|
||||
"integrity": "sha512-An7l1hEr0w1HMMh1LU+rtDtqL7/jw74ORlc9Wnh06v7TU/xpG39/Zdr1ZJu3QpjUfKJ+E0/OXMW8DRSWTlh7qQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@azure/msal-common": "14.16.0",
|
||||
|
@ -36,9 +36,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz",
|
||||
"integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==",
|
||||
"version": "22.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.1.tgz",
|
||||
"integrity": "sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.19.8"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "botv12",
|
||||
"version": "12.0.0-alpha.1",
|
||||
"version": "12.0.0-alpha.2",
|
||||
"description": "Minecraft bot for the Kaboom server",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import chatlog from '../util/chatlog.js'
|
||||
import { readdirSync, mkdirSync } from "node:fs"
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import { readdirSync, mkdirSync } from 'node:fs'
|
||||
import settings from '../settings.js'
|
||||
|
||||
const checkLog = () => {
|
||||
if (settings.disableLogging) return
|
||||
|
@ -17,10 +17,9 @@ const checkLog = () => {
|
|||
}
|
||||
}
|
||||
|
||||
setInterval(checkLog, 3600000) // Runs once every hour,
|
||||
setInterval(checkLog, 7200000) // Runs once every two hours,
|
||||
checkLog() // and at bot startup.
|
||||
|
||||
|
||||
export default function load (b) {
|
||||
b.on('plainchat', (msg, type) => {
|
||||
if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`)
|
||||
|
@ -28,4 +27,4 @@ export default function load (b) {
|
|||
b.on('command', c => {
|
||||
if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `[${c.msgType}] ${c.username} (${c.uuid}): ${c.command}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
21
plugins/cloop.js
Executable file
21
plugins/cloop.js
Executable file
|
@ -0,0 +1,21 @@
|
|||
export default function load (b) {
|
||||
b.cloops = []
|
||||
b.addCloop = function (command, rate) {
|
||||
b.cloops.push({
|
||||
command,
|
||||
rate,
|
||||
interval: setInterval(() => { b.ccq.push(command) }, rate)
|
||||
})
|
||||
b.ccq.push(command)
|
||||
}
|
||||
b.removeCloop = function (index) {
|
||||
clearInterval(b.cloops[index].interval)
|
||||
b.cloops.splice(index, 1)
|
||||
}
|
||||
b.clearCloops = function () {
|
||||
for (const cloop of b.cloops) {
|
||||
clearInterval(cloop.interval)
|
||||
}
|
||||
b.cloops = []
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import cmds from "../util/commands.js"
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import cmds from '../util/commands.js'
|
||||
import settings from '../settings.js'
|
||||
import Command from '../util/Command.js'
|
||||
import hashcheck from '../util/hashcheck.js'
|
||||
import { getMessage } from '../util/lang.js'
|
||||
export default function load (b) {
|
||||
b.on('chat', (data) => {
|
||||
const fullCommand = data.message
|
||||
|
@ -11,18 +13,53 @@ export default function load (b) {
|
|||
}
|
||||
}
|
||||
})
|
||||
b.runCommand = function (user, nick, uuid, command, type, subtype, prefix){
|
||||
const context = new Command(uuid, user, nick, command, "minecraft", type, subtype, prefix, b, 0)
|
||||
b.runCommand = function (user, nick, uuid, command, type, subtype, prefix) {
|
||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||
if (Date.now() - b.lastCmd <= 1000) return
|
||||
b.lastCmd = Date.now()
|
||||
|
||||
const context = new Command(uuid, user, nick, command, 'minecraft', type, subtype, prefix, b)
|
||||
|
||||
b.emit('command', context)
|
||||
if (context.cancel === true) return
|
||||
|
||||
if(cmds[context.cmdName.toLowerCase()]){
|
||||
const commandItem = cmds[context.cmdName.toLowerCase()]
|
||||
|
||||
const cmdsplit = command.split(' ')
|
||||
const verify = hashcheck(cmdsplit, uuid)
|
||||
const permsN = getMessage(context.lang, 'command.help.permsNormal')
|
||||
const permsT = getMessage(context.lang, 'command.help.permsTrusted')
|
||||
const permsO = getMessage(context.lang, 'command.help.permsOwner')
|
||||
if (commandItem && commandItem.level !== undefined && commandItem.level > verify) {
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(context.lang, 'command.disallowed.perms')
|
||||
})
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(context.lang, 'command.disallowed.perms.yourLevel', [[permsN, permsT, permsO][verify]])
|
||||
})
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(context.lang, 'command.disallowed.perms.cmdLevel', [[permsN, permsT, permsO][commandItem.level]])
|
||||
})
|
||||
return
|
||||
} else if (verify > 0) {
|
||||
context.rewriteCommand(cmdsplit.slice(0, cmdsplit.length - 1).join(' '))
|
||||
context.verify = verify
|
||||
}
|
||||
|
||||
if (commandItem) {
|
||||
try {
|
||||
cmds[context.cmdName.toLowerCase()].execute(context)
|
||||
commandItem.execute(context)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.reply({
|
||||
text: "An error occured (check console)"
|
||||
b.tellraw(uuid, {
|
||||
text: getMessage(context.lang, 'command.error'),
|
||||
color: context.colors.error,
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
text: e.stack
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { default as uuidToInt } from '../util/uuidtoint.js'
|
||||
import { default as plainParser } from '../util/chatparse_plain.js'
|
||||
import { default as mcParser } from '../util/chatparse_mc.js'
|
||||
import uuidToInt from '../util/uuidtoint.js'
|
||||
import plainParser from '../util/chatparse_plain.js'
|
||||
import mcParser from '../util/chatparse_mc.js'
|
||||
const cs = {
|
||||
x: 4,
|
||||
y: 6,
|
||||
|
@ -135,4 +135,4 @@ export default function load (b) {
|
|||
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import { createInterface, cursorTo, clearLine } from "node:readline"
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import cmds from "../util/commands.js"
|
||||
import { bots } from "../index.js"
|
||||
import { createInterface, cursorTo, clearLine } from 'node:readline'
|
||||
import settings from '../settings.js'
|
||||
import cmds from '../util/commands.js'
|
||||
import { bots } from '../index.js'
|
||||
import Command from '../util/Command.js'
|
||||
import parse2 from "../util/chatparse_console.js"
|
||||
import { userInfo } from "node:os"
|
||||
import parse2 from '../util/chatparse_console.js'
|
||||
import { userInfo } from 'node:os'
|
||||
|
||||
const consoleBotStub = {
|
||||
host: {
|
||||
host: "bot console ",
|
||||
host: 'bot console ',
|
||||
port: 3
|
||||
},
|
||||
tellraw: (_unused, data) => console.log(parse2(data))
|
||||
}
|
||||
const uuid = "4d616465-6c69-6e65-2075-7775203a3300"
|
||||
const uuid = '4d616465-6c69-6e65-2075-7775203a3300'
|
||||
const user = userInfo().username // OS user the bot is running as
|
||||
const nick = "console"
|
||||
const nick = user
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
|
@ -29,16 +29,19 @@ rl.on('line', (l) => {
|
|||
const tmpcmd = l.split(' ')
|
||||
const index2 = tmpcmd.splice(1, 1)[0]
|
||||
if (index2 === '*') {
|
||||
for (let i = 0; i < index.bots.length; i++) {
|
||||
const cmd = new Command(uuid, user, nick, tmpcmd.join(' '), "console", "console", "console", "", bots[i], 2, {})
|
||||
for (let i = 0; i < bots.length; i++) {
|
||||
const cmd = new Command(uuid, user, nick, tmpcmd.join(' '), 'console', 'console', 'console', '', bots[i])
|
||||
cmd.verify = 2
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new Command(uuid, user, nick, tmpcmd.join(' '), "console", "console", "console", "", bots[+index2], 2, {})
|
||||
const cmd = new Command(uuid, user, nick, tmpcmd.join(' '), 'console', 'console', 'console', '', bots[+index2])
|
||||
cmd.verify = 2
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
} else {
|
||||
const cmd = new Command(uuid, user, nick, l, "console", "console", "console", "", consoleBotStub, 2, {})
|
||||
const cmd = new Command(uuid, user, nick, l, 'console', 'console', 'console', '', consoleBotStub)
|
||||
cmd.verify = 2
|
||||
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
|
||||
}
|
||||
}
|
||||
|
@ -66,4 +69,4 @@ export default function load (b) {
|
|||
consoleWrite(`[${b.id}] [${type}] ${msg}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import { default as version } from '../version.json' with {type: "json"}
|
||||
import { bots } from "../index.js"
|
||||
import botVersion from "../util/version.js"
|
||||
import settings from '../settings.js'
|
||||
import version from '../version.js'
|
||||
import { bots } from '../index.js'
|
||||
import botVersion from '../util/version.js'
|
||||
import chatlog from '../util/chatlog.js'
|
||||
|
||||
process.on("uncaughtException",(e, o)=>{
|
||||
for(const i in bots){
|
||||
try{
|
||||
bots[i].ccq[0]=`/tellraw ${version.botAuthor} ${
|
||||
process.on('uncaughtException', (e, o) => {
|
||||
for (const i in bots) {
|
||||
try {
|
||||
bots[i].ccq[0] = `/tellraw ${version.botAuthor} ${
|
||||
JSON.stringify({
|
||||
translate: "%s\n",
|
||||
translate: '%s\n',
|
||||
color: settings.colors.fatalError,
|
||||
with: [
|
||||
`An error occured and ${version.botName} will now shut down.`
|
||||
|
@ -17,9 +17,9 @@ process.on("uncaughtException",(e, o)=>{
|
|||
})
|
||||
}`
|
||||
bots[i].advanceccq()
|
||||
const stack = e.stack.split("\n")
|
||||
for(const item of stack){
|
||||
bots[i].ccq[0]=`/tellraw ${version.botAuthor} ${
|
||||
const stack = e.stack.split('\n')
|
||||
for (const item of stack) {
|
||||
bots[i].ccq[0] = `/tellraw ${version.botAuthor} ${
|
||||
JSON.stringify({
|
||||
text: item,
|
||||
color: settings.colors.fatalError
|
||||
|
@ -27,13 +27,13 @@ process.on("uncaughtException",(e, o)=>{
|
|||
}`
|
||||
bots[i].advanceccq()
|
||||
}
|
||||
bots[i].ccq[0]=`/tellraw ${version.botAuthor} ${
|
||||
bots[i].ccq[0] = `/tellraw ${version.botAuthor} ${
|
||||
JSON.stringify({
|
||||
translate: "\n%s",
|
||||
translate: '\n%s',
|
||||
color: settings.colors.fatalError,
|
||||
with: [
|
||||
[
|
||||
"Additional info:\n",
|
||||
'Additional info:\n',
|
||||
`Bot version: ${botVersion}`
|
||||
]
|
||||
]
|
||||
|
@ -42,11 +42,11 @@ process.on("uncaughtException",(e, o)=>{
|
|||
bots[i].advanceccq() // Force the command queue to advance
|
||||
} catch (e) {}
|
||||
}
|
||||
chatlog("error", e.stack)
|
||||
chatlog('error', e.stack)
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
export default function load (b) {
|
||||
// Due to the nature of this plugin, it does not need to do anything at the bot level
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
export default function load (b) {
|
||||
console.log(`Test plugin loaded on bot ${b.id}`)
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { default as parse } from '../util/chatparse_plain.js'
|
||||
import { default as parseNBT } from '../util/parseNBT.js'
|
||||
|
||||
import parse from '../util/chatparse_plain.js'
|
||||
import parseNBT from '../util/parseNBT.js'
|
||||
|
||||
export default function load (b) {
|
||||
b.players = {}
|
||||
b._client.on('player_info', (data) => {
|
||||
|
@ -72,4 +72,4 @@ export default function load (b) {
|
|||
return '[[[[ No display name ]]]]'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { createBot } from "../index.js"
|
||||
import { createBot } from '../index.js'
|
||||
export default function load (b) {
|
||||
b._client.on('end', () => {
|
||||
b.info(`Bot ${b.id} disconnected`)
|
||||
|
@ -10,4 +10,4 @@ export default function load (b) {
|
|||
createBot(b.host, b.id)
|
||||
}, 5000)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import { default as parseMc } from '../util/chatparse_mc_withHex.js'
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import { default as version } from '../version.json' with {type: "json"}
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
import parseMc from '../util/chatparse_mc_withHex.js'
|
||||
import settings from '../settings.js'
|
||||
import version from '../version.js'
|
||||
class SCTask {
|
||||
constructor (failTask, startFailed = false) {
|
||||
/*
|
||||
|
@ -13,11 +13,10 @@ class SCTask {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export default function load (b) {
|
||||
b.sc_tasks = {}
|
||||
b.selfcareRun = 0
|
||||
b._client.on("login", ()=>{
|
||||
b._client.on('login', () => {
|
||||
b.interval.sc = setInterval(() => {
|
||||
if (Date.now() - b.selfcareRun <= 600) {
|
||||
return
|
||||
|
@ -96,7 +95,7 @@ export default function load (b) {
|
|||
if (!b.host.options.isVanilla) {
|
||||
b.adPrefix = {
|
||||
translate: '[%s] %s', // Since the bot aims to have an invisible name, the ad prefix should contain information about the bot.
|
||||
color: 'white',
|
||||
color: settings.colors.tertiary,
|
||||
with: [
|
||||
{
|
||||
translate: '%s: %s',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import { default as parsePlain } from '../util/chatparse_plain.js'
|
||||
import { default as parseConsole } from '../util/chatparse_console.js'
|
||||
import { default as parse1204 } from '../util/parseNBT.js'
|
||||
import settings from '../settings.js'
|
||||
import parsePlain from '../util/chatparse_plain.js'
|
||||
import parseConsole from '../util/chatparse_console.js'
|
||||
import parse1204 from '../util/parseNBT.js'
|
||||
import { getMessage } from '../util/lang.js'
|
||||
import { readdirSync } from "node:fs"
|
||||
import { readdirSync } from 'node:fs'
|
||||
const convertChatStyleItem = (item) => {
|
||||
const output = {}
|
||||
for (const i in item) {
|
||||
|
@ -38,13 +38,12 @@ for (const plugin of bpl) {
|
|||
continue
|
||||
}
|
||||
try {
|
||||
import(`../chatParsers/${plugin}`).then((pluginItem)=>{
|
||||
import(`../chatParsers/${plugin}`).then((pluginItem) => {
|
||||
parsers[pluginItem.priority].push(pluginItem.parse)
|
||||
})
|
||||
} catch (e) { console.log(e) }
|
||||
}
|
||||
|
||||
|
||||
export default function load (b) {
|
||||
b.messageCount = 0
|
||||
b.chatDisabledUntil = 0
|
||||
|
@ -52,22 +51,22 @@ export default function load (b) {
|
|||
b.messageCount = 0
|
||||
}, 4000)
|
||||
b.messageTypes = []
|
||||
b._client.on('registry_data', (data) => {
|
||||
b._client.on('registry_data', (data) => {
|
||||
if (data.codec && data.codec.value['minecraft:chat_type']) {
|
||||
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value
|
||||
nbtItems.forEach((item, i) => {
|
||||
b.messageTypes[i] = convertChatTypeItem(item.element.value.chat.value)
|
||||
})
|
||||
} else if(data.entries && data.id == 'minecraft:chat_type'){
|
||||
data.entries.forEach((item, i)=>{
|
||||
} else if (data.entries && data.id === 'minecraft:chat_type') {
|
||||
data.entries.forEach((item, i) => {
|
||||
b.messageTypes[i] = convertChatTypeItem(data.entries[i].value.value.chat.value)
|
||||
})
|
||||
}
|
||||
})
|
||||
b._client.on('profileless_chat', (data) => {
|
||||
let messageType;
|
||||
if(data.type.registryIndex){
|
||||
messageType = b.messageTypes[data.type.registryIndex-1]
|
||||
let messageType
|
||||
if (data.type.registryIndex) {
|
||||
messageType = b.messageTypes[data.type.registryIndex - 1]
|
||||
} else {
|
||||
messageType = b.messageTypes[data.type]
|
||||
}
|
||||
|
@ -101,9 +100,9 @@ export default function load (b) {
|
|||
})
|
||||
|
||||
b._client.on('player_chat', (data) => {
|
||||
let messageType;
|
||||
if(data.type.registryIndex){
|
||||
messageType = b.messageTypes[data.type.registryIndex-1]
|
||||
let messageType
|
||||
if (data.type.registryIndex) {
|
||||
messageType = b.messageTypes[data.type.registryIndex - 1]
|
||||
} else {
|
||||
messageType = b.messageTypes[data.type]
|
||||
}
|
||||
|
|
38
settings_example.js
Normal file
38
settings_example.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
export default {
|
||||
terminalMode: 'blackTerminal_24bit', // Terminal mode. Most modern terminals support 24-bit color
|
||||
version_mc: '1.21.1', // Minecraft version to connect with
|
||||
defaultLang: 'en-US', // Default language
|
||||
keyTrusted: '3e9f13473eec8d64c3eabf6385e3f8585f0af39ed30a8db9a4c8d8bcfa35659d7d06a58b342bfd2db5e3cbb4003a81da8f9d25f7cce1ad26face8e2871c3b217', // Trusted key
|
||||
keyOwner: '17d2c6c53b8919dc1ec22c42845018ac389824c4d73a68572b7fc57ff1442c6bbf9924d5ee5fa90cb23e384278d469c4e260208265b8ba2e2bc873045d5ed42e', // Owner key
|
||||
colors: { // All colors the bot uses
|
||||
primary: '#EECCFF', // Used for primary subjects (e.g. items in lists)
|
||||
secondary: '#DD99FF', // Used for secondary subjects (e.g. list labels)
|
||||
tertiary: 'white', // Used mostly for messages
|
||||
warning: '#FFAA33', // Used for warnings that are sent to Minecraft chat
|
||||
error: '#FF6688', // Used for errors that are sent to Minecraft chat
|
||||
fatalError: '#BB3344' // Used in errorh for crashes
|
||||
},
|
||||
prefixes: [ // A list of prefixes the bot will respond to in-game
|
||||
'ubotesm:',
|
||||
'ubotdev:',
|
||||
'es"',
|
||||
'd"'
|
||||
],
|
||||
servers: [ // Server list
|
||||
{
|
||||
host: 'kaboom.pw', // Server address
|
||||
port: 25565, // Server port. The default is 25565.
|
||||
options: {
|
||||
name: 'kaboom' // Server name in netmsg
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
host: 'chipmunk.land',
|
||||
port: 25565,
|
||||
options: {
|
||||
name: 'chipmunk'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"version_mc": "1.20.4",
|
||||
"terminalMode": "blackTerminal_24bit",
|
||||
"colors": {
|
||||
"primary": "#ffccee",
|
||||
"secondary": "#ff99dd"
|
||||
},
|
||||
"prefixes": [
|
||||
"d\"",
|
||||
"ubotdev:",
|
||||
"owobotdev:"
|
||||
],
|
||||
"servers": [
|
||||
{
|
||||
"host": "kaboom.pw",
|
||||
"port": 25565,
|
||||
"options": {
|
||||
"name": "kaboom"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
"host": "chipmunk.land",
|
||||
"port": 25565,
|
||||
"options": {
|
||||
"name": "chipmunk"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,22 +1,28 @@
|
|||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import settings from '../settings.js'
|
||||
export default class Command {
|
||||
constructor (uuid, user, nick, cmd, senderType, msgType, msgSubtype, prefix, bot, verify) {
|
||||
this.uuid=uuid;
|
||||
this.reply = text => bot.tellraw(uuid, text)
|
||||
this.username = user;
|
||||
this.nickname = nick;
|
||||
this.command = cmd;
|
||||
this.type = senderType;
|
||||
this.msgType = msgType;
|
||||
this.msgSubtype = msgSubtype;
|
||||
this.args = cmd.split(' ').slice(1)
|
||||
this.cmdName = cmd.split(' ')[0]
|
||||
this.prefix = prefix
|
||||
this.colors = settings.colors
|
||||
this.lang = settings.defaultLang
|
||||
this.verify = verify
|
||||
this.host = bot.host.host
|
||||
this.port = bot.host.port
|
||||
this.bot = bot
|
||||
constructor (uuid, user, nick, cmd, senderType, msgType, msgSubtype, prefix, bot) {
|
||||
this.uuid = uuid
|
||||
this.reply = text => bot.tellraw(uuid, text)
|
||||
this.username = user
|
||||
this.nickname = nick
|
||||
this.command = cmd
|
||||
this.type = senderType
|
||||
this.msgType = msgType
|
||||
this.msgSubtype = msgSubtype
|
||||
this.args = cmd.split(' ').slice(1)
|
||||
this.cmdName = cmd.split(' ')[0]
|
||||
this.prefix = prefix
|
||||
this.colors = settings.colors
|
||||
this.lang = settings.defaultLang
|
||||
this.verify = 0
|
||||
this.host = bot.host.host
|
||||
this.port = bot.host.port
|
||||
this.bot = bot
|
||||
|
||||
this.rewriteCommand = newCmd => {
|
||||
this.command = newCmd
|
||||
this.args = newCmd.split(' ').slice(1)
|
||||
this.cmdName = newCmd.split(' ')[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { appendFileSync } from 'node:fs'
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import settings from '../settings.js'
|
||||
|
||||
export default function chatlog (fileName, item) {
|
||||
if (settings.disableLogging) return
|
||||
|
|
|
@ -1,6 +1,188 @@
|
|||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
import settings from '../settings.js'
|
||||
import lang from './mc_lang.js'
|
||||
import { default as _consoleColors } from './consolecolors.json' with {type: "json"}
|
||||
|
||||
const _consoleColors = {
|
||||
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;124m',
|
||||
red: '\u001B[0;38;5;203m',
|
||||
dark_green: '\u001B[0;38;5;34m',
|
||||
green: '\u001B[0;38;5;83m',
|
||||
gold: '\u001B[0;38;5;214m',
|
||||
yellow: '\u001B[0;38;5;227m',
|
||||
dark_blue: '\u001B[0;38;5;19m',
|
||||
blue: '\u001B[0;38;5;63m',
|
||||
dark_purple: '\u001B[0;38;5;127m',
|
||||
light_purple: '\u001B[0;38;5;207m',
|
||||
dark_aqua: '\u001B[0;38;5;37m',
|
||||
aqua: '\u001B[0;38;5;87m',
|
||||
black: '\u001B[0;48;5;253;38;5;16m',
|
||||
gray: '\u001B[0;38;5;145m',
|
||||
dark_gray: '\u001B[0;38;5;59m',
|
||||
white: '\u001B[0;38;5;231m',
|
||||
reset: '\u001B[0;38;5;231m'
|
||||
},
|
||||
twentyFourBit: {
|
||||
enabled: true,
|
||||
bit: 8,
|
||||
lightMode: false
|
||||
}
|
||||
},
|
||||
whiteTerminal_8bit: {
|
||||
fourBit: {
|
||||
dark_red: '\u001B[0;38;5;124m',
|
||||
red: '\u001B[0;38;5;203m',
|
||||
dark_green: '\u001B[0;38;5;34m',
|
||||
green: '\u001B[0;48;5;16;38;5;83m',
|
||||
gold: '\u001B[0;38;5;214m',
|
||||
yellow: '\u001B[0;48;5;16;38;5;227m',
|
||||
dark_blue: '\u001B[0;38;5;19m',
|
||||
blue: '\u001B[0;38;5;63m',
|
||||
dark_purple: '\u001B[0;38;5;127m',
|
||||
light_purple: '\u001B[0;38;5;207m',
|
||||
dark_aqua: '\u001B[0;38;5;37m',
|
||||
aqua: '\u001B[0;48;5;16;38;5;87m',
|
||||
black: '\u001B[0;38;5;16m',
|
||||
gray: '\u001B[0;38;5;145m',
|
||||
dark_gray: '\u001B[0;38;5;59m',
|
||||
white: '\u001B[0;48;5;16;38;5;231m',
|
||||
reset: '\u001B[0;48;5;16;38;5;231m'
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let consoleColors
|
||||
let consoleColors24
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const cmds = Object.create(null)
|
||||
import { readdirSync } from 'node:fs'
|
||||
|
||||
import { readdirSync } from "node:fs"
|
||||
const cmds = Object.create(null)
|
||||
const bpl = readdirSync('commands')
|
||||
|
||||
for (const plugin of bpl) {
|
||||
|
@ -9,20 +9,20 @@ for (const plugin of bpl) {
|
|||
}
|
||||
try {
|
||||
const commandName = plugin.split('.js')[0]
|
||||
import(`../commands/${plugin}`).then((pluginItem)=>{
|
||||
cmds[commandName] = pluginItem // For rejoining
|
||||
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
|
||||
}
|
||||
import(`../commands/${plugin}`).then((pluginItem) => {
|
||||
cmds[commandName] = pluginItem // For rejoining
|
||||
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) }
|
||||
}
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
{
|
||||
"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;124m",
|
||||
"red": "\u001B[0;38;5;203m",
|
||||
"dark_green": "\u001B[0;38;5;34m",
|
||||
"green": "\u001B[0;38;5;83m",
|
||||
"gold": "\u001B[0;38;5;214m",
|
||||
"yellow": "\u001B[0;38;5;227m",
|
||||
"dark_blue": "\u001B[0;38;5;19m",
|
||||
"blue": "\u001B[0;38;5;63m",
|
||||
"dark_purple": "\u001B[0;38;5;127m",
|
||||
"light_purple": "\u001B[0;38;5;207m",
|
||||
"dark_aqua": "\u001B[0;38;5;37m",
|
||||
"aqua": "\u001B[0;38;5;87m",
|
||||
"black": "\u001B[0;48;5;253;38;5;16m",
|
||||
"gray": "\u001B[0;38;5;145m",
|
||||
"dark_gray": "\u001B[0;38;5;59m",
|
||||
"white": "\u001B[0;38;5;231m",
|
||||
"reset": "\u001B[0;38;5;231m"
|
||||
},
|
||||
"twentyFourBit":{
|
||||
"enabled": true,
|
||||
"bit": 8,
|
||||
"lightMode": false
|
||||
}
|
||||
},
|
||||
"whiteTerminal_8bit":{
|
||||
"fourBit":{
|
||||
"dark_red": "\u001B[0;38;5;124m",
|
||||
"red": "\u001B[0;38;5;203m",
|
||||
"dark_green": "\u001B[0;38;5;34m",
|
||||
"green": "\u001B[0;48;5;16;38;5;83m",
|
||||
"gold": "\u001B[0;38;5;214m",
|
||||
"yellow": "\u001B[0;48;5;16;38;5;227m",
|
||||
"dark_blue": "\u001B[0;38;5;19m",
|
||||
"blue": "\u001B[0;38;5;63m",
|
||||
"dark_purple": "\u001B[0;38;5;127m",
|
||||
"light_purple": "\u001B[0;38;5;207m",
|
||||
"dark_aqua": "\u001B[0;38;5;37m",
|
||||
"aqua": "\u001B[0;48;5;16;38;5;87m",
|
||||
"black": "\u001B[0;38;5;16m",
|
||||
"gray": "\u001B[0;38;5;145m",
|
||||
"dark_gray": "\u001B[0;38;5;59m",
|
||||
"white": "\u001B[0;48;5;16;38;5;231m",
|
||||
"reset": "\u001B[0;48;5;16;38;5;231m"
|
||||
},
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
19
util/hashcheck.js
Executable file
19
util/hashcheck.js
Executable file
|
@ -0,0 +1,19 @@
|
|||
import { createHash } from 'node:crypto'
|
||||
import settings from '../settings.js'
|
||||
|
||||
export default function (cmd, uuid) {
|
||||
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:${settings.keyTrusted}:${uuid}:${cmdWithoutHash}:${dateString}`
|
||||
const hashOwner = `babyboom:${settings.keyOwner}:${uuid}:${cmdWithoutHash}:${dateString}`
|
||||
const validhashT = createHash('sha256').update(hashTrusted).digest('hex')
|
||||
const validhashO = createHash('sha256').update(hashOwner).digest('hex')
|
||||
if (cmd[cmd.length - 1] === validhashT) {
|
||||
return 1
|
||||
}
|
||||
if (cmd[cmd.length - 1] === validhashO) {
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
14
util/lang.js
14
util/lang.js
|
@ -1,16 +1,16 @@
|
|||
import { readdirSync } from "node:fs"
|
||||
import { readdirSync } from 'node:fs'
|
||||
import settings from '../settings.js'
|
||||
const languages = {}
|
||||
import { default as settings } from '../settings.json' with {type: "json"}
|
||||
const fallbackLocale = settings.fallbackLocale ? settings.fallbackLocale : 'en-US'
|
||||
|
||||
const loadplug = () => {
|
||||
const bpl = readdirSync('lang')
|
||||
for (const plugin of bpl) {
|
||||
if (!plugin.endsWith('.json')) {
|
||||
if (!plugin.endsWith('.js')) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
import(`../lang/${plugin}`, {with: {type: "json"}}).then(languageFile => {
|
||||
import(`../lang/${plugin}`).then(languageFile => {
|
||||
languages[plugin.split('.')[0]] = languageFile.default
|
||||
})
|
||||
} catch (e) { console.log(e) }
|
||||
|
@ -34,7 +34,7 @@ const getMessage = function (l, msg, with2) {
|
|||
return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||
}
|
||||
|
||||
const languages_keys = Object.keys(languages)
|
||||
const languagesKeys = Object.keys(languages)
|
||||
const formatTime = function (time, language) {
|
||||
let finalString = ''
|
||||
const seconds = Math.floor(time / 1000) % 60
|
||||
|
@ -66,7 +66,7 @@ const formatTime = function (time, language) {
|
|||
}
|
||||
|
||||
export {
|
||||
languages_keys as languages,
|
||||
languagesKeys as languages,
|
||||
formatTime,
|
||||
getMessage
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
export default function memoryconvert (bytes) {
|
||||
if (bytes >= 1125899906842624) { // Petabytes
|
||||
return `${Math.round(bytes / 1125899906842624 * 100) / 100} PB`
|
||||
} else if (bytes >= 1099511627776) { // Terabytes
|
||||
return `${Math.round(bytes / 1099511627776 * 100) / 100} TB`
|
||||
} else if (bytes >= 1073741824) { // Gigabytes
|
||||
return `${Math.round(bytes / 1073741824 * 100) / 100} GB`
|
||||
} else if (bytes >= 1048576) { // Megabytes
|
||||
return `${Math.round(bytes / 1048576 * 100) / 100} MB`
|
||||
} else if (bytes >= 1024) { // Kilobytes
|
||||
return `${Math.round(bytes / 1024 * 100) / 100} KB`
|
||||
} else { // Bytes
|
||||
return `${bytes} B`
|
||||
}
|
||||
if (bytes >= 1125899906842624) { // Petabytes
|
||||
return `${Math.round(bytes / 1125899906842624 * 100) / 100} PB`
|
||||
} else if (bytes >= 1099511627776) { // Terabytes
|
||||
return `${Math.round(bytes / 1099511627776 * 100) / 100} TB`
|
||||
} else if (bytes >= 1073741824) { // Gigabytes
|
||||
return `${Math.round(bytes / 1073741824 * 100) / 100} GB`
|
||||
} else if (bytes >= 1048576) { // Megabytes
|
||||
return `${Math.round(bytes / 1048576 * 100) / 100} MB`
|
||||
} else if (bytes >= 1024) { // Kilobytes
|
||||
return `${Math.round(bytes / 1024 * 100) / 100} KB`
|
||||
} else { // Bytes
|
||||
return `${bytes} B`
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { randomBytes } from "crypto";
|
||||
import { randomBytes } from 'crypto'
|
||||
const rsg = function (count) {
|
||||
let output = ''
|
||||
for (let i = 0; i < count; i++) {
|
||||
|
@ -44,4 +44,4 @@ export default function generateUser (legal) {
|
|||
} else {
|
||||
return rsg(6 + Math.floor(Math.random() * 3))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@ export default function uuidToInt (uuid) {
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { default as version } from "../version.json" with { type: "json" }
|
||||
import { execSync } from "child_process"
|
||||
import version from '../version.js'
|
||||
import { execSync } from 'child_process'
|
||||
let botVersion = version.botVersion
|
||||
let gitCommit
|
||||
let gitBranch
|
||||
|
|
7
version.js
Normal file
7
version.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
export default {
|
||||
botName: 'botv12 Dev', // Name of the bot
|
||||
botVersion: '12.0.0-alpha.2', // Version of the bot. This is different from the one in package.json, which has to be updated seperately.
|
||||
botAuthor: 'owo439895035', // The creator of the bot
|
||||
isPreRelease: true, // If this version is a pre-release version. Used by the about command to show a warning if set to true.
|
||||
sourceURL: 'https://code.chipmunk.land/7cc5c4f330d47060/botv12' // Source code repository URL. This is different from the one in package.json.
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"botName": "botv12 Dev",
|
||||
"botVersion": "12.0.0-alpha.1",
|
||||
"botAuthor": "owo439895035",
|
||||
"isPreRelease": true,
|
||||
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botv12"
|
||||
}
|
Loading…
Add table
Reference in a new issue