aboutsummaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorkongr45gpen <kongr45gpen@helit.org>2013-08-01 14:06:19 +0300
committerkongr45gpen <kongr45gpen@helit.org>2013-08-01 14:06:19 +0300
commit472155a60589820058f539efe6d77affa3ba061c (patch)
tree0e6ca0e5873aacbe969f7f4679d0bfe7b22a0e26 /plugin.py
parent1f54970da256d1a868e8bb960baf0c319f173214 (diff)
downloadsupybot_github-472155a60589820058f539efe6d77affa3ba061c.tar.gz
supybot_github-472155a60589820058f539efe6d77affa3ba061c.tar.bz2
supybot_github-472155a60589820058f539efe6d77affa3ba061c.zip
Support issue comments
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py67
1 files changed, 56 insertions, 11 deletions
diff --git a/plugin.py b/plugin.py
index e063431..e8cf51c 100644
--- a/plugin.py
+++ b/plugin.py
@@ -156,7 +156,10 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
elif 'commits' in data:
msgs = s.handle_push(irc, data, channel)
elif 'issue' in data:
- msgs = s.handle_issue(irc, data, channel)
+ if 'comment' in data:
+ msgs = s.handle_issue_comment(irc, data, channel)
+ else:
+ msgs = s.handle_issue(irc, data, channel)
else:
msgs.append( ircmsgs.privmsg(channel, "Something happened"))
@@ -170,40 +173,49 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
commitno = len(data['commits'])
branch = data['ref'].split('/',2)[2]
+ colon = ''
+ if data['commits']:
+ colon = ':'
+
branched = data['created'] or data['deleted']
branchFrom = ''
if branched:
+ urls = ' (%s)' % (getShortURL(data['compare']),)
if 'base_ref' in data:
branchFrom = ' by %s' % (data['base_ref'].split('/',2)[2],)
if data['created'] and not data['forced']:
action = "created"
elif data['deleted'] and not data['forced']:
action = "deleted"
+ urls = ''
elif data['created']:
action = "created"
elif data['deleted']:
action = "deleted"
+ urls = ''
else:
action = "did something with"
if configValue("hidePush",None) == False and not branched:
- msgs.append( ircmsgs.privmsg(channel, "%s @ %s: %s pushed %s %s (%s):" % (
+ msgs.append( ircmsgs.privmsg(channel, "%s @ %s: %s pushed %s %s (%s)%s" % (
ircutils.bold(ircutils.mircColor(branch, "blue")),
ircutils.bold(data['repository']['name']),
ircutils.mircColor(data['pusher']['name'], "green"),
ircutils.bold(str(commitno)),
plural(commitno, "commit", "commits"),
- getShortURL(data['compare'])
+ getShortURL(data['compare']),
+ colon
)) )
elif branched:
- msgs.append( ircmsgs.privmsg(channel, "%s: %s %s branch %s%s (%s):" % (
+ msgs.append( ircmsgs.privmsg(channel, "%s: %s %s branch %s%s%s%s" % (
ircutils.bold(data['repository']['name']),
ircutils.mircColor(data['pusher']['name'], "green"),
colorAction(action),
ircutils.bold(ircutils.mircColor(branch, "blue")),
branchFrom,
- getShortURL(data['compare'])
+ urls,
+ colon
)) )
for commit in data['commits']:
@@ -224,13 +236,13 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
for rawline in commitlines:
if len(rawline) > 400:
line = "%s..." % (rawline[0:397])
- else :
+ else:
line = rawline
- msgs.append(ircmsgs.privmsg(channel, "%s @ %s: %s" % (
- ircutils.bold(ircutils.mircColor(branch, "blue")),
- ircutils.bold(data['repository']['name']),
- line,
- )) )
+ msgs.append(ircmsgs.privmsg(channel, "%s @ %s: %s" % (
+ ircutils.bold(ircutils.mircColor(branch, "blue")),
+ ircutils.bold(data['repository']['name']),
+ line,
+ )) )
return msgs
@@ -307,9 +319,42 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
oparen, url
)) )
+ return msgs
+
+ def handle_issue_comment(s, irc, data, channel):
+ msgs = []
+
+ url = getShortURL(data['comment']['url'])
+
+
+ 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 = '('
+ lines = data['comment']['body'].splitlines()
+ line = lines[0]
+ if len(line) > 100:
+ line = "%s..." % (line[0:97])
+ msgs.append( ircmsgs.privmsg(channel, "%s: %s commented on issue %s \"%s\"%s%s %s%s): %s" % (
+ ircutils.bold(data['repository']['name']),
+ ircutils.mircColor(data['comment']['user']['login'], "green"),
+ ''.join(["#",str(data['issue']['number'])]),
+ ircutils.bold(data['issue']['title']),
+ creator,
+ milestone,
+ oparen, url,
+ line
+ )) )
return msgs

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