diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-04-27 22:13:28 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-04-27 23:02:17 +0300 |
commit | 44e5718b218b879d7cc5e83ad387e02b9668937e (patch) | |
tree | 7d87a6e7b1858454996b368def87e508992450b3 /local | |
parent | f77b81fb4b8da3e014959ef72cc20d3c64479a4e (diff) | |
download | supybot_github-44e5718b218b879d7cc5e83ad387e02b9668937e.tar.gz supybot_github-44e5718b218b879d7cc5e83ad387e02b9668937e.tar.bz2 supybot_github-44e5718b218b879d7cc5e83ad387e02b9668937e.zip |
Make sure that the event handlers return an array of strings as opposed to an array of IRC messages
Diffstat (limited to 'local')
-rw-r--r-- | local/handler/GithubHandler.py | 12 | ||||
-rw-r--r-- | local/handler/IssueCommentHandler.py | 9 | ||||
-rw-r--r-- | local/handler/IssueHandler.py | 8 | ||||
-rw-r--r-- | local/handler/PushHandler.py | 20 | ||||
-rw-r--r-- | local/handler/StatusHandler.py | 8 | ||||
-rw-r--r-- | local/handler/WikiHandler.py | 8 |
6 files changed, 27 insertions, 38 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index c5510c8..2b4096d 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -90,22 +90,22 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): msgs = [] if 'pages' in data: - msgs = WikiHandler.handle(irc, data, channel) + msgs = WikiHandler.handle(irc, data) elif 'state' in data: - msgs = StatusHandler.handle(irc, data, channel) + msgs = StatusHandler.handle(irc, data) elif 'commits' in data: - msgs = PushHandler.handle(irc, data, channel) + msgs = PushHandler.handle(irc, data) elif 'issue' in data: if 'comment' in data: - msgs = IssueCommentHandler.handle(irc, data, channel) + msgs = IssueCommentHandler.handle(irc, data) else: - msgs = IssueHandler.handle(irc, data, channel) + msgs = IssueHandler.handle(irc, data) else: msgs.append( ircmsgs.privmsg(channel, "Something happened")) #msgs.append( ircmsgs.privmsg("#main", "%s" % ()) ) for msg in msgs: - irc.queueMsg(msg) + irc.queueMsg(ircmsgs.privmsg(channel, msg)) def log_message(self, format, *args): log.info(format % args) diff --git a/local/handler/IssueCommentHandler.py b/local/handler/IssueCommentHandler.py index 92a3b65..b5f70c0 100644 --- a/local/handler/IssueCommentHandler.py +++ b/local/handler/IssueCommentHandler.py @@ -1,8 +1,6 @@ -import supybot.ircmsgs as ircmsgs - from ..utility import * -def handle(irc, data, channel): +def handle(irc, data): msgs = [] url = getShortURL(data['comment']['html_url']) @@ -27,8 +25,7 @@ def handle(irc, data, channel): elif len(lines) > 1: line += "..." - msgs.append( ircmsgs.privmsg( - channel, "%s: %s commented on issue %s \"%s\"%s%s %s%s): %s" % ( + msgs.append( "%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'])]), @@ -37,6 +34,6 @@ def handle(irc, data, channel): milestone, oparen, url, line - )) ) + )) return msgs diff --git a/local/handler/IssueHandler.py b/local/handler/IssueHandler.py index ec66cd7..642b042 100644 --- a/local/handler/IssueHandler.py +++ b/local/handler/IssueHandler.py @@ -1,8 +1,6 @@ -import supybot.ircmsgs as ircmsgs - from ..utility import * -def handle(irc, data, channel): +def handle(irc, data): msgs = [] url = data['issue']['url'] @@ -25,7 +23,7 @@ def handle(irc, data, channel): else: oparen = '(' - msgs.append( ircmsgs.privmsg(channel, "%s: %s %s issue %s \"%s\"%s%s %s%s)" % ( + msgs.append( "%s: %s %s issue %s \"%s\"%s%s %s%s)" % ( ircutils.bold(data['repository']['name']), ircutils.mircColor(data['sender']['login'], senderColor), colorAction(data['action']), @@ -34,6 +32,6 @@ def handle(irc, data, channel): creator, milestone, oparen, url - )) ) + )) return msgs diff --git a/local/handler/PushHandler.py b/local/handler/PushHandler.py index 3755cc9..3ce24f9 100644 --- a/local/handler/PushHandler.py +++ b/local/handler/PushHandler.py @@ -1,8 +1,6 @@ -import supybot.ircmsgs as ircmsgs - from ..utility import * -def handle(irc, data, channel): +def handle(irc, data): msgs = [] commitno = len(data['commits']) @@ -70,7 +68,7 @@ def handle(irc, data, channel): if configValue("hidePush",None) == False and not branched: - msgs.append( ircmsgs.privmsg(channel, "%s @ %s: %s pushed %s %s (%s)%s" % ( + msgs.append( "%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"), @@ -78,7 +76,7 @@ def handle(irc, data, channel): plural(commitno, "commit", "commits"), getShortURL(data['compare']), colon - )) ) + )) elif branched: if isTag: if onlyDeleted: @@ -101,7 +99,7 @@ def handle(irc, data, channel): if configValue("hidePush",None) == False and regularCommitCount > 0: distinctMessage = " and %s %s %s" % ( colorAction("pushed"), regularCommitCount, plural(regularCommitCount, 'commit', 'commits')) - msgs.append( ircmsgs.privmsg(channel, "%s: %s %s %s %s%s%s into %s%s" % ( + msgs.append( "%s: %s %s %s %s%s%s into %s%s" % ( ircutils.bold(data['repository']['name']), ircutils.mircColor(data['pusher']['name'], "green"), colorAction(action), @@ -111,7 +109,7 @@ def handle(irc, data, channel): distinctMessage, ircutils.bold(ircutils.mircColor(branch, "blue")), urls - )) ) + )) else: msgs.append( ircmsgs.privmsg(channel, "%s: %s %s branch %s%s%s%s" % ( ircutils.bold(data['repository']['name']), @@ -137,21 +135,21 @@ def handle(irc, data, channel): if isMerge and not commit['distinct']: commitBranch = "%s -> %s" % ( baseBranch, branch ) - msgs.append( ircmsgs.privmsg(channel, "%s @ %s: %s * %s (%s)" % ( + msgs.append("%s @ %s: %s * %s (%s)" % ( ircutils.bold(ircutils.mircColor(commitBranch, "blue")), ircutils.bold(data['repository']['name']), ircutils.mircColor(author, "green"), ircutils.bold(commit['id'][0:6]), getShortURL(commit['url']), - )) ) + )) commitlines = commit['message'].splitlines() for rawline in commitlines: line = maxLen(rawline, 400) - msgs.append(ircmsgs.privmsg(channel, "%s @ %s: %s" % ( + msgs.append( "%s @ %s: %s" % ( ircutils.bold(ircutils.mircColor(commitBranch, "blue")), ircutils.bold(data['repository']['name']), line, - )) ) + )) return msgs diff --git a/local/handler/StatusHandler.py b/local/handler/StatusHandler.py index 219a7dd..270e9f3 100644 --- a/local/handler/StatusHandler.py +++ b/local/handler/StatusHandler.py @@ -1,15 +1,13 @@ -import supybot.ircmsgs as ircmsgs - from ..utility import * -def handle(irc, data, channel): +def handle(irc, data): msgs = [] - msgs.append( ircmsgs.privmsg(channel, "%s: %s - %s (%s)" % ( + msgs.append( "%s: %s - %s (%s)" % ( ircutils.bold(data['repository']['name']), colorAction(data['state']), data['description'], data['target_url'] - )) ) + )) return msgs diff --git a/local/handler/WikiHandler.py b/local/handler/WikiHandler.py index 6e0cd5d..8739159 100644 --- a/local/handler/WikiHandler.py +++ b/local/handler/WikiHandler.py @@ -1,8 +1,6 @@ -import supybot.ircmsgs as ircmsgs - from ..utility import * -def handle(irc, data, channel): +def handle(irc, data): msgs = [] pageno = len(data['pages']) @@ -30,13 +28,13 @@ def handle(irc, data, channel): pageurl = "(%s)" % (page['html_url'],) # Unfortunately github doesn't support edit summaries :( - 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['sender']['login'], "green"), colorAction(page['action']), ircutils.bold(ircutils.mircColor(page['page_name'], "blue")), ircutils.bold(page['sha'][0:6]), pageurl, - )) ) + )) return msgs |