Skip to content

Commit

Permalink
Send user details to metasmoke
Browse files Browse the repository at this point in the history
  • Loading branch information
Undo1 committed Sep 21, 2015
1 parent 76a2a3e commit b627734
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions metasmoke.py
Expand Up @@ -5,13 +5,13 @@

class Metasmoke:
@classmethod
def send_stats_on_post(self, title, link, reasons, body):
def send_stats_on_post(self, title, link, reasons, body, username, user_link):
if GlobalVars.metasmoke_host is None:
print "Metasmoke location not defined, not reporting"
return

try:
payload = {'post': {'title': title, 'link': link, 'reasons': reasons, 'body': body}}
payload = {'post': {'title': title, 'link': link, 'reasons': reasons, 'body': body, 'username': username, 'user_link': user_link}}

headers = {'Content-type': 'application/json'}
requests.post(GlobalVars.metasmoke_host + "/posts.json", data=json.dumps(payload), headers=headers)
Expand Down
13 changes: 9 additions & 4 deletions spamhandling.py
Expand Up @@ -94,16 +94,21 @@ def handle_spam(title, body, poster, site, post_url, poster_url, post_id, reason
try:
title = escape_special_chars_in_title(title)

t_metasmoke = Thread(target=Metasmoke.send_stats_on_post,
args=(title, post_url, reason.split(", "), body,))
t_metasmoke.start()

if not poster.strip():
s = u"[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] {}: [{}]({}) by a deleted user on `{}`" \
.format(reason, title.strip(), post_url, site)
username = ""
user_link = ""
else:
s = u"[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] {}: [{}]({}) by [{}]({}) on `{}`" \
.format(reason, title.strip(), post_url, poster.strip(), poster_url, site)
username = poster.strip
user_link = poster_url

t_metasmoke = Thread(target=Metasmoke.send_stats_on_post,
args=(title, post_url, reason.split(", "), body, username, user_link))
t_metasmoke.start()

print GlobalVars.parser.unescape(s).encode('ascii', errors='replace')
if time.time() >= GlobalVars.blockedTime:
append_to_latest_questions(site, post_id, title)
Expand Down

0 comments on commit b627734

Please sign in to comment.