aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2016-09-15 17:44:30 +0300
committerkongr45gpen <electrovesta@gmail.com>2016-09-15 17:44:30 +0300
commit420453c38d2dbca742f0b2b041b989355ace9c80 (patch)
treeb6abea8e97d7d593bef468e330aceb0e56d47d58
parent93beeec8ceb8cb62c1da3ae5239e4299ebf3dc50 (diff)
downloadsupybot_github-420453c38d2dbca742f0b2b041b989355ace9c80.tar.gz
supybot_github-420453c38d2dbca742f0b2b041b989355ace9c80.tar.bz2
supybot_github-420453c38d2dbca742f0b2b041b989355ace9c80.zip
Add support for pull requests
-rw-r--r--local/handler/GithubHandler.py2
-rw-r--r--local/handler/IssueCommentHandler.py8
-rw-r--r--local/handler/IssueHandler.py28
-rw-r--r--local/theme/DefaultTheme.py5
4 files changed, 30 insertions, 13 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py
index ffb5010..909484e 100644
--- a/local/handler/GithubHandler.py
+++ b/local/handler/GithubHandler.py
@@ -160,7 +160,7 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
StatusHandler.handle(data, theme)
elif 'commits' in data:
PushHandler.handle(data, theme)
- elif 'issue' in data:
+ elif 'issue' in data or 'pull_request' in data:
if 'comment' in data:
IssueCommentHandler.handle(data, theme)
else:
diff --git a/local/handler/IssueCommentHandler.py b/local/handler/IssueCommentHandler.py
index b066013..26f272d 100644
--- a/local/handler/IssueCommentHandler.py
+++ b/local/handler/IssueCommentHandler.py
@@ -1,6 +1,11 @@
from ..utility import *
def handle(data, theme):
+ if 'pull_request' in data['issue']:
+ type = 'pull request'
+ else:
+ type = 'issue'
+
milestone = ''
if configValue("showMilestone") and 'milestone' in data['issue'] and data['issue']['milestone']:
milestone = data['issue']['milestone']['title']
@@ -18,5 +23,6 @@ def handle(data, theme):
creator = data['issue']['user']['login'],
milestone = milestone,
url = getShortURL(data['comment']['html_url']),
- assignee = assignee
+ assignee = assignee,
+ type = type
)
diff --git a/local/handler/IssueHandler.py b/local/handler/IssueHandler.py
index bd133b9..68317c8 100644
--- a/local/handler/IssueHandler.py
+++ b/local/handler/IssueHandler.py
@@ -1,15 +1,24 @@
from ..utility import *
def handle(data, theme):
+ if 'issue' in data:
+ issue = data['issue']
+ type = 'issue'
+ elif 'pull_request' in data:
+ issue = data['pull_request']
+ type = 'pull request'
+ else:
+ type = 'something'
+
milestone = ''
- if data['issue']['milestone'] and configValue("showMilestone"):
- milestone = data['issue']['milestone']['title']
+ if issue['milestone'] and configValue("showMilestone"):
+ milestone = issue['milestone']['title']
assignee = ''
if 'assignee' in data and data['assignee']:
assignee = data['assignee']['login']
- elif 'assignee' in data['issue'] and data['issue']['assignee']:
- assignee = data['issue']['assignee']['login']
+ elif 'assignee' in issue and issue['assignee']:
+ assignee = issue['assignee']['login']
labelName = None
labelColor = None
@@ -20,12 +29,13 @@ def handle(data, theme):
theme.issue(
actor = data['sender']['login'],
action = data['action'],
- issueNo = data['issue']['number'],
- issueTitle = data['issue']['title'],
- creator = data['issue']['user']['login'],
+ issueNo = issue['number'],
+ issueTitle = issue['title'],
+ creator = issue['user']['login'],
milestone = milestone,
- url = getShortURL(data['issue']['html_url']),
+ url = getShortURL(issue['html_url']),
assignee = assignee,
labelName = labelName,
- labelColor = labelColor
+ labelColor = labelColor,
+ type = type
)
diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py
index 3f29022..2cd6226 100644
--- a/local/theme/DefaultTheme.py
+++ b/local/theme/DefaultTheme.py
@@ -74,7 +74,7 @@ class DefaultTheme(Theme):
' %s' % self.enclose(url) if url else ''
))
- def issue(self, actor, action, issueNo, issueTitle, creator, milestone, url, assignee = None, comment = None, labelName = None, labelColor = None):
+ def issue(self, actor, action, type, issueNo, issueTitle, creator, milestone, url, assignee = None, comment = None, labelName = None, labelColor = None):
formattedActor = ircutils.mircColor(actor, "green")
if actor == assignee:
@@ -88,10 +88,11 @@ class DefaultTheme(Theme):
elif action == 'labeled' or action == 'unlabeled':
extra = " as %s" % ircutils.mircColor(labelName, hexToMirc(labelColor))
- self.msgs.append( "%s: %s %s issue #%s \"%s\"%s%s %s%s" % (
+ self.msgs.append( "%s: %s %s %s #%s \"%s\"%s%s %s%s" % (
self.repo(),
formattedActor,
colorAction(action),
+ type,
issueNo,
ircutils.bold(issueTitle),
" by %s" % ircutils.mircColor(creator,"green") if creator != actor else '',

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