Compare commits
6 commits
10.0.0-bet
...
10_0_0-bet
Author | SHA1 | Date | |
---|---|---|---|
8d23595a2a | |||
7606f0d2a5 | |||
a276f2db6e | |||
314e9c3f9c | |||
7042401873 | |||
ed7eef49ec |
8 changed files with 52 additions and 48 deletions
|
@ -9,6 +9,10 @@ botvX is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones. It has
|
|||
- a command core, to run commands quickly
|
||||
- a hashing system, to enable trusted users to securely run certain commands in chat
|
||||
|
||||
If you are not sure if this code is safe to run, you can read through every line of code. You can also see the commit history by clicking on the (n) commits button, to make sure nobody added any exploits to the code.
|
||||
|
||||
If you find any exploits, security issues, etc in the code, please send me an issue or pull request and I will try to respond to it whenever I see it.
|
||||
|
||||
## 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.
|
||||
|
|
|
@ -61,7 +61,7 @@ const os2 = function (o2, l) {
|
|||
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')
|
||||
return getMessage(l, 'command.about.serverInfo.os.android.noVersion')
|
||||
}
|
||||
}
|
||||
case 'linux':
|
||||
|
|
|
@ -2,9 +2,9 @@ const { bot } = require('../index.js')
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
if(c.bot.host && c.bot.host.options.netmsgDisabled){
|
||||
if (c.bot.host && c.bot.host.options.netmsgDisabled) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, "command.netmsg.disabled"),
|
||||
text: getMessage(c.lang, 'command.netmsg.disabled'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
|
@ -37,7 +37,7 @@ module.exports = {
|
|||
color: 'white'
|
||||
}
|
||||
for (const i in bot) {
|
||||
if(bot[i].host.options.netmsgDisabled) continue
|
||||
if (bot[i].host.options.netmsgDisabled) continue
|
||||
bot[i].tellraw('@a', json)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,38 +4,38 @@ module.exports = {
|
|||
execute: (c) => {
|
||||
const subcmd = c.args.splice(0, 1)[0]
|
||||
switch (subcmd) {
|
||||
case 'set':
|
||||
const allowedKeys = ["colorPrimary", "colorSecondary", "lang"]
|
||||
case 'set':{
|
||||
const allowedKeys = ['colorPrimary', 'colorSecondary', 'lang']
|
||||
const key = c.args.splice(0, 1)[0]
|
||||
if(!allowedKeys.includes(key)){
|
||||
if (!allowedKeys.includes(key)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidKey'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
const value = c.args.join(" ")
|
||||
if(value === "" && key==="lang"){
|
||||
const value = c.args.join(' ')
|
||||
if (value === '' && key === 'lang') {
|
||||
// Show all valid languages to user
|
||||
for(const i in languages){
|
||||
for (const i in languages) {
|
||||
c.reply({
|
||||
translate: "%s (%s)",
|
||||
translate: '%s (%s)',
|
||||
color: c.colors.secondary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(languages[i], 'language.name'),
|
||||
color: c.colors.primary
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: getMessage(languages[i], 'language.region'),
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
hoverEvent:{
|
||||
action: "show_text",
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
translate: getMessage(languages[i], 'command.settings.setLanguage'),
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}settings set lang ${languages[i]}`,
|
||||
color: c.colors.secondary
|
||||
|
@ -47,19 +47,19 @@ module.exports = {
|
|||
}
|
||||
return
|
||||
}
|
||||
if(value === ""){
|
||||
if (value === '') {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.mustProvideValue'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
if(key==="lang" && !languages.includes(value)){
|
||||
if (key === 'lang' && !languages.includes(value)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidLanguage'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
c.prefs[key] = value
|
||||
|
||||
|
@ -67,19 +67,20 @@ module.exports = {
|
|||
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]
|
||||
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':{
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'get':
|
||||
c.reply({
|
||||
translate: "%s: %s",
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
|
||||
color: c.colors.secondary
|
||||
|
@ -91,9 +92,9 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s",
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
|
||||
color: c.colors.secondary
|
||||
|
@ -105,9 +106,9 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s (%s)",
|
||||
translate: '%s: %s (%s)',
|
||||
color: c.colors.primary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.language'),
|
||||
color: c.colors.secondary
|
||||
|
@ -123,7 +124,6 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
|
|
|
@ -3,11 +3,11 @@ const hashcheck = require('../util/hashcheck.js')
|
|||
const settings = require('../settings.json')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
const cmds = require('../util/commands.js')
|
||||
const fs = require("fs")
|
||||
const fs = require('fs')
|
||||
|
||||
if(!fs.readdirSync('.').includes('userPref')) fs.mkdirSync("userPref");
|
||||
if (!fs.readdirSync('.').includes('userPref')) fs.mkdirSync('userPref')
|
||||
|
||||
const loadSettings = function(uuid){
|
||||
const loadSettings = function (uuid) {
|
||||
try {
|
||||
return require(`../userPref/${uuid}.json`)
|
||||
} catch (e) {
|
||||
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
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);
|
||||
const userSettings = loadSettings(uuid)
|
||||
b.lastCmd = Date.now()
|
||||
const cmd = text.split(' ')
|
||||
const lang = settings.defaultLang
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
b.advanceccq = function () {
|
||||
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
||||
b._client.write('update_command_block', {
|
||||
command: b.ccq[0],
|
||||
command: "/",
|
||||
location: {
|
||||
x: b.commandPos.x + b.blocknoX,
|
||||
y: b.commandPos.y + b.blocknoY,
|
||||
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
flags: 1
|
||||
})
|
||||
b._client.write('update_command_block', {
|
||||
command: b.ccq[0],
|
||||
command: b.ccq[0].substr(0,32767),
|
||||
location: {
|
||||
x: b.commandPos.x + b.blocknoX,
|
||||
y: b.commandPos.y + b.blocknoY,
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
b.sc_tasks = {}
|
||||
b.selfcareRun = 0
|
||||
b.interval.sc = setInterval(() => {
|
||||
if(Date.now() - b.selfcareRun <= 600){
|
||||
if (Date.now() - b.selfcareRun <= 600) {
|
||||
return
|
||||
}
|
||||
for (const i in b.sc_tasks) {
|
||||
|
|
|
@ -18,19 +18,19 @@ class Command {
|
|||
this.port = bot.host.port
|
||||
// this.lang = lang
|
||||
this.prefs = prefs
|
||||
if(prefs.lang){
|
||||
if (prefs.lang) {
|
||||
this.lang = prefs.lang
|
||||
} else {
|
||||
this.lang = settings.defaultLang
|
||||
}
|
||||
|
||||
let _colors = {}
|
||||
if(prefs.colorPrimary){
|
||||
|
||||
const _colors = {}
|
||||
if (prefs.colorPrimary) {
|
||||
_colors.primary = prefs.colorPrimary
|
||||
} else {
|
||||
_colors.primary = settings.colors.primary
|
||||
}
|
||||
if(prefs.colorSecondary){
|
||||
if (prefs.colorSecondary) {
|
||||
_colors.secondary = prefs.colorSecondary
|
||||
} else {
|
||||
_colors.secondary = settings.colors.secondary
|
||||
|
|
Loading…
Reference in a new issue