Fixed config issues

This commit is contained in:
Collin R
2020-02-05 10:39:05 -08:00
parent a0462d3bda
commit deff37a30f
3 changed files with 18 additions and 32 deletions

View File

@@ -19,7 +19,6 @@ TEST_COMMENTS = False
def run():
#cfg = config.Config.load()
cfg = config.load()
levels = cfg.levels
@@ -42,10 +41,6 @@ def run():
db = database.Database(cfg.database_path)
# The pattern that determines whether a post is marked as solved
# Could also just use re.IGNORECASE flag
# solved_pat = re.compile('![Ss]olved')
# Monitor new comments for confirmed solutions
# Passing pause_after=0 will bypass the internal exponential delay; instead,
# have to check if any comments are returned with each query
@@ -56,9 +51,7 @@ def run():
print_level(0, '\nFound comment')
print_level(1, f'Comment text: "{comm.body}"')
# if marks_as_solved(comm, solved_pat):
if marks_as_solved(comm):
# if not is_first_solution(comm, solved_pat):
if not is_first_solution(comm):
# Skip this "!solved" comment and wait for the next
print_level(1, 'Not the first solution')
@@ -100,30 +93,23 @@ def run():
### Reddit Comment Functions ###
# def marks_as_solved(comment, solved_pattern):
def marks_as_solved(comment):
'''Return True if the comment meets the criteria for marking the submission
as solved, False otherwise.
'''
op_resp_to_solver = (comment.is_submitter
and comment.parent() != comment.submission
op_resp_to_solver = (not comment.is_root
and comment.is_submitter
and not comment.parent().is_submitter
and SOLVED_PAT.search(comment.body))
mod_resp_to_solver = (comment.subreddit.moderator(redditor=comment.author)
# Mod can only used MOD_SOLVED_PAT on any post, including their own
mod_resp_to_solver = (not comment.is_root
and comment.subreddit.moderator(redditor=comment.author)
and MOD_SOLVED_PAT.search(comment.body))
return not comment.is_root and (op_resp_to_solver or mod_resp_to_solver)
"""
return (not comment.is_root
and comment.is_submitter
and not comment.parent().is_submitter
and solved_pattern.search(comment.body))
"""
return op_resp_to_solver or mod_resp_to_solver
# def is_first_solution(solved_comment, solved_pattern):
def is_first_solution(solved_comment):
# Retrieve any comments hidden by "more comments"
# Passing limit=0 will replace all "more comments"
@@ -133,7 +119,6 @@ def is_first_solution(solved_comment):
# Search the flattened comments tree
for comment in submission.comments.list():
if (comment.id != solved_comment.id
# and marks_as_solved(comment, solved_pattern)
and marks_as_solved(comment)
and comment.created_utc < solved_comment.created_utc):
# There is an earlier comment for the same submission