diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-05-11 15:15:43 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-05-11 15:15:43 +0300 |
commit | b566a6c3008af7b2549431cfe08c571c1d9cf8e5 (patch) | |
tree | 5b2108a571e969f0690d82fba0b4f1d9c8310ddc /local | |
parent | 7a959464a488e539a442bdbcefb9daa5684f44ac (diff) | |
download | supybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.tar.gz supybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.tar.bz2 supybot_github-b566a6c3008af7b2549431cfe08c571c1d9cf8e5.zip |
Add showSuccessfulBuildMessages configuration variable
Diffstat (limited to 'local')
-rw-r--r-- | local/globals.py | 3 | ||||
-rw-r--r-- | local/handler/TravisHandler.py | 19 | ||||
-rw-r--r-- | local/utility.py | 28 |
3 files changed, 42 insertions, 8 deletions
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 |