Make echo send the message normally, and don't use non-initialized memory for the acknowledged buffer
This commit is contained in:
parent
5a1eff9e1b
commit
93f911aaa8
2 changed files with 16 additions and 2 deletions
|
@ -16,6 +16,20 @@ module.exports = {
|
|||
|
||||
echoCommand (context) {
|
||||
const bot = context.source.bot
|
||||
bot.core.run(`essentials:sudo ${bot.uuid} c:${context.getArgument('message')}`)
|
||||
bot.chat.queue.push(this.sanitize(context.getArgument('message')))
|
||||
},
|
||||
|
||||
sanitize (message) {
|
||||
let clean = ''
|
||||
|
||||
for (let i = 0; i < message.length && clean.length < 256; i++) {
|
||||
const c = message[i]
|
||||
const cc = c.charCodeAt(0)
|
||||
|
||||
if (cc < 0x20 || cc === 0x7f || cc === 0xa7) continue
|
||||
clean += c
|
||||
}
|
||||
|
||||
return clean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ function inject (bot) {
|
|||
timestamp: BigInt(Date.now()),
|
||||
salt: 0n,
|
||||
offset: 0,
|
||||
acknowledged: Buffer.allocUnsafe(3)
|
||||
acknowledged: Buffer.alloc(3)
|
||||
})
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue