Skip to content

Commit

Permalink
improve pre-blacklist checking logics
Browse files Browse the repository at this point in the history
  • Loading branch information
𝐢𝐁𝐮𝐠 ♦ committed Jan 22, 2019
1 parent b296073 commit b6ffc06
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions chatcommands.py
Expand Up @@ -208,23 +208,22 @@ def check_blacklist(string_to_test, is_username, is_watchlist, is_phone):
reasons = list(set(question_reasons) | set(answer_reasons))

# Filter out watchlist results
filter_out = ["potentially bad ns", "potentially bad asn"]
filter_out = ["potentially bad ns", "potentially bad asn", "potentially problematic"]
if not is_watchlist:
filter_out.append("potentially bad keyword")
# Ignore "Mostly non-latin body/answer" for phone number watches
if is_phone:
filter_out.extend(["mostly non-latin", "phone number detected", "messaging number detected"])

if filter_out:
reasons = list(filter(
lambda reason: all([x not in reason.lower() for x in filter_out]), reasons))
reasons = [reason for reason in reasons if all([x not in reason.lower() for x in filter_out])]

return reasons


def format_blacklist_reasons(reasons):
# Capitalize
reasons = list(map(lambda reason: reason.capitalize(), reasons))
reasons = [reason.capitalize() for reason in reasons]

# Join
if len(reasons) < 3:
Expand Down Expand Up @@ -255,7 +254,7 @@ def do_blacklist(blacklist_type, msg, force=False):
r = regex.compile(pattern, city=findspam.city_list)
except regex._regex_core.error:
raise CmdException("An invalid pattern was provided, please check your command.")
if r.search(GlobalVars.valid_content):
if r.search(GlobalVars.valid_content) is not None:
raise CmdException("That pattern is probably too broad, refusing to commit.")

if not force:
Expand Down

0 comments on commit b6ffc06

Please sign in to comment.