Skip to content

Commit

Permalink
Expire last_feedbacked after 60 seconds --autopull
Browse files Browse the repository at this point in the history
  • Loading branch information
quartata committed May 7, 2018
1 parent 56f6d5f commit 7fd5848
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ def true(feedback, msg, alias_used="true"):
else:
result = "Registered " + post_type + " as true positive."

datahandling.last_feedbacked = (post_id, site)
datahandling.last_feedbacked = ((post_id, site), time.time() + 60)

return result if not feedback_type.always_silent else ""

Expand Down
7 changes: 5 additions & 2 deletions chatcommunicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ def on_msg(msg, client):
if result:
_msg_queue.put((room_data, ":{} {}".format(message.id, result), None))
elif classes.feedback.FEEDBACK_REGEX.search(message.content) and is_privileged(message.owner, message.room):
Tasks.do(metasmoke.Metasmoke.post_auto_comment, message.content_source, message.owner,
ids=datahandling.last_feedbacked)
ids, expires_in = datahandling.last_feedbacked

if expires_in < time.time():
Tasks.do(metasmoke.Metasmoke.post_auto_comment, message.content_source, message.owner,
ids=datahandling.last_feedbacked)


def tell_rooms_with(prop, msg, notify_site="", report_data=None):
Expand Down
5 changes: 4 additions & 1 deletion datahandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def add_false_positive(site_post_id_tuple):
pickle.dump(GlobalVars.false_positives, f, protocol=pickle.HIGHEST_PROTOCOL)

global last_feedbacked
last_feedbacked = site_post_id_tuple
last_feedbacked = (site_post_id_tuple, time.time() + 60)


# noinspection PyMissingTypeHints
Expand All @@ -178,6 +178,9 @@ def add_ignored_post(postid_site_tuple):
with open("ignoredPosts.p", "wb") as f:
pickle.dump(GlobalVars.ignored_posts, f, protocol=pickle.HIGHEST_PROTOCOL)

global last_feedbacked
last_feedbacked = (postid_site_tuple, time.time() + 60)


def remove_blacklisted_user(user):
blacklisted_user_data = get_blacklisted_user_data(user)
Expand Down
2 changes: 1 addition & 1 deletion metasmoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def handle_websocket_data(data):
ids = (message['blacklist']['uid'], message['blacklist']['site'])

datahandling.add_blacklisted_user(ids, "metasmoke", message['blacklist']['post'])
datahandling.last_feedbacked = ids
datahandling.last_feedbacked = (ids, time.time() + 60)
elif "unblacklist" in message:
datahandling.remove_blacklisted_user(message['unblacklist']['uid'])
elif "naa" in message:
Expand Down

0 comments on commit 7fd5848

Please sign in to comment.