christopher commited on
Commit
6e40ba5
·
verified ·
1 Parent(s): 15b70fb

Update forbidden strings

Browse files

Attempted to implement a fix for this: https://huggingface.co/spaces/discord-community/HuggingMod/discussions/5

Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -68,8 +68,10 @@ async def on_message(message):
68
  """Antispam"""
69
  #Detecting certain unwanted strings
70
  try:
71
- forbidden_strings = ["@everyone", "@here"]
72
- if any(string.lower() in message.content.lower() for string in forbidden_strings):
 
 
73
  ignored_role_ids = [897381378172264449, 897376942817419265] #admins, huggingfolks
74
  if any(role.id in ignored_role_ids for role in message.author.roles):
75
  if message.author != lunarflu:
 
68
  """Antispam"""
69
  #Detecting certain unwanted strings
70
  try:
71
+ forbidden_patterns = [r"@everyone",
72
+ r"@here",
73
+ r"(https?:\/\/|http?:\/\/)?(www.)?(discord.(gg|io|me|li)|discordapp.com\/invite|discord.com\/invite)\/[^\s\/]+?(?=\b)"]
74
+ if any(re.search(pattern, message.content, re.IGNORECASE) for pattern in forbidden_patterns):
75
  ignored_role_ids = [897381378172264449, 897376942817419265] #admins, huggingfolks
76
  if any(role.id in ignored_role_ids for role in message.author.roles):
77
  if message.author != lunarflu: