Rework of things for improved functionality.

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

@ -85,58 +85,55 @@ 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: else:
if epoch: print("No, it's not a new task.")
if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch:
newcomment = True
else:
print("Nope, not new.")
newcomment = False
break
else:
epoch = task["dateCreated"]
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"]
link = "\x032" + phab.phid.query(phids=[data["object"]["phid"]])[data["object"]["phid"]]["uri"] + "#" + str(commentid) + "\x03" if commentid:
message = "\x033[\x03\x0313"+ fulltaskname +"\x03\x033]\x03 \x0315" + str(who) + "\x03 " link = link + "#" + str(commentid) + "\x03"
if comment == True: else:
message = message + "commented on the task: " + link link = link + "\x03"
elif edited == True: message = "\x033[\x03\x0313"+ fulltaskname +"\x03\x033]\x03 \x0315" + str(who) + "\x03 "
message = message + "edited a message on the task: " + link if comment == True:
elif newcomment == True: message = message + "commented on the task: " + link
message = message + "just created this task: " + link elif edited == True:
print(message) message = message + "edited a message on the task: " + link
sendnotice(message) elif newtask == True:
message = message + "just created this task: " + link
print(message)
sendnotice(message)
return "OK" return "OK"

Loading…
Cancel
Save