Compare commits

..

27 commits

Author SHA1 Message Date
b950a12be3
Merge branch 'main' of https://code.chipmunk.land/7cc5c4f330d47060/botvX 2024-08-22 07:32:15 -04:00
3e31b2f4f3
71 unstaged files 2024-08-12 05:13:32 -04:00
7cc5c4f330d47060
f5b85902b6 Update README.md 2024-07-29 00:51:07 -04:00
7cc5c4f330d47060
ae073d4177 Update README.md 2024-07-29 00:50:33 -04:00
7cc5c4f330d47060
77e260c128 Update README.md 2024-07-29 00:50:02 -04:00
7cc5c4f330d47060
5e15d32ccd Add echo alias to say 2024-07-28 03:42:15 -04:00
7cc5c4f330d47060
d1993a6bc1 Copy settings2.json to settings.json , and adjust the settings to fit your needs. Do not forget to also create a secrets file. 2024-07-28 03:42:03 -04:00
7cc5c4f330d47060
df5e56ffe0 Merge branch 'main' of https://10.0.0.151:3000/7cc5c4f330d47060/botvX 2024-07-28 02:37:45 -04:00
7cc5c4f330d47060
ed53c4ac38 Update every JavaScript source file
Linting!
2024-07-28 02:37:31 -04:00
7cc5c4f330d47060
9dec12f1bb Update README.md 2024-07-27 18:11:11 -04:00
7cc5c4f330d47060
7d89c2e2b3 Merge pull request 'alpha9' (#3) from alpha9 into main
Reviewed-on: https://10.0.0.151:3000/7cc5c4f330d47060/botvX/pulls/3
2024-07-27 04:34:33 -04:00
7cc5c4f330d47060
7442900bcb Make settings2 kawaii! :3 2024-07-27 04:33:48 -04:00
7cc5c4f330d47060
157bfc890f Merge branch 'alpha9' of https://10.0.0.151:3000/7cc5c4f330d47060/botvX into alpha9 2024-07-27 04:17:39 -04:00
7cc5c4f330d47060
fa1b9820bc fwafawfa 2024-07-27 04:17:35 -04:00
7cc5c4f330d47060
13a905e08c a 2024-07-27 04:16:21 -04:00
7cc5c4f330d47060
0976f6d4b2 Cloop level 1 2024-07-27 04:15:26 -04:00
7cc5c4f330d47060
f7b21b41f4 Mainline is beta 2024-07-27 04:06:20 -04:00
7cc5c4f330d47060
25173b5689 Merge pull request 'alpha9' (#2) from alpha9 into main
Reviewed-on: https://10.0.0.151:3000/7cc5c4f330d47060/botvX/pulls/2
2024-07-27 04:05:52 -04:00
7cc5c4f330d47060
5b90ad7954 Merge pull request 'module.exports={ execute: (c)=>{ if(c.args.length>0){ c.bot.printCmdHelp(c.uuid,c.args[0],c.lang,c.colors); } else { c.bot.printHelp(c.uuid,c.prefix,c.lang,c.colors); } }, aliases: [ "hek' (#1) from main into alpha9
Reviewed-on: https://10.0.0.151:3000/7cc5c4f330d47060/botvX/pulls/1
2024-07-27 04:03:52 -04:00
7cc5c4f330d47060
1d57af5993 Update help command to not be completely white 2024-07-27 04:02:39 -04:00
7cc5c4f330d47060
183c388f00 Make cloop permisision level 1 2024-07-27 04:02:18 -04:00
7cc5c4f330d47060
b30a0a21b9 Update cloop translation 2024-07-27 04:01:56 -04:00
7cc5c4f330d47060
f8ee6905c2 Make cloop subcommand use translations 2024-07-27 03:58:09 -04:00
7cc5c4f330d47060
73f0a9d262 Remove Hebrew uwu language notice 2024-07-27 02:43:52 -04:00
7cc5c4f330d47060
6eca4f3c64 Downgrade to alpha (this is gonna go to chipmunk) 2024-07-27 02:42:50 -04:00
7cc5c4f330d47060
0b1f3634c4 Add gitignore 2024-07-27 02:40:47 -04:00
7cc5c4f330d47060
00966b2913 omagad!!!! poco!!!! *POCO ringtone* 2024-07-27 02:39:18 -04:00
30 changed files with 440 additions and 708 deletions

View file

@ -2,13 +2,17 @@
## 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)
- a self care system
- a command core, to run commands quickly
- a hashing system, to enable trusted users to securely run certain commands in chat
## What does "botvX" mean?
"botvX" means "bot version 10". The v is used to signify that whatever after it is a version, as was done with previous versions (botv4, botv6, botv8, botv9), and the X is the Roman numeral for 10, since this is the 10th major version.
## How to install?
1. Install [Node.js](https://nodejs.org/) for your operating system.

View file

@ -4,7 +4,6 @@ const { getMessage, formatTime } = require('../util/lang.js')
const fs = require('fs')
const botVersion = require('../util/version.js')
const version = require('../version.json')
const index = require('../index.js')
const aboutBot = function (c) {
c.reply({
@ -56,13 +55,13 @@ const aboutBot = function (c) {
const os2 = function (o2, l) {
switch (o2) {
case 'win32':
return `${os.version()}`
return `${os.version()} (${os.release})`
case 'android':{
try {
const version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
return getMessage(l, 'command.about.serverInfo.os.android', [version])
} catch (e) {
return getMessage(l, 'command.about.serverInfo.os.android.noVersion')
getMessage(l, 'command.about.serverInfo.os.android.noVersion')
}
}
case 'linux':
@ -70,20 +69,20 @@ const os2 = function (o2, l) {
if (fs.readdirSync('/etc').includes('os-release')) {
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
const osrelease2 = {}
for (const item of osrelease) {
if (!item.includes('=')) continue
let osrvalue = item.split('=')[1]
for (const i in osrelease) {
if (!osrelease[i].includes('=')) continue
let osrvalue = osrelease[i].split('=')[1]
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
osrelease2[item.split('=')[0]] = osrvalue
osrelease2[osrelease[i].split('=')[0]] = osrvalue
}
if (osrelease2.PRETTY_NAME) {
return getMessage(l, '%s', [osrelease2.PRETTY_NAME])
return getMessage(l, '%s %s', [osrelease2.PRETTY_NAME, os.release()])
} else {
return getMessage(l, `command.about.serverInfo.os.${o2}`)
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
}
} else {
return getMessage(l, `command.about.serverInfo.os.${o2}`)
return getMessage(l, `command.about.serverInfo.os.${o2}`, [os.release()])
}
}
default:
@ -121,11 +120,6 @@ const aboutServer = function (c) {
return os2(process.platform, c.lang)
})
// Kernel version: os.release()
displayInfo('command.about.serverInfo.kernelVer', () => {
return os.release()
})
// Processor
if (os.cpus()[0]) {
displayInfo('command.about.serverInfo.processor', () => {
@ -184,33 +178,10 @@ const aboutServer = function (c) {
return botVersion
})
}
const displayServerList = function (c) {
index.bot.forEach((item, i)=>{
if (item.host.options && item.host.options.hidden) return
c.reply({
translate: getMessage(c.lang, 'command.about.serverListItem'),
color: c.colors.secondary,
with: [
{
text: i.toString(),
color: c.colors.primary
},
{
text: `${item.host.host}:${item.host.port}`,
color: c.colors.primary
}
]
})
})
}
module.exports = {
execute: function (c) {
if (c.args[0] === 'server') {
aboutServer(c)
} else if (c.args[0] === 'serverlist') {
displayServerList(c)
} else {
aboutBot(c)
}

View file

@ -44,26 +44,26 @@ module.exports = {
break
}
case 'list':
c.bot.cloops.forEach((item, i)=>{
for (const i in c.bot.cloops) {
c.reply({
translate: getMessage(c.lang, 'command.cloop.list'),
color: c.colors.secondary,
with: [
{
text: i.toString(),
text: i,
color: c.colors.primary
},
{
text: item.command,
text: c.bot.cloops[i].command,
color: c.colors.primary
},
{
text: item.rate + '',
text: c.bot.cloops[i].rate + '',
color: c.colors.primary
}
]
})
})
}
break
case 'clear':
c.bot.clearCloops()

View file

@ -9,14 +9,14 @@ const sortHelp = function sortHelp (c1, c2) {
}
const bpl = fs.readdirSync('./commands')
for (const plugin of bpl) {
if (!plugin.endsWith('.js')) {
for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circular require
if (!bpl[i].endsWith('.js')) {
continue
}
try {
const commandName = plugin.split('.js')[0]
const commandName = bpl[i].split('.js')[0]
if (commandName !== 'help') {
cmds[commandName] = require(`./${plugin}`)
cmds[commandName] = require(`./${bpl[i]}`)
if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0
}
@ -89,7 +89,7 @@ const printCmdHelp = (c) => {
desc = cmds[cmds[cmd].alias].desc
}
}
for (const item of usage) {
for (const i in usage) {
c.reply({
translate: getMessage(c.lang, 'command.help.commandUsage'),
color: c.colors.secondary,
@ -99,7 +99,7 @@ const printCmdHelp = (c) => {
color: c.colors.primary
},
{
text: item,
text: usage[i],
color: c.colors.primary
}
]
@ -152,8 +152,8 @@ if (cmds.help.level === undefined) {
for (const i in cmds) {
if (cmds[i].aliases) {
for (const alias of cmds[commandName].aliases) {
cmds[alias] = {
for (const j in cmds[i].aliases) {
cmds[cmds[i].aliases[j]] = {
alias: i,
usage: cmds[i].usage,
level: cmds[i].level,

View file

@ -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.hidden) {
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
@ -36,9 +36,9 @@ module.exports = {
],
color: 'white'
}
bot.forEach(item => {
if (item.host.options.hidden) return
item.tellraw('@a', json)
})
for (const i in bot) {
if(bot[i].host.options.netmsgDisabled) continue
bot[i].tellraw('@a', json)
}
}
}

View file

@ -4,40 +4,40 @@ 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)){
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 item of languages) {
for(const i in languages){
c.reply({
translate: '%s (%s)',
translate: "%s (%s)",
color: c.colors.secondary,
with:[
{
text: getMessage(item, 'language.name'),
text: getMessage(languages[i], 'language.name'),
color: c.colors.primary
},
{
text: getMessage(item, 'language.region'),
text: getMessage(languages[i], 'language.region'),
color: c.colors.primary
}
],
hoverEvent:{
action: 'show_text',
action: "show_text",
value: {
translate: getMessage(item, 'command.settings.setLanguage'),
translate: getMessage(languages[i], 'command.settings.setLanguage'),
with:[
{
text: `${c.prefix}settings set lang ${item}`,
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
@ -73,13 +73,12 @@ module.exports = {
c.reply({
text: getMessage(c.lang, 'command.settings.saved'),
color: c.colors.secondary
})
break
}
case 'get':
});
break;
case 'get':{
c.reply({
translate: '%s: %s',
color: c.colors.primary,
translate: "%s: %s",
color: c.colors.secondary,
with:[
{
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
@ -92,8 +91,8 @@ module.exports = {
]
})
c.reply({
translate: '%s: %s',
color: c.colors.primary,
translate: "%s: %s",
color: c.colors.secondary,
with:[
{
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
@ -106,12 +105,12 @@ module.exports = {
]
})
c.reply({
translate: '%s: %s (%s)',
color: c.colors.primary,
translate: "%s: %s (%s)",
color: c.colors.secondary,
with:[
{
text: getMessage(c.lang, 'command.settings.get.language'),
color: c.colors.secondary
color: c.colors.primary
},
{
text: getMessage(c.lang, 'language.name'),
@ -124,6 +123,7 @@ module.exports = {
]
})
break
}
default:
c.reply({
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),

View file

@ -6,18 +6,17 @@ const fs = require('fs')
module.exports.bot = []
const loadplug = (botno) => {
const botplug = []
const bpl = fs.readdirSync('plugins')
for (const plugin of bpl) {
if (!plugin.endsWith('.js')) {
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
}
try {
botplug.push(require(`./plugins/${plugin}`))
botplug.push(require(`./plugins/${bpl[i]}`))
} catch (e) { console.log(e) }
}
const loadplug = (botno) => {
botplug.forEach((plug) => {
try {
if (plug.load) {
@ -67,8 +66,8 @@ const createBot = function createBot (host, oldId) {
})
}
for (const server of settings.servers) {
createBot(server)
for (const i in settings.servers) {
createBot(settings.servers[i])
}
module.exports.createBot = createBot

38
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "botv10",
"version": "10.0.0",
"version": "10.0.0-beta-2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "botv10",
"version": "10.0.0",
"version": "10.0.0-beta-2",
"license": "MIT",
"dependencies": {
"minecraft-protocol": "^1.45.0",
@ -14,21 +14,21 @@
}
},
"node_modules/@azure/msal-common": {
"version": "14.14.1",
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.1.tgz",
"integrity": "sha512-2Q3tqNz/PZLfSr8BvcHZVpRRfSn4MjGSqjj9J+HlBsmbf1Uu4P0WeXnemjTJwwx9KrmplsrN3UkZ/LPOR720rw==",
"version": "14.14.0",
"resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.14.0.tgz",
"integrity": "sha512-OxcOk9H1/1fktHh6//VCORgSNJc2dCQObTm6JNmL824Z6iZSO6eFo/Bttxe0hETn9B+cr7gDouTQtsRq3YPuSQ==",
"license": "MIT",
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/@azure/msal-node": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.13.0.tgz",
"integrity": "sha512-DhP97ycs7qlCVzzzWGzJiwAFyFj5okno74E4FUZ61oCLfKh4IxA1kxirqzrWuYZWpBe9HVPL6GA4NvmlEOBN5Q==",
"version": "2.12.0",
"resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.12.0.tgz",
"integrity": "sha512-jmk5Im5KujRA2AcyCb0awA3buV8niSrwXZs+NBJWIvxOz76RvNlusGIqi43A0h45BPUy93Qb+CPdpJn82NFTIg==",
"license": "MIT",
"dependencies": {
"@azure/msal-common": "14.14.1",
"@azure/msal-common": "14.14.0",
"jsonwebtoken": "^9.0.0",
"uuid": "^8.3.0"
},
@ -37,12 +37,12 @@
}
},
"node_modules/@types/node": {
"version": "22.5.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz",
"integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==",
"version": "22.2.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz",
"integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
"undici-types": "~6.13.0"
}
},
"node_modules/@types/readable-stream": {
@ -427,9 +427,9 @@
"license": "MIT"
},
"node_modules/minecraft-data": {
"version": "3.68.0",
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.68.0.tgz",
"integrity": "sha512-pNBTi39a1zbFpN9itwi0YSL3hqAsSw38D7pE9C6m+aURmXljpBlNTO+TkpZxxDv4KqqtNBOhmkj4x46IDW6R+Q==",
"version": "3.67.0",
"resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.67.0.tgz",
"integrity": "sha512-/hLeYXopx9o1UdViPPFenLJ3hT5S4qUEwLQM0MAHOIhqkAUGXdkl47O7ohG+f87DH3+cZksbbM61sTnSRsQpsA==",
"license": "MIT"
},
"node_modules/minecraft-folder-path": {
@ -762,9 +762,9 @@
"license": "MIT"
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
"integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==",
"license": "MIT"
},
"node_modules/uri-js": {

View file

@ -4,7 +4,7 @@
"prismarine-chat": "^1.10.0"
},
"name": "botv10",
"version": "10.0.0",
"version": "10.0.0-beta-2",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

View file

@ -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 parsePlain = require('../util/chatparse_plain.js')
const parseConsole = require('../util/chatparse_console.js')
@ -122,21 +20,10 @@ module.exports = {
const parsed = parsePlain(json)
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const chatNameSplit = chatName.split(' ')
const nickname = chatNameSplit[chatNameSplit.length - 1]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', {
json,
type: 'profileless',
uuid,
message: split.join(': '),
nickname,
username
})
b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username })
} else if (data.type === 6 || data.type === 7) {
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
const nickname = b.findDisplayName(uuid)
b.emit('chat', {
json: {
translate: messageTypes[data.type],
@ -148,14 +35,11 @@ module.exports = {
]
},
type: 'profileless',
uuid,
uuid: data.senderUuid,
message: parsePlain(data.message),
nickname,
username: parsePlain(parse1204(data.name))
})
} else {
const uuid = b.findUUID(parsePlain(parse1204(data.name)))
const nickname = b.findDisplayName(uuid)
b.emit('chat', {
json: {
translate: messageTypes[data.type],
@ -166,9 +50,8 @@ module.exports = {
]
},
type: 'profileless',
uuid,
uuid: '00000000-0000-0000-0000-000000000000',
message: parsePlain(parse1204(data.message)),
nickname,
username: parsePlain(parse1204(data.name))
})
}
@ -176,14 +59,7 @@ module.exports = {
b._client.on('player_chat', (data) => {
if (data.type === 4) {
b.emit('chat', {
json: parse1204(data.unsignedChatContent),
type: 'player',
uuid: data.senderUuid,
message: data.plainMessage,
nickname: parsePlain(parse1204(data.networkName)),
username: b.findRealNameFromUUID(data.senderUuid)
})
b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parsePlain(parse1204(data.networkName)) })
} else if (data.type === 6 || data.type === 7) {
b.emit('chat', {
json: {
@ -198,8 +74,7 @@ module.exports = {
type: 'player',
uuid: data.senderUuid,
message: parsePlain(data.plainMessage),
nickname: parsePlain(parse1204(data.networkName)),
username: b.findRealNameFromUUID(data.senderUuid)
username: parsePlain(parse1204(data.networkName))
})
} else {
b.emit('chat', {
@ -214,8 +89,7 @@ module.exports = {
type: 'player',
uuid: data.senderUuid,
message: parsePlain(data.plainMessage),
nickname: parsePlain(parse1204(data.networkName)),
username: b.findRealNameFromUUID(data.senderUuid)
username: parsePlain(parse1204(data.networkName))
})
}
})
@ -225,25 +99,15 @@ module.exports = {
const parsed = parsePlain(json)
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const chatNameSplit = chatName.split(' ')
const nickname = chatNameSplit[chatNameSplit.length - 1]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', {
json,
type: 'system',
uuid,
message: split.join(': '),
nickname,
username
})
b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), 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 parsed = parsePlain(json)
let chatName
let nickname
let username
let message
let uuid
@ -255,22 +119,12 @@ module.exports = {
uuid = b.findUUID(username)
} else { // Servers with Extras chat, such as Kaboom
const split = parsed.split(': ')
chatName = split.splice(0, 1)[0]
const chatNameSplit = chatName.split(' ')
nickname = chatNameSplit[chatNameSplit.length - 1]
username = b.findRealName(chatName)
uuid = b.findUUID(username)
message = split.join(': ')
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,
message,
nickname,
username
})
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username })
})
b.on('chat', (data) => {
@ -279,14 +133,14 @@ module.exports = {
if (settings.logJSONmessages) console.log(data.json)
if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
if (msgPlain.startsWith('Command set: ')) return
b.emit('plainchat', msgPlain, data.type)
b.emit('plainchat', msgPlain)
b.displayChat(data.type, `${msgConsole}\x1b[0m`)
const fullCommand = data.message
for (const prefix of b.prefix) {
if (fullCommand.startsWith(prefix)) {
const command = fullCommand.slice(prefix.length)
b.runCommand(data.username, data.nickname, data.uuid, command, data.type, prefix)
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])
}
}
})

View file

@ -14,8 +14,8 @@ module.exports = {
b.cloops.splice(index, 1)
}
b.clearCloops = function () {
for (const cloop of b.cloops) {
clearInterval(cloop.interval)
for (const i in b.cloops) {
clearInterval(b.cloops[i].interval)
}
b.cloops = []
}

View file

@ -3,9 +3,9 @@ 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){
try {
@ -18,10 +18,10 @@ module.exports = {
load: (b) => {
b.prefix = settings.prefix
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 (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
@ -29,7 +29,6 @@ module.exports = {
if (verify > 0) {
text = cmd.slice(0, cmd.length - 1).join(' ')
}
b.emit('command', name, uuid, text, prefix)
if (cmds[cmd[0].toLowerCase()]) {
const command = cmds[cmd[0].toLowerCase()]
if (command.level !== undefined && command.level > verify) {
@ -45,7 +44,7 @@ module.exports = {
return
}
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) {
console.log(e)
b.tellraw(uuid, {

View file

@ -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 cs = {
x: 4,
@ -126,7 +19,7 @@ module.exports = {
b.advanceccq = function () {
if (b.ccq[0] && b.ccq[0].length !== 0) {
b._client.write('update_command_block', {
command: '/',
command: b.ccq[0],
location: {
x: b.commandPos.x + b.blocknoX,
y: b.commandPos.y + b.blocknoY,
@ -136,7 +29,7 @@ module.exports = {
flags: 1
})
b._client.write('update_command_block', {
command: b.ccq[0].substr(0, 32767),
command: b.ccq[0],
location: {
x: b.commandPos.x + b.blocknoX,
y: b.commandPos.y + b.blocknoY,
@ -162,14 +55,6 @@ module.exports = {
}
b._client.on('login', () => {
b._client.write('settings', {
locale: 'ru_RU',
viewDistance: 4,
chatFlags: 0, // Enable full chat functionality
chatColors: true,
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
mainHand: 1 // Right hand
})
b.add_sc_task('cc', () => {
b.chat(b.refillCoreCmd)
}, true)
@ -178,7 +63,7 @@ module.exports = {
})
})
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.on('chat', (data) => {

View file

@ -1,40 +1,30 @@
const readln = require('readline')
const index = require('../index.js')
const ConsoleCommand = require('../util/ConsoleCommand.js')
const fs = require('fs')
const newercommands = require('./command.js').cmds;
let rl
function consoleWrite(text) {
readln.cursorTo(process.stdout, 0)
readln.clearLine(process.stdout, 0)
process.stdout.write(text + '\n')
rl.prompt(true)
}
module.exports = {
load: () => {
rl = readln.createInterface({
const cmds = require('../util/commands.js')
const rl = readln.createInterface({
input: process.stdin,
output: process.stdout,
prompt: '\x1b[0m\x1b[38;5;15m> '
prompt: '\x1b[0m> '
})
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 (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);
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
const cmd = new ConsoleCommand(tmpcmd.join(' '), i)
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
}
} else {
const cmd = new ConsoleCommand(tmpcmd.join(' '),+index2);
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2)
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
}
} else {
const cmd = new ConsoleCommand(l,-2);
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
const cmd = new ConsoleCommand(l, -2)
cmds[l.split(' ')[0].toLowerCase()].execute(cmd)
}
}
} catch (e) {
@ -43,12 +33,20 @@ module.exports = {
rl.prompt(false)
})
rl.prompt()
},
loadBot: (b)=>{
function consoleWrite (text) {
readln.cursorTo(process.stdout, 0)
readln.clearLine(process.stdout, 0)
process.stdout.write(text + '\n')
rl.prompt(true)
}
module.exports = {
load: (b) => {
b.info = (msg) => {
consoleWrite(`[${b.id}] [info] ${msg}`)
}
},
rl,
write: consoleWrite
b.displayChat = (type, msg) => {
consoleWrite(`[${b.id}] [${type}] ${msg}`)
}
}
}

View file

@ -1,23 +1,19 @@
module.exports = {
load:()=>{
},
loadBot:(b)=>{
b._client.on("login",()=>{
load: (b) => {
b._client.on('login', () => {
b.interval.chatQueue = setInterval(() => {
if(b.chatqueue.length!=0){
b._client.chat(b.chatqueue[0]);
if (b.chatqueue.length !== 0) {
b._client.chat(b.chatqueue[0])
b.chatqueue.splice(0, 1)
}
},150)
}, 100)
})
b.chatqueue=[];
b.chatqueue = []
b.chat = function chat (msg) {
if(msg.length==0) return;
msg.match(/.{1,250}/g).forEach(element => {
if (msg.length === 0) return
msg.match(/.{1,255}/g).forEach(element => {
b.chatqueue.push(element)
});
}
})
}
}
}

View file

@ -5,25 +5,25 @@ module.exports = {
b.players = {}
b._client.on('player_info', (data) => {
const buffer2 = {}
for (const player of data.data) {
for (const i in data.data) {
let uuid
if (player.uuid) {
uuid = player.uuid
} else if (player.UUID) {
uuid = player.UUID
if (data.data[i].uuid) {
uuid = data.data[i].uuid
} else if (data.data[i].UUID) {
uuid = data.data[i].UUID
}
let displayName
if (player.displayName !== undefined) {
displayName = player.displayName
if (data.data[i].displayName !== undefined) {
displayName = data.data[i].displayName
} else {
displayName = '{"text":"[[[[ No display name ]]]]"}'
}
if (player.player && player.player.name !== undefined) {
buffer2[uuid] = { realName: player.player.name, displayName: parse(parseNBT(displayName)) }
} else if (player.name !== undefined) {
buffer2[uuid] = { realName: player.name, displayName: parse(parseNBT(displayName)) }
} else if (player.displayName !== undefined) {
buffer2[uuid] = { displayName: parse(parseNBT(displayName)) }
if (data.data[i].player && data.data[i].player.name !== undefined) {
buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parseNBT(displayName)) }
} else if (data.data[i].name !== undefined) {
buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parseNBT(displayName)) }
} else if (data.data[i].displayName !== undefined) {
buffer2[uuid] = { displayName: displayName.plain }
}
}
for (const uuid in buffer2) {
@ -48,20 +48,5 @@ module.exports = {
}
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 ]]]]'
}
}
}
}

View file

@ -1,17 +1,14 @@
const index = require('../index.js')
module.exports = {
load:()=>{
},
loadBot:(b)=>{
b._client.on("end",()=>{
b.info("bot "+b.id+" disconnected");
load: (b) => {
b._client.on('end', () => {
b.info(`Bot ${b.id} disconnected`)
for (const i in b.interval) {
clearInterval(b.interval[i])
}
setTimeout(() => {
b.info("Re-connecting bot "+b.id)
const b_id = b.id;
index.createBot(b.host,b.id);
b.info(`Re-connecting bot ${b.id}`)
index.createBot(b.host, b.id)
}, 5000)
})
}

View file

@ -76,8 +76,7 @@ module.exports = {
b.sc_tasks.respawn.failed = 0
})
b.on('chat', (data) => {
if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options') ||
data.json.translate === 'Chat disabled in client options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'Chat disabled in client options')) {
if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options')) {
b.sc_tasks.respawn.failed = 1
}
})

View file

@ -3,4 +3,3 @@ module.exports = {
}
}

View file

@ -1,25 +1,42 @@
// HOW TO WRITE CLASS JS
const parse = require("../util/chatparse.js");
const settings = require("../settings.json");
const settings = require('../settings.json')
class Command {
constructor (uuid,user,nick,cmd,prefix,bot,verify,lang = settings.defaultLang){
this.send = (text,uuid)=>{bot.tellraw(uuid?uuid:"@a",text)};
this.reply = text => bot.tellraw(uuid,text);
this.uuid = uuid;
this.username = user;
this.nickname = nick;
this.command = cmd;
this.prefix = prefix;
this.bot = bot;
this.type = 'minecraft';
this.index = bot.id;
this.args = cmd.split(' ').slice(1);
this.verify = verify;
this.host = bot.host.host;
this.port = bot.host.port;
this.lang = lang;
this.colors = settings.colors;
constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) {
this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) }
this.reply = text => bot.tellraw(uuid, text)
this.uuid = uuid
this.username = user
this.nickname = nick
this.command = cmd
this.prefix = prefix
this.bot = bot
this.type = 'minecraft'
this.index = bot.id
this.args = cmd.split(' ').slice(1)
this.verify = verify
this.host = bot.host.host
this.port = bot.host.port
// this.lang = lang
this.prefs = prefs
if(prefs.lang){
this.lang = prefs.lang
} else {
this.lang = settings.defaultLang
}
let _colors = {}
if(prefs.colorPrimary){
_colors.primary = prefs.colorPrimary
} else {
_colors.primary = settings.colors.primary
}
if(prefs.colorSecondary){
_colors.secondary = prefs.colorSecondary
} else {
_colors.secondary = settings.colors.secondary
}
this.colors = _colors
}
}
module.exports = Command;
module.exports = Command

View file

@ -1,58 +1,28 @@
// HOW TO WRITE CLASS JS
const index = require('../index.js')
const { cmds } = require('../plugins/command.js');
const parse = require("../util/chatparse.js");
const settings = require("../settings.json");
const getMessage = require('../util/lang.js');
const lang=settings.defaultLang;
const parse = require('../util/chatparse_console.js')
const settings = require('../settings.json')
class ConsoleCommand {
constructor (cmd, index2) {
this.send = ()=>{}; //not needed for console
this.reply = text => process.stdout.write(parse(text)[0]+'\n');
this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console'; //hard-coded because uuid does not exist at console
this.username = 'Owner';
this.nickname = 'Console';
this.command = cmd;
this.prefix = ''; //prefix does not exist at console
this.bot = index2 >= 0 ? index.bot[index2] : {
printHelp:()=>{
let helpCmds=[];
for(const i in cmds){
//if(cmds[i].hidden) continue;
helpCmds.push(i)
}
console.log(getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")]))
},
printCmdHelp:(uuid,cmd)=>{
let usage=getMessage(lang,`command.${cmd}.usage`).split("||");
let desc=getMessage(lang,`command.${cmd}.desc`);
if(cmds[cmd].usage){
usage=cmds[cmd].usage.split("||");
}
if(cmds[cmd].desc){
desc=cmds[cmd].desc;
}
for(const i in usage){
console.log(getMessage(lang,"command.help.commandUsage",[cmd,usage[i]]));
}
console.log(getMessage(lang,"command.help.commandDesc",[desc]));
const permsN=getMessage(lang,"command.help.permsNormal");
const permsT=getMessage(lang,"command.help.permsTrusted");
const permsO=getMessage(lang,"command.help.permsOwner");
const permsC=getMessage(lang,"command.help.permsConsole");
const rPerms=cmds[cmd].level?cmds[cmd].level:0;
console.log(getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]]));
}
}; //bot does not exist at console
this.type = 'console';
this.index = index2;
this.args = cmd.split(' ').slice(1);
this.verify = 3;
this.host = "";
this.port = "3"; // :3
this.lang = settings.defaultLang;
this.colors = settings.colors;
this.send = () => {} // not needed for console
this.reply = text => process.stdout.write(parse(text) + '\n')
this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' // hard-coded because uuid does not exist at console
this.username = 'Owner'
this.nickname = 'Console'
this.command = cmd
this.prefix = '' // prefix does not exist at console
this.bot = index2 >= 0
? index.bot[index2]
: {}
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

View file

@ -70,25 +70,23 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
if (typeof _text === 'number') {
_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) {
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) {
trans = lang[trans].replace(/%%/g, '\ue123')
}
if(data.with){
data.with.forEach((item, i) => {
const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
})
for (const i in data.with) {
const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}
out += trans.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) {
for (const item of data.extra) {
const parsed = parse(item, l, data.color ? processColor(data.color, resetColor) : resetColor)
for (const i in data.extra) {
const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor)
out += parsed
}
}

View file

@ -31,14 +31,14 @@ const parse = function (_data, l = 0) {
}
for (const i in data.with) {
const j2 = parse(data.with[i], l + 1)
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))
trans = trans.replace(/%s/, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans = trans.replaceAll(`%${+i + 1}$s`, j2.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}
out += trans.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) {
for (const item of data.extra) {
const parsed = parse(item, l)
for (const i in data.extra) {
const parsed = parse(data.extra[i], l)
out += parsed
}
}

View file

@ -1,19 +1,19 @@
const fs = require('fs')
const cmds = Object.create(null)
const bpl = fs.readdirSync('./commands')
for (const plugin of bpl) {
if (!plugin.endsWith('.js')) {
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
}
try {
const commandName = plugin.split('.js')[0]
cmds[commandName] = require(`../commands/${plugin}`)
const commandName = bpl[i].split('.js')[0]
cmds[commandName] = require(`../commands/${bpl[i]}`)
if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0
}
if (cmds[commandName].aliases) {
for (const alias of cmds[commandName].aliases) {
cmds[alias] = {
for (const j in cmds[commandName].aliases) {
cmds[cmds[commandName].aliases[j]] = {
execute: cmds[commandName].execute,
alias: commandName,
usage: cmds[commandName].usage,

View file

@ -1,19 +1,19 @@
const crypto=require("crypto");
const settings = require("../settings.json");
const secret = require(settings.secret);
const crypto = require('crypto')
const settings = require('../settings.json')
const secret = require(settings.secret)
module.exports = function (cmd) {
const cmdWithoutHash=cmd.slice(0,cmd.length-1).join(" ");
const _dateString=Date.now().toString();
const dateString=_dateString.slice(0,_dateString.length-4);
const hashTrusted="babyboom:"+secret.keyTrusted+":"+cmdWithoutHash+":"+dateString
const hashOwner="babyboom:"+secret.keyOwner+":"+cmdWithoutHash+":"+dateString
const validhashT=crypto.createHash("sha256").update(hashTrusted).digest("hex");
const validhashO=crypto.createHash("sha256").update(hashOwner).digest("hex");
if(cmd[cmd.length-1]==validhashT){
return 1;
const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ')
const _dateString = Date.now().toString()
const dateString = _dateString.slice(0, _dateString.length - 4)
const hashTrusted = `babyboom:${secret.keyTrusted}:${cmdWithoutHash}:${dateString}`
const hashOwner = `babyboom:${secret.keyOwner}:${cmdWithoutHash}:${dateString}`
const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex')
const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex')
if (cmd[cmd.length - 1] === validhashT) {
return 1
}
if(cmd[cmd.length-1]==validhashO){
return 2;
if (cmd[cmd.length - 1] === validhashO) {
return 2
}
return 0;
return 0
}

View file

@ -1,5 +1,6 @@
const fs=require("fs")
let languages={};
const fs = require('fs')
const languages = {}
const loadplug = (botno) => {
const bpl = fs.readdirSync('util/lang')
for (const i in bpl) {
@ -7,21 +8,56 @@ const loadplug = (botno) => {
continue
}
try {
languages[bpl[i].split(".")[0]]=require(`./lang/${bpl[i]}`)
languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`)
} catch (e) { console.log(e) }
}
}
loadplug()
module.exports = function (l, msg, with2) {
let message=msg.replace(/%%/g, '\ue123');
if (languages[l][message] !== undefined) {
const getMessage = function (l, msg, with2) {
let message = msg.replace(/%%/g, '\ue123')
if (languages[l] && languages[l][message] !== undefined) {
message = languages[l][message].replace(/%%/g, '\ue123')
} else if (languages["en-US"][message] !== undefined) {
message = languages["en-US"][message].replace(/%%/g, '\ue123')
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
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.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')
}
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
}
}

View file

@ -1,4 +1,6 @@
{
"language.name": "English",
"language.region": "United States",
"time.week": " week ",
"time.weekPlural": " weeks ",
"time.day": " day ",
@ -27,8 +29,6 @@
"command.refill.desc": "Refill core",
"command.say.usage": " <message>",
"command.say.desc": "Sends a message to chat",
"command.serverinfo.usage": "",
"command.serverinfo.desc": "Get system/bot info",
"command.stop.usage": "",
"command.stop.desc": "Restart bot",
"command.template.usage": " <required> [optional]",
@ -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.sourceCode": "Source code: %s",
"command.about.sourceCode.openInBrowser": "Click to open the source code link in your default browser",
"command.about.serverinfo": "To view system information, run the command %s.",
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
"command.cloop.error.subcommand": "Unknown subcommand, please do %s",
"command.cloop.success.add": "Added command loop with command %s and rate %s",
@ -59,26 +58,36 @@
"command.help.permsOwner": "Owner",
"command.help.permsConsole": "Console",
"command.help.noCommand": "Command does not exist",
"command.serverinfo.os.android": "Android",
"command.serverinfo.os.freebsd": "FreeBSD",
"command.serverinfo.os.linux": "Linux %s",
"command.serverinfo.os.macos": "macOS",
"command.serverinfo.os.macos_old": "OS X",
"command.serverinfo.os": "Operating system",
"command.serverinfo.processor": "CPU",
"command.serverinfo.arch": "Architecture",
"command.serverinfo.osUsername": "Username",
"command.serverinfo.hostName": "Hostname",
"command.serverinfo.workingDir": "Working directory",
"command.serverinfo.runTime": "Bot uptime",
"command.serverinfo.upTime": "System uptime",
"command.serverinfo.nodeVersion": "Node.js version",
"command.serverinfo.osRelease": "Linux release",
"command.serverinfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
"command.serverinfo.os.android.version": "Android version",
"command.serverinfo.os.android.model": "Device model",
"command.serverinfo.botName": "Bot name",
"command.serverinfo.botVer": "Bot version",
"command.help.alias": "Alias to %s",
"command.netmsg.disabled": "This command has been disabled on this server.",
"command.settings.get.colorPrimary": "Primary color",
"command.settings.get.colorSecondary": "Secondary color",
"command.settings.get.language": "Language",
"command.settings.setLanguage": "Run %s to set this as your language",
"command.settings.error.invalidKey": "Invalid key",
"command.settings.error.invalidLanguage": "Invalid language",
"command.settings.error.mustProvideValue": "You must provide a value",
"command.about.serverInfo.os.android": "Android %s",
"command.about.serverInfo.os.android.noVersion": "Android",
"command.about.serverInfo.os.freebsd": "FreeBSD %s",
"command.about.serverInfo.os.linux": "Linux %s",
"command.about.serverInfo.os.macos": "macOS",
"command.about.serverInfo.os.macos_old": "OS X",
"command.about.serverInfo.os": "Operating system",
"command.about.serverInfo.processor": "CPU",
"command.about.serverInfo.arch": "Architecture",
"command.about.serverInfo.osUsername": "Username",
"command.about.serverInfo.hostName": "Hostname",
"command.about.serverInfo.workingDir": "Working directory",
"command.about.serverInfo.runTime": "Bot uptime",
"command.about.serverInfo.upTime": "System uptime",
"command.about.serverInfo.nodeVersion": "Node.js version",
"command.about.serverInfo.osRelease": "Linux release",
"command.about.serverInfo.osRelease.missing": "/etc/os-release does not exist. Information may be limited.",
"command.about.serverInfo.os.android.version": "Android version",
"command.about.serverInfo.os.android.model": "Device model",
"command.about.serverInfo.botName": "Bot name",
"command.about.serverInfo.botVer": "Bot version",
"command.tpr.success": "Teleporting %s to %s, %s, %s",
"command.verify.success": "Successfully verified with permission level %s",
"command.error": "An error occured (check console for more info)",

View file

@ -1,22 +1,38 @@
const rsg = function (count) {
let output="";
let output = ''
for (let i = 0; i < count; i++) {
let rng=Math.floor(Math.random()*16)+1;
if(rng==7) rng=17; //No bells
if(rng==10) rng=18; //No line feeds
if(rng==11) rng=19; //No vertical tabulations
if(rng==12) rng=20; //No form feed
if(rng==13) rng=21; //No carriage returns
if(rng==14) rng=22; //No shift out
if(rng==15) rng=23; //No shift in
output+=String.fromCharCode(rng)
const type = Math.floor(Math.random() * 6)
switch (type) {
case 0:
output += ' '
break
case 1:
output += '§§'
break
case 2:
output += '§ '
break
case 3:
case 4:
case 5:{ // Make this case more likely
let rng = Math.floor(Math.random() * 16) + 1
if (rng === 7) rng = 17 // No bells
if (rng === 10) rng = 18 // No line feeds
if (rng === 11) rng = 19 // No vertical tabulations
if (rng === 12) rng = 20 // No form feed
if (rng === 13) rng = 21 // No carriage returns
if (rng === 14) rng = 22 // No shift out
if (rng === 15) rng = 23 // No shift in
output += `§${String.fromCharCode(rng)}`
}
return output;
}
}
return output
}
module.exports = function (legal) {
if (legal) {
return Math.floor(Math.random() * 1000000).toString()
} else {
return " \xa7"+rsg(6)+" "+rsg(4)
return rsg(6 + Math.floor(Math.random() * 3))
}
}

View file

@ -1,5 +1,5 @@
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 num_uuid = [+split_uuid[0] << 0, +split_uuid[1] << 0, +split_uuid[2] << 0, +split_uuid[3] << 0]
return num_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
}

View file

@ -1,6 +1,6 @@
{
"botName": "botvX Dev",
"botVersion": "10.0.0",
"botVersion": "10.0.0-beta.2",
"botAuthor": "a5a06d596f15c7db",
"isPreRelease": true,
"sourceURL": "https://code.chipmunk.land/7cc5c4f330d47060/botvX"