slack-machine
slack-machine copied to clipboard
Custom Slack client
This change will allow to pass an importable and valid class that will be used to initialize the base Machine class
Missing methods and additional attributes may be created and used.
It defaults to machine.clients.slack.SlackClient if there is no SLACK_CLIENT in local_settings.py
This is especially useful when in a project some more sugar around the Slack API is needed and the slack-machine default client doesn't provide such APIs
Hey, thanks for your contribution. I'm trying to understand the goal of this change? What do you want to achieve with the ability to pass in a custom SlackClient?
Also, the tests are failing
hi @DonDebonair the idea is to have the capability to add some more APIs on the SlackClient itself for very specific use case instead of making standalone functions. The client is injected everywhere and this may provide a nice shortcut to use some additional APIs which are not provided out of the box by the default client. Example
class MySlackCLient(SlackClient):
_some_fancy_cache = {}
def archive_channel_by_id(self, channel):
pass
def archive_channel_by_name(self, channel):
pass
and then in any plugin I can do
self._client.archive_channel_by_id(KAH21438)
or every custom use case one may have.
Will look into tests, I cannot guess atm what's wrong cause I am using this approach already in production and everything is working flawlessy :D maybe something related to mocking
PS: the SlackClient has some useful data already and building APIs on the top of existing API or reference data within the client itself (users, channels) is probably more concise than having to pass the client around