Rework of things for improved functionality.

pull/1/head
Simon Quigley 6 years ago
parent f941220d8c
commit 5a633cead3

@ -85,55 +85,52 @@ def main():
if taskexists: if taskexists:
print("Task exists, checking to see if it's new.") print("Task exists, checking to see if it's new.")
# First, let's see if it's a new task newtask = isnewtask(tasksearch)
newcomment = False if newtask:
epoch = False print("Yes, it's a new task.")
for task in tasksearch:
if epoch:
if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch:
newcomment = True
else:
print("Nope, not new.")
newcomment = False
break
else: else:
epoch = task["dateCreated"] print("No, it's not a new task.")
if newcomment:
print("Yes, it's a new comment.")
# If it's not a new task, let's see if it's a comment, and if it's just an edit # If it's not a new task, let's see if it's a comment, and if it's just an edit
if not newcomment: comment = None
commentid = None
edited = None
if not newtask:
commentid = None commentid = None
edited = False edited = False
for task in tasksearch: for task in tasksearch:
dataepoch = data["action"]["epoch"] dataepoch = data["action"]["epoch"]
datemodified = task["dateModified"] datemodified = task["dateModified"]
if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []: if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []:
print("It's a comment, yes.")
comment = True comment = True
commentid = task["id"] commentid = task["id"]
if datemodified != task["dateCreated"]: if datemodified != task["dateCreated"]:
print("The comment was edited.")
edited = True edited = True
else: else:
print("The comment was NOT edited.")
edited = False edited = False
break break
else: else:
comment = False comment = False
# We should also know who did this thing # We should also know who did this thing
userlookup = tasksearch[0]["authorPHID"] userlookup = tasksearch[0]["authorPHID"]
who = dict(phab.phid.query(phids=[userlookup]))[userlookup]["fullName"] who = dict(phab.phid.query(phids=[userlookup]))[userlookup]["fullName"]
if isnewtask(tasksearch) is False and commentid is not None:
fulltaskname = phab.phid.query(phids=[data["object"]["phid"]])[data["object"]["phid"]]["fullName"] fulltaskname = phab.phid.query(phids=[data["object"]["phid"]])[data["object"]["phid"]]["fullName"]
link = "\x032" + phab.phid.query(phids=[data["object"]["phid"]])[data["object"]["phid"]]["uri"] + "#" + str(commentid) + "\x03" link = "\x032" + phab.phid.query(phids=[data["object"]["phid"]])[data["object"]["phid"]]["uri"]
if commentid:
link = link + "#" + str(commentid) + "\x03"
else:
link = link + "\x03"
message = "\x033[\x03\x0313"+ fulltaskname +"\x03\x033]\x03 \x0315" + str(who) + "\x03 " message = "\x033[\x03\x0313"+ fulltaskname +"\x03\x033]\x03 \x0315" + str(who) + "\x03 "
if comment == True: if comment == True:
message = message + "commented on the task: " + link message = message + "commented on the task: " + link
elif edited == True: elif edited == True:
message = message + "edited a message on the task: " + link message = message + "edited a message on the task: " + link
elif newcomment == True: elif newtask == True:
message = message + "just created this task: " + link message = message + "just created this task: " + link
print(message) print(message)
sendnotice(message) sendnotice(message)

Loading…
Cancel
Save