70CentsApple / ChatTools

Chat Tools 一个 Minecraft Fabric 辅助模组 | A Fabric client-side Minecraft Mod
GNU General Public License v3.0
13 stars 4 forks source link

Chat Filter Bug #39

Closed AlphaLeoli closed 2 months ago

AlphaLeoli commented 2 months ago

Bug description

When the server sends a message with multiple lines, and you set the filter to ^something here$, then even if that only matches the first line of the one message it will still disabled the full message. I know that's confusing, so I will show exactly what I mean:

This is a message that is sent in pvp legacy: image As you can see, the message is three lines.

If you make your chat filter ^\s*$, then it will remove the full message, even the actual text.

Steps to reproduce

  1. go on a server that sends multiple line messages (not to be confused with multiple messages at the same time)
  2. make the filter regex match only one of the lines in the message, with ^ and $ to make sure it's only one line
  3. see the full message disappear

Expected behavior

either only the whitespace lines should have disappeared or nothing should have. Honestly could be either, both are better than the normal functionality

Actual behavior

The whole message is removed

Relevant logs

No response

Minecraft version

1.20.4

Mod version

2.2.1

Other information

tested on play.pvplegacy.net. u can wait for a message like that or you can 1v1 someone and it will have a message at the end like that, which is "____ has won the game!"

Check list

70CentsApple commented 2 months ago

It might be weird, but it is actually working as intended. This message, which can be easily showing as \nNot an empty line.\n indeed had a match, resulting in being filtered.

img

either only the whitespace lines should have disappeared

It will be difficult and unnessasary to split those message into lines and deal with them seperately, so 🤷.

or nothing should have.

Then just modify or disable this RegEx rule.

AlphaLeoli commented 2 months ago

well hold on there's gotta be some solution... i know you said it's working as intended but then that means there is no way to remove messages that are only whitespace without removing messages that have whitespace and then a new line

what if you used # 3 in this to make it so that it only replaces the \n with ""?

or what if instead of fixing the problem that it matches the one line and then deletes the other lines, you can just re append the message to chat. like, it matches the \n line, and removes "\n hello there \n", but then a clientside message "hello there" is sent?

or maybe, for each message that is checked for the filter, it first removes the new lines and makes them empty messages (or a new message with the text) and then runs the checks on those seperately??? idk...

70CentsApple commented 2 months ago

what if you used # 3 in this to make it so that it only replaces the \n with ""?

Personally, I consider this a good idea. You will be able to turn ^\s$ into nothing, and everything will work well.