diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-04-25 16:18:15 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-04-25 16:18:15 +0300 |
commit | 59aa66b0b8e1e17255effc3a4a6e32994be8d177 (patch) | |
tree | d795e500931c29f4f516489eb654cd08b6bd0720 /local | |
parent | 29f8b71c828f1c1d423e1f9f032db3c574eb499a (diff) | |
download | supybot_github-59aa66b0b8e1e17255effc3a4a6e32994be8d177.tar.gz supybot_github-59aa66b0b8e1e17255effc3a4a6e32994be8d177.tar.bz2 supybot_github-59aa66b0b8e1e17255effc3a4a6e32994be8d177.zip |
Add basic status message handler (fixes #3)
Diffstat (limited to 'local')
-rw-r--r-- | local/handler/GithubHandler.py | 3 | ||||
-rw-r--r-- | local/handler/StatusHandler.py | 15 | ||||
-rw-r--r-- | local/utility.py | 5 |
3 files changed, 21 insertions, 2 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index 340a65d..598dc36 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -23,6 +23,7 @@ from ..utility import * import PushHandler import WikiHandler import IssueHandler +import StatusHandler import IssueCommentHandler class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): @@ -84,6 +85,8 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): if 'pages' in data: msgs = WikiHandler.handle(irc, data, channel) + elif 'state' in data: + msgs = StatusHandler.handle(irc, data, channel) elif 'commits' in data: msgs = PushHandler.handle(irc, data, channel) elif 'issue' in data: diff --git a/local/handler/StatusHandler.py b/local/handler/StatusHandler.py new file mode 100644 index 0000000..219a7dd --- /dev/null +++ b/local/handler/StatusHandler.py @@ -0,0 +1,15 @@ +import supybot.ircmsgs as ircmsgs + +from ..utility import * + +def handle(irc, data, channel): + msgs = [] + + msgs.append( ircmsgs.privmsg(channel, "%s: %s - %s (%s)" % ( + ircutils.bold(data['repository']['name']), + colorAction(data['state']), + data['description'], + data['target_url'] + )) ) + + return msgs diff --git a/local/utility.py b/local/utility.py index c6a6c60..4fba906 100644 --- a/local/utility.py +++ b/local/utility.py @@ -38,20 +38,21 @@ def maxLen(msg, maxn=400): def colorAction(action): """Give an action string (e.g. created, edited) and get a nice IRC colouring""" - if action == "created" or action == "opened" or action == "tagged": + if action == "created" or action == "opened" or action == "tagged" or action == "success": return ircutils.bold(ircutils.mircColor(action, "green")) if action == "deleted" or action == "closed" or action == "re-tagged" or \ action == "deleted tag" or action == "failed" or action == "still failing": return ircutils.bold(ircutils.mircColor(action, "red")) if action == "merged": return ircutils.bold(ircutils.mircColor(action, "light blue")) - if action == "reopened": + if action == "reopened" or action == "pending": return ircutils.bold(ircutils.mircColor(action, "blue")) if action == "forced the creation of" or action == "forced the deletion of": return ircutils.bold(ircutils.mircColor(action,"brown")) return action def getShortURL(longurl): + """ Returns a short URL generated by git.io""" if configValue("shortURL") is False: url = longurl else: |