EzSlack
EzSlack is a Python framework wrapping Bolt for Python to provide useful utilities.
- Encapsule parsing low-level information
- Provide
Handlerclass to improve cohesion
Get Started
from ezslack import App
# Running over HTTP
app = App(token=SLACK_BOT_TOKEN, signing_secret=SLACK_SIGNING_SECRET)
app.start(PORT)
# Running in Socket Mode
app = App(token=SLACK_BOT_TOKEN)
app.start_socket_mode(SLACK_APP_TOKEN)
Handler
Whenever subclass of Handler is defined, handler methods are registered in REGISTRIES. String arguments in handler decorator are automatically converted into regex pattern with anchors. Matched groups are passed to arguments and keyword arguments whether they are named.
from ezslack import Handler, message
class MyHandler(Handler):
@message("hello", "hi")
def greet(self):
self.ack()
self.say(
f"Nice to meet you <@{self.user_id}>",
thread_ts=self.thread_ts,
)
@message(r"(?P<first>\w+)(?P<op>[+*])(?P<second>\w+)")
def calculate(self, first, second, op):
if op == "+":
result = int(first) + int(second)
else:
result = int(first) * int(second)
self.say(f"Result: {result}", thread_ts=self.thread_ts)
Supported features
Requests supported: ACTION, MESSAGE, VIEW_CLOSED, VIEW_SUBMISSION
Each request has an id such as action_id, message.text, callback_id. When a request id matches handling method's regex pattern, handler is instantiated with the following context fields, then call the method.
| field | type | description | event |
|---|---|---|---|
ack |
Ack |
See Reference | - |
client |
WebClient |
See Reference | - |
respond |
Respond |
See Reference | - |
say |
Say |
See Reference | - |
channel_id |
Optional[str] |
Channel where the event was triggered | ACTION, MESSAGE |
channel_name |
Optional[str] |
Channel where the event was triggered | MESSAGE |
message_ts |
Optional[str] |
Timestamp of the message | ACTION, MESSAGE |
metadata |
Optional[Metadata] |
Metadata of the message | ACTION |
private_metadata |
Optional[str] |
Private metadata of the view | VIEW_SUBMISSION, VIEW_CLOSED |
request_id |
str |
Identifier such as action_id, message.text, callback_id which is used to match handler |
- |
thread_ts |
Optional[str] |
Timestamp of the thread | ACTION, MESSAGE |
trigger_id |
Optional[str] |
Trigger id from the event | ACTION |
user_id |
Optional[str] |
User who triggers the event | - |
user_name |
Optional[str] |
User who triggers the event | ACTION, VIEW_SUBMISSION, VIEW_CLOSED |
bot_id |
Optional[str] |
Bot which triggers the event | MESSAGE |
view_state |
Optional[ViewState] |
View state which has selected values | VIEW_SUBMISSION, VIEW_CLOSED |
Metadata
Release files for ezslack 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ezslack-0.1.2.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ezslack-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.1 kB
Release files / ezslack-0.1.2.tar.gz
| Download URL | ezslack-0.1.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1a60081f8f382ea3ab15808f0365e564e8c9a37ef4905e2913aa1f3f1b04c3c
|
|
BLAKE2b-256 checksum How to use checksums |
fa212a7b16dc727efe4f848fc3a2c9b420e59c945be871a5debec9e8f79f2fec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ezslack-0.1.2-py3-none-any.whl
| Download URL | ezslack-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1d00230f5511602868aeae6ecbfe50ffc7ef32705cff5b1a304f4a85a8ef6f6
|
|
BLAKE2b-256 checksum How to use checksums |
5415a21bfd69ed4a86d16608f4a234ca8df996ff397b654fbc2bed1b4e2032da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|