logs: Make suspect words configurable
This commit move the hardcoded suspect words to the configuration.
This commit is contained in:
parent
9433380a69
commit
95dd28d7a6
2 changed files with 14 additions and 11 deletions
14
cogs/logs.py
14
cogs/logs.py
|
@ -20,18 +20,10 @@ class Logs(Cog):
|
||||||
self.name_re = re.compile(r"[a-zA-Z0-9].*")
|
self.name_re = re.compile(r"[a-zA-Z0-9].*")
|
||||||
self.clean_re = re.compile(r'[^a-zA-Z0-9_ ]+', re.UNICODE)
|
self.clean_re = re.compile(r'[^a-zA-Z0-9_ ]+', re.UNICODE)
|
||||||
# All lower case, no spaces, nothing non-alphanumeric
|
# All lower case, no spaces, nothing non-alphanumeric
|
||||||
self.susp_words = ["sx", "tx", "reinx", # piracy-enabling cfws
|
|
||||||
"gomanx", # piracy-enabling cfws
|
|
||||||
"tinfoil", "dz", # title managers
|
|
||||||
"goldleaf", "lithium", # title managers
|
|
||||||
"cracked", # older term for pirated games
|
|
||||||
"xci", "nsz"] # "backup" format
|
|
||||||
susp_hellgex = "|".join([r"\W*".join(list(word)) for
|
susp_hellgex = "|".join([r"\W*".join(list(word)) for
|
||||||
word in self.susp_words])
|
word in config.suspect_words])
|
||||||
self.susp_hellgex = re.compile(susp_hellgex, re.IGNORECASE)
|
self.susp_hellgex = re.compile(susp_hellgex, re.IGNORECASE)
|
||||||
|
|
||||||
self.ok_words = []
|
|
||||||
|
|
||||||
@Cog.listener()
|
@Cog.listener()
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
|
@ -162,9 +154,9 @@ class Logs(Cog):
|
||||||
msg += f"\n- Has invite: https://{invite[0]}"
|
msg += f"\n- Has invite: https://{invite[0]}"
|
||||||
alert = True
|
alert = True
|
||||||
|
|
||||||
for susp_word in self.susp_words:
|
for susp_word in config.suspect_words:
|
||||||
if susp_word in cleancont and\
|
if susp_word in cleancont and\
|
||||||
not any(ok_word in cleancont for ok_word in self.ok_words):
|
not any(ok_word in cleancont for ok_word in config.suspect_ignored_words):
|
||||||
msg += f"\n- Contains suspicious word: `{susp_word}`"
|
msg += f"\n- Contains suspicious word: `{susp_word}`"
|
||||||
alert = True
|
alert = True
|
||||||
|
|
||||||
|
|
|
@ -103,3 +103,14 @@ list_files_channel = 0
|
||||||
|
|
||||||
# Channels that are lists that are controlled by the lists cog.
|
# Channels that are lists that are controlled by the lists cog.
|
||||||
list_channels = []
|
list_channels = []
|
||||||
|
|
||||||
|
# All lower case, no spaces, nothing non-alphanumeric
|
||||||
|
suspect_words = ["sx", "tx", "reinx", # piracy-enabling cfws
|
||||||
|
"gomanx", # piracy-enabling cfws
|
||||||
|
"tinfoil", "dz", # title managers
|
||||||
|
"goldleaf", "lithium", # title managers
|
||||||
|
"cracked", # older term for pirated games
|
||||||
|
"xci", "nsz"] # "backup" format
|
||||||
|
|
||||||
|
# List of words that will be ignored if they match one of the suspect_words (This is used to remove false positives)
|
||||||
|
suspect_ignored_words = []
|
||||||
|
|
Loading…
Reference in a new issue