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 | |
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)
-rw-r--r-- | __init__.py | 11 | ||||
-rw-r--r-- | local/handler/GithubHandler.py | 3 | ||||
-rw-r--r-- | local/handler/StatusHandler.py | 15 | ||||
-rw-r--r-- | local/utility.py | 5 | ||||
-rw-r--r-- | plugin.py | 2 |
5 files changed, 31 insertions, 5 deletions
diff --git a/__init__.py b/__init__.py index 435c2af..9a47fe9 100644 --- a/__init__.py +++ b/__init__.py @@ -29,14 +29,19 @@ reload(plugin) # In case we're being reloaded. # reloaded when this plugin is reloaded. Don't forget to import them as well! import local.handler.GithubHandler as RequestHandler import local.handler.PushHandler +import local.handler.WikiHandler +import local.handler.IssueHandler +import local.handler.StatusHandler +import local.handler.IssueCommentHandler import local.utility reload(RequestHandler) reload(local.handler.PushHandler) +reload(local.handler.WikiHandler) +reload(local.handler.IssueHandler) +reload(local.handler.StatusHandler) +reload(local.handler.IssueCommentHandler) reload(local.utility) -print "PushHandler reloaded" - - if world.testing: import test 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: @@ -44,6 +44,7 @@ import supybot.registry as registry import supybot.callbacks as callbacks RequestHandler = utils.python.universalImport('handler.GithubHandler', 'local.handler.GithubHandler') +Utility = utils.python.universalImport('local.utility') # Possible colours: # white, black, (light/dark) blue, (light) green, red, brown, purple, @@ -80,6 +81,7 @@ class Github(callbacks.Plugin): self.httpd.shutdown() self.__parent.die() reload(RequestHandler) + reload(Utility) Class = Github |