moiph / ub3r-b0t

A Discord/IRC Bot
MIT License
94 stars 27 forks source link

Moderation - Regex Capturing doesn't exactly work correctly #30

Closed GDSeirya closed 2 years ago

GDSeirya commented 2 years ago

I'm trying to catch a bulk of people doing nitro scams with the regex capture tool, but it doesn't appear to be working as expected. I'm using a tool to write regex - multiples: https://regex101.com/ https://lsvhome.github.io/regex-tester/ http://regexstorm.net/tester And they all capture as expected. When I add the regex in, it doesn't capture correctly, and when it does, it captures the wrong things. The regex is here: (https?\:\/\/)(?!discord\.(?:com|gg))(?!cdn\.discordapp\.com)(?!cdn\.discordapp\.com)(?!(support|blog)\.discord\.com)(?!discordstatus\.com)(?!discord\.gift)(?!discord\.me)(?!discord\.js\.org)([^. \r\n\t]*?\.?[dbqp]+[il1]+[sz]+)([-.])?(c+[rdesflo01g]*)(\w)*[-.]*(g*f*[1il]*f[t]s*)?(n[1il]*tr[0o])? When I link something from cdn.discord, it captures it when the tools I've used does not capture it. That's a false positive.

moiph commented 2 years ago

I'm not sure what your exact test case is, but you can fiddle around here as an example: https://dotnetfiddle.net/TST6JW

GDSeirya commented 2 years ago

Hey, This should return false for the bot. The dotnet fiddle returns false - is expected. https://cdn.discordapp.com/attachments/151899390229872640/935696165494743110/tomPLS.jpg Ub3r B0t in action reads the above as true. That's not correct.

moiph commented 2 years ago

Stop by the support server (https://ub3r-b0t.com/join) with your server ID and we can try to debug what's not working

GDSeirya commented 2 years ago

I've been informed that there is an accumulated total max number of characters you can put into the regex. The bot was silently clipping excess characters. I've also been informed that the config should inform me that I've went over the limit - it not doing that is a bug.