AdvancedChat icon indicating copy to clipboard operation
AdvancedChat copied to clipboard

[FEATURE] Add multiple conditions to filters

Open sphings79 opened this issue 6 years ago • 12 comments

Describe the bug set the case to "findstring|(?i)ignorestring

Minecraft Info Minecraft information:

  • AdvancedChat-2.0.3-1.15.2-beta.jar

To Reproduce Steps to reproduce the behavior:

  1. Go to 'chatfilter'
  2. Set filter like described
  3. Set filter methode to REGEX
  4. Save and test in chat.

Expected behavior The ignorecase in the chatfilter won't work.

sphings79 avatar Jul 27 '20 17:07 sphings79

May have accidentally told the wrong regex filter for ignore case. The ? and the i need to be reversed. This should work: findstring|(i?)ignoreString

DarkKronicle avatar Jul 27 '20 20:07 DarkKronicle

Sorry but still won't work. findstring|(i?)ignoreString will give me a sound notification if i write both in chat.

sphings79 avatar Jul 27 '20 21:07 sphings79

Sorry, but what exactly are you trying to have the regex do? I was using an online regex tester and it said that ?i was incorrect, and that is why I told you that i? would work. It is actually (?i) that works. The regex that is correct and what you were using (findstring|(?i)ignoreString) will notify you if it finds 'findstring' exactly, and then 'ignoreString' in any case (i.e. 'IGNOREstRing', 'ignorestring'... etc). I just tested it on my client and it works as expected.

DarkKronicle avatar Jul 27 '20 23:07 DarkKronicle

Can you give me your full regex expression that you are using without the placeholder names?

DarkKronicle avatar Jul 27 '20 23:07 DarkKronicle

[13:00:47] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] sphings ? : findstring ignoreString [13:00:58] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] sphings ? : ignoreString

{ "name": "Default", "active": true, "findString": "findstring|(i?)ignoreString", "findType": "regex", "replaceType": "none", "replaceTo": "AWESOME!", "notifySound": "BEACON_ACTIVATE", "soundPitch": 1.0, "soundVol": 1.0, "replaceBackgroundColor": false, "color": { "red": 0, "green": 0, "blue": 0, "alpha": 255, "color": -16777216 }

Will give me a sound even if i only type the ignoreString into the chat.

sphings79 avatar Jul 28 '20 11:07 sphings79

{ "name": "Default", "active": true, "findString": "findstring|(?i)ignoreString", "findType": "regex", "replaceType": "none", "replaceTo": "AWESOME!", "notifySound": "BEACON_ACTIVATE", "soundPitch": 1.0, "soundVol": 1.0, "replaceBackgroundColor": false, "color": { "red": 0, "green": 0, "blue": 0, "alpha": 255, "color": -16777216 }

[13:05:49] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] sphings ? : ignoreString [13:05:54] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] sphings ? : findstring ignoreString

Will also give me a sound alert on both lines.

sphings79 avatar Jul 28 '20 11:07 sphings79

Then it works how the expression works. It doesn't 'ignore' a string with that expression, it ignores case on that string. I currently don't know how to accomplish what you are trying to do. You may want to google some regex expression help. If I find anything I'll let you know.

DarkKronicle avatar Jul 28 '20 21:07 DarkKronicle

[13:05:49] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] sphings ? : Hey there ... [13:06:49] [main/INFO]: [CHAT] [Plot Chat][2;5] [Master] TESTUSER ? : Hey sphings whats up? [13:07:49] [main/INFO]: [CHAT] [Plot Chat][2;5] : Welcome to the communityfarm. regards sphings

In the first line i don't want to get an audio notification, cuase i'm writing my self. so i thougt, i can ignore these line with (?i)sphings ? :

in the second line i want to get a notification, cause someone wrote my name in chat.

in the third line i don't want to get an alert cuase this message was generated out of plotsquared every time i visit my plot. so i added (?i)communityfarm

I thout it would be possible to use the regex like this: sphings|(?i)sphings ? :|(?i)communityfarm

I hope you understand what i want to do :)

sphings79 avatar Jul 29 '20 13:07 sphings79

I'm sorry, I have been messing around with regex for a bit and am not experienced enough to come up with an answer for you. You could maybe do some research online. I may add multiple cases for filters to be able to achieve what you want in the future.

DarkKronicle avatar Jul 29 '20 22:07 DarkKronicle

That would be really great. I'm also note the buddy for regex :D

sphings79 avatar Jul 29 '20 22:07 sphings79

I know that this question is 4 months old and you probably don't need it anymore, but "(?<!] |regards )sphings" should do what you described. (?<! .... ) ist the beginning of a negative lookbehind and if any of the following strings appears before sphings, the regex fails. So "] " stops the notification when you write something yourself, because it detects the closing bracket in [Master] before your name. And "regards " stops the notification for the plot message. The "|" works as an or and seperates the two strings in the negative lookbehind

Toseflo avatar Dec 02 '20 13:12 Toseflo

Children should fix this issue :)

DarkKronicle avatar Apr 19 '21 22:04 DarkKronicle