aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2014-05-11 15:15:43 +0300
committerkongr45gpen <electrovesta@gmail.com>2014-05-11 15:15:43 +0300
commitb566a6c3008af7b2549431cfe08c571c1d9cf8e5 (patch)
tree5b2108a571e969f0690d82fba0b4f1d9c8310ddc
parent7a959464a488e539a442bdbcefb9daa5684f44ac (diff)
downloadsupybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.tar.gz
supybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.tar.bz2
supybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.zip
Add showSuccessfulBuildMessages configuration variable
-rw-r--r--config.py4
-rw-r--r--local/globals.py3
-rw-r--r--local/handler/TravisHandler.py19
-rw-r--r--local/utility.py28
-rw-r--r--samples/travis-notification.json4
5 files changed, 48 insertions, 10 deletions
diff --git a/config.py b/config.py
index fac9aa2..57a511e 100644
--- a/config.py
+++ b/config.py
@@ -49,6 +49,10 @@ conf.registerGlobalValue(Github, 'showMergedCommits',
registry.Boolean(False,
"""Show merged commits when a branch is merged into another"""))
+conf.registerGlobalValue(Github, 'showSuccessfulBuildMessages',
+ registry.String('change',
+ """Whether to show successful build messages - can be never, change or always"""))
+
conf.registerGlobalValue(Github, 'port',
registry.Integer(8093,
"""The port where Github will send HTTP requests"""))
diff --git a/local/globals.py b/local/globals.py
index 55addab..6cc8c7b 100644
--- a/local/globals.py
+++ b/local/globals.py
@@ -1,5 +1,8 @@
def init():
global messageList
global configOverrides
+ global travisStatuses
+
messageList = []
configOverrides = {}
+ travisStatuses = {}
diff --git a/local/handler/TravisHandler.py b/local/handler/TravisHandler.py
index a8a8d86..b32aa71 100644
--- a/local/handler/TravisHandler.py
+++ b/local/handler/TravisHandler.py
@@ -3,13 +3,16 @@ from ..utility import *
def handle(data):
msgs = []
- msgs.append( "%s: The build %s * %s by %s (%s - %s)" % (
- ircutils.bold(data['repository']['name']),
- colorAction(data['status_message'].lower()),
- ircutils.bold(data['commit'][0:6]),
- ircutils.mircColor(data['author_name'], "green"),
- ircutils.mircColor(maxLen(data['message'].splitlines()[0], 50), "dark gray"),
- getShortURL(data['build_url'])
- ))
+ status = data['status_message'].lower()
+
+ if isStatusVisible(data['repository']['url'], status):
+ msgs.append( "%s: The build %s * %s by %s (%s - %s)" % (
+ ircutils.bold(data['repository']['name']),
+ colorAction(status),
+ ircutils.bold(data['commit'][0:6]),
+ ircutils.mircColor(data['author_name'], "green"),
+ ircutils.mircColor(maxLen(data['message'].splitlines()[0], 50), "dark gray"),
+ getShortURL(data['build_url'])
+ ))
return msgs
diff --git a/local/utility.py b/local/utility.py
index 1c478c3..dbdb69a 100644
--- a/local/utility.py
+++ b/local/utility.py
@@ -87,6 +87,34 @@ def clean(string):
regex = re.compile("(([\x02\x1f\x16\x0f])|(\x03(?:\d{1,2}(?:,\d{1,2})?)?))", re.UNICODE)
return regex.sub('', string)
+def isYes(string):
+ """Returns True if the string represents a yes, False, if it represents
+ no, and another string if it represents something else"""
+ value = string.strip().lower()
+
+ if value in ['yes', 'always', 'on', 'true']:
+ return True
+ if value in ['no', 'never', 'off', 'false', 'null']:
+ return False
+ if value in ['changed', 'change', 'on_change', 'diff']:
+ return 'change'
+
+def isStatusVisible(repo, status):
+ """Returns whether the build status message should be shown"""
+ config = isYes(configValue('showSuccessfulBuildMessages'))
+
+ changed = False
+ if status != "passed":
+ changed = True
+ elif type(config) is bool:
+ changed = config
+ elif repo not in globals.travisStatuses or status != globals.travisStatuses[repo]:
+ # Config is 'on_change'
+ changed = True
+
+ globals.travisStatuses[repo] = status
+ return changed
+
# Possible colours:
# white, black, (light/dark) blue, (light) green, red, brown, purple,
# orange, yellow, teal, pink, light/dark gray/grey
diff --git a/samples/travis-notification.json b/samples/travis-notification.json
index 90475ad..c2a4055 100644
--- a/samples/travis-notification.json
+++ b/samples/travis-notification.json
@@ -36,8 +36,8 @@
"started_at": null,
"finished_at": null,
"config": {
- "notifications": {
- "webhooks": ["http://evome.fr/notifications", "http://example.com/"]
+ "notifications": {
+ "webhooks": ["http://evome.fr/notifications", "http://example.com/"]
}
},
"status": null,

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