Compare commits
27 commits
06b1e28490
...
b950a12be3
Author | SHA1 | Date | |
---|---|---|---|
b950a12be3 | |||
3e31b2f4f3 | |||
|
f5b85902b6 | ||
|
ae073d4177 | ||
|
77e260c128 | ||
|
5e15d32ccd | ||
|
d1993a6bc1 | ||
|
df5e56ffe0 | ||
|
ed53c4ac38 | ||
|
9dec12f1bb | ||
|
7d89c2e2b3 | ||
|
7442900bcb | ||
|
157bfc890f | ||
|
fa1b9820bc | ||
|
13a905e08c | ||
|
0976f6d4b2 | ||
|
f7b21b41f4 | ||
|
25173b5689 | ||
|
5b90ad7954 | ||
|
1d57af5993 | ||
|
183c388f00 | ||
|
b30a0a21b9 | ||
|
f8ee6905c2 | ||
|
73f0a9d262 | ||
|
6eca4f3c64 | ||
|
0b1f3634c4 | ||
|
00966b2913 |
30 changed files with 440 additions and 708 deletions
|
@ -2,13 +2,17 @@
|
||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
|
|
||||||
botvX is a Minecraft bot originally designed for [Kaboom](https://kaboom.pw/) and its clones. It has many of the features that you would expect in a modern Kaboom bot:
|
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)
|
- commands (obviously)
|
||||||
- a self care system
|
- a self care system
|
||||||
- a command core, to run commands quickly
|
- a command core, to run commands quickly
|
||||||
- a hashing system, to enable trusted users to securely run certain commands in chat
|
- 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?
|
## How to install?
|
||||||
|
|
||||||
1. Install [Node.js](https://nodejs.org/) for your operating system.
|
1. Install [Node.js](https://nodejs.org/) for your operating system.
|
||||||
|
|
|
@ -4,7 +4,6 @@ const { getMessage, formatTime } = require('../util/lang.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const botVersion = require('../util/version.js')
|
const botVersion = require('../util/version.js')
|
||||||
const version = require('../version.json')
|
const version = require('../version.json')
|
||||||
const index = require('../index.js')
|
|
||||||
|
|
||||||
const aboutBot = function (c) {
|
const aboutBot = function (c) {
|
||||||
c.reply({
|
c.reply({
|
||||||
|
@ -56,13 +55,13 @@ const aboutBot = function (c) {
|
||||||
const os2 = function (o2, l) {
|
const os2 = function (o2, l) {
|
||||||
switch (o2) {
|
switch (o2) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return `${os.version()}`
|
return `${os.version()} (${os.release})`
|
||||||
case 'android':{
|
case 'android':{
|
||||||
try {
|
try {
|
||||||
const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
|
const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
|
||||||
return getMessage(l, 'command.about.serverInfo.os.android', [version])
|
return getMessage(l, 'command.about.serverInfo.os.android', [version])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return getMessage(l, 'command.about.serverInfo.os.android.noVersion')
|
getMessage(l, 'command.about.serverInfo.os.android.noVersion')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
@ -70,20 +69,20 @@ const os2 = function (o2, l) {
|
||||||
if (fs.readdirSync('/etc').includes('os-release')) {
|
if (fs.readdirSync('/etc').includes('os-release')) {
|
||||||
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
|
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
|
||||||
const osrelease2 = {}
|
const osrelease2 = {}
|
||||||
for (const item of osrelease) {
|
for (const i in osrelease) {
|
||||||
if (!item.includes('=')) continue
|
if (!osrelease[i].includes('=')) continue
|
||||||
let osrvalue = item.split('=')[1]
|
let osrvalue = osrelease[i].split('=')[1]
|
||||||
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
|
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
|
||||||
osrelease2[item.split('=')[0]] = osrvalue
|
osrelease2[osrelease[i].split('=')[0]] = osrvalue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osrelease2.PRETTY_NAME) {
|
if (osrelease2.PRETTY_NAME) {
|
||||||
return getMessage(l, '%s', [osrelease2.PRETTY_NAME])
|
return getMessage(l, '%s %s', [osrelease2.PRETTY_NAME, os.release()])
|
||||||
} else {
|
} else {
|
||||||
return getMessage(l, `command.about.serverInfo.os.${o2}`)
|
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return getMessage(l, `command.about.serverInfo.os.${o2}`)
|
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -121,11 +120,6 @@ const aboutServer = function (c) {
|
||||||
return os2(process.platform, c.lang)
|
return os2(process.platform, c.lang)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Kernel version: os.release()
|
|
||||||
displayInfo('command.about.serverInfo.kernelVer', () => {
|
|
||||||
return os.release()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Processor
|
// Processor
|
||||||
if (os.cpus()[0]) {
|
if (os.cpus()[0]) {
|
||||||
displayInfo('command.about.serverInfo.processor', () => {
|
displayInfo('command.about.serverInfo.processor', () => {
|
||||||
|
@ -184,33 +178,10 @@ const aboutServer = function (c) {
|
||||||
return botVersion
|
return botVersion
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const displayServerList = function (c) {
|
|
||||||
index.bot.forEach((item, i)=>{
|
|
||||||
if (item.host.options && item.host.options.hidden) return
|
|
||||||
c.reply({
|
|
||||||
translate: getMessage(c.lang, 'command.about.serverListItem'),
|
|
||||||
color: c.colors.secondary,
|
|
||||||
with: [
|
|
||||||
{
|
|
||||||
text: i.toString(),
|
|
||||||
color: c.colors.primary
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: `${item.host.host}:${item.host.port}`,
|
|
||||||
color: c.colors.primary
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
execute: function (c) {
|
execute: function (c) {
|
||||||
if (c.args[0] === 'server') {
|
if (c.args[0] === 'server') {
|
||||||
aboutServer(c)
|
aboutServer(c)
|
||||||
} else if (c.args[0] === 'serverlist') {
|
|
||||||
displayServerList(c)
|
|
||||||
} else {
|
} else {
|
||||||
aboutBot(c)
|
aboutBot(c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,26 +44,26 @@ module.exports = {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'list':
|
case 'list':
|
||||||
c.bot.cloops.forEach((item, i)=>{
|
for (const i in c.bot.cloops) {
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: getMessage(c.lang, 'command.cloop.list'),
|
translate: getMessage(c.lang, 'command.cloop.list'),
|
||||||
color: c.colors.secondary,
|
color: c.colors.secondary,
|
||||||
with: [
|
with: [
|
||||||
{
|
{
|
||||||
text: i.toString(),
|
text: i,
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: item.command,
|
text: c.bot.cloops[i].command,
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: item.rate + '',
|
text: c.bot.cloops[i].rate + '',
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
break
|
break
|
||||||
case 'clear':
|
case 'clear':
|
||||||
c.bot.clearCloops()
|
c.bot.clearCloops()
|
||||||
|
|
|
@ -9,14 +9,14 @@ const sortHelp = function sortHelp (c1, c2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bpl = fs.readdirSync('./commands')
|
const bpl = fs.readdirSync('./commands')
|
||||||
for (const plugin of bpl) {
|
for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require
|
||||||
if (!plugin.endsWith('.js')) {
|
if (!bpl[i].endsWith('.js')) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const commandName = plugin.split('.js')[0]
|
const commandName = bpl[i].split('.js')[0]
|
||||||
if (commandName !== 'help') {
|
if (commandName !== 'help') {
|
||||||
cmds[commandName] = require(`./${plugin}`)
|
cmds[commandName] = require(`./${bpl[i]}`)
|
||||||
if (cmds[commandName].level === undefined) {
|
if (cmds[commandName].level === undefined) {
|
||||||
cmds[commandName].level = 0
|
cmds[commandName].level = 0
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ const printCmdHelp = (c) => {
|
||||||
desc = cmds[cmds[cmd].alias].desc
|
desc = cmds[cmds[cmd].alias].desc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const item of usage) {
|
for (const i in usage) {
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: getMessage(c.lang, 'command.help.commandUsage'),
|
translate: getMessage(c.lang, 'command.help.commandUsage'),
|
||||||
color: c.colors.secondary,
|
color: c.colors.secondary,
|
||||||
|
@ -99,7 +99,7 @@ const printCmdHelp = (c) => {
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: item,
|
text: usage[i],
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -152,8 +152,8 @@ if (cmds.help.level === undefined) {
|
||||||
|
|
||||||
for (const i in cmds) {
|
for (const i in cmds) {
|
||||||
if (cmds[i].aliases) {
|
if (cmds[i].aliases) {
|
||||||
for (const alias of cmds[commandName].aliases) {
|
for (const j in cmds[i].aliases) {
|
||||||
cmds[alias] = {
|
cmds[cmds[i].aliases[j]] = {
|
||||||
alias: i,
|
alias: i,
|
||||||
usage: cmds[i].usage,
|
usage: cmds[i].usage,
|
||||||
level: cmds[i].level,
|
level: cmds[i].level,
|
||||||
|
|
|
@ -2,9 +2,9 @@ const { bot } = require('../index.js')
|
||||||
const { getMessage } = require('../util/lang.js')
|
const { getMessage } = require('../util/lang.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
execute: (c) => {
|
execute: (c) => {
|
||||||
if (c.bot.host && c.bot.host.options.hidden) {
|
if(c.bot.host && c.bot.host.options.netmsgDisabled){
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.netmsg.disabled'),
|
text: getMessage(c.lang, "command.netmsg.disabled"),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
@ -36,9 +36,9 @@ module.exports = {
|
||||||
],
|
],
|
||||||
color: 'white'
|
color: 'white'
|
||||||
}
|
}
|
||||||
bot.forEach(item => {
|
for (const i in bot) {
|
||||||
if (item.host.options.hidden) return
|
if(bot[i].host.options.netmsgDisabled) continue
|
||||||
item.tellraw('@a', json)
|
bot[i].tellraw('@a', json)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,40 +4,40 @@ module.exports = {
|
||||||
execute: (c) => {
|
execute: (c) => {
|
||||||
const subcmd = c.args.splice(0, 1)[0]
|
const subcmd = c.args.splice(0, 1)[0]
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case 'set':{
|
case 'set':
|
||||||
const allowedKeys = ['colorPrimary', 'colorSecondary', 'lang']
|
const allowedKeys = ["colorPrimary", "colorSecondary", "lang"]
|
||||||
const key = c.args.splice(0, 1)[0]
|
const key = c.args.splice(0, 1)[0]
|
||||||
if (!allowedKeys.includes(key)) {
|
if(!allowedKeys.includes(key)){
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.settings.error.invalidKey'),
|
text: getMessage(c.lang, 'command.settings.error.invalidKey'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const value = c.args.join(' ')
|
const value = c.args.join(" ")
|
||||||
if (value === '' && key === 'lang') {
|
if(value === "" && key==="lang"){
|
||||||
// Show all valid languages to user
|
// Show all valid languages to user
|
||||||
for (const item of languages) {
|
for(const i in languages){
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: '%s (%s)',
|
translate: "%s (%s)",
|
||||||
color: c.colors.secondary,
|
color: c.colors.secondary,
|
||||||
with: [
|
with:[
|
||||||
{
|
{
|
||||||
text: getMessage(item, 'language.name'),
|
text: getMessage(languages[i], 'language.name'),
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: getMessage(item, 'language.region'),
|
text: getMessage(languages[i], 'language.region'),
|
||||||
color: c.colors.primary
|
color: c.colors.primary
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
hoverEvent: {
|
hoverEvent:{
|
||||||
action: 'show_text',
|
action: "show_text",
|
||||||
value: {
|
value: {
|
||||||
translate: getMessage(item, 'command.settings.setLanguage'),
|
translate: getMessage(languages[i], 'command.settings.setLanguage'),
|
||||||
with: [
|
with:[
|
||||||
{
|
{
|
||||||
text: `${c.prefix}settings set lang ${item}`,
|
text: `${c.prefix}settings set lang ${languages[i]}`,
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -47,19 +47,19 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (value === '') {
|
if(value === ""){
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.settings.error.mustProvideValue'),
|
text: getMessage(c.lang, 'command.settings.error.mustProvideValue'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (key === 'lang' && !languages.includes(value)) {
|
if(key==="lang" && !languages.includes(value)){
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.settings.error.invalidLanguage'),
|
text: getMessage(c.lang, 'command.settings.error.invalidLanguage'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
c.prefs[key] = value
|
c.prefs[key] = value
|
||||||
|
|
||||||
|
@ -67,20 +67,19 @@ module.exports = {
|
||||||
fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs))
|
fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs))
|
||||||
|
|
||||||
// Delete require cache
|
// Delete require cache
|
||||||
for (const i in require.cache) {
|
for(const i in require.cache){
|
||||||
if (i.endsWith(`${c.uuid}.json`)) delete require.cache[i]
|
if(i.endsWith(`${c.uuid}.json`)) delete require.cache[i]
|
||||||
}
|
}
|
||||||
c.reply({
|
c.reply({
|
||||||
text: getMessage(c.lang, 'command.settings.saved'),
|
text: getMessage(c.lang, 'command.settings.saved'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
})
|
});
|
||||||
break
|
break;
|
||||||
}
|
case 'get':{
|
||||||
case 'get':
|
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: '%s: %s',
|
translate: "%s: %s",
|
||||||
color: c.colors.primary,
|
color: c.colors.secondary,
|
||||||
with: [
|
with:[
|
||||||
{
|
{
|
||||||
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
|
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
|
@ -92,9 +91,9 @@ module.exports = {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: '%s: %s',
|
translate: "%s: %s",
|
||||||
color: c.colors.primary,
|
color: c.colors.secondary,
|
||||||
with: [
|
with:[
|
||||||
{
|
{
|
||||||
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
|
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
|
||||||
color: c.colors.secondary
|
color: c.colors.secondary
|
||||||
|
@ -106,12 +105,12 @@ module.exports = {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: '%s: %s (%s)',
|
translate: "%s: %s (%s)",
|
||||||
color: c.colors.primary,
|
color: c.colors.secondary,
|
||||||
with: [
|
with:[
|
||||||
{
|
{
|
||||||
text: getMessage(c.lang, 'command.settings.get.language'),
|
text: getMessage(c.lang, 'command.settings.get.language'),
|
||||||
color: c.colors.secondary
|
color: c.colors.primary
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: getMessage(c.lang, 'language.name'),
|
text: getMessage(c.lang, 'language.name'),
|
||||||
|
@ -124,6 +123,7 @@ module.exports = {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
c.reply({
|
c.reply({
|
||||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||||
|
|
25
index.js
25
index.js
|
@ -6,18 +6,17 @@ const fs = require('fs')
|
||||||
|
|
||||||
module.exports.bot = []
|
module.exports.bot = []
|
||||||
|
|
||||||
const botplug = []
|
|
||||||
const bpl = fs.readdirSync('plugins')
|
|
||||||
for (const plugin of bpl) {
|
|
||||||
if (!plugin.endsWith('.js')) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
botplug.push(require(`./plugins/${plugin}`))
|
|
||||||
} catch (e) { console.log(e) }
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadplug = (botno) => {
|
const loadplug = (botno) => {
|
||||||
|
const botplug = []
|
||||||
|
const bpl = fs.readdirSync('plugins')
|
||||||
|
for (const i in bpl) {
|
||||||
|
if (!bpl[i].endsWith('.js')) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
botplug.push(require(`./plugins/${bpl[i]}`))
|
||||||
|
} catch (e) { console.log(e) }
|
||||||
|
}
|
||||||
botplug.forEach((plug) => {
|
botplug.forEach((plug) => {
|
||||||
try {
|
try {
|
||||||
if (plug.load) {
|
if (plug.load) {
|
||||||
|
@ -67,8 +66,8 @@ const createBot = function createBot (host, oldId) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const server of settings.servers) {
|
for (const i in settings.servers) {
|
||||||
createBot(server)
|
createBot(settings.servers[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.createBot = createBot
|
module.exports.createBot = createBot
|
||||||
|
|
38
package-lock.json
generated
38
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "botv10",
|
"name": "botv10",
|
||||||
"version": "10.0.0",
|
"version": "10.0.0-beta-2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "botv10",
|
"name": "botv10",
|
||||||
"version": "10.0.0",
|
"version": "10.0.0-beta-2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minecraft-protocol": "^1.45.0",
|
"minecraft-protocol": "^1.45.0",
|
||||||
|
@ -14,21 +14,21 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@azure/msal-common": {
|
"node_modules/@azure/msal-common": {
|
||||||
"version": "14.14.1",
|
"version": "14.14.0",
|
||||||
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz",
|
||||||
"integrity": "sha512-2Q3tqNz/PZLfSr8BvcHZVpRRfSn4MjGSqjj9J+HlBsmbf1Uu4P0WeXnemjTJwwx9KrmplsrN3UkZ/LPOR720rw==",
|
"integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@azure/msal-node": {
|
"node_modules/@azure/msal-node": {
|
||||||
"version": "2.13.0",
|
"version": "2.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz",
|
||||||
"integrity": "sha512-DhP97ycs7qlCVzzzWGzJiwAFyFj5okno74E4FUZ61oCLfKh4IxA1kxirqzrWuYZWpBe9HVPL6GA4NvmlEOBN5Q==",
|
"integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/msal-common": "14.14.1",
|
"@azure/msal-common": "14.14.0",
|
||||||
"jsonwebtoken": "^9.0.0",
|
"jsonwebtoken": "^9.0.0",
|
||||||
"uuid": "^8.3.0"
|
"uuid": "^8.3.0"
|
||||||
},
|
},
|
||||||
|
@ -37,12 +37,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.5.0",
|
"version": "22.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz",
|
||||||
"integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==",
|
"integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.2"
|
"undici-types": "~6.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/readable-stream": {
|
"node_modules/@types/readable-stream": {
|
||||||
|
@ -427,9 +427,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/minecraft-data": {
|
"node_modules/minecraft-data": {
|
||||||
"version": "3.68.0",
|
"version": "3.67.0",
|
||||||
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.68.0.tgz",
|
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz",
|
||||||
"integrity": "sha512-pNBTi39a1zbFpN9itwi0YSL3hqAsSw38D7pE9C6m+aURmXljpBlNTO+TkpZxxDv4KqqtNBOhmkj4x46IDW6R+Q==",
|
"integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/minecraft-folder-path": {
|
"node_modules/minecraft-folder-path": {
|
||||||
|
@ -762,9 +762,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.19.8",
|
"version": "6.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
|
||||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
"integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/uri-js": {
|
"node_modules/uri-js": {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"prismarine-chat": "^1.10.0"
|
"prismarine-chat": "^1.10.0"
|
||||||
},
|
},
|
||||||
"name": "botv10",
|
"name": "botv10",
|
||||||
"version": "10.0.0",
|
"version": "10.0.0-beta-2",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|
180
plugins/!chat.js
180
plugins/!chat.js
|
@ -1,105 +1,3 @@
|
||||||
const console2 = require("./console.js")
|
|
||||||
const parse = require("../util/chatparse.js")
|
|
||||||
const parse1204 = require("../util/chatparse_1204.js")
|
|
||||||
const messageTypes=[
|
|
||||||
"",
|
|
||||||
"chat.type.emote",
|
|
||||||
"commands.message.display.incoming",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"chat.type.announcement",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
]
|
|
||||||
module.exports={
|
|
||||||
load:()=>{
|
|
||||||
|
|
||||||
},
|
|
||||||
loadBot:(b)=>{
|
|
||||||
b._client.on("profileless_chat",(data)=>{
|
|
||||||
if(data.type==4){
|
|
||||||
const json=parse1204(data.message);
|
|
||||||
const parsed=parse(json)[1];
|
|
||||||
let 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 {
|
|
||||||
b.emit("chat",{
|
|
||||||
json: {
|
|
||||||
translate: messageTypes[data.type],
|
|
||||||
color:data.type==2?"gray":"reset",
|
|
||||||
with:[
|
|
||||||
parse1204(data.name),
|
|
||||||
parse1204(data.message)
|
|
||||||
]
|
|
||||||
},
|
|
||||||
type:"profileless",
|
|
||||||
uuid:"00000000-0000-0000-0000-000000000000",
|
|
||||||
message: parse(parse1204(data.message))[1],
|
|
||||||
username:parse(parse1204(data.name))[1]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
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: {
|
|
||||||
translate: messageTypes[data.type],
|
|
||||||
color:data.type==2?"gray":"reset",
|
|
||||||
with:[
|
|
||||||
parse1204(data.networkName),
|
|
||||||
data.plainMessage
|
|
||||||
]
|
|
||||||
},
|
|
||||||
type:"player",
|
|
||||||
uuid:data.senderUuid,
|
|
||||||
message: parse(data.plainMessage)[1],
|
|
||||||
username:parse(parse1204(data.networkName))[1]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
b._client.on("system_chat",(data)=>{
|
|
||||||
const json=parse1204(data.content);
|
|
||||||
const parsed=parse(json)[1];
|
|
||||||
let 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];
|
|
||||||
let 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})
|
|
||||||
})
|
|
||||||
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])
|
|
||||||
let fullCommand = data.message;
|
|
||||||
|
|
||||||
for(const i in b.prefix){
|
|
||||||
if(fullCommand.startsWith(b.prefix[i])){
|
|
||||||
const command=fullCommand.slice(b.prefix[i].length);
|
|
||||||
b.runCommand(data.username,data.uuid,command,b.prefix[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
parse
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = require('../settings.json')
|
const settings = require('../settings.json')
|
||||||
const parsePlain = require('../util/chatparse_plain.js')
|
const parsePlain = require('../util/chatparse_plain.js')
|
||||||
const parseConsole = require('../util/chatparse_console.js')
|
const parseConsole = require('../util/chatparse_console.js')
|
||||||
|
@ -122,21 +20,10 @@ module.exports = {
|
||||||
const parsed = parsePlain(json)
|
const parsed = parsePlain(json)
|
||||||
const split = parsed.split(': ')
|
const split = parsed.split(': ')
|
||||||
const chatName = split.splice(0, 1)[0]
|
const chatName = split.splice(0, 1)[0]
|
||||||
const chatNameSplit = chatName.split(' ')
|
|
||||||
const nickname = chatNameSplit[chatNameSplit.length - 1]
|
|
||||||
const username = b.findRealName(chatName)
|
const username = b.findRealName(chatName)
|
||||||
const uuid = b.findUUID(username)
|
const uuid = b.findUUID(username)
|
||||||
b.emit('chat', {
|
b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username })
|
||||||
json,
|
|
||||||
type: 'profileless',
|
|
||||||
uuid,
|
|
||||||
message: split.join(': '),
|
|
||||||
nickname,
|
|
||||||
username
|
|
||||||
})
|
|
||||||
} else if (data.type === 6 || data.type === 7) {
|
} else if (data.type === 6 || data.type === 7) {
|
||||||
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
|
|
||||||
const nickname = b.findDisplayName(uuid)
|
|
||||||
b.emit('chat', {
|
b.emit('chat', {
|
||||||
json: {
|
json: {
|
||||||
translate: messageTypes[data.type],
|
translate: messageTypes[data.type],
|
||||||
|
@ -148,14 +35,11 @@ module.exports = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
type: 'profileless',
|
type: 'profileless',
|
||||||
uuid,
|
uuid: data.senderUuid,
|
||||||
message: parsePlain(data.message),
|
message: parsePlain(data.message),
|
||||||
nickname,
|
|
||||||
username: parsePlain(parse1204(data.name))
|
username: parsePlain(parse1204(data.name))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
|
|
||||||
const nickname = b.findDisplayName(uuid)
|
|
||||||
b.emit('chat', {
|
b.emit('chat', {
|
||||||
json: {
|
json: {
|
||||||
translate: messageTypes[data.type],
|
translate: messageTypes[data.type],
|
||||||
|
@ -166,9 +50,8 @@ module.exports = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
type: 'profileless',
|
type: 'profileless',
|
||||||
uuid,
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
message: parsePlain(parse1204(data.message)),
|
message: parsePlain(parse1204(data.message)),
|
||||||
nickname,
|
|
||||||
username: parsePlain(parse1204(data.name))
|
username: parsePlain(parse1204(data.name))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -176,14 +59,7 @@ module.exports = {
|
||||||
|
|
||||||
b._client.on('player_chat', (data) => {
|
b._client.on('player_chat', (data) => {
|
||||||
if (data.type === 4) {
|
if (data.type === 4) {
|
||||||
b.emit('chat', {
|
b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) })
|
||||||
json: parse1204(data.unsignedChatContent),
|
|
||||||
type: 'player',
|
|
||||||
uuid: data.senderUuid,
|
|
||||||
message: data.plainMessage,
|
|
||||||
nickname: parsePlain(parse1204(data.networkName)),
|
|
||||||
username: b.findRealNameFromUUID(data.senderUuid)
|
|
||||||
})
|
|
||||||
} else if (data.type === 6 || data.type === 7) {
|
} else if (data.type === 6 || data.type === 7) {
|
||||||
b.emit('chat', {
|
b.emit('chat', {
|
||||||
json: {
|
json: {
|
||||||
|
@ -198,8 +74,7 @@ module.exports = {
|
||||||
type: 'player',
|
type: 'player',
|
||||||
uuid: data.senderUuid,
|
uuid: data.senderUuid,
|
||||||
message: parsePlain(data.plainMessage),
|
message: parsePlain(data.plainMessage),
|
||||||
nickname: parsePlain(parse1204(data.networkName)),
|
username: parsePlain(parse1204(data.networkName))
|
||||||
username: b.findRealNameFromUUID(data.senderUuid)
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
b.emit('chat', {
|
b.emit('chat', {
|
||||||
|
@ -214,8 +89,7 @@ module.exports = {
|
||||||
type: 'player',
|
type: 'player',
|
||||||
uuid: data.senderUuid,
|
uuid: data.senderUuid,
|
||||||
message: parsePlain(data.plainMessage),
|
message: parsePlain(data.plainMessage),
|
||||||
nickname: parsePlain(parse1204(data.networkName)),
|
username: parsePlain(parse1204(data.networkName))
|
||||||
username: b.findRealNameFromUUID(data.senderUuid)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -225,25 +99,15 @@ module.exports = {
|
||||||
const parsed = parsePlain(json)
|
const parsed = parsePlain(json)
|
||||||
const split = parsed.split(': ')
|
const split = parsed.split(': ')
|
||||||
const chatName = split.splice(0, 1)[0]
|
const chatName = split.splice(0, 1)[0]
|
||||||
const chatNameSplit = chatName.split(' ')
|
|
||||||
const nickname = chatNameSplit[chatNameSplit.length - 1]
|
|
||||||
const username = b.findRealName(chatName)
|
const username = b.findRealName(chatName)
|
||||||
const uuid = b.findUUID(username)
|
const uuid = b.findUUID(username)
|
||||||
b.emit('chat', {
|
b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username })
|
||||||
json,
|
|
||||||
type: 'system',
|
|
||||||
uuid,
|
|
||||||
message: split.join(': '),
|
|
||||||
nickname,
|
|
||||||
username
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
b._client.on('chat', (data) => { // Legacy chat for versions <1.19
|
b._client.on('chat', (data) => { // Legacy chat
|
||||||
const json = parse1204(data.message)
|
const json = parse1204(data.message)
|
||||||
const parsed = parsePlain(json)
|
const parsed = parsePlain(json)
|
||||||
let chatName
|
let chatName
|
||||||
let nickname
|
|
||||||
let username
|
let username
|
||||||
let message
|
let message
|
||||||
let uuid
|
let uuid
|
||||||
|
@ -255,22 +119,12 @@ module.exports = {
|
||||||
uuid = b.findUUID(username)
|
uuid = b.findUUID(username)
|
||||||
} else { // Servers with Extras chat, such as Kaboom
|
} else { // Servers with Extras chat, such as Kaboom
|
||||||
const split = parsed.split(': ')
|
const split = parsed.split(': ')
|
||||||
chatName = split.splice(0, 1)[0]
|
|
||||||
const chatNameSplit = chatName.split(' ')
|
|
||||||
nickname = chatNameSplit[chatNameSplit.length - 1]
|
|
||||||
username = b.findRealName(chatName)
|
|
||||||
uuid = b.findUUID(username)
|
|
||||||
message = split.join(': ')
|
message = split.join(': ')
|
||||||
|
uuid = b.findUUID(username)
|
||||||
|
chatName = split.splice(0, 1)[0]
|
||||||
|
username = b.findRealName(chatName)
|
||||||
}
|
}
|
||||||
if (data.uuid) uuid = data.uuid
|
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username })
|
||||||
b.emit('chat', {
|
|
||||||
json,
|
|
||||||
type: 'legacy',
|
|
||||||
uuid,
|
|
||||||
message,
|
|
||||||
nickname,
|
|
||||||
username
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
b.on('chat', (data) => {
|
b.on('chat', (data) => {
|
||||||
|
@ -279,14 +133,14 @@ module.exports = {
|
||||||
if (settings.logJSONmessages) console.log(data.json)
|
if (settings.logJSONmessages) console.log(data.json)
|
||||||
if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
|
if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
|
||||||
if (msgPlain.startsWith('Command set: ')) return
|
if (msgPlain.startsWith('Command set: ')) return
|
||||||
b.emit('plainchat', msgPlain, data.type)
|
b.emit('plainchat', msgPlain)
|
||||||
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
|
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
|
||||||
|
|
||||||
const fullCommand = data.message
|
const fullCommand = data.message
|
||||||
for (const prefix of b.prefix) {
|
for (const i in b.prefix) {
|
||||||
if (fullCommand.startsWith(prefix)) {
|
if (fullCommand.startsWith(b.prefix[i])) {
|
||||||
const command = fullCommand.slice(prefix.length)
|
const command = fullCommand.slice(b.prefix[i].length)
|
||||||
b.runCommand(data.username, data.nickname, data.uuid, command, data.type, prefix)
|
b.runCommand(data.username, data.uuid, command, b.prefix[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,8 +14,8 @@ module.exports = {
|
||||||
b.cloops.splice(index, 1)
|
b.cloops.splice(index, 1)
|
||||||
}
|
}
|
||||||
b.clearCloops = function () {
|
b.clearCloops = function () {
|
||||||
for (const cloop of b.cloops) {
|
for (const i in b.cloops) {
|
||||||
clearInterval(cloop.interval)
|
clearInterval(b.cloops[i].interval)
|
||||||
}
|
}
|
||||||
b.cloops = []
|
b.cloops = []
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ const hashcheck = require('../util/hashcheck.js')
|
||||||
const settings = require('../settings.json')
|
const settings = require('../settings.json')
|
||||||
const { getMessage } = require('../util/lang.js')
|
const { getMessage } = require('../util/lang.js')
|
||||||
const cmds = require('../util/commands.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 {
|
try {
|
||||||
return require(`../userPref/${uuid}.json`)
|
return require(`../userPref/${uuid}.json`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -18,10 +18,10 @@ module.exports = {
|
||||||
load: (b) => {
|
load: (b) => {
|
||||||
b.prefix = settings.prefix
|
b.prefix = settings.prefix
|
||||||
b.lastCmd = 0
|
b.lastCmd = 0
|
||||||
b.runCommand = (name, nickname, uuid, text, msgType, prefix) => {
|
b.runCommand = (name, uuid, text, prefix) => {
|
||||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||||
if (Date.now() - b.lastCmd <= 1000) return
|
if (Date.now() - b.lastCmd <= 1000) return
|
||||||
const userSettings = loadSettings(uuid)
|
const userSettings = loadSettings(uuid);
|
||||||
b.lastCmd = Date.now()
|
b.lastCmd = Date.now()
|
||||||
const cmd = text.split(' ')
|
const cmd = text.split(' ')
|
||||||
const lang = settings.defaultLang
|
const lang = settings.defaultLang
|
||||||
|
@ -29,7 +29,6 @@ module.exports = {
|
||||||
if (verify > 0) {
|
if (verify > 0) {
|
||||||
text = cmd.slice(0, cmd.length - 1).join(' ')
|
text = cmd.slice(0, cmd.length - 1).join(' ')
|
||||||
}
|
}
|
||||||
b.emit('command', name, uuid, text, prefix)
|
|
||||||
if (cmds[cmd[0].toLowerCase()]) {
|
if (cmds[cmd[0].toLowerCase()]) {
|
||||||
const command = cmds[cmd[0].toLowerCase()]
|
const command = cmds[cmd[0].toLowerCase()]
|
||||||
if (command.level !== undefined && command.level > verify) {
|
if (command.level !== undefined && command.level > verify) {
|
||||||
|
@ -45,7 +44,7 @@ module.exports = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings))
|
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify, userSettings))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
b.tellraw(uuid, {
|
b.tellraw(uuid, {
|
||||||
|
|
|
@ -1,110 +1,3 @@
|
||||||
const uuidToInt = require('../util/uuidtoint.js')
|
|
||||||
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)
|
|
||||||
b.ccq = []
|
|
||||||
b.blocknoX = 0
|
|
||||||
b.blocknoZ = 0
|
|
||||||
b.ccStarted = 0
|
|
||||||
b.blocknoY = 0
|
|
||||||
b.pos = { x: 0, y: 0, z: 0, correct: 0 }
|
|
||||||
|
|
||||||
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
|
|
||||||
},
|
|
||||||
mode: 2,
|
|
||||||
flags: 1
|
|
||||||
})
|
|
||||||
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
|
|
||||||
},
|
|
||||||
mode: 2,
|
|
||||||
flags: 5
|
|
||||||
})
|
|
||||||
b.blocknoX++
|
|
||||||
if (b.blocknoX == module.exports.cs) {
|
|
||||||
b.blocknoY++
|
|
||||||
b.blocknoX = 0
|
|
||||||
if (b.blocknoY == module.exports.cs_v) {
|
|
||||||
b.blocknoZ++
|
|
||||||
b.blocknoY = 0
|
|
||||||
if (b.blocknoZ == module.exports.cs) {
|
|
||||||
b.blocknoZ = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.on('ccstart', () => {
|
|
||||||
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds
|
|
||||||
b.ccStarted = true;
|
|
||||||
})
|
|
||||||
b.on('chat', (data) => {
|
|
||||||
if(data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') ||
|
|
||||||
data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success')){
|
|
||||||
if (!b.ccStarted) {
|
|
||||||
b.emit('ccstart')
|
|
||||||
}
|
|
||||||
b.sc_tasks["cc"].failed = 0;
|
|
||||||
b.sc_tasks["cc_size"].failed = 0;
|
|
||||||
} else if(data.json.translate == 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.toobig')){
|
|
||||||
b.sc_tasks["cc_size"].failed = 1;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
b._client.on('position', function (a) {
|
|
||||||
if (!b.ccStarted) {
|
|
||||||
b.original_pos = { x: a.x, y: a.y, z: a.z }
|
|
||||||
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
|
|
||||||
} else {
|
|
||||||
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
|
|
||||||
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
|
|
||||||
}
|
|
||||||
b._client.write('teleport_confirm', { teleportId: a.teleportId })
|
|
||||||
})
|
|
||||||
b.tellraw = (uuid, message) => {
|
|
||||||
let finalname = ''
|
|
||||||
if (uuid == '@a') {
|
|
||||||
finalname = '@a'
|
|
||||||
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
|
|
||||||
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
|
|
||||||
} else {
|
|
||||||
finalname = uuid
|
|
||||||
}
|
|
||||||
b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const uuidToInt = require('../util/uuidtoint.js')
|
const uuidToInt = require('../util/uuidtoint.js')
|
||||||
const cs = {
|
const cs = {
|
||||||
x: 4,
|
x: 4,
|
||||||
|
@ -126,7 +19,7 @@ module.exports = {
|
||||||
b.advanceccq = function () {
|
b.advanceccq = function () {
|
||||||
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
||||||
b._client.write('update_command_block', {
|
b._client.write('update_command_block', {
|
||||||
command: '/',
|
command: b.ccq[0],
|
||||||
location: {
|
location: {
|
||||||
x: b.commandPos.x + b.blocknoX,
|
x: b.commandPos.x + b.blocknoX,
|
||||||
y: b.commandPos.y + b.blocknoY,
|
y: b.commandPos.y + b.blocknoY,
|
||||||
|
@ -136,7 +29,7 @@ module.exports = {
|
||||||
flags: 1
|
flags: 1
|
||||||
})
|
})
|
||||||
b._client.write('update_command_block', {
|
b._client.write('update_command_block', {
|
||||||
command: b.ccq[0].substr(0, 32767),
|
command: b.ccq[0],
|
||||||
location: {
|
location: {
|
||||||
x: b.commandPos.x + b.blocknoX,
|
x: b.commandPos.x + b.blocknoX,
|
||||||
y: b.commandPos.y + b.blocknoY,
|
y: b.commandPos.y + b.blocknoY,
|
||||||
|
@ -162,14 +55,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
b._client.on('login', () => {
|
b._client.on('login', () => {
|
||||||
b._client.write('settings', {
|
|
||||||
locale: 'ru_RU',
|
|
||||||
viewDistance: 4,
|
|
||||||
chatFlags: 0, // Enable full chat functionality
|
|
||||||
chatColors: true,
|
|
||||||
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
|
|
||||||
mainHand: 1 // Right hand
|
|
||||||
})
|
|
||||||
b.add_sc_task('cc', () => {
|
b.add_sc_task('cc', () => {
|
||||||
b.chat(b.refillCoreCmd)
|
b.chat(b.refillCoreCmd)
|
||||||
}, true)
|
}, true)
|
||||||
|
@ -178,7 +63,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
b.on('ccstart', () => {
|
b.on('ccstart', () => {
|
||||||
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000)
|
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds
|
||||||
b.ccStarted = true
|
b.ccStarted = true
|
||||||
})
|
})
|
||||||
b.on('chat', (data) => {
|
b.on('chat', (data) => {
|
||||||
|
|
|
@ -1,54 +1,52 @@
|
||||||
const readln = require('readline')
|
const readln = require('readline')
|
||||||
const index = require('../index.js')
|
const index = require('../index.js')
|
||||||
const ConsoleCommand = require('../util/ConsoleCommand.js')
|
const ConsoleCommand = require('../util/ConsoleCommand.js')
|
||||||
const fs = require('fs')
|
const cmds = require('../util/commands.js')
|
||||||
const newercommands = require('./command.js').cmds;
|
const rl = readln.createInterface({
|
||||||
let rl
|
input: process.stdin,
|
||||||
function consoleWrite(text) {
|
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.cursorTo(process.stdout, 0)
|
||||||
readln.clearLine(process.stdout, 0)
|
readln.clearLine(process.stdout, 0)
|
||||||
process.stdout.write(text + '\n')
|
process.stdout.write(text + '\n')
|
||||||
rl.prompt(true)
|
rl.prompt(true)
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
load: () => {
|
load: (b) => {
|
||||||
rl = readln.createInterface({
|
b.info = (msg) => {
|
||||||
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){
|
|
||||||
let 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)=>{
|
|
||||||
b.info=(msg)=>{
|
|
||||||
consoleWrite(`[${b.id}] [info] ${msg}`)
|
consoleWrite(`[${b.id}] [info] ${msg}`)
|
||||||
}
|
}
|
||||||
},
|
b.displayChat = (type, msg) => {
|
||||||
rl,
|
consoleWrite(`[${b.id}] [${type}] ${msg}`)
|
||||||
write: consoleWrite
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
module.exports={
|
module.exports = {
|
||||||
load:()=>{
|
load: (b) => {
|
||||||
|
b._client.on('login', () => {
|
||||||
},
|
b.interval.chatQueue = setInterval(() => {
|
||||||
loadBot:(b)=>{
|
if (b.chatqueue.length !== 0) {
|
||||||
b._client.on("login",()=>{
|
b._client.chat(b.chatqueue[0])
|
||||||
b.interval.chatQueue=setInterval(()=>{
|
b.chatqueue.splice(0, 1)
|
||||||
if(b.chatqueue.length!=0){
|
|
||||||
b._client.chat(b.chatqueue[0]);
|
|
||||||
b.chatqueue.splice(0,1)
|
|
||||||
}
|
|
||||||
},150)
|
|
||||||
})
|
|
||||||
b.chatqueue=[];
|
|
||||||
b.chat=function chat(msg){
|
|
||||||
if(msg.length==0) return;
|
|
||||||
msg.match(/.{1,250}/g).forEach(element => {
|
|
||||||
b.chatqueue.push(element)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
b.chatqueue = []
|
||||||
|
b.chat = function chat (msg) {
|
||||||
|
if (msg.length === 0) return
|
||||||
|
msg.match(/.{1,255}/g).forEach(element => {
|
||||||
|
b.chatqueue.push(element)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,25 @@ module.exports = {
|
||||||
b.players = {}
|
b.players = {}
|
||||||
b._client.on('player_info', (data) => {
|
b._client.on('player_info', (data) => {
|
||||||
const buffer2 = {}
|
const buffer2 = {}
|
||||||
for (const player of data.data) {
|
for (const i in data.data) {
|
||||||
let uuid
|
let uuid
|
||||||
if (player.uuid) {
|
if (data.data[i].uuid) {
|
||||||
uuid = player.uuid
|
uuid = data.data[i].uuid
|
||||||
} else if (player.UUID) {
|
} else if (data.data[i].UUID) {
|
||||||
uuid = player.UUID
|
uuid = data.data[i].UUID
|
||||||
}
|
}
|
||||||
let displayName
|
let displayName
|
||||||
if (player.displayName !== undefined) {
|
if (data.data[i].displayName !== undefined) {
|
||||||
displayName = player.displayName
|
displayName = data.data[i].displayName
|
||||||
} else {
|
} else {
|
||||||
displayName = '{"text":"[[[[ No display name ]]]]"}'
|
displayName = '{"text":"[[[[ No display name ]]]]"}'
|
||||||
}
|
}
|
||||||
if (player.player && player.player.name !== undefined) {
|
if (data.data[i].player && data.data[i].player.name !== undefined) {
|
||||||
buffer2[uuid] = { realName: player.player.name, displayName: parse(parseNBT(displayName)) }
|
buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parseNBT(displayName)) }
|
||||||
} else if (player.name !== undefined) {
|
} else if (data.data[i].name !== undefined) {
|
||||||
buffer2[uuid] = { realName: player.name, displayName: parse(parseNBT(displayName)) }
|
buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) }
|
||||||
} else if (player.displayName !== undefined) {
|
} else if (data.data[i].displayName !== undefined) {
|
||||||
buffer2[uuid] = { displayName: parse(parseNBT(displayName)) }
|
buffer2[uuid] = { displayName: displayName.plain }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const uuid in buffer2) {
|
for (const uuid in buffer2) {
|
||||||
|
@ -48,20 +48,5 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return '[[[[ no name ]]]]'
|
return '[[[[ no name ]]]]'
|
||||||
}
|
}
|
||||||
b.findRealNameFromUUID = (name) => {
|
|
||||||
if (b.players[name]) {
|
|
||||||
return b.players[name].realName
|
|
||||||
} else {
|
|
||||||
return '[[[[ no name ]]]]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.findDisplayName = (name) => {
|
|
||||||
if (b.players[name]) {
|
|
||||||
const displayName = b.players[name].displayName.split(' ')
|
|
||||||
return displayName[displayName.length - 1]
|
|
||||||
} else {
|
|
||||||
return '[[[[ No display name ]]]]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
const index = require('../index.js')
|
const index = require('../index.js')
|
||||||
module.exports={
|
module.exports = {
|
||||||
load:()=>{
|
load: (b) => {
|
||||||
},
|
b._client.on('end', () => {
|
||||||
loadBot:(b)=>{
|
b.info(`Bot ${b.id} disconnected`)
|
||||||
b._client.on("end",()=>{
|
for (const i in b.interval) {
|
||||||
b.info("bot "+b.id+" disconnected");
|
clearInterval(b.interval[i])
|
||||||
for(const i in b.interval){
|
}
|
||||||
clearInterval(b.interval[i])
|
setTimeout(() => {
|
||||||
}
|
b.info(`Re-connecting bot ${b.id}`)
|
||||||
setTimeout(()=>{
|
index.createBot(b.host, b.id)
|
||||||
b.info("Re-connecting bot "+b.id)
|
}, 5000)
|
||||||
const b_id = b.id;
|
})
|
||||||
index.createBot(b.host,b.id);
|
}
|
||||||
},5000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
b.sc_tasks = {}
|
b.sc_tasks = {}
|
||||||
b.selfcareRun = 0
|
b.selfcareRun = 0
|
||||||
b.interval.sc = setInterval(() => {
|
b.interval.sc = setInterval(() => {
|
||||||
if (Date.now() - b.selfcareRun <= 600) {
|
if(Date.now() - b.selfcareRun <= 600){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (const i in b.sc_tasks) {
|
for (const i in b.sc_tasks) {
|
||||||
|
@ -76,8 +76,7 @@ module.exports = {
|
||||||
b.sc_tasks.respawn.failed = 0
|
b.sc_tasks.respawn.failed = 0
|
||||||
})
|
})
|
||||||
b.on('chat', (data) => {
|
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') ||
|
if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')) {
|
||||||
data.json.translate === 'Chat disabled in client options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'Chat disabled in client options')) {
|
|
||||||
b.sc_tasks.respawn.failed = 1
|
b.sc_tasks.respawn.failed = 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
load: (b) => {
|
load: (b) => {
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,25 +1,42 @@
|
||||||
//HOW TO WRITE CLASS JS
|
// HOW TO WRITE CLASS JS
|
||||||
const parse = require("../util/chatparse.js");
|
const settings = require('../settings.json')
|
||||||
const settings = require("../settings.json");
|
class Command {
|
||||||
class Command{
|
constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) {
|
||||||
constructor (uuid,user,nick,cmd,prefix,bot,verify,lang = settings.defaultLang){
|
this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) }
|
||||||
this.send = (text,uuid)=>{bot.tellraw(uuid?uuid:"@a",text)};
|
this.reply = text => bot.tellraw(uuid, text)
|
||||||
this.reply = text => bot.tellraw(uuid,text);
|
this.uuid = uuid
|
||||||
this.uuid = uuid;
|
this.username = user
|
||||||
this.username = user;
|
this.nickname = nick
|
||||||
this.nickname = nick;
|
this.command = cmd
|
||||||
this.command = cmd;
|
this.prefix = prefix
|
||||||
this.prefix = prefix;
|
this.bot = bot
|
||||||
this.bot = bot;
|
this.type = 'minecraft'
|
||||||
this.type = 'minecraft';
|
this.index = bot.id
|
||||||
this.index = bot.id;
|
this.args = cmd.split(' ').slice(1)
|
||||||
this.args = cmd.split(' ').slice(1);
|
this.verify = verify
|
||||||
this.verify = verify;
|
this.host = bot.host.host
|
||||||
this.host = bot.host.host;
|
this.port = bot.host.port
|
||||||
this.port = bot.host.port;
|
// this.lang = lang
|
||||||
this.lang = lang;
|
this.prefs = prefs
|
||||||
this.colors = settings.colors;
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Command;
|
module.exports = Command
|
||||||
|
|
|
@ -1,58 +1,28 @@
|
||||||
//HOW TO WRITE CLASS JS
|
// HOW TO WRITE CLASS JS
|
||||||
const index = require('../index.js')
|
const index = require('../index.js')
|
||||||
const { cmds } = require('../plugins/command.js');
|
const parse = require('../util/chatparse_console.js')
|
||||||
const parse = require("../util/chatparse.js");
|
const settings = require('../settings.json')
|
||||||
const settings = require("../settings.json");
|
class ConsoleCommand {
|
||||||
const getMessage = require('../util/lang.js');
|
constructor (cmd, index2) {
|
||||||
const lang=settings.defaultLang;
|
this.send = () => {} // not needed for console
|
||||||
class ConsoleCommand{
|
this.reply = text => process.stdout.write(parse(text) + '\n')
|
||||||
constructor (cmd,index2){
|
this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console
|
||||||
this.send = ()=>{}; //not needed for console
|
this.username = 'Owner'
|
||||||
this.reply = text => process.stdout.write(parse(text)[0]+'\n');
|
this.nickname = 'Console'
|
||||||
this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console'; //hard-coded because uuid does not exist at console
|
this.command = cmd
|
||||||
this.username = 'Owner';
|
this.prefix = '' // prefix does not exist at console
|
||||||
this.nickname = 'Console';
|
this.bot = index2 >= 0
|
||||||
this.command = cmd;
|
? index.bot[index2]
|
||||||
this.prefix = ''; //prefix does not exist at console
|
: {}
|
||||||
this.bot = index2 >= 0 ? index.bot[index2] : {
|
this.type = 'console'
|
||||||
printHelp:()=>{
|
this.index = index2
|
||||||
let helpCmds=[];
|
this.args = cmd.split(' ').slice(1)
|
||||||
for(const i in cmds){
|
this.verify = 3
|
||||||
//if(cmds[i].hidden) continue;
|
this.host = ''
|
||||||
helpCmds.push(i)
|
this.port = '3' // :3
|
||||||
}
|
this.lang = settings.defaultLang
|
||||||
console.log(getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")]))
|
this.colors = settings.colors
|
||||||
},
|
}
|
||||||
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);
|
|
||||||
this.verify = 3;
|
|
||||||
this.host = "";
|
|
||||||
this.port = "3"; // :3
|
|
||||||
this.lang = settings.defaultLang;
|
|
||||||
this.colors = settings.colors;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ConsoleCommand;
|
module.exports = ConsoleCommand
|
||||||
|
|
|
@ -70,25 +70,23 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
|
||||||
if (typeof _text === 'number') {
|
if (typeof _text === 'number') {
|
||||||
_text = _text.toString()
|
_text = _text.toString()
|
||||||
}
|
}
|
||||||
out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '')
|
out += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format
|
||||||
}
|
}
|
||||||
if (data.translate) {
|
if (data.translate) {
|
||||||
let trans = data.translate.replaceAll('%%', '\ud900\ud801').replaceAll('\x1b', '').replaceAll('\x0e', '')
|
let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format
|
||||||
if (lang[trans] !== undefined) {
|
if (lang[trans] !== undefined) {
|
||||||
trans = lang[trans].replace(/%%/g, '\ue123')
|
trans = lang[trans].replace(/%%/g, '\ue123')
|
||||||
}
|
}
|
||||||
if(data.with){
|
for (const i in data.with) {
|
||||||
data.with.forEach((item, i) => {
|
const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||||
const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
|
trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s')
|
out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||||
}
|
}
|
||||||
if (data.extra) {
|
if (data.extra) {
|
||||||
for (const item of data.extra) {
|
for (const i in data.extra) {
|
||||||
const parsed = parse(item, l, data.color ? processColor(data.color, resetColor) : resetColor)
|
const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor)
|
||||||
out += parsed
|
out += parsed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,14 @@ const parse = function (_data, l = 0) {
|
||||||
}
|
}
|
||||||
for (const i in data.with) {
|
for (const i in data.with) {
|
||||||
const j2 = parse(data.with[i], l + 1)
|
const j2 = parse(data.with[i], l + 1)
|
||||||
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
|
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
}
|
}
|
||||||
out += trans.replaceAll('\ud900\ud801', '%').replaceAll('\ud900\ud804', '%s').replaceAll('\ud900\ud805', '$s')
|
out += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
||||||
}
|
}
|
||||||
if (data.extra) {
|
if (data.extra) {
|
||||||
for (const item of data.extra) {
|
for (const i in data.extra) {
|
||||||
const parsed = parse(item, l)
|
const parsed = parse(data.extra[i], l)
|
||||||
out += parsed
|
out += parsed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const cmds = Object.create(null)
|
const cmds = Object.create(null)
|
||||||
const bpl = fs.readdirSync('./commands')
|
const bpl = fs.readdirSync('./commands')
|
||||||
for (const plugin of bpl) {
|
for (const i in bpl) {
|
||||||
if (!plugin.endsWith('.js')) {
|
if (!bpl[i].endsWith('.js')) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const commandName = plugin.split('.js')[0]
|
const commandName = bpl[i].split('.js')[0]
|
||||||
cmds[commandName] = require(`../commands/${plugin}`)
|
cmds[commandName] = require(`../commands/${bpl[i]}`)
|
||||||
if (cmds[commandName].level === undefined) {
|
if (cmds[commandName].level === undefined) {
|
||||||
cmds[commandName].level = 0
|
cmds[commandName].level = 0
|
||||||
}
|
}
|
||||||
if (cmds[commandName].aliases) {
|
if (cmds[commandName].aliases) {
|
||||||
for (const alias of cmds[commandName].aliases) {
|
for (const j in cmds[commandName].aliases) {
|
||||||
cmds[alias] = {
|
cmds[cmds[commandName].aliases[j]] = {
|
||||||
execute: cmds[commandName].execute,
|
execute: cmds[commandName].execute,
|
||||||
alias: commandName,
|
alias: commandName,
|
||||||
usage: cmds[commandName].usage,
|
usage: cmds[commandName].usage,
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
const crypto=require("crypto");
|
const crypto = require('crypto')
|
||||||
const settings = require("../settings.json");
|
const settings = require('../settings.json')
|
||||||
const secret = require(settings.secret);
|
const secret = require(settings.secret)
|
||||||
module.exports = function (cmd) {
|
module.exports = function (cmd) {
|
||||||
const cmdWithoutHash=cmd.slice(0,cmd.length-1).join(" ");
|
const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ')
|
||||||
const _dateString=Date.now().toString();
|
const _dateString = Date.now().toString()
|
||||||
const dateString=_dateString.slice(0,_dateString.length-4);
|
const dateString = _dateString.slice(0, _dateString.length - 4)
|
||||||
const hashTrusted="babyboom:"+secret.keyTrusted+":"+cmdWithoutHash+":"+dateString
|
const hashTrusted = `babyboom:${secret.keyTrusted}:${cmdWithoutHash}:${dateString}`
|
||||||
const hashOwner="babyboom:"+secret.keyOwner+":"+cmdWithoutHash+":"+dateString
|
const hashOwner = `babyboom:${secret.keyOwner}:${cmdWithoutHash}:${dateString}`
|
||||||
const validhashT=crypto.createHash("sha256").update(hashTrusted).digest("hex");
|
const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex')
|
||||||
const validhashO=crypto.createHash("sha256").update(hashOwner).digest("hex");
|
const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex')
|
||||||
if(cmd[cmd.length-1]==validhashT){
|
if (cmd[cmd.length - 1] === validhashT) {
|
||||||
return 1;
|
return 1
|
||||||
}
|
}
|
||||||
if(cmd[cmd.length-1]==validhashO){
|
if (cmd[cmd.length - 1] === validhashO) {
|
||||||
return 2;
|
return 2
|
||||||
}
|
}
|
||||||
return 0;
|
return 0
|
||||||
}
|
}
|
||||||
|
|
66
util/lang.js
66
util/lang.js
|
@ -1,27 +1,63 @@
|
||||||
const fs=require("fs")
|
const fs = require('fs')
|
||||||
let languages={};
|
const languages = {}
|
||||||
|
|
||||||
const loadplug = (botno) => {
|
const loadplug = (botno) => {
|
||||||
const bpl = fs.readdirSync('util/lang')
|
const bpl = fs.readdirSync('util/lang')
|
||||||
for (const i in bpl) {
|
for (const i in bpl) {
|
||||||
if (!bpl[i].endsWith('.json')) {
|
if (!bpl[i].endsWith('.json')) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
languages[bpl[i].split(".")[0]]=require(`./lang/${bpl[i]}`)
|
languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`)
|
||||||
} catch (e) { console.log(e) }
|
} catch (e) { console.log(e) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadplug()
|
loadplug()
|
||||||
module.exports = function (l, msg, with2) {
|
|
||||||
let message=msg.replace(/%%/g, '\ue123');
|
const getMessage = function (l, msg, with2) {
|
||||||
if (languages[l][message] !== undefined) {
|
let message = msg.replace(/%%/g, '\ue123')
|
||||||
|
if (languages[l] && languages[l][message] !== undefined) {
|
||||||
message = languages[l][message].replace(/%%/g, '\ue123')
|
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')
|
message = languages['en-US'][message].replace(/%%/g, '\ue123')
|
||||||
}
|
}
|
||||||
for(i in with2){
|
for (const i in with2) {
|
||||||
message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
message = message.replaceAll(`%${+i+1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
|
||||||
}
|
}
|
||||||
return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
|
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,6 @@
|
||||||
{
|
{
|
||||||
|
"language.name": "English",
|
||||||
|
"language.region": "United States",
|
||||||
"time.week": " week ",
|
"time.week": " week ",
|
||||||
"time.weekPlural": " weeks ",
|
"time.weekPlural": " weeks ",
|
||||||
"time.day": " day ",
|
"time.day": " day ",
|
||||||
|
@ -27,8 +29,6 @@
|
||||||
"command.refill.desc": "Refill core",
|
"command.refill.desc": "Refill core",
|
||||||
"command.say.usage": " <message>",
|
"command.say.usage": " <message>",
|
||||||
"command.say.desc": "Sends a message to chat",
|
"command.say.desc": "Sends a message to chat",
|
||||||
"command.serverinfo.usage": "",
|
|
||||||
"command.serverinfo.desc": "Get system/bot info",
|
|
||||||
"command.stop.usage": "",
|
"command.stop.usage": "",
|
||||||
"command.stop.desc": "Restart bot",
|
"command.stop.desc": "Restart bot",
|
||||||
"command.template.usage": " <required> [optional]",
|
"command.template.usage": " <required> [optional]",
|
||||||
|
@ -42,7 +42,6 @@
|
||||||
"command.about.preRelease": "This is prerelease software - there may be errors, and features may be changed or removed at any time.",
|
"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": "Source code: %s",
|
||||||
"command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser",
|
"command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser",
|
||||||
"command.about.serverinfo": "To view system information, run the command %s.",
|
|
||||||
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
|
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
|
||||||
"command.cloop.error.subcommand": "Unknown subcommand, please do %s",
|
"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.add": "Added command loop with command %s and rate %s",
|
||||||
|
@ -59,26 +58,36 @@
|
||||||
"command.help.permsOwner": "Owner",
|
"command.help.permsOwner": "Owner",
|
||||||
"command.help.permsConsole": "Console",
|
"command.help.permsConsole": "Console",
|
||||||
"command.help.noCommand": "Command does not exist",
|
"command.help.noCommand": "Command does not exist",
|
||||||
"command.serverinfo.os.android": "Android",
|
"command.help.alias": "Alias to %s",
|
||||||
"command.serverinfo.os.freebsd": "FreeBSD",
|
"command.netmsg.disabled": "This command has been disabled on this server.",
|
||||||
"command.serverinfo.os.linux": "Linux %s",
|
"command.settings.get.colorPrimary": "Primary color",
|
||||||
"command.serverinfo.os.macos": "macOS",
|
"command.settings.get.colorSecondary": "Secondary color",
|
||||||
"command.serverinfo.os.macos_old": "OS X",
|
"command.settings.get.language": "Language",
|
||||||
"command.serverinfo.os": "Operating system",
|
"command.settings.setLanguage": "Run %s to set this as your language",
|
||||||
"command.serverinfo.processor": "CPU",
|
"command.settings.error.invalidKey": "Invalid key",
|
||||||
"command.serverinfo.arch": "Architecture",
|
"command.settings.error.invalidLanguage": "Invalid language",
|
||||||
"command.serverinfo.osUsername": "Username",
|
"command.settings.error.mustProvideValue": "You must provide a value",
|
||||||
"command.serverinfo.hostName": "Hostname",
|
"command.about.serverInfo.os.android": "Android %s",
|
||||||
"command.serverinfo.workingDir": "Working directory",
|
"command.about.serverInfo.os.android.noVersion": "Android",
|
||||||
"command.serverinfo.runTime": "Bot uptime",
|
"command.about.serverInfo.os.freebsd": "FreeBSD %s",
|
||||||
"command.serverinfo.upTime": "System uptime",
|
"command.about.serverInfo.os.linux": "Linux %s",
|
||||||
"command.serverinfo.nodeVersion": "Node.js version",
|
"command.about.serverInfo.os.macos": "macOS",
|
||||||
"command.serverinfo.osRelease": "Linux release",
|
"command.about.serverInfo.os.macos_old": "OS X",
|
||||||
"command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
|
"command.about.serverInfo.os": "Operating system",
|
||||||
"command.serverinfo.os.android.version": "Android version",
|
"command.about.serverInfo.processor": "CPU",
|
||||||
"command.serverinfo.os.android.model": "Device model",
|
"command.about.serverInfo.arch": "Architecture",
|
||||||
"command.serverinfo.botName": "Bot name",
|
"command.about.serverInfo.osUsername": "Username",
|
||||||
"command.serverinfo.botVer": "Bot version",
|
"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.tpr.success": "Teleporting %s to %s, %s, %s",
|
||||||
"command.verify.success": "Successfully verified with permission level %s",
|
"command.verify.success": "Successfully verified with permission level %s",
|
||||||
"command.error": "An error occured (check console for more info)",
|
"command.error": "An error occured (check console for more info)",
|
||||||
|
|
|
@ -1,22 +1,38 @@
|
||||||
const rsg=function(count){
|
const rsg = function (count) {
|
||||||
let output="";
|
let output = ''
|
||||||
for(let i=0; i<count; i++){
|
for (let i = 0; i < count; i++) {
|
||||||
let rng=Math.floor(Math.random()*16)+1;
|
const type = Math.floor(Math.random() * 6)
|
||||||
if(rng==7) rng=17; //No bells
|
switch (type) {
|
||||||
if(rng==10) rng=18; //No line feeds
|
case 0:
|
||||||
if(rng==11) rng=19; //No vertical tabulations
|
output += ' '
|
||||||
if(rng==12) rng=20; //No form feed
|
break
|
||||||
if(rng==13) rng=21; //No carriage returns
|
case 1:
|
||||||
if(rng==14) rng=22; //No shift out
|
output += '§§'
|
||||||
if(rng==15) rng=23; //No shift in
|
break
|
||||||
output+=String.fromCharCode(rng)
|
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;
|
return output
|
||||||
}
|
}
|
||||||
module.exports = function (legal) {
|
module.exports = function (legal) {
|
||||||
if(legal){
|
if (legal) {
|
||||||
return Math.floor(Math.random()*1000000).toString()
|
return Math.floor(Math.random() * 1000000).toString()
|
||||||
} else {
|
} else {
|
||||||
return " \xa7"+rsg(6)+" "+rsg(4)
|
return rsg(6 + Math.floor(Math.random() * 3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = function (uuid) {
|
module.exports = function (uuid) {
|
||||||
const split_uuid = 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 num_uuid = [+split_uuid[0] << 0, +split_uuid[1] << 0, +split_uuid[2] << 0, +split_uuid[3] << 0]
|
const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0]
|
||||||
return num_uuid
|
return numUUID
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"botName": "botvX Dev",
|
"botName": "botvX Dev",
|
||||||
"botVersion": "10.0.0",
|
"botVersion": "10.0.0-beta.2",
|
||||||
"botAuthor": "a5a06d596f15c7db",
|
"botAuthor": "a5a06d596f15c7db",
|
||||||
"isPreRelease": true,
|
"isPreRelease": true,
|
||||||
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX"
|
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX"
|
||||||
|
|
Loading…
Reference in a new issue