mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

message event processing issue.. crash down your bot

Open AsherJingkongChen opened this issue 3 years ago • 7 comments

  • [ ] The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 3.11.2
  • server: paper 1.17.1
  • node: 16.11.0

Detailed description of a problem

When I put 32*[] on the chatroom: [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] The bot stuck in the event processing, because I can't see the message or jsonMsg in 'message' or 'messagestr' event via console.log().

What did you try yet?

  1. Whether console.log(jsonMsg) exists, bot crashes down.
  2. When 32[] is sent, the bot stopped any process.
  3. Take 2 times long to finish processing to display on console as one more [] is sent. 31[] => took 60s to finish. 30[] => took 30s to finish. 29[] => took 15s to finish. 28[] => took 7s to finish. 27[] => took 3s to finish.

Your current code

const mineflayer = require('mineflayer')
const bot = mineflayer.createBot({~Options~})
bot.on('messagestr',(message, messagePosition, jsonMsg)=>{console.log(message)})

Expected behavior

<bot> [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] displayed on the console.

Additional context

Maybe it doesn't work on other servers, but it may works if it's 64[] in singleplayer 1.17.1 Thanks if you try to help out!

AsherJingkongChen avatar Nov 07 '21 14:11 AsherJingkongChen

can you try adding a return at the line before there https://github.com/PrismarineJS/mineflayer/blob/8bdce55dc3e0311ab979bc901b53f85becf7abce/lib/plugins/chat.js#L174 and try again?

rom1504 avatar Nov 07 '21 15:11 rom1504

can you try adding a return at the line before there

https://github.com/PrismarineJS/mineflayer/blob/8bdce55dc3e0311ab979bc901b53f85becf7abce/lib/plugins/chat.js#L174

and try again?

Do you mean: 截圖 2021-11-07 下午11 12 17

AsherJingkongChen avatar Nov 07 '21 15:11 AsherJingkongChen

Thanks @rom1504! it works!

AsherJingkongChen avatar Nov 07 '21 15:11 AsherJingkongChen

ok I guess that is one valid use case of #2247 then and also of fixing these regex to not be so easy to break

rom1504 avatar Nov 07 '21 15:11 rom1504

https://github.com/PrismarineJS/mineflayer/issues/2328#issuecomment-985246695 temporary workaround

U5B avatar Dec 03 '21 06:12 U5B

What is a proper solution for this? A better chat regex?

Zn10plays avatar Feb 09 '22 23:02 Zn10plays

What is a proper solution for this? A better chat regex?

A proper solution is to make chat regexes in prismarine-chat that support different server chat formats such as vanilla, essential and hypixel. Another thing that could be added to prismarine-chat or minecraft-data is a list of chat regexes for various servers.

The problem with this regex is that it tries to match too many things at once, and matching too many things at once can lead to mistakes or regex dos.

U5B avatar Feb 10 '22 19:02 U5B