Fix for filtering curse words

This patch adds a fix for filtering out curse words.
This adds a flag to the regex to ignore case!
This commit is contained in:
Hemna 2024-03-23 18:02:01 -04:00
parent 873fc06608
commit f400c6004e
2 changed files with 6 additions and 3 deletions

View File

@ -171,7 +171,10 @@ class Packet:
message = msg[:67] message = msg[:67]
# We all miss George Carlin # We all miss George Carlin
return re.sub("fuck|shit|cunt|piss|cock|bitch", "****", message) return re.sub(
"fuck|shit|cunt|piss|cock|bitch", "****",
message, flags=re.IGNORECASE,
)
def __str__(self) -> str: def __str__(self) -> str:
"""Show the raw version of the packet""" """Show the raw version of the packet"""

View File

@ -272,8 +272,8 @@ class TestPacketBase(unittest.TestCase):
# test with bad words # test with bad words
# Currently fails with mixed case # Currently fails with mixed case
message = "My cunt piss fuck text" message = "My cunt piss fuck shIt text"
exp_msg = "My **** **** **** text" exp_msg = "My **** **** **** **** text"
msgno = "ABX" msgno = "ABX"
packet = packets.MessagePacket( packet = packets.MessagePacket(
from_call=fake.FAKE_FROM_CALLSIGN, from_call=fake.FAKE_FROM_CALLSIGN,