sym.sdk.integrations.slack¶
Helpers for interacting with a Slack workspace.
Functions
|
A reference to a Slack channel. |
|
An instruction to try a series of slack.channel, slack.user, and slack.group until one succeeds. |
|
Get information about a Slack user. |
|
A reference to a Slack group. |
|
Returns a list of all users in the workspace. |
|
Returns a string that mentions a Slack user given their identifier. |
|
Sends a simple message to a destination in Slack. |
|
A reference to a Slack user. |
Classes
An enumeration. |
- class sym.sdk.integrations.slack.SlackChannel(lookup_type: sym.sdk.integrations.slack.SlackLookupType, lookup_keys: List[Union[str, sym.sdk.user.User]], allow_self: bool = True)¶
Bases:
object
- sym.sdk.integrations.slack.channel(name: str, allow_self: bool = False) sym.sdk.integrations.slack.SlackChannel ¶
A reference to a Slack channel.
- Parameters
name – The channel name to send the message to.
allow_self – Whether to allow the current user to approve their own request.
- sym.sdk.integrations.slack.fallback(*channels: sym.sdk.integrations.slack.SlackChannel) sym.sdk.integrations.slack.SlackChannel ¶
An instruction to try a series of slack.channel, slack.user, and slack.group until one succeeds.
e.g. slack.fallback(slack.channel(“#missing”), slack.user(“@david”))
- sym.sdk.integrations.slack.get_user_info(user: sym.sdk.user.User) dict ¶
Get information about a Slack user.
Refer to Slack’s users.info API documentation for the details on the response format: https://api.slack.com/methods/users.info
- Parameters
user – The Sym user to get info about.
- sym.sdk.integrations.slack.group(users: Sequence[Union[str, sym.sdk.user.User]], allow_self: bool = False) sym.sdk.integrations.slack.SlackChannel ¶
A reference to a Slack group.
- sym.sdk.integrations.slack.list_users(self, active_only: bool = True) list ¶
Returns a list of all users in the workspace.
Refer to Slack’s users.info API documentation for the details on the response format: https://api.slack.com/methods/users.list
- Parameters
active_only – A boolean indicating whether or not to exclude deactivated and deleted users.
- sym.sdk.integrations.slack.mention(identifier: Union[str, sym.sdk.user.User]) str ¶
Returns a string that mentions a Slack user given their identifier.
Users can be specified with a Slack user ID, email, a string version of an @mention e.g. @Jane Austen, or Sym
User
instance.
- sym.sdk.integrations.slack.send_message(destination: Union[sym.sdk.user.User, sym.sdk.integrations.slack.SlackChannel], message: str) None ¶
Sends a simple message to a destination in Slack. Accepts either a
User
or aSlackChannel
, which may represent a user, group, or channel in Slack.For example:
# To send to #general: slack.send_message(slack.channel("#general"), "Hello, world!") # To DM a specific user: slack.send_message(slack.user("me@symops.io"), "It works!") # To DM the user who triggered an event: slack.send_message(event.user, "You did a thing!")
- Parameters
destination – where the message should go.
message – the text contents of the message to send.
- sym.sdk.integrations.slack.user(identifier: Union[str, sym.sdk.user.User]) sym.sdk.integrations.slack.SlackChannel ¶
A reference to a Slack user.
Users can be specified with a Slack user ID, email, a string version of an @mention e.g. @Jane Austen, or Sym
User
instance.