@@ -0,0 +1,3064 @@
+import json%0Afrom twisted.internet import defer%0Afrom twisted.python import log%0A%0Afrom buildbot.process.results import CANCELLED, EXCEPTION, FAILURE, SUCCESS, WARNINGS%0Afrom buildbot.reporters.notifier import NotifierBase%0Afrom buildbot.util import httpclientservice%0A%0ACOLORS = %7B%0A    CANCELLED: 'warning',%0A    EXCEPTION: 'warning',%0A    FAILURE: 'danger',%0A    SUCCESS: 'good',%0A    WARNINGS: 'warning'%0A%7D%0A%0A%0Aclass SlackNotifier(NotifierBase):%0A%0A    def checkConfig(self, hook,%0A                    mode=(%22failing%22, %22passing%22, %22warnings%22),%0A                    tags=None, builders=None,%0A                    buildSetSummary=False, messageFormatter=None,%0A                    subject=%22Buildbot %25(result)s in %25(title)s on %25(builder)s%22,%0A                    schedulers=None, branches=None,%0A                    colors=None, base_url='https://hooks.slack.com/services',%0A                    watchedWorkers=None, messageFormatterMissingWorker=None):%0A        super(SlackNotifier, self).checkConfig(mode, tags, builders,%0A                                               buildSetSummary, messageFormatter,%0A                                               subject, False, False,%0A                                               schedulers,%0A                                               branches, watchedWorkers)%0A%0A        httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name__)%0A%0A    @defer.inlineCallbacks%0A    def reconfigService(self, hook,%0A                        mode=(%22failing%22, %22passing%22, %22warnings%22),%0A                        tags=None, builders=None,%0A                        buildSetSummary=False, messageFormatter=None,%0A                        subject=%22Buildbot %25(result)s in %25(title)s on %25(builder)s%22,%0A                        schedulers=None, branches=None,%0A                        colors=None, base_url='https://hooks.slack.com/services',%0A                        watchedWorkers=None, messageFormatterMissingWorker=None):%0A        super(SlackNotifier, self).reconfigService(mode, tags, builders,%0A                                                   buildSetSummary, messageFormatter,%0A                                                   subject, False, False,%0A                                                   schedulers, branches,%0A                                                   watchedWorkers, messageFormatterMissingWorker)%0A        self.hook = hook%0A        self.colors = colors if colors is not None else COLORS%0A        self._http = yield httpclientservice.HTTPClientService.getService(%0A            self.master, base_url)%0A%0A    @defer.inlineCallbacks%0A    def sendMessage(self, body, subject=None, type='plain', builderName=None,%0A                    results=None, builds=None, users=None, patches=None,%0A                    logs=None, worker=None):%0A        msgtext = %22%25s%5Cn%25s%22 %25 (subject, body)%0A        msg = %7B'attachments': %5B%7B'color': self.colors.get(results, 'warning'), 'text': msgtext%7D%5D%7D%0A        response = yield self._http.post(self.hook, json=msg)%0A        if response.code != 200:%0A            log.msg(%22POST response code %25s: %25s%22 %25 (response.code, response.content))%0A

Add Slack notifier supporting buildset summaries