Skip to content

Commit

Permalink
cleanup missed stuff
Browse files Browse the repository at this point in the history
so findspam.py is fully reload-able
  • Loading branch information
iBug committed Sep 2, 2018
1 parent a2da933 commit e93d744
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions chatcommands.py
Expand Up @@ -5,7 +5,6 @@
# noinspection PyUnresolvedReferences
from globalvars import GlobalVars
import findspam
from findspam import FindSpam
# noinspection PyUnresolvedReferences
from datetime import datetime
from utcdate import UtcDate
Expand Down Expand Up @@ -202,8 +201,8 @@ def check_blacklist(string_to_test, is_username, is_watchlist, is_phone):
'owner': {'display_name': "Valid username", 'reputation': 1, 'link': ''},
'site': "", 'IsAnswer': True, 'score': 0})

question_reasons, _ = FindSpam.test_post(question)
answer_reasons, _ = FindSpam.test_post(answer)
question_reasons, _ = findspam.FindSpam.test_post(question)
answer_reasons, _ = findspam.FindSpam.test_post(answer)

# Filter out duplicates
reasons = list(set(question_reasons) | set(answer_reasons))
Expand Down Expand Up @@ -252,7 +251,7 @@ def do_blacklist(blacklist_type, msg, force=False):
# noinspection PyProtectedMember
pattern = rebuild_str(msg.content_source.split(" ", 1)[1])
try:
regex.compile(pattern, city=FindSpam.city_list)
regex.compile(pattern, city=findspam.FindSpam.city_list)
except regex._regex_core.error:
raise CmdException("An invalid pattern was provided, not blacklisting.")

Expand Down Expand Up @@ -619,7 +618,7 @@ def pull():
"""
if only_blacklists_changed(GitManager.get_remote_diff()):
GitManager.pull_remote()
FindSpam.reload_blacklists()
findspam.FindSpam.reload_blacklists()
GlobalVars.reload()
tell_rooms_with('debug', GlobalVars.s_norestart)
return
Expand Down Expand Up @@ -864,7 +863,7 @@ def test(content, alias_used="test"):
'owner': {'display_name': content, 'reputation': 1, 'link': ''},
'site': site, 'IsAnswer': False, 'score': 0})

reasons, why_response = FindSpam.test_post(fakepost)
reasons, why_response = findspam.FindSpam.test_post(fakepost)

if len(reasons) == 0:
result += "Would not be caught as {}".format(kind)
Expand Down
4 changes: 2 additions & 2 deletions metasmoke.py
Expand Up @@ -147,7 +147,7 @@ def handle_websocket_data(data):
integrity = blacklist_integrity_check()
if len(integrity) == 0: # No issues
GitManager.pull_remote()
findspam.FindSpam.reload_blacklists()
findspam.reload_blacklists()
chatcommunicate.tell_rooms_with("debug", "No code modified in {0}, only blacklists"
" reloaded.".format(commit_md))
else:
Expand All @@ -173,7 +173,7 @@ def handle_websocket_data(data):
log('warning', "Pulling remote with HEAD detached, checkout deploy", f=True)
os._exit(8)
GlobalVars.reload()
findspam.FindSpam.reload_blacklists()
findspam.reload_blacklists()
chatcommunicate.tell_rooms_with('debug', GlobalVars.s_norestart)
elif only_modules_changed(remote_diff):
GitManager.pull_remote()
Expand Down
4 changes: 2 additions & 2 deletions spamhandling.py
@@ -1,7 +1,7 @@
# coding=utf-8
import sys
import random
from findspam import FindSpam
import findspam
import datahandling
import chatcommunicate
from globalvars import GlobalVars
Expand All @@ -24,7 +24,7 @@ def should_whitelist_prevent_alert(user_url, reasons):

# noinspection PyMissingTypeHints
def check_if_spam(post):
test, why = FindSpam.test_post(post)
test, why = findspam.FindSpam.test_post(post)
if datahandling.is_blacklisted_user(parsing.get_user_from_url(post.user_url)):
test.append("blacklisted user")
blacklisted_user_data = datahandling.get_blacklisted_user_data(parsing.get_user_from_url(post.user_url))
Expand Down

0 comments on commit e93d744

Please sign in to comment.