Skip to content

Commit

Permalink
Merge pull request #2245 from iBug/feature-1
Browse files Browse the repository at this point in the history
Show reasons for posts reported via MS
  • Loading branch information
ArtOfCode- committed Jun 11, 2018
2 parents 36c9609 + 819e1f3 commit cb19df2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
8 changes: 3 additions & 5 deletions chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,12 +1166,10 @@ def report(msg, args):
batch = " (batch report: post {} out of {})".format(index, len(urls))

if scan_spam:
why_append = ', '.join(scan_reasons)
why_append = ''.join(["This post would have also been caught for: ",
why_append[0].upper() + why_append[1:],
'\n' + scan_why])
why_append = u"This post would have also been caught for: " + ", ".join(scan_reasons).capitalize() + \
'\n' + scan_why
else:
why_append = "This post would not have been caught otherwise."
why_append = u"This post would not have been caught otherwise."

handle_spam(post=post,
reasons=["Manually reported " + post_data.post_type + batch],
Expand Down
27 changes: 15 additions & 12 deletions metasmoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,23 @@ def handle_websocket_data(data):
and not datahandling.is_false_positive((post_data.post_id, post_data.site)):
return
user = parsing.get_user_from_url(post_data.owner_url)
post = classes.Post(api_response=post_data)

scan_spam, scan_reasons, scan_why = spamhandling.check_if_spam(post)
if scan_spam:
why_append = u"This post would have also been caught for: " + \
u", ".join(scan_reasons).capitalize() + "\n" + scan_why
else:
why_append = u"This post would not have been caught otherwise."

# Add user to blacklist *after* post is scanned
if user is not None:
datahandling.add_blacklisted_user(user, "metasmoke", post_data.post_url)
why = u"Post manually reported by user *{}* from metasmoke.\n".format(message["report"]["user"])
postobj = classes.Post(api_response={'title': post_data.title, 'body': post_data.body,
'owner': {'display_name': post_data.owner_name,
'reputation': post_data.owner_rep,
'link': post_data.owner_url},
'site': post_data.site,
'is_answer': (post_data.post_type == "answer"),
'score': post_data.score, 'link': post_data.post_url,
'question_id': post_data.post_id,
'up_vote_count': post_data.up_vote_count,
'down_vote_count': post_data.down_vote_count})
spamhandling.handle_spam(post=postobj,

why = u"Post manually reported by user *{}* from metasmoke.\n\n{}".format(
message["report"]["user"], why_append)

spamhandling.handle_spam(post=post,
reasons=["Manually reported " + post_data.post_type],
why=why)
elif "deploy_updated" in message:
Expand Down

0 comments on commit cb19df2

Please sign in to comment.