Change how strings work

This commit is contained in:
7cc5c4f330d47060 2024-08-08 03:01:25 -04:00
parent af0b2405b4
commit 7d93eafd72
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
6 changed files with 11 additions and 11 deletions

View file

@ -81,7 +81,7 @@ module.exports = {
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors))
const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0] const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]
const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0] const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), `${dBrand} ${dModel}`, c.colors))
} }
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors)) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors))
} }

View file

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

View file

@ -17,9 +17,9 @@ const hexColorParser = (color) => {
return '' return ''
} }
let out = '\x1B[0;' let out = '\x1B[0;'
const redChannel = Number('0x' + color.slice(1, 3)) const redChannel = Number(`0x${color.slice(1, 3)}`)
const greenChannel = Number('0x' + color.slice(3, 5)) const greenChannel = Number(`0x${color.slice(3, 5)}`)
const blueChannel = Number('0x' + color.slice(5, 7)) const blueChannel = Number(`0x${color.slice(5, 7)}`)
if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) { if (!consoleColors24.lightMode && redChannel < 64 && greenChannel < 64 && blueChannel < 64) {
out += '48;2;220;220;220;' out += '48;2;220;220;220;'
} else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) { } else if (consoleColors24.lightMode && ((redChannel > 192 && greenChannel > 192 && blueChannel > 192) || greenChannel > 160)) {
@ -98,7 +98,7 @@ const parse2 = function (_data, l, resetColor) {
return parse(_data) return parse(_data)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
return '\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data) return `\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ${JSON.stringify(_data)}`
} }
} }
module.exports = parse2 module.exports = parse2

View file

@ -49,7 +49,7 @@ const parse2 = function (_data, l) {
return parse(_data) return parse(_data)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
return 'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data) return `An error occured while parsing a message. See console for more information. JSON that caused the error: ${JSON.stringify(_data)}`
} }
} }
module.exports = parse2 module.exports = parse2

View file

@ -5,8 +5,8 @@ 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) {

View file

@ -1,5 +1,5 @@
module.exports = function (uuid) { module.exports = function (uuid) {
const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g) const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return `0x${a}` }).match(/.{1,10}/g)
const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0] const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0]
return numUUID return numUUID
} }