mirror of
https://github.com/lubuntu-team/lugito.git
synced 2025-06-06 13:31:32 +00:00
Re-implement the previous commit in a much better way.
This commit is contained in:
parent
fa063eec73
commit
adcfa174e3
85
lugito
85
lugito
@ -82,49 +82,60 @@ def ircmessage(objectstr, who, body, link):
|
|||||||
# Aaaaand, send it off!
|
# Aaaaand, send it off!
|
||||||
sendnotice(message)
|
sendnotice(message)
|
||||||
|
|
||||||
def ircbot(message):
|
def gettaskinfo(task):
|
||||||
message = message.split(" :" + username + ": info")[1]
|
|
||||||
sendmessage = ""
|
sendmessage = ""
|
||||||
|
try:
|
||||||
|
# We only need the task number.
|
||||||
|
taskinfo = phab.maniphest.info(task_id=int(task.split("T")[1]))
|
||||||
|
|
||||||
for item in message.split():
|
sendmessage = sendmessage + "\x033[\x03"
|
||||||
if item.startswith("T"):
|
|
||||||
try:
|
|
||||||
# We only need the task number.
|
|
||||||
taskinfo = phab.maniphest.info(task_id=int(item.split("T")[1]))
|
|
||||||
|
|
||||||
sendmessage = sendmessage + "\x033[\x03"
|
# The color of the priority text should correspond to its value.
|
||||||
|
color = taskinfo["priorityColor"]
|
||||||
|
if color == "violet":
|
||||||
|
sendmessage = sendmessage + "\x036Needs Triage"
|
||||||
|
elif color == "pink":
|
||||||
|
sendmessage = sendmessage + "\x035Unbreak Now!"
|
||||||
|
elif color == "red":
|
||||||
|
sendmessage = sendmessage + "\x034High"
|
||||||
|
elif color == "orange":
|
||||||
|
sendmessage = sendmessage + "\x037Medium"
|
||||||
|
elif color == "yellow":
|
||||||
|
sendmessage = sendmessage + "\x038Low"
|
||||||
|
elif color == "sky":
|
||||||
|
sendmessage = sendmessage + "\x037Wishlist"
|
||||||
|
|
||||||
# The color of the priority text should correspond to its value.
|
# Put the task status in the message.
|
||||||
color = taskinfo["priorityColor"]
|
sendmessage = sendmessage + ", " + taskinfo["statusName"] + "\x03"
|
||||||
if color == "violet":
|
|
||||||
sendmessage = sendmessage + "\x036Needs Triage"
|
|
||||||
elif color == "pink":
|
|
||||||
sendmessage = sendmessage + "\x035Unbreak Now!"
|
|
||||||
elif color == "red":
|
|
||||||
sendmessage = sendmessage + "\x034High"
|
|
||||||
elif color == "orange":
|
|
||||||
sendmessage = sendmessage + "\x037Medium"
|
|
||||||
elif color == "yellow":
|
|
||||||
sendmessage = sendmessage + "\x038Low"
|
|
||||||
elif color == "sky":
|
|
||||||
sendmessage = sendmessage + "\x037Wishlist"
|
|
||||||
|
|
||||||
# Put the task status in the message.
|
sendmessage = sendmessage + "\x033]\x03 "
|
||||||
sendmessage = sendmessage + ", " + taskinfo["statusName"] + "\x03"
|
|
||||||
|
|
||||||
sendmessage = sendmessage + "\x033]\x03 "
|
# Put the title in there as well.
|
||||||
|
sendmessage = sendmessage + taskinfo["title"].strip() + ": "
|
||||||
|
|
||||||
# Put the title in there as well.
|
# And the link.
|
||||||
sendmessage = sendmessage + taskinfo["title"].strip() + ": "
|
sendmessage = sendmessage + "\x032" + taskinfo["uri"] + "\x03"
|
||||||
|
|
||||||
# And the link.
|
# Send it off!
|
||||||
sendmessage = sendmessage + "\x032" + taskinfo["uri"] + "\x03"
|
sendnotice(sendmessage)
|
||||||
|
# If someone wrote something like "Tblah", obviously that's not right.
|
||||||
|
except ValueError:
|
||||||
|
sendnotice("\x034Error: " + task.strip() + "is an invalid task reference.\x03")
|
||||||
|
return None
|
||||||
|
|
||||||
# Send it off!
|
def ircbot(message, msgtype):
|
||||||
sendnotice(sendmessage)
|
if msgtype == "info":
|
||||||
# If someone wrote something like "Tblah", obviously that's not right.
|
message = message.split(" :" + username + ": info")[1]
|
||||||
except ValueError:
|
for item in message.split():
|
||||||
sendnotice("\x034Error: " + item.strip() + "is an invalid task reference.\x03")
|
if item.startswith("T"):
|
||||||
|
gettaskinfo(item.strip())
|
||||||
|
elif msgtype == "link":
|
||||||
|
for item in message.split("https://phab.lubuntu.me/"):
|
||||||
|
if item.split()[0].strip().startswith("T"):
|
||||||
|
gettaskinfo(item.split()[0].strip())
|
||||||
|
else:
|
||||||
|
sendnotice("\x034Error: unknown command.\x03")
|
||||||
|
return None
|
||||||
|
|
||||||
def listenirc():
|
def listenirc():
|
||||||
while True:
|
while True:
|
||||||
@ -137,10 +148,10 @@ def listenirc():
|
|||||||
print(ircmsg)
|
print(ircmsg)
|
||||||
if ircmsg.find("PING :") != -1:
|
if ircmsg.find("PING :") != -1:
|
||||||
conn.send(bytes("PONG :pingis\n", "UTF-8"))
|
conn.send(bytes("PONG :pingis\n", "UTF-8"))
|
||||||
elif ircmsg.find(" :" + username + ": ") != -1:
|
elif ircmsg.find(" :" + username + ": info") != -1:
|
||||||
ircbot(ircmsg)
|
ircbot(ircmsg, "info")
|
||||||
elif ircmsg.find("https://phab.lubuntu.me/T") != -1:
|
elif ircmsg.find("https://phab.lubuntu.me/T") != -1:
|
||||||
ircbot(ircmsg.split("https://phab.lubuntu.me/")[1])
|
ircbot(ircmsg, "link")
|
||||||
|
|
||||||
@app.route("/", methods=["POST"])
|
@app.route("/", methods=["POST"])
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user