aboutsummaryrefslogtreecommitdiff
path: root/modules/github
diff options
context:
space:
mode:
authorGravatar jesopo2019-03-02 21:32:08 +0000
committerGravatar jesopo2019-03-02 21:32:08 +0000
commit7c654b4475c290d752b1f237e490a3df9076b303 (patch)
tree6426a5fabcd9c967bf9289d612b21e8b5001e65b /modules/github
parentDon't show "[]" when there are no labels in !ghissue (diff)
signature
Add COLOR_NEUTRAL, show repo/number/state colours in !ghissue
Diffstat (limited to 'modules/github')
-rw-r--r--modules/github/__init__.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/modules/github/__init__.py b/modules/github/__init__.py
index 79895f57..187ce514 100644
--- a/modules/github/__init__.py
+++ b/modules/github/__init__.py
@@ -4,6 +4,7 @@ from src import ModuleManager, utils
COLOR_BRANCH = utils.consts.ORANGE
COLOR_REPO = utils.consts.GREY
COLOR_POSITIVE = utils.consts.GREEN
+COLOR_NEUTRAL = utils.consts.LIGHTGREY
COLOR_NEGATIVE = utils.consts.RED
COLOR_ID = utils.consts.PINK
@@ -108,6 +109,8 @@ class Module(ModuleManager.BaseModule):
return 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_str = ""
if labels:
@@ -115,9 +118,14 @@ class Module(ModuleManager.BaseModule):
url = self._short_url(page.data["html_url"])
- event["stdout"].write("(%s/%s issue#%s, %s) %s %s%s" % (
- username, repository, number, page.data["state"],
- page.data["title"], labels_str, url))
+ state = page.data["state"]
+ if state == "open":
+ 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):
return utils.http.request(
API_ISSUE_URL % (username, repository, number),
@@ -148,22 +156,17 @@ class Module(ModuleManager.BaseModule):
url = self._short_url(page.data["html_url"])
state = page.data["state"]
- state_color = None
if page.data["merged"]:
- state = "merged"
- state_color = utils.consts.GREEN
+ state = utils.irc.color("merged", COLOR_POSITIVE)
elif state == "open":
- state_color = utils.consts.GREEN
+ state = utils.irc.color("open", COLOR_NEUTRAL)
elif state == "closed":
- state_color = utils.consts.RED
-
- if state_color:
- state = utils.irc.color(state, state_color)
+ state = utils.irc.color("closed", COLOR_NEGATIVE)
event["stdout"].write(
"(%s pull%s, %s) %s → %s [%s/%s] %s %s" % (
- repo, number, state, branch_from, branch_to,
- added, removed, page.data["title"], url))
+ repo, number, state, branch_from, branch_to, added, removed,
+ page.data["title"], url))
def _gh_get_pull(self, username, repository, number):
return utils.http.request(
API_PULL_URL % (username, repository, number),
@@ -630,7 +633,7 @@ class Module(ModuleManager.BaseModule):
if conclusion in CHECK_RUN_FAILURES:
conclusion_color = COLOR_NEGATIVE
if conclusion == "neutral":
- conclusion_color = utils.consts.GREY
+ conclusion_color = COLOR_NEUTRAL
status_str = utils.irc.color(
CHECK_RUN_CONCLUSION[conclusion], conclusion_color)