Skip to content

Commit

Permalink
Check for None, fix feedback comments
Browse files Browse the repository at this point in the history
  • Loading branch information
quartata committed May 7, 2018
1 parent 7fd5848 commit 012db51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def false(feedback, msg, alias_used="false"):
except:
pass

if not msg.content[-1].endswith(alias_used[-1]): # lazy, pls fix
if msg.content[-1] != "-" and not msg.content.endswith(alias_used):
Tasks.do(Metasmoke.post_auto_comment, feedback.content_source, feedback.owner, url=post_url)

return result if not feedback_type.always_silent else ""
Expand Down Expand Up @@ -1525,6 +1525,9 @@ def naa(feedback, msg, alias_used="naa"):
post_id, site, _ = fetch_post_id_and_site_from_url(post_url)
add_ignored_post((post_id, site))

if msg.content[-1] != "-" and not msg.content.endswith(alias_used):
Tasks.do(Metasmoke.post_auto_comment, feedback.content_source, feedback.owner, url=post_url)

return "Recorded answer as an NAA in metasmoke." if not feedback_type.always_silent else ""


Expand Down Expand Up @@ -1561,6 +1564,9 @@ def true(feedback, msg, alias_used="true"):
else:
result = "Registered " + post_type + " as true positive."

if msg.content[-1] != "-" and not msg.content.endswith(alias_used):
Tasks.do(Metasmoke.post_auto_comment, feedback.content_source, feedback.owner, url=post_url)

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

return result if not feedback_type.always_silent else ""
Expand Down
9 changes: 5 additions & 4 deletions chatcommunicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ 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):
ids, expires_in = datahandling.last_feedbacked
if 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)
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

0 comments on commit 012db51

Please sign in to comment.