Merge pull request #67 from Ryujinx/feature/configurable-suspect-words

logs: Make suspect words configurable
This commit is contained in:
Ave 2020-04-09 23:54:52 +03:00 committed by GitHub
commit 534085fb5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View file

@ -20,18 +20,10 @@ class Logs(Cog):
self.name_re = re.compile(r"[a-zA-Z0-9].*")
self.clean_re = re.compile(r'[^a-zA-Z0-9_ ]+', re.UNICODE)
# 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
word in self.susp_words])
word in config.suspect_words])
self.susp_hellgex = re.compile(susp_hellgex, re.IGNORECASE)
self.ok_words = []
@Cog.listener()
async def on_member_join(self, member):
await self.bot.wait_until_ready()
@ -162,9 +154,9 @@ class Logs(Cog):
msg += f"\n- Has invite: https://{invite[0]}"
alert = True
for susp_word in self.susp_words:
for susp_word in config.suspect_words:
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}`"
alert = True

View file

@ -103,3 +103,14 @@ list_files_channel = 0
# Channels that are lists that are controlled by the lists cog.
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 = []