aboutsummaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorkongr45gpen <kongr45gpen@helit.org>2013-08-01 12:21:45 +0300
committerkongr45gpen <kongr45gpen@helit.org>2013-08-01 12:21:45 +0300
commitb05c1fb9aa25f4794dfd9d9f23ffc1a1881e5cf8 (patch)
treed33c8af0b116fc824c63c94644bf32f7e42e26cc /plugin.py
parentf245c9dc0e6e154fcb6f5bd0dfe52889482c08e6 (diff)
downloadsupybot_github-b05c1fb9aa25f4794dfd9d9f23ffc1a1881e5cf8.tar.gz
supybot_github-b05c1fb9aa25f4794dfd9d9f23ffc1a1881e5cf8.tar.bz2
supybot_github-b05c1fb9aa25f4794dfd9d9f23ffc1a1881e5cf8.zip
Handle issues
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py51
1 files changed, 48 insertions, 3 deletions
diff --git a/plugin.py b/plugin.py
index 8d89b05..08bc78c 100644
--- a/plugin.py
+++ b/plugin.py
@@ -51,10 +51,14 @@ def plural(number, s, p):
def colorAction(action):
"""Get an action string (e.g. created, edited) and get a nice IRC colouring"""
- if action == "created":
+ if action == "created" or action == "opened":
return ircutils.bold(ircutils.mircColor(action, "green"))
- if action == "deleted":
+ if action == "deleted" or action == "closed":
return ircutils.bold(ircutils.mircColor(action, "red"))
+ if action == "merged":
+ return ircutils.bold(ircutils.mircColor(action, "light blue"))
+ if action == "reopened":
+ return ircutils.bold(ircutils.mircColor(action, "blue"))
return action
def registryValue(plugin, name, channel=None, value=True):
@@ -104,7 +108,7 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
s.wfile.write('</body></html>\n')
s.wfile.write(s.path.split('/'))
- #print json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
+ print json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
path = s.path.split('/')
channel = configValue('channel')
@@ -149,6 +153,8 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
msgs = s.handle_wiki(irc, data, channel)
elif 'commits' in data:
msgs = s.handle_push(irc, data, channel)
+ elif 'issue' in data:
+ msgs = s.handle_issue(irc, data, channel)
else:
msgs.append( ircmsgs.privmsg(channel, "Something happened"))
@@ -239,6 +245,45 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return msgs
+ def handle_issue(s, irc, data, channel):
+ msgs = []
+
+ url = data['issue']['url']
+
+ if data['issue']['assignee'] and data['sender']['login'] == data['issue']['assignee']['login']:
+ senderColor = "green"
+ else:
+ senderColor = "dark grey"
+
+ creator = ''
+ if data['sender']['login'] != data['issue']['user']['login']:
+ creator = " by %s" % (ircutils.mircColor(data['issue']['user']['login'],"green"),)
+
+ milestone = ''
+ if data['issue']['milestone']:
+ milestone = ircutils.mircColor(" (%s" % (data['issue']['milestone']['title']),"brown")
+
+ if milestone:
+ oparen = '- '
+ else:
+ oparen = '('
+
+ msgs.append( ircmsgs.privmsg(channel, "%s: %s %s issue %s \"%s\"%s%s %s%s)" % (
+ ircutils.bold(data['repository']['name']),
+ ircutils.mircColor(data['sender']['login'], senderColor),
+ colorAction(data['action']),
+ ''.join(["#",str(data['issue']['number'])]),
+ ircutils.bold(data['issue']['title']),
+ creator,
+ milestone,
+ oparen, url
+ )) )
+
+
+
+
+
+ return msgs
class Github(callbacks.Plugin):

© 2014-2024 Faster IT GmbH | imprint | privacy policy