Skip to content

Commit

Permalink
Custom Slack client
Browse files Browse the repository at this point in the history

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
  • Loading branch information
MattBlack85 authored Jan 3, 2024
1 parent 57ac0c2 commit e9d09a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion machine/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ async def _setup_slack_clients(self) -> None:
proxy=self._settings["HTTP_PROXY"],
)

# Find out if the default client should be used or a custom one
client = self._settings.get("SLACK_CLIENT", "machine.clients.slack.SlackClient")
logger.info("Initializing Slack client `%s`...", client)
_, cls = import_string(client)[0]

# Setup high-level Slack client for plugins
self._client = SlackClient(self._socket_mode_client, self._tz)
self._client = cls(self._socket_mode_client, self._tz)
logger.info("Slack client `%s` initialized", client)
await self._client.setup()

# TODO: factor out plugin registration in separate class / set of functions
Expand Down

0 comments on commit e9d09a0

Please sign in to comment.