Skip to content

Commit b208c6d

Browse files
committed
Make search_keyword search regex patterns too
1 parent 3e53880 commit b208c6d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cogs/automod.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,18 @@ async def search_keyword(self, interaction: discord.Interaction, word: str):
7575
for keyword in rule.trigger.keyword_filter:
7676
if word in keyword:
7777
count += 1
78-
matches[rule.name].append(f"{keyword} contains {word}")
79-
text = ""
78+
matches[rule.name].append(keyword)
79+
for keyword in rule.trigger.regex_patterns:
80+
if word in keyword:
81+
count += 1
82+
matches[rule.name].append(f"{keyword} (Regex)")
83+
text = f"Matches for {word}\n"
8084
if not count:
8185
return await interaction.response.send_message("No match found.")
8286
for rule_name in matches:
8387
if not matches[rule_name]:
8488
continue
85-
text = f'Rule {rule_name}:\n ' + ' \n'.join(matches[rule_name])
89+
text = f' Rule {rule_name}:\n' + ' \n'.join(matches[rule_name])
8690
file = text_to_discord_file(text, name='matches.txt')
8791
await interaction.response.send_message(f"{count} matches found.", file=file)
8892

0 commit comments

Comments
 (0)