GitHub

SlackChatService

API reference for SlackChatService.

The Slack side of the adapter, for what the core has no op for.

  • bot_user_id comes from auth.test, read once. A failed read is tried again next time.
  • user calls users.info each time.
  • interaction is the entry for a decoded Interactivity payload (block_actions or view_submission) and for a slash command's fields. It normalises with normalize_interaction, calls the handler through chat_interaction.handle inside deadline (2.5 seconds by default, the handler's share of Slack's 3), opens a modal with views.open and calls Handler.refused when it can't. It succeeds with the body to answer Slack with; None is an empty answer, and Late (a submit or command past the deadline) is no answer at all: layer_interactivity answers 503 for it. It checks no signature and no app id: that is the transport's job.

Attributes

AttributeTypeDescription
team_idstr

The workspace.

bot_user_idEffect[str, ChatError]

The bot's user id, from auth.test.

Functions

__init__

__init__(*, team_id, bot_user_id, adapter, interaction) -> None
ParameterTypeDescription
team_idstr
bot_user_idEffect[str, ChatError]
adapterSlackAdapter
interactionCallable[[object, Duration], Effect[Body, Never, Handler]]
def __init__(
    self,
    *,
    team_id: str,
    bot_user_id: Effect[str, ChatError],
    adapter: SlackAdapter,
    interaction: Callable[[object, Duration], Effect[Body, Never, Handler]],
) -> None:
    self._team_id = team_id
    self._bot_user_id = bot_user_id
    self._adapter = adapter
    self._interaction = interaction

user

user(id) -> Effect[SlackUser, ChatError]

A user from users.info, with team, guest and Slack Connect status.

ParameterTypeDescription
idstr

Returns Effect[SlackUser, ChatError]

def user(self, id: str) -> Effect[SlackUser, ChatError]:
    """A user from ``users.info``, with team, guest and Slack Connect status."""
    return self._adapter.user(id)

interaction

interaction(payload, *, deadline=_interactions.DEFAULT_DEADLINE) -> Effect[Body, Never, Handler]

Handles one interactivity payload or slash command; see the class.

ParameterTypeDescription
payloadobject
deadlineDurationInput = _interactions.DEFAULT_DEADLINE

Returns Effect[Body, Never, Handler]

def interaction(
    self, payload: object, *, deadline: DurationInput = _interactions.DEFAULT_DEADLINE
) -> Effect[Body, Never, Handler]:
    """Handles one interactivity payload or slash command; see the class."""
    return self._interaction(payload, from_input_unsafe(deadline))