This commit is contained in:
7cc5c4f330d47060 2024-08-25 22:31:09 -04:00
parent 49485b1040
commit a608d852dd
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
5 changed files with 38 additions and 38 deletions

View file

@ -204,7 +204,7 @@ const displayServerList = function (c) {
index.bot.forEach((item, i) => {
if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return
let message = 'command.about.serverListItem'
if (c.bot.id == i) message = 'command.about.serverListItem.thisServer'
if (c.bot.id === i) message = 'command.about.serverListItem.thisServer'
c.reply({
translate: getMessage(c.lang, message),
color: c.colors.secondary,

View file

@ -3,7 +3,7 @@ const fs = require('fs')
const settings = require('../settings.json')
module.exports = {
execute: (c) => {
if (c.type == 'console') {
if (c.type === 'console') {
c.reply({
text: getMessage(c.lang, 'command.settings.disabled.console'),
color: c.colors.secondary

View file

@ -4,11 +4,11 @@ const parseConsole = require('../util/chatparse_console.js')
const parse1204 = require('../util/parseNBT.js')
const { getMessage } = require('../util/lang.js')
const convertChatStyleItem = (item) => {
let output={};
const output = {}
for (const i in item) {
output[i] = item[i].value
}
return output;
return output
}
const convertChatTypeItem = (item) => {
if (item.style) {
@ -27,16 +27,16 @@ const convertChatTypeItem = (item) => {
}
module.exports = {
load: (b) => {
b.messageCount = 0;
b.chatDisabledUntil = 0;
b.messageCount = 0
b.chatDisabledUntil = 0
b.interval.antiSpam = setInterval(() => {
b.messageCount = 0;
b.messageCount = 0
}, 4000)
b.messageTypes = []
b._client.on('registry_data', (data) => {
if (data.codec.value['minecraft:chat_type']) {
b.messageTypes = data.codec.value['minecraft:chat_type']
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value;
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value
nbtItems.forEach((item, i) => {
b.messageTypes[i] = convertChatTypeItem(item.element.value.chat.value)
})
@ -44,24 +44,24 @@ module.exports = {
})
b._client.on('profileless_chat', (data) => {
const messageType = b.messageTypes[data.type]
let json = {translate: messageType.translation_key, with: []}
const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => {
if(item == "content"){
if (item === 'content') {
json.with[i] = parse1204(data.message)
} else if(item == "sender"){
} else if (item === 'sender') {
json.with[i] = parse1204(data.name)
} else if(item == "target"){
} else if (item === 'target') {
json.with[i] = parse1204(data.target)
}
})
for (const i in messageType.style) {
json[i] = messageType.style[i]
}
let username = ""
let nickname = ""
let uuid = "00000000-0000-0000-0000-000000000000"
let message = ""
if (messageType.translation_key == "%s") {
let username = ''
let nickname = ''
let uuid = '00000000-0000-0000-0000-000000000000'
let message = ''
if (messageType.translation_key === '%s') {
const parsed = parsePlain(json)
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
@ -69,7 +69,7 @@ module.exports = {
nickname = chatNameSplit[chatNameSplit.length - 1]
username = b.findRealName(chatName)
uuid = b.findUUID(username)
message = split.join(": ")
message = split.join(': ')
} else {
message = parsePlain(parse1204(data.message))
uuid = b.findUUID(parsePlain(parse1204(data.name)))
@ -77,7 +77,7 @@ module.exports = {
username = parsePlain(parse1204(data.name))
}
b.emit('chat', {
json: json,
json,
type: 'profileless',
uuid,
message,
@ -88,17 +88,17 @@ module.exports = {
b._client.on('player_chat', (data) => {
const messageType = b.messageTypes[data.type]
let json = {translate: messageType.translation_key, with: []}
const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => {
if(item == "content"){
if(messageType.translation_key === "%s"){
if (item === 'content') {
if (messageType.translation_key === '%s') {
json.with[i] = parse1204(data.unsignedChatContent)
} else {
json.with[i] = data.plainMessage
}
} else if(item == "sender"){
} else if (item === 'sender') {
json.with[i] = parse1204(data.networkName)
} else if(item == "target"){
} else if (item === 'target') {
json.with[i] = parse1204(data.networkTargetName)
}
})
@ -106,7 +106,7 @@ module.exports = {
json[i] = messageType.style[i]
}
b.emit('chat', {
json: json,
json,
type: 'player',
uuid: data.senderUuid,
message: data.plainMessage,
@ -169,10 +169,10 @@ module.exports = {
})
b.on('chat', (data) => {
b.messageCount++;
b.messageCount++
if (Date.now() < b.chatDisabledUntil) return
if (b.messageCount >= 100) {
b.info(getMessage(settings.defaultLang, "chat.antiSpamTriggered"))
b.info(getMessage(settings.defaultLang, 'chat.antiSpamTriggered'))
b.chatDisabledUntil = Date.now() + 30000
return
}