will
will copied to clipboard
#359 Adds Slack bot message support to Slack backend
PR adds support for Slack bot messages that come in via WebHooks. Based on the work from @Ashex in the original issue, it updates the message type check, and creates a Sender object from the bot details.
Additionally adds a new method in the SlackBackend, get_bot(self, bot_id)
that queries the info for the specified bot from Slack. It then creates a new dict object containing the bot information, and stores it under self._bots
. If we already have the bot stored, we return the stored object.
Slack does not have a "get all bot info" API call, so, we must get them one at a time like this, unfortunately. The event object received does not contain the bot name, only an ID, hence the inclusion of the above method to get the info.
Tested locally, the PR allows me to receive messages from our Jenkins app integration.
EDIT: PR also sets version of pytest-cov to 2.5.1, as 2.6.0 (The newest version as of 7 days ago) requires an upgrade to pytest 2.9
Fixes #359
@skoczen if you could please take a look at this - Without this PR, our bot is broken after moving to Slack, since it can't pick up any messages from our Jenkins or Rundeck integrations.
This is a nice coincidence, I had just started taking a second look at my patch to see how to fix the issue you addressed! I'll patch this in and verify it.
@Ashex Ah good timing then - thanks for the original patch! Hope this works for you as well.
Added a commit that sets the event content to the first attachment's fallback field. Otherwise, content ends up equaling the original event object, which isn't what we want.
I'm not sure there's a better way of extracting the message texts from bot_messages as they always seem to come as attachments with fields, AFAIK, and there can be zero or more.
/cc @Ashex