diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/404.html b/404.html new file mode 100644 index 00000000..b7c1a389 --- /dev/null +++ b/404.html @@ -0,0 +1,703 @@ + + + +
+ + + + + + + + + + + + + + +This is the API documentation of all the classes and functions relevant for Plugin development. The rest of the code +deals with the internal workings of Slack Machine and is very much an implementation detail and subject to change. +Therefore it is not documented.
+The following classes form the basis for Plugin development.
+ + +
machine.plugins.base.MachineBasePlugin
+
+
+Base class for all Slack Machine plugins
+The purpose of this class is two-fold:
+Attributes:
+Name | +Type | +Description | +
---|---|---|
settings |
+
+ CaseInsensitiveDict
+ |
+
+
+
+ Slack Machine settings object that contains all settings that
+ were defined through |
+
storage |
+
+ PluginStorage
+ |
+
+
+
+ Plugin storage object that allows plugins to store and retrieve data + |
+
src/machine/plugins/base.py
21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 |
|
users: dict[str, User]
+
+
+ property
+
+
+
users_by_email: dict[str, User]
+
+
+ property
+
+
+Dictionary of all users in the Slack workspace by email
+ + +not every user might have an email address in their profile, so this +dictionary might not contain all users in the Slack workspace
+Returns:
+Type | +Description | +
---|---|
+ dict[str, User]
+ |
+
+
+
+ a dictionary of all users in the Slack workspace, where the key is the email and
+the value is a |
+
channels: dict[str, Channel]
+
+
+ property
+
+
+List of all channels in the Slack workspace
+This is a list of all channels in the Slack workspace that the bot is aware of. This +includes all public channels, all private channels the bot is a member of and all DM +channels the bot is a member of.
+ + +Returns:
+Type | +Description | +
---|---|
+ dict[str, Channel]
+ |
+
+
+
+ a list of all channels in the Slack workspace, where each channel is a
+ |
+
web_client: AsyncWebClient
+
+
+ property
+
+
+Slack SDK web client to access the Slack Web API
+ + +Returns:
+Type | +Description | +
---|---|
+ AsyncWebClient
+ |
+
+
+
+ an instance of |
+
bot_info: dict[str, Any]
+
+
+ property
+
+
+
init() -> None
+
+
+ async
+
+
+Initialize plugin
+This method can be implemented by concrete plugin classes. It will be called once
+for each plugin, when that plugin is first loaded. You can refer to settings via
+self.settings
, and access storage through self.storage
, but the Slack client has
+not been initialized yet, so you cannot send or process messages during initialization.
src/machine/plugins/base.py
108 +109 +110 +111 +112 +113 +114 +115 +116 |
|
find_channel_by_name(channel_name: str) -> Channel | None
+
+Find a channel by its name, irrespective of a preceding pound symbol. This does not include DMs.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel_name
+ |
+
+ str
+ |
+
+
+
+ The name of the channel to retrieve. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Channel | None
+ |
+
+
+
+ The channel if found, |
+
src/machine/plugins/base.py
118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 |
|
get_user_by_id(user_id: str) -> User | None
+
+Get a user by their ID.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ user_id
+ |
+
+ str
+ |
+
+
+
+ The ID of the user to retrieve. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ User | None
+ |
+
+
+
+ The user if found, None otherwise. + |
+
src/machine/plugins/base.py
134 +135 +136 +137 +138 +139 +140 +141 +142 +143 |
|
get_user_by_email(email: str) -> User | None
+
+Get a user by their email address.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ email
+ |
+
+ str
+ |
+
+
+
+ The email address of the user to retrieve. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ User | None
+ |
+
+
+
+ The user if found, None otherwise. + |
+
src/machine/plugins/base.py
145 +146 +147 +148 +149 +150 +151 +152 +153 +154 |
|
at(user: User) -> str
+
+Create a mention of the provided user
+Create a mention of the provided user in the form of <@[user_id]>
. This method is
+convenient when you want to include mentions in your message. This method does not send
+a message, but should be used together with methods like
+say()
.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ user
+ |
+
+ User
+ |
+
+
+
+ user your want to mention + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ user mention + |
+
src/machine/plugins/base.py
156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 |
|
say(channel: Channel | str, text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, thread_ts: str | None = None, ephemeral_user: User | str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a message to a channel
+Send a message to a channel using the WebAPI. Allows for rich formatting using
+blocks and/or attachments. You can provide blocks and attachments as Python dicts or
+you can use the convenience classes that the underlying slack client provides.
+Can also reply in-thread and send ephemeral messages, visible to only one user.
+Ephemeral messages and threaded messages are mutually exclusive, and ephemeral_user
+takes precedence over thread_ts
Any extra kwargs you provide, will be passed on directly to the chat.postMessage or +chat.postEphemeral request.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+
|
+ + required + | +
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ thread_ts
+ |
+
+ str | None
+ |
+
+
+
+ optional timestamp of thread, to send a message in that thread + |
+
+ None
+ |
+
+ ephemeral_user
+ |
+
+ User | str | None
+ |
+
+
+
+ optional user name or id if the message needs to visible +to a specific user only + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response,
+or chat.postEphemeral if |
+
src/machine/plugins/base.py
172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 |
|
say_scheduled(when: datetime, channel: Channel | str, text: str, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, thread_ts: str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Schedule a message to a channel
+This is the scheduled version of say()
.
+It behaves the same, but will send the message at the scheduled time.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ when
+ |
+
+ datetime
+ |
+
+
+
+ when you want the message to be sent, as |
+ + required + | +
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+
|
+ + required + | +
+ text
+ |
+
+ str
+ |
+
+
+
+ message text + |
+ + required + | +
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ thread_ts
+ |
+
+ str | None
+ |
+
+
+
+ optional timestamp of thread, to send a message in that thread + |
+
+ None
+ |
+
Returns: + Dictionary deserialized from chat.scheduleMessage + response.
+ +src/machine/plugins/base.py
225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 |
|
update(channel: Channel | str, ts: str, text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, ephemeral_user: User | str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Update an existing message
+Update an existing message using the WebAPI. Allows for rich formatting using
+blocks and/or attachments. You can provide blocks and attachments as Python dicts or
+you can use the convenience classes that the underlying slack client provides.
+Can also update in-thread and ephemeral messages, visible to only one user.
+Any extra kwargs you provide, will be passed on directly to the chat.update
request.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+
|
+ + required + | +
+ ts
+ |
+
+ str
+ |
+
+
+
+ timestamp of the message to be updated. + |
+ + required + | +
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ ephemeral_user
+ |
+
+ User | str | None
+ |
+
+
+
+ optional user name or id if the message needs to visible +to a specific user only + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from |
+
src/machine/plugins/base.py
262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 |
|
delete(channel: Channel | str, ts: str, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Delete an existing message
+Delete an existing message using the WebAPI.
+Any extra kwargs you provide, will be passed on directly to the chat.delete
request.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+
|
+ + required + | +
+ ts
+ |
+
+ str
+ |
+
+
+
+ timestamp of the message to be deleted. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from |
+
src/machine/plugins/base.py
308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 |
|
react(channel: Channel | str, ts: str, emoji: str) -> AsyncSlackResponse
+
+
+ async
+
+
+React to a message in a channel
+Add a reaction to a message in a channel. What message to react to, is determined by the +combination of the channel and the timestamp of the message.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+
|
+ + required + | +
+ ts
+ |
+
+ str
+ |
+
+
+
+ timestamp of the message to react to + |
+ + required + | +
+ emoji
+ |
+
+ str
+ |
+
+
+
+ what emoji to react with (should be a string, like 'angel', 'thumbsup', etc.) + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from reactions.add response. + |
+
src/machine/plugins/base.py
335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 |
|
send_dm(user: User | str, text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a Direct Message
+Send a Direct Message to a user by opening a DM channel and sending a message to it. Allows +for rich formatting using blocks and/or attachments. You can provide blocks and +attachments as Python dicts or you can use the convenience classes that the underlying +slack client provides. +Any extra kwargs you provide, will be passed on directly to the chat.postMessage request.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ user
+ |
+
+ User | str
+ |
+
+
+
+
|
+ + required + | +
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response. + |
+
src/machine/plugins/base.py
352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 |
|
send_dm_scheduled(when: datetime, user: User | str, text: str, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Schedule a Direct Message
+This is the scheduled version of
+send_dm()
. It behaves the same, but
+will send the DM at the scheduled time.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ when
+ |
+
+ datetime
+ |
+
+
+
+ when you want the message to be sent, as |
+ + required + | +
+ user
+ |
+
+ User | str
+ |
+
+
+
+
|
+ + required + | +
+ text
+ |
+
+ str
+ |
+
+
+
+ message text + |
+ + required + | +
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.scheduleMessage +response. + |
+
src/machine/plugins/base.py
385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 |
|
open_im(users: User | str | list[User | str]) -> str
+
+
+ async
+
+
+Open a DM channel with one or more users
+Open a DM channel with one or more users. If the DM channel already exists, the existing channel id +will be returned. If the DM channel does not exist, a new channel will be created and the +id of the new channel will be returned.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ users
+ |
+
+ User | str | list[User | str]
+ |
+
+
+
+
|
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ id of the DM channel + |
+
src/machine/plugins/base.py
415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 |
|
emit(event: str, **kwargs: Any) -> None
+
+Emit an event
+Emit an event that plugins can listen for. You can include arbitrary data as keyword +arguments.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ event
+ |
+
+ str
+ |
+
+
+
+ name of the event + |
+ + required + | +
+ **kwargs
+ |
+
+ Any
+ |
+
+
+
+ any data you want to emit with the event + |
+
+ {}
+ |
+
src/machine/plugins/base.py
431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 |
|
pin_message(channel: Channel | str, ts: str) -> AsyncSlackResponse
+
+
+ async
+
+
+Pin message
+Pin a message in a channel
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+ channel to pin the message in + |
+ + required + | +
+ ts
+ |
+
+ str
+ |
+
+
+
+ timestamp of the message to pin + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from pins.add response. + |
+
src/machine/plugins/base.py
443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 |
|
unpin_message(channel: Channel | str, ts: str) -> AsyncSlackResponse
+
+
+ async
+
+
+Unpin message
+Unpin a message that was previously pinned in a channel
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+ channel where the message is pinned that needs to be unpinned + |
+ + required + | +
+ ts
+ |
+
+ str
+ |
+
+
+
+ timestamp of the message to unpin + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from pins.remove response. + |
+
src/machine/plugins/base.py
457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 |
|
set_topic(channel: Channel | str, topic: str, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Set channel topic
+Set or update topic for the channel
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ channel
+ |
+
+ Channel | str
+ |
+
+
+
+ channel where topic needs to be set or updated + |
+ + required + | +
+ topic
+ |
+
+ str
+ |
+
+
+
+ topic for the channel (slack does not support formatting for topics) + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from conversations.setTopic +response. + |
+
src/machine/plugins/base.py
471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 |
|
open_modal(trigger_id: str, view: dict | View, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Open a modal dialog
+Open a modal dialog in response to a user action. The modal dialog can be used to collect +information from the user, or to display information to the user.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ trigger_id
+ |
+
+ str
+ |
+
+
+
+ trigger id is provided by Slack when a user action is performed, such as a slash command +or a button click + |
+ + required + | +
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ view definition for the modal dialog + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.open response. + |
+
src/machine/plugins/base.py
486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 |
|
push_modal(trigger_id: str, view: dict | View, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Push a new view onto the stack of a modal that was already opened
+Push a new view onto the stack of a modal that was already opened by a open_modal call. At most 3 views can be +active in a modal at the same time. For more information on the lifecycle of modals, refer to the +relevant Slack documentation
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ trigger_id
+ |
+
+ str
+ |
+
+
+
+ trigger id is provided by Slack when a user action is performed, such as a slash command +or a button click + |
+ + required + | +
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ view definition for the modal dialog + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.push response. + |
+
src/machine/plugins/base.py
502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 |
|
update_modal(view: dict | View, view_id: str | None = None, external_id: str | None = None, hash: str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Update a modal dialog
+Update a modal dialog that was previously opened. You can update the view by providing the view_id or the +external_id of the modal. external_id has precedence over view_id, but at least one needs to be provided. +You can also provide a hash of the view that you want to update to prevent race conditions.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ view definition for the modal dialog + |
+ + required + | +
+ view_id
+ |
+
+ str | None
+ |
+
+
+
+ id of the view to update + |
+
+ None
+ |
+
+ external_id
+ |
+
+ str | None
+ |
+
+
+
+ external id of the view to update + |
+
+ None
+ |
+
+ hash
+ |
+
+ str | None
+ |
+
+
+
+ hash of the view to update + |
+
+ None
+ |
+
Returns: + Dictionary deserialized from views.update response.
+ +src/machine/plugins/base.py
519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 |
|
publish_home_tab(user: User | str, view: dict | View, hash: str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Publish a view to the home tab of a user
+Publish a view to the home tab of a user. The view will be visible to the user when they open the home tab of +your Slack app. This method can be used both to publish a new view for the home tab or update an existing view. +You can provide a hash of the view that you want to update to prevent race conditions.
+ + +Be careful with the use of this method, as you might be overwriting the user's home tab that was set by +another Slack Machine plugin enabled in your bot.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ user
+ |
+
+ User | str
+ |
+
+
+
+ user for whom to publish or update the home tab + |
+ + required + | +
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ view definition for the home tab + |
+ + required + | +
+ hash
+ |
+
+ str | None
+ |
+
+
+
+ hash of the view to update + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.publish response. + |
+
src/machine/plugins/base.py
543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 |
|
machine.plugins.message.Message
+
+
+A message that was received by the bot
+This class represents a message that was received by the bot and passed to one or more +plugins. It contains the message (text) itself, and metadata about the message, such as the +sender of the message, the channel the message was sent to.
+The Message
class also contains convenience methods for replying to the message in the
+right channel, replying to the sender, etc.
src/machine/plugins/message.py
16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 |
|
sender: User
+
+
+ property
+
+
+The sender of the message
+ + +Returns:
+Type | +Description | +
---|---|
+ User
+ |
+
+
+
+ the User the message was sent by + |
+
channel: Channel
+
+
+ property
+
+
+The channel the message was sent to
+ + +Returns:
+Type | +Description | +
---|---|
+ Channel
+ |
+
+
+
+ the Channel the message was sent to + |
+
is_dm: bool
+
+
+ property
+
+
+Is the message a direct message
+ + +Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+
|
+
text: str
+
+
+ property
+
+
+The body of the actual message
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the body (text) of the actual message + |
+
at_sender: str
+
+
+ property
+
+
+
ts: str
+
+
+ property
+
+
+The timestamp of the message
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the timestamp of the message + |
+
in_thread: bool
+
+
+ property
+
+
+Is message in a thread
+ + +Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+ the message is in a thread + |
+
say(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, thread_ts: str | None = None, ephemeral: bool = False, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a new message to the channel the original message was received in
+Send a new message to the channel the original message was received in, using the WebAPI.
+Allows for rich formatting using blocks and/or attachments. You can provide blocks
+and attachments as Python dicts or you can use the convenience classes that the
+underlying slack client provides.
+Can also reply to a thread and send an ephemeral message only visible to the sender of the
+original message. Ephemeral messages and threaded messages are mutually exclusive, and
+ephemeral
takes precedence over thread_ts
+Any extra kwargs you provide, will be passed on directly to the chat.postMessage or
+chat.postEphemeral request.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ thread_ts
+ |
+
+ str | None
+ |
+
+
+
+ optional timestamp of thread, to send a message in that thread + |
+
+ None
+ |
+
+ ephemeral
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response,
+or chat.postEphemeral if |
+
src/machine/plugins/message.py
98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 |
|
say_scheduled(when: datetime, text: str, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, thread_ts: str | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Schedule a message
+This is the scheduled version of say()
.
+It behaves the same, but will send the message at the scheduled time.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ when
+ |
+
+ datetime
+ |
+
+
+
+ when you want the message to be sent, as |
+ + required + | +
+ text
+ |
+
+ str
+ |
+
+
+
+ message text + |
+ + required + | +
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ thread_ts
+ |
+
+ str | None
+ |
+
+
+
+ optional timestamp of thread, to send a message in that thread + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.scheduleMessage +response. + |
+
src/machine/plugins/message.py
152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 |
|
reply(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, in_thread: bool = False, ephemeral: bool = False, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Reply to the sender of the original message
+Reply to the sender of the original message with a new message, mentioning that user. Rich
+formatting using blocks and/or attachments is possible. You can provide blocks
+and attachments as Python dicts or you can use the convenience classes that the
+underlying slack client provides.
+Can also reply to a thread and send an ephemeral message only visible to the sender of the
+original message. In the case of in-thread response, the sender of the original message
+will not be mentioned. Ephemeral messages and threaded messages are mutually exclusive,
+and ephemeral
takes precedence over in_thread
+Any extra kwargs you provide, will be passed on directly to the chat.postMessage or
+chat.postEphemeral request.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks + |
+
+ None
+ |
+
+ in_thread
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
+ ephemeral
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response,
+or chat.postEphemeral if |
+
src/machine/plugins/message.py
187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 |
|
reply_scheduled(when: datetime, text: str, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, in_thread: bool = False, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Schedule a reply and send it
+This is the scheduled version of reply()
.
+It behaves the same, but will send the reply at the scheduled time.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ when
+ |
+
+ datetime
+ |
+
+
+
+ when you want the message to be sent, as :py:class: |
+ + required + | +
+ text
+ |
+
+ str
+ |
+
+
+
+ message text + |
+ + required + | +
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ in_thread
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.scheduleMessage +response. + |
+
src/machine/plugins/message.py
234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 |
|
reply_dm(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Reply to the sender of the original message with a DM
+Reply in a Direct Message to the sender of the original message by opening a DM channel and +sending a message to it. Allows for rich formatting using blocks and/or attachments. +You can provide blocks and attachments as Python dicts or you can use the +convenience classes that the underlying slack client provides. +Any extra kwargs you provide, will be passed on directly to the chat.postMessage request.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response. + |
+
src/machine/plugins/message.py
267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 |
|
reply_dm_scheduled(when: datetime, text: str, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Schedule a DM reply and send it
+This is the scheduled version of reply_dm()
.
+It behaves the same, but will send the DM at the scheduled time.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ when
+ |
+
+ datetime
+ |
+
+
+
+ when you want the message to be sent, as :py:class: |
+ + required + | +
+ text
+ |
+
+ str
+ |
+
+
+
+ message text + |
+ + required + | +
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.scheduleMessage +response. + |
+
src/machine/plugins/message.py
298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 |
|
react(emoji: str) -> AsyncSlackResponse
+
+
+ async
+
+
+React to the original message
+Add a reaction to the original message
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ emoji
+ |
+
+ str
+ |
+
+
+
+ what emoji to react with (should be a string, like 'angel', 'thumbsup', etc.) + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from reactions.add response. + |
+
src/machine/plugins/message.py
325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 |
|
pin_message() -> AsyncSlackResponse
+
+
+ async
+
+
+Pin message
+Pin the current message in the channel it was posted in
+ + +Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from pins.add response. + |
+
src/machine/plugins/message.py
344 +345 +346 +347 +348 +349 +350 +351 +352 |
|
machine.plugins.command.Command
+
+
+A Slack command that was received by the bot
+This class represents a Slack command that was received by the bot and passed to a plugin. +It contains the text that was included when the command was invoked, and metadata about +the command, such as the user that invoked the command, the channel the command was invoked +in.
+The Command
class also contains convenience methods for sending messages in the right
+channel, opening modals etc.
src/machine/plugins/command.py
17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 |
|
sender: User
+
+
+ property
+
+
+The user that invoked the command
+ + +Returns:
+Type | +Description | +
---|---|
+ User
+ |
+
+
+
+ the User that invoked the command + |
+
channel: Channel
+
+
+ property
+
+
+The channel the command was invoked in
+ + +Returns:
+Type | +Description | +
---|---|
+ Channel
+ |
+
+
+
+ the Channel the command was invoked in + |
+
is_dm: bool
+
+
+ property
+
+
+Whether the command was invoked in a DM
+ + +Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+
|
+
text: str
+
+
+ property
+
+
+The body of the command (i.e. anything after the command itself)
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the body (text) of the command + |
+
command: str
+
+
+ property
+
+
+The command that was invoked
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the command that was invoked + |
+
response_url: str
+
+
+ property
+
+
+The response url associated with the command
+This is a unique url for this specific command invocation. +It can be used for sending messages in response to the command. +This can only be used 5 times within 30 minutes of receiving the payload.
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the response url associated with the command + |
+
trigger_id: str
+
+
+ property
+
+
+The trigger id associated with the command
+The trigger id can be used to trigger modals
+ + +The trigger_id
is only valid for 3 seconds after the modal was submitted.
You can use open_modal
to open a modal instead of using
+the trigger_id
directly.
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the trigger id associated with the command + |
+
say(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, ephemeral: bool = True, **kwargs: Any) -> WebhookResponse
+
+
+ async
+
+
+Send a new message to the channel the command was invoked in
+Send a new message to the channel the command was invoked in, using the response_url as a webhook.
+Allows for rich formatting using blocks and/or attachments . You can provide blocks
+and attachments as Python dicts or you can use the convenience classes that the
+underlying slack client provides.
+This will send an ephemeral message by default, only visible to the user that invoked the command.
+You can set ephemeral
to False
to make the message visible to everyone in the channel
+Any extra kwargs you provide, will be passed on directly to AsyncWebhookClient.send()
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ ephemeral
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ True
+ |
+
Returns:
+Type | +Description | +
---|---|
+ WebhookResponse
+ |
+
+
+
+ Dictionary deserialized from |
+
src/machine/plugins/command.py
111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 |
|
open_modal(view: dict | View, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Open a modal in response to the command
+Open a modal in response to the command, using the trigger_id that was returned when the command was invoked.
+Any extra kwargs you provide, will be passed on directly to AsyncWebClient.views_open()
You have to call this method within 3 seconds of receiving the command payload.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ the view to open + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from |
+
src/machine/plugins/command.py
149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 |
|
machine.plugins.block_action.BlockAction
+
+
+A Slack block action that was received by the bot
+This class represents a block action that was received by the bot and passed to a plugin. +Block actions are actions that are triggered by interactions with blocks in Slack messages and modals. +This class contains metadata about the block action, such as the action that happened that triggered this handler, +the user that triggered the action, the state of the block when the action was triggered, the payload that was +received when the action was triggered.
+ + +Attributes:
+Name | +Type | +Description | +
---|---|---|
payload |
+
+ BlockActionsPayload
+ |
+
+
+
+ The payload that was received by the bot when the action was triggered that this +plugin method listens for + |
+
triggered_action |
+
+ Action
+ |
+
+
+
+ The action that triggered this plugin method + |
+
src/machine/plugins/block_action.py
21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 |
|
payload: BlockActionsPayload = payload
+
+
+ instance-attribute
+
+
+The payload that was received by the bot when the action was triggered that this plugin method listens for
+
triggered_action: Action = triggered_action
+
+
+ instance-attribute
+
+
+The action that triggered this plugin method
+
user: User
+
+
+ property
+
+
+The user that triggered the action
+ + +Returns:
+Type | +Description | +
---|---|
+ User
+ |
+
+
+
+ the user that triggered the action + |
+
channel: Optional[Channel]
+
+
+ property
+
+
+
state: Optional[State]
+
+
+ property
+
+
+
response_url: Optional[str]
+
+
+ property
+
+
+
trigger_id: str
+
+
+ property
+
+
+The trigger id associated with the action
+The trigger id can be used to open a modal
+ + +The trigger_id
is only valid for 3 seconds after the modal was submitted.
You can use open_modal
to open a modal instead of
+using the trigger_id
directly.
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the trigger id for the action + |
+
say(text: Optional[str] = None, attachments: Union[Sequence[Attachment], Sequence[dict[str, Any]], None] = None, blocks: Union[Sequence[Block], Sequence[dict[str, Any]], None] = None, ephemeral: bool = True, replace_original: bool = False, delete_original: bool = False, **kwargs: Any) -> Optional[WebhookResponse]
+
+
+ async
+
+
+Send a new message to the channel the block action was triggered in
+Send a new message to the channel the block action was triggered in, using the response_url as a webhook.
+If the block action happened in a modal, the response_url will be None and this method will not send a message
+but instead log a warning.
+Allows for rich formatting using blocks and/or attachments. You can provide blocks
+and attachments as Python dicts or you can use the convenience classes that the
+underlying slack client provides.
+This will send an ephemeral message by default, only visible to the user that triggered the action.
+You can set ephemeral
to False
to make the message visible to everyone in the channel.
+By default, Slack replaces the original message in which the action was triggered. This method overrides this
+behavior. If you want your message to replace the original, set replace_original to True.
+Any extra kwargs you provide, will be passed on directly to AsyncWebhookClient.send()
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ Optional[str]
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Union[Sequence[Attachment], Sequence[dict[str, Any]], None]
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Union[Sequence[Block], Sequence[dict[str, Any]], None]
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
+ ephemeral
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ True
+ |
+
+ replace_original
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
+ delete_original
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Optional[WebhookResponse]
+ |
+
+
+
+ Dictionary deserialized from |
+
src/machine/plugins/block_action.py
102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 |
|
send_dm(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a DM to the user that triggered the block action
+Send a Direct Message to the user that triggered the block action by opening a DM channel and
+sending a message to it.
+Allows for rich formatting using blocks and/or attachments. You can provide blocks
+and attachments as Python dicts or you can use the convenience classes that the
+underlying slack client provides.
+Any extra kwargs you provide, will be passed on directly to the chat.postMessage
request.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response. + |
+
src/machine/plugins/block_action.py
162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 |
|
open_modal(view: dict | View, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Open a modal in response to the block action
+Open a modal in response to the block action, using the trigger_id that was returned when the block action was +triggered. +Any extra kwargs you provide, will be passed on directly to +views.open
+ + +You have to call this method within 3 seconds of receiving the block action payload.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ the view to open + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.open + |
+
src/machine/plugins/block_action.py
192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 |
|
machine.plugins.modals.ModalSubmission
+
+
+A Slack modal submission that was received by the bot
+This class represents a modal submission that was received by the bot and passed to a plugin.
+ + +Attributes:
+Name | +Type | +Description | +
---|---|---|
payload |
+
+ ViewSubmissionPayload
+ |
+
+
+
+ The payload that was received by the bot when the modal was submitted + |
+
src/machine/plugins/modals.py
16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 |
|
user: User
+
+
+ property
+
+
+The user that submitted the modal
+ + +Returns:
+Type | +Description | +
---|---|
+ User
+ |
+
+
+
+ the user that submitted the modal + |
+
view: View
+
+
+ property
+
+
+The view that was submitted including the state of all the elements in the view
+ + +Returns:
+Type | +Description | +
---|---|
+ View
+ |
+
+
+
+ the view that was submitted + |
+
trigger_id: str
+
+
+ property
+
+
+The trigger id associated with the submitted modal
+The trigger id can be used to open another modal
+ + +The trigger id is only valid for 3 seconds after the modal was submitted.
+You can use open_modal()
to open a modal instead of
+using the trigger_id
directly.
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the trigger id for the modal + |
+
open_modal(view: dict | SlackSDKView, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Open another modal in response to the modal submission
+Open another modal in response to modal submission, using the trigger_id that was returned when the modal was +submitted. +Any extra kwargs you provide, will be passed on directly to +views.open
+ + +You have to call this method within 3 seconds of receiving the modal submission payload.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ the view to open + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.open + |
+
src/machine/plugins/modals.py
66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 |
|
push_modal(view: dict | SlackSDKView, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Push a new modal view in response to the modal submission
+Push a new modal view on top of the view stack in response to modal submission, using the trigger_id that was +returned when the modal was submitted. +Any extra kwargs you provide, will be passed on directly to +views.push
+ + +You have to call this method within 3 seconds of receiving the modal submission payload.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ the view to push + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.push + |
+
src/machine/plugins/modals.py
89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 |
|
update_modal(view: dict | SlackSDKView, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Update the modal view in response to the modal submission
+Update the modal view in response to modal submission, using the trigger_id that was returned when the modal was +submitted. +Any extra kwargs you provide, will be passed on directly to +views.update
+ + +You have to call this method within 3 seconds of receiving the modal submission payload.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ view
+ |
+
+ dict | View
+ |
+
+
+
+ the view to update + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from views.update + |
+
src/machine/plugins/modals.py
112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 |
|
send_dm(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a DM to the user that submitted the modal
+Send a Direct Message to the user that submitted the modal by opening a DM channel and +sending a message to it. +Allows for rich formatting using blocks and/or attachments . You can provide blocks +and attachments as Python dicts or you can use the convenience classes that the +underlying slack client provides. +Any extra kwargs you provide, will be passed on directly to the +chat.postMessage request.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AsyncSlackResponse
+ |
+
+
+
+ Dictionary deserialized from chat.postMessage response. + |
+
src/machine/plugins/modals.py
135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 |
|
machine.plugins.modals.ModalClosure
+
+
+A Slack modal closure that was received by the bot
+This class represents the closure (cancellation) of a modal that was received by the bot and passed to a plugin.
+ + +Attributes:
+Name | +Type | +Description | +
---|---|---|
payload |
+
+ ViewClosedPayload
+ |
+
+
+
+ The payload that was received by the bot when the modal was closed + |
+
src/machine/plugins/modals.py
167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 |
|
user: User
+
+
+ property
+
+
+The user that closed the modal
+ + +Returns:
+Type | +Description | +
---|---|
+ User
+ |
+
+
+
+ the user that closed the modal + |
+
view: View
+
+
+ property
+
+
+The view that was closed including the state of all the elements in the view when it was closed
+ + +Returns:
+Type | +Description | +
---|---|
+ View
+ |
+
+
+
+ the view that was closed + |
+
send_dm(text: str | None = None, attachments: Sequence[Attachment] | Sequence[dict[str, Any]] | None = None, blocks: Sequence[Block] | Sequence[dict[str, Any]] | None = None, **kwargs: Any) -> AsyncSlackResponse
+
+
+ async
+
+
+Send a DM to the user that closed the modal
+Send a Direct Message to the user that closed the modal by opening a DM channel and +sending a message to it. +Allows for rich formatting using blocks and/or attachments . You can provide blocks +and attachments as Python dicts or you can use the convenience classes that the +underlying slack client provides. +Any extra kwargs you provide, will be passed on directly to the +chat.postMessage request.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ text
+ |
+
+ str | None
+ |
+
+
+
+ message text + |
+
+ None
+ |
+
+ attachments
+ |
+
+ Sequence[Attachment] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional attachments (see attachments) + |
+
+ None
+ |
+
+ blocks
+ |
+
+ Sequence[Block] | Sequence[dict[str, Any]] | None
+ |
+
+
+
+ optional blocks (see blocks) + |
+
+ None
+ |
+
Returns: + Dictionary deserialized from chat.postMessage response.
+ +src/machine/plugins/modals.py
200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 |
|
These are the decorators you can use to have Slack Machine respond to +specific things (events, messages, etc.)
+ + +
machine.plugins.decorators
+
+
+
process(slack_event_type: str) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Process Slack events of a specific type
+This decorator will enable a Plugin method to process Slack events of a specific type. The +Plugin method will be called for each event of the specified type that the bot receives. +The received event will be passed to the method when called.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ slack_event_type
+ |
+
+ str
+ |
+
+
+
+ type of event the method needs to process. Can be any event supported +by the Events API + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 |
|
listen_to(regex: str, flags: re.RegexFlag | int = re.IGNORECASE, handle_message_changed: bool = False) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Listen to messages matching a regex pattern
+This decorator will enable a Plugin method to listen to messages that match a regex pattern.
+The Plugin method will be called for each message that matches the specified regex pattern.
+The received Message
will be passed to the method when called.
+Named groups can be used in the regex pattern, to catch specific parts of the message. These
+groups will be passed to the method as keyword arguments when called.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ regex
+ |
+
+ str
+ |
+
+
+
+ regex pattern to listen for + |
+ + required + | +
+ flags
+ |
+
+ RegexFlag | int
+ |
+
+
+
+ regex flags to apply when matching + |
+
+ IGNORECASE
+ |
+
+ handle_message_changed
+ |
+
+ bool
+ |
+
+
+
+ if changed messages should trigger the decorated function + |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 |
|
respond_to(regex: str, flags: re.RegexFlag | int = re.IGNORECASE, handle_message_changed: bool = False) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Listen to messages mentioning the bot and matching a regex pattern
+This decorator will enable a Plugin method to listen to messages that are directed to the bot
+(ie. message starts by mentioning the bot) and match a regex pattern.
+The Plugin method will be called for each message that mentions the bot and matches the
+specified regex pattern. The received Message
will be passed
+to the method when called. Named groups can be used in the regex pattern, to catch specific
+parts of the message. These groups will be passed to the method as keyword arguments when
+called.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ regex
+ |
+
+ str
+ |
+
+
+
+ regex pattern to listen for + |
+ + required + | +
+ flags
+ |
+
+ RegexFlag | int
+ |
+
+
+
+ regex flags to apply when matching + |
+
+ IGNORECASE
+ |
+
+ handle_message_changed
+ |
+
+ bool
+ |
+
+
+
+ if changed messages should trigger the decorated function + |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 |
|
command(slash_command: str) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Respond to a slash command
+This decorator will enable a Plugin method to respond to slash commands
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ slash_command
+ |
+
+ str
+ |
+
+
+
+ the slash command to respond to + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 |
|
action(action_id: Union[re.Pattern[str], str, None] = None, block_id: Union[re.Pattern[str], str, None] = None) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Respond to block actions
+This decorator will enable a Plugin method to be triggered when certain block actions are
+received. The Plugin method will be called when a block action event is received for which
+the action_id
and block_id
match the provided values. action_id
and block_id
can be strings,
+in which case the incoming action_id and block_id must match exactly, or regex patterns, in
+which case the incoming action_id and block_id must match the regex pattern.
Both action_id and block_id are optional, but at least one of them must be provided.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ action_id
+ |
+
+ Union[Pattern[str], str, None]
+ |
+
+
+
+ the action_id to respond to, can be a string or regex pattern + |
+
+ None
+ |
+
+ block_id
+ |
+
+ Union[Pattern[str], str, None]
+ |
+
+
+
+ the block_id to respond to, can be a string or regex pattern + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 |
|
modal(callback_id: Union[re.Pattern[str], str]) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Respond to modal submissions
+This decorator will enable a Plugin method to be triggered when certain modals are submitted.
+The Plugin method will be called when a modal submission event is received for which the
+callback_id
matches the provided value. The callback_id
can be a string or a regex pattern.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ callback_id
+ |
+
+ Union[Pattern[str], str]
+ |
+
+
+
+ the callback id to respond to, can be a string or regex pattern + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 |
|
modal_closed(callback_id: Union[re.Pattern[str], str]) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Respond to modal closures
+This decorator will enable a Plugin method to be triggered when certain modals are closed.
+The Plugin method will be called when a modal closure event is received for which the
+callback_id
matches the provided value. The callback_id
can be a string or a regex pattern.
In order to receive modal close events, the modal must have the notify_on_close
property set to True
.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ callback_id
+ |
+
+ Union[Pattern[str], str]
+ |
+
+
+
+ the callback id to respond to, can be a string or regex pattern + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 |
|
schedule(year: int | str | None = None, month: int | str | None = None, day: int | str | None = None, week: int | str | None = None, day_of_week: int | str | None = None, hour: int | str | None = None, minute: int | str | None = None, second: int | str | None = None, start_date: datetime | str | None = None, end_date: datetime | str | None = None, timezone: tzinfo | str | None = None) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Schedule a function to be executed according to a crontab-like schedule
+The decorated function will be executed according to the schedule provided. Slack Machine uses
+APScheduler under the hood for scheduling. For more information on the interpretation of the
+provided parameters, see CronTrigger
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ year
+ |
+
+ int | str | None
+ |
+
+
+
+ 4-digit year + |
+
+ None
+ |
+
+ month
+ |
+
+ int | str | None
+ |
+
+
+
+ month (1-12) + |
+
+ None
+ |
+
+ day
+ |
+
+ int | str | None
+ |
+
+
+
+ day of the (1-31) + |
+
+ None
+ |
+
+ week
+ |
+
+ int | str | None
+ |
+
+
+
+ ISO week (1-53) + |
+
+ None
+ |
+
+ day_of_week
+ |
+
+ int | str | None
+ |
+
+
+
+ number or name of weekday (0-6 or mon,tue,wed,thu,fri,sat,sun) + |
+
+ None
+ |
+
+ hour
+ |
+
+ int | str | None
+ |
+
+
+
+ hour (0-23) + |
+
+ None
+ |
+
+ minute
+ |
+
+ int | str | None
+ |
+
+
+
+ minute (0-59) + |
+
+ None
+ |
+
+ second
+ |
+
+ int | str | None
+ |
+
+
+
+ second (0-59) + |
+
+ None
+ |
+
+ start_date
+ |
+
+ datetime | str | None
+ |
+
+
+
+ earliest possible date/time to trigger on (inclusive) + |
+
+ None
+ |
+
+ end_date
+ |
+
+ datetime | str | None
+ |
+
+
+
+ latest possible date/time to trigger on (inclusive) + |
+
+ None
+ |
+
+ timezone
+ |
+
+ tzinfo | str | None
+ |
+
+
+
+ time zone to use for the date/time calculations (defaults to scheduler timezone) + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 |
|
on(event: str) -> Callable[[Callable[P, R]], Callable[P, R]]
+
+Listen for an event
+The decorated function will be called whenever a plugin (or Slack Machine itself) emits an +event with the given name.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ event
+ |
+
+ str
+ |
+
+
+
+ name of the event to listen for. Event names are global + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], Callable[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 |
|
required_settings(settings: list[str] | str) -> Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+
+Specify a required setting for a plugin or plugin method
+The settings specified with this decorator will be added to the required settings for the +plugin. If one or more settings have not been defined by the user, the plugin will not be +loaded and a warning will be written to the console upon startup.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ settings
+ |
+
+ list[str] | str
+ |
+
+
+
+ settings that are required (can be list of strings, or single string) + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[P, R]], DecoratedPluginFunc[P, R]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 |
|
require_any_role(required_roles: list[str]) -> Callable[[Callable[..., Awaitable[None]]], Callable[..., Awaitable[None]]]
+
+Specify required roles for a plugin method
+To use the plugin method where this decorator is applied, the user must have +at least one of the listed roles.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ required_roles
+ |
+
+ list[str]
+ |
+
+
+
+ list of roles required to use the plugin method + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[..., Awaitable[None]]], Callable[..., Awaitable[None]]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 |
|
require_all_roles(required_roles: list[str]) -> Callable[[Callable[..., Awaitable[None]]], Callable[..., Awaitable[None]]]
+
+Specify required roles for a plugin method
+To use the plugin method where this decorator is applied, the user must have +all of the listed roles.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ required_roles
+ |
+
+ list[str]
+ |
+
+
+
+ list of roles required to use the plugin method + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Callable[[Callable[..., Awaitable[None]]], Callable[..., Awaitable[None]]]
+ |
+
+
+
+ wrapped method + |
+
src/machine/plugins/decorators.py
364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 |
|
These classes represent base objects from the Slack API
+ + +
machine.models.user.User
+
+
+
+ Bases: BaseModel
User model that represents a user object from the Slack API
+ + + + + + +src/machine/models/user.py
28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 |
|
fmt_mention() -> str
+
+Format the user as a mention
+ +src/machine/models/user.py
55 +56 +57 |
|
machine.models.channel.Channel
+
+
+
+ Bases: BaseModel
Channel model that represents a channel object from the Slack API
+ + + + + + +src/machine/models/channel.py
14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 |
|
identifier: str
+
+
+ property
+
+
+Return the name of the channel if it exists, otherwise return the id
+
machine.models.interactive.BlockActionsPayload
+
+
+
+ Bases: TypedModel
src/machine/models/interactive.py
386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 |
|
machine.models.interactive.Action = Annotated[Union[RadioButtonsAction, ButtonAction, CheckboxAction, DatepickerAction, StaticSelectAction, ChannelSelectAction, ConversationSelectAction, UserSelectAction, ExternalSelectAction, MultiStaticSelectAction, MultiChannelSelectAction, MultiConversationSelectAction, MultiUserSelectAction, MultiExternalSelectAction, TimepickerAction, UrlAction, OverflowAction, PlainTextInputAction, RichTextInputAction], Field(discriminator='type')]
+
+
+ module-attribute
+
+
+
machine.models.interactive.ViewSubmissionPayload
+
+
+
+ Bases: TypedModel
src/machine/models/interactive.py
417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 |
|
machine.models.interactive.View
+
+
+
+ Bases: BaseModel
src/machine/models/interactive.py
357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 |
|
machine.models.interactive.State
+
+
+
+ Bases: BaseModel
src/machine/models/interactive.py
202 +203 |
|
Storage is exposed to plugins through the self.storage
field. The following class implements the interface plugins
+can use to interact with the storage backend.
machine.storage.PluginStorage
+
+
+Class providing access to persistent storage for plugins
+This class is the main access point for plugins to work with persistent storage. It is
+accessible from plugins using self.storage
. Data is serialized before sending it to
+the storage backend, and deserialized upon retrieval. Serialization is done by dill, so
+pretty much any Python object can be stored and retrieved.
src/machine/storage/__init__.py
12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 |
|
set(key: str, value: Any, expires: int | timedelta | None = None, shared: bool = False) -> None
+
+
+ async
+
+
+Store or update a value by key
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ the key under which to store the data + |
+ + required + | +
+ value
+ |
+
+ Any
+ |
+
+
+
+ the data to store + |
+ + required + | +
+ expires
+ |
+
+ int | timedelta | None
+ |
+
+
+
+ optional number of seconds after which the data is expired + |
+
+ None
+ |
+
+ shared
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
src/machine/storage/__init__.py
33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 |
|
get(key: str, shared: bool = False) -> Any | None
+
+
+ async
+
+
+Retrieve data by key
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ key for the data to retrieve + |
+ + required + | +
+ shared
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Any | None
+ |
+
+
+
+ the data, or |
+
src/machine/storage/__init__.py
48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 |
|
has(key: str, shared: bool = False) -> bool
+
+
+ async
+
+
+Check if the key exists in storage
+ + +this class implements __contains__
so instead of calling
+self.storage.has(...)
, you can also use: key in self.storage
. This will check the
+namespaced version of the key, so it's the same as: self.storage.has('key', shared=False)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ key to check + |
+ + required + | +
+ shared
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+
|
+
src/machine/storage/__init__.py
65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 |
|
delete(key: str, shared: bool = False) -> None
+
+
+ async
+
+
+Remove a key and its data from storage
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ key to remove + |
+ + required + | +
+ shared
+ |
+
+ bool
+ |
+
+
+
+
|
+
+ False
+ |
+
src/machine/storage/__init__.py
84 +85 +86 +87 +88 +89 +90 +91 +92 +93 |
|
get_storage_size() -> int
+
+
+ async
+
+
+Calculate the total size of the storage
+ + +Returns:
+Type | +Description | +
---|---|
+ int
+ |
+
+
+
+ the total size of the storage in bytes (integer) + |
+
src/machine/storage/__init__.py
95 + 96 + 97 + 98 + 99 +100 +101 |
|
get_storage_size_human() -> str
+
+
+ async
+
+
+Calculate the total size of the storage in human readable format
+ + +Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ the total size of the storage in a human readable string, rounded to the nearest +applicable division. eg. B for Bytes, KiB for Kilobytes, MiB for Megabytes etc. + |
+
src/machine/storage/__init__.py
103 +104 +105 +106 +107 +108 +109 +110 +111 |
|
New Storage Backends can be implemented by extending the following +class:
+ + +
machine.storage.backends.base.MachineBaseStorage
+
+
+
+ Bases: ABC
Base class for storage backends
+Extending classes should implement the five methods in this base class. Slack Machine takes +care of a lot of details regarding the persistent storage of data. So storage backends +do not have to deal with the following, because Slack Machine takes care of these:
+src/machine/storage/backends/base.py
8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 |
|
init() -> None
+
+
+ async
+
+
+Initialize the storage backend
+To be implemented by subclasses if initialization is required. This method is called once after instantiation.
+ +src/machine/storage/backends/base.py
24 +25 +26 +27 +28 +29 |
|
get(key: str) -> bytes | None
+
+
+ abstractmethod
+ async
+
+
+Retrieve data by key
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ key for which to retrieve data + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bytes | None
+ |
+
+
+
+ the raw data for the provided key, as (byte)string. Should return |
+
src/machine/storage/backends/base.py
31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 |
|
set(key: str, value: bytes, expires: int | None = None) -> None
+
+
+ abstractmethod
+ async
+
+
+Store data by key
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ the key under which to store the data + |
+ + required + | +
+ value
+ |
+
+ bytes
+ |
+
+
+
+ data as (byte)string + |
+ + required + | +
+ expires
+ |
+
+ int | None
+ |
+
+
+
+ optional expiration time in seconds, after which the data should not be +returned any more. + |
+
+ None
+ |
+
src/machine/storage/backends/base.py
44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 |
|
delete(key: str) -> None
+
+
+ abstractmethod
+ async
+
+
+Delete data by key
+:param key: key for which to delete the data
+ +src/machine/storage/backends/base.py
56 +57 +58 +59 +60 +61 +62 |
|
has(key: str) -> bool
+
+
+ abstractmethod
+ async
+
+
+Check if the key exists
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
+ key
+ |
+
+ str
+ |
+
+
+
+ key to check + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+
|
+
src/machine/storage/backends/base.py
64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 |
|
size() -> int
+
+
+ abstractmethod
+ async
+
+
+Calculate the total size of the storage
+ + +Returns:
+Type | +Description | +
---|---|
+ int
+ |
+
+
+
+ total size of storage in bytes (integer) + |
+
src/machine/storage/backends/base.py
76 +77 +78 +79 +80 +81 +82 +83 |
|
close() -> None
+
+
+ abstractmethod
+ async
+
+
+Close the storage backend
+ +src/machine/storage/backends/base.py
85 +86 +87 +88 |
|