Add COLOR_NEUTRAL, show repo/number/state colours in !ghissue
This commit is contained in:
parent
a063f54a38
commit
7c654b4475
1 changed files with 17 additions and 14 deletions
|
@ -4,6 +4,7 @@ from src import ModuleManager, utils
|
||||||
COLOR_BRANCH = utils.consts.ORANGE
|
COLOR_BRANCH = utils.consts.ORANGE
|
||||||
COLOR_REPO = utils.consts.GREY
|
COLOR_REPO = utils.consts.GREY
|
||||||
COLOR_POSITIVE = utils.consts.GREEN
|
COLOR_POSITIVE = utils.consts.GREEN
|
||||||
|
COLOR_NEUTRAL = utils.consts.LIGHTGREY
|
||||||
COLOR_NEGATIVE = utils.consts.RED
|
COLOR_NEGATIVE = utils.consts.RED
|
||||||
COLOR_ID = utils.consts.PINK
|
COLOR_ID = utils.consts.PINK
|
||||||
|
|
||||||
|
@ -108,6 +109,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
return username, repository, number
|
return username, repository, number
|
||||||
|
|
||||||
def _gh_issue(self, event, page, username, repository, number):
|
def _gh_issue(self, event, page, username, repository, number):
|
||||||
|
repo = utils.irc.color("%s/%s" % (username, repository), COLOR_REPO)
|
||||||
|
number = utils.irc.color("#%s" % number, COLOR_ID)
|
||||||
labels = [label["name"] for label in page.data["labels"]]
|
labels = [label["name"] for label in page.data["labels"]]
|
||||||
labels_str = ""
|
labels_str = ""
|
||||||
if labels:
|
if labels:
|
||||||
|
@ -115,9 +118,14 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
url = self._short_url(page.data["html_url"])
|
url = self._short_url(page.data["html_url"])
|
||||||
|
|
||||||
event["stdout"].write("(%s/%s issue#%s, %s) %s %s%s" % (
|
state = page.data["state"]
|
||||||
username, repository, number, page.data["state"],
|
if state == "open":
|
||||||
page.data["title"], labels_str, url))
|
state = utils.irc.color("open", COLOR_NEUTRAL)
|
||||||
|
elif state == "closed":
|
||||||
|
state = utils.irc.color("closed", COLOR_NEGATIVE)
|
||||||
|
|
||||||
|
event["stdout"].write("(%s issue%s, %s) %s %s%s" % (
|
||||||
|
repo, number, state, page.data["title"], labels_str, url))
|
||||||
def _gh_get_issue(self, username, repository, number):
|
def _gh_get_issue(self, username, repository, number):
|
||||||
return utils.http.request(
|
return utils.http.request(
|
||||||
API_ISSUE_URL % (username, repository, number),
|
API_ISSUE_URL % (username, repository, number),
|
||||||
|
@ -148,22 +156,17 @@ class Module(ModuleManager.BaseModule):
|
||||||
url = self._short_url(page.data["html_url"])
|
url = self._short_url(page.data["html_url"])
|
||||||
|
|
||||||
state = page.data["state"]
|
state = page.data["state"]
|
||||||
state_color = None
|
|
||||||
if page.data["merged"]:
|
if page.data["merged"]:
|
||||||
state = "merged"
|
state = utils.irc.color("merged", COLOR_POSITIVE)
|
||||||
state_color = utils.consts.GREEN
|
|
||||||
elif state == "open":
|
elif state == "open":
|
||||||
state_color = utils.consts.GREEN
|
state = utils.irc.color("open", COLOR_NEUTRAL)
|
||||||
elif state == "closed":
|
elif state == "closed":
|
||||||
state_color = utils.consts.RED
|
state = utils.irc.color("closed", COLOR_NEGATIVE)
|
||||||
|
|
||||||
if state_color:
|
|
||||||
state = utils.irc.color(state, state_color)
|
|
||||||
|
|
||||||
event["stdout"].write(
|
event["stdout"].write(
|
||||||
"(%s pull%s, %s) %s → %s [%s/%s] %s %s" % (
|
"(%s pull%s, %s) %s → %s [%s/%s] %s %s" % (
|
||||||
repo, number, state, branch_from, branch_to,
|
repo, number, state, branch_from, branch_to, added, removed,
|
||||||
added, removed, page.data["title"], url))
|
page.data["title"], url))
|
||||||
def _gh_get_pull(self, username, repository, number):
|
def _gh_get_pull(self, username, repository, number):
|
||||||
return utils.http.request(
|
return utils.http.request(
|
||||||
API_PULL_URL % (username, repository, number),
|
API_PULL_URL % (username, repository, number),
|
||||||
|
@ -630,7 +633,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if conclusion in CHECK_RUN_FAILURES:
|
if conclusion in CHECK_RUN_FAILURES:
|
||||||
conclusion_color = COLOR_NEGATIVE
|
conclusion_color = COLOR_NEGATIVE
|
||||||
if conclusion == "neutral":
|
if conclusion == "neutral":
|
||||||
conclusion_color = utils.consts.GREY
|
conclusion_color = COLOR_NEUTRAL
|
||||||
|
|
||||||
status_str = utils.irc.color(
|
status_str = utils.irc.color(
|
||||||
CHECK_RUN_CONCLUSION[conclusion], conclusion_color)
|
CHECK_RUN_CONCLUSION[conclusion], conclusion_color)
|
||||||
|
|
Loading…
Reference in a new issue