From 8dd785e693406693ca2a1b92efecd1d9e53e17d9 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Sun, 17 Jul 2016 22:19:27 +0300 Subject: Add support for Github releases --- local/handler/GithubHandler.py | 3 +++ local/handler/ReleaseHandler.py | 13 +++++++++++++ local/theme/DefaultTheme.py | 12 ++++++++++++ local/utility.py | 3 ++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 local/handler/ReleaseHandler.py (limited to 'local') diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index 8788ea3..ffb5010 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -33,6 +33,7 @@ import IssueHandler import StatusHandler import TravisHandler import MessageHandler +import ReleaseHandler import CreateDeleteHandler import IssueCommentHandler @@ -166,6 +167,8 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): IssueHandler.handle(data, theme) elif 'ref_type' in data: CreateDeleteHandler.handle(data, theme) + elif 'release' in data: + ReleaseHandler.handle(data, theme) elif 'zen' in data: PingHandler.handle(data, theme) elif 'message' in data: diff --git a/local/handler/ReleaseHandler.py b/local/handler/ReleaseHandler.py new file mode 100644 index 0000000..4c13a69 --- /dev/null +++ b/local/handler/ReleaseHandler.py @@ -0,0 +1,13 @@ +from ..utility import * + +def handle(data, theme): + theme.release( + action = data['action'], + author = data['release']['author']['login'], + commit = data['release']['target_commitish'], + description = data['release']['body'], + name = data['release']['name'], + prerelease = data['release']['prerelease'], + tag = data['release']['tag_name'], + url = getShortURL(data['release']['html_url']) + ) diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py index 55d0863..3f29022 100644 --- a/local/theme/DefaultTheme.py +++ b/local/theme/DefaultTheme.py @@ -103,6 +103,18 @@ class DefaultTheme(Theme): ": %s" % maxLen(comment, 70) if comment else '' )) + def release(self, author, action, name, tag, description, commit, prerelease, url): + self.msgs.append( "%s: %s %s%s %s (%s): %s %s" % ( + self.repo(), + ircutils.mircColor(author, "green"), + colorAction(action), + " %s" % (ircutils.mircColor('prerelease', "orange")) if prerelease else '', + ircutils.bold(name), + ircutils.mircColor(tag, "dark gray"), + maxLen(description, 100), + self.enclose(url) + )) + def wikiPush(self, actor, count, url): self.msgs.append( "%s: %s modified %s wiki %s %s:" % ( self.repo(), diff --git a/local/utility.py b/local/utility.py index ef37c28..a1d41bd 100644 --- a/local/utility.py +++ b/local/utility.py @@ -80,7 +80,8 @@ def maxLen(msg, maxn=400, splitLines=True): def colorAction(action): """Give an action string (e.g. created, edited) and get a nice IRC colouring""" - if action in [ "created", "opened", "tagged", "success", "passed", "fixed" ]: + if action in [ "created", "opened", "tagged", "success", "passed", "fixed", + "published" ]: return ircutils.bold(ircutils.mircColor(action, "green")) if action in [ "deleted" ,"closed", "re-tagged", "deleted tag", "failed", "errored", "failure", "still failing", -- cgit v1.2.3