diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-05-11 14:33:34 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-05-11 14:33:34 +0300 |
commit | 7a959464a488e539a442bdbcefb9daa5684f44ac (patch) | |
tree | cc58ccd8821394191bdf4cbc5cf1d8ea717d71e0 /local | |
parent | 9b117389606bbe5c398c52bf7001c0324ba83183 (diff) | |
download | supybot_github-7a959464a488e539a442bdbcefb9daa5684f44ac.tar.gz supybot_github-7a959464a488e539a442bdbcefb9daa5684f44ac.tar.bz2 supybot_github-7a959464a488e539a442bdbcefb9daa5684f44ac.zip |
Add setting to allow config value overrides on the URL
Diffstat (limited to 'local')
-rw-r--r-- | local/globals.py | 2 | ||||
-rw-r--r-- | local/handler/GithubHandler.py | 6 | ||||
-rw-r--r-- | local/handler/PushHandler.py | 8 | ||||
-rw-r--r-- | local/utility.py | 9 |
4 files changed, 21 insertions, 4 deletions
diff --git a/local/globals.py b/local/globals.py index faf425c..55addab 100644 --- a/local/globals.py +++ b/local/globals.py @@ -1,3 +1,5 @@ def init(): global messageList + global configOverrides messageList = [] + configOverrides = {} diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index fabe544..13410c3 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -62,6 +62,8 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): and configValue('passcode').strip().lower() != 'null' \ and configValue('passcode').strip().lower() != 'no' + resetConfigOverrides() + # Analyse the URL i = 0 for part in path: @@ -77,6 +79,10 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): if part.startswith("#") and not configValue('disallowChannelOverride'): channel = part + elif '=' in part and not configValue('disallowConfigOverride'): + explosion = part.split('=', 1) + addConfigOverride(explosion[0], explosion[1]) + i+=1 diff --git a/local/handler/PushHandler.py b/local/handler/PushHandler.py index 12c9455..f7c1141 100644 --- a/local/handler/PushHandler.py +++ b/local/handler/PushHandler.py @@ -85,14 +85,14 @@ def handle(data): if configValue("tagShowCommitMsg"): commitMsg = ircutils.mircColor(" (%s)" % (maxLen(data['head_commit']['message'].splitlines()[0],75)),"brown") commitInfo = " %s %s%s as" % (branchFrom, ircutils.bold(data['head_commit']['id'][0:6]), commitMsg) - msgs.append( ircmsgs.privmsg(channel, "%s: %s %s%s %s%s" % ( + msgs.append("%s: %s %s%s %s%s" % ( ircutils.bold(data['repository']['name']), ircutils.mircColor(data['pusher']['name'], "green"), colorAction(action), commitInfo, ircutils.bold(ircutils.mircColor(branch, "blue")), urls, - )) ) + )) elif isMerge: distinctMessage = "" if configValue("hidePush",None) == False and regularCommitCount > 0: @@ -110,7 +110,7 @@ def handle(data): urls )) else: - msgs.append( ircmsgs.privmsg(channel, "%s: %s %s branch %s%s%s%s" % ( + msgs.append( "%s: %s %s branch %s%s%s%s" % ( ircutils.bold(data['repository']['name']), ircutils.mircColor(data['pusher']['name'], "green"), colorAction(action), @@ -118,7 +118,7 @@ def handle(data): branchFrom, urls, colon - )) ) + )) for commit in data['commits']: if 'username' in commit['author']: diff --git a/local/utility.py b/local/utility.py index fa8ca28..1c478c3 100644 --- a/local/utility.py +++ b/local/utility.py @@ -24,8 +24,17 @@ def registryValue(plugin, name, channel=None, value=True): return group def configValue(name, channel=None, repo=None, type=None, module=None): + if globals.configOverrides and name in globals.configOverrides: + return globals.configOverrides[name] return registryValue("Github", name, channel) +def addConfigOverride(name, value): + if not 'override' in name.lower(): + globals.configOverrides[name] = value + +def resetConfigOverrides(): + globals.configOverrides = {} + def plural(number, s, p): if number != 1: return p |