Slack. Lookups
(SlackKit v1.0.0-alpha.0)
View Source
Translates between Slack's IDs and human-friendly names.
Slack's RTM events almost always carry IDs ("U…", "C…", "G…", "D…","B…") rather than display names; these helpers resolve them either
direction against the live Slack.State your bot holds. All functions are
imported into modules that use Slack, so you can call them unqualified
from within callbacks.
The functions that accept "@USER_NAME" / "#CHANNEL_NAME" strings are
convenient but slow (linear scan over slack.users or slack.channels).
Prefer raw IDs in hot paths.
Username references are deprecated
Slack deprecated @username references in 2017; see the
changelog.
Functions that accept them log a warning on each call and may be removed
in a future major version.
Summary
Functions
Resolves a "#CHANNEL_NAME" string to its ID.
Resolves a Slack channel ID to a "#CHANNEL_NAME" string.
Resolves a user reference to its DM channel ID ("D…").
Resolves a "@USER_NAME" string to a user ID ("U…").
Resolves a Slack ID to a "@USER_NAME" string.
Types
@type slack() :: Slack.State.t()
Functions
Resolves a "#CHANNEL_NAME" string to its ID.
Returns the channel's ID as "C…" for a public channel or "G…" for a
private channel/group. Returns nil if no channel with that name is known
to slack.
Resolves a Slack channel ID to a "#CHANNEL_NAME" string.
Accepts a public channel ID ("C…") or a private channel ID ("G…").
Returns the name prefixed with #.
Resolves a user reference to its DM channel ID ("D…").
Accepts either a user ID ("U…") or a "@USER_NAME" string (deprecated).
Returns nil if a DM channel with that user has not been opened yet —Slack.Sends.send_message/3 will open one transparently in that case.
Resolves a "@USER_NAME" string to a user ID ("U…").
Returns nil if no user with that name is present in slack.users.
Deprecated; see the module docs.
Resolves a Slack ID to a "@USER_NAME" string.
Accepts a user ID ("U…" or "W…"), a DM channel ID ("D…" — looked up
via the user on the other side of the DM), or a bot ID ("B…"). Returns
the name prefixed with @. Deprecated; see the module docs.