mirror of
https://github.com/lubuntu-team/lugito.git
synced 2025-06-07 14:01:29 +00:00
Re-implement the previous commit in a much better way.
This commit is contained in:
parent
fa063eec73
commit
adcfa174e3
31
lugito
31
lugito
@ -82,15 +82,11 @@ 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 = ""
|
||||||
|
|
||||||
for item in message.split():
|
|
||||||
if item.startswith("T"):
|
|
||||||
try:
|
try:
|
||||||
# We only need the task number.
|
# We only need the task number.
|
||||||
taskinfo = phab.maniphest.info(task_id=int(item.split("T")[1]))
|
taskinfo = phab.maniphest.info(task_id=int(task.split("T")[1]))
|
||||||
|
|
||||||
sendmessage = sendmessage + "\x033[\x03"
|
sendmessage = sendmessage + "\x033[\x03"
|
||||||
|
|
||||||
@ -124,7 +120,22 @@ def ircbot(message):
|
|||||||
sendnotice(sendmessage)
|
sendnotice(sendmessage)
|
||||||
# If someone wrote something like "Tblah", obviously that's not right.
|
# If someone wrote something like "Tblah", obviously that's not right.
|
||||||
except ValueError:
|
except ValueError:
|
||||||
sendnotice("\x034Error: " + item.strip() + "is an invalid task reference.\x03")
|
sendnotice("\x034Error: " + task.strip() + "is an invalid task reference.\x03")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def ircbot(message, msgtype):
|
||||||
|
if msgtype == "info":
|
||||||
|
message = message.split(" :" + username + ": info")[1]
|
||||||
|
for item in message.split():
|
||||||
|
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