ezslack


Nameezslack JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/taekop/ezslack
SummaryEasy Slack framework wrapping Bolt for Python
upload_time2024-02-26 09:55:57
maintainer
docs_urlNone
authortaekop
requires_python>=3.9,<4.0
licenseMIT
keywords slack
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # EzSlack

EzSlack is a Python framework wrapping [Bolt for Python](https://github.com/slackapi/bolt-python) to provide useful utilities.

- Encapsule parsing low-level information
- Provide `Handler` class to improve cohesion

## Get Started

```python
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`](ezslack/handler/handler.py) is defined, handler methods are registered in [`REGISTRIES`](ezslack/handler/registry.py#L33). 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.

```python
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](https://github.com/slackapi/bolt-python#making-things-happen)         |                     -                      |
|      `client`      |      `WebClient`      |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |
|     `respond`      |       `Respond`       |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |
|       `say`        |         `Say`         |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |
|    `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`      |

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/taekop/ezslack",
    "name": "ezslack",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "slack",
    "author": "taekop",
    "author_email": "taekop@naver.com",
    "download_url": "https://files.pythonhosted.org/packages/fa/21/2a7b16dc727efe4f848fc3a2c9b420e59c945be871a5debec9e8f79f2fec/ezslack-0.1.2.tar.gz",
    "platform": null,
    "description": "# EzSlack\n\nEzSlack is a Python framework wrapping [Bolt for Python](https://github.com/slackapi/bolt-python) to provide useful utilities.\n\n- Encapsule parsing low-level information\n- Provide `Handler` class to improve cohesion\n\n## Get Started\n\n```python\nfrom ezslack import App\n\n# Running over HTTP\napp = App(token=SLACK_BOT_TOKEN, signing_secret=SLACK_SIGNING_SECRET)\napp.start(PORT)\n\n# Running in Socket Mode\napp = App(token=SLACK_BOT_TOKEN)\napp.start_socket_mode(SLACK_APP_TOKEN)\n```\n\n## Handler\n\nWhenever subclass of [`Handler`](ezslack/handler/handler.py) is defined, handler methods are registered in [`REGISTRIES`](ezslack/handler/registry.py#L33). 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.\n\n```python\nfrom ezslack import Handler, message\n\nclass MyHandler(Handler):\n    @message(\"hello\", \"hi\")\n    def greet(self):\n        self.ack()\n        self.say(\n            f\"Nice to meet you <@{self.user_id}>\",\n            thread_ts=self.thread_ts,\n        )\n\n    @message(r\"(?P<first>\\w+)(?P<op>[+*])(?P<second>\\w+)\")\n    def calculate(self, first, second, op):\n        if op == \"+\":\n            result = int(first) + int(second)\n        else:\n            result = int(first) * int(second)\n        self.say(f\"Result: {result}\", thread_ts=self.thread_ts)\n```\n\n## Supported features\n\nRequests supported: `ACTION`, `MESSAGE`, `VIEW_CLOSED`, `VIEW_SUBMISSION`\n\nEach 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.\n\n|       field        |         type          |                                         description                                          |                   event                    |\n| :----------------: | :-------------------: | :------------------------------------------------------------------------------------------: | :----------------------------------------: |\n|       `ack`        |         `Ack`         |        See [Reference](https://github.com/slackapi/bolt-python#making-things-happen)         |                     -                      |\n|      `client`      |      `WebClient`      |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |\n|     `respond`      |       `Respond`       |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |\n|       `say`        |         `Say`         |        See  [Reference](https://github.com/slackapi/bolt-python#making-things-happen)        |                     -                      |\n|    `channel_id`    |    `Optional[str]`    |                            Channel where the event was triggered                             |            `ACTION`, `MESSAGE`             |\n|   `channel_name`   |    `Optional[str]`    |                            Channel where the event was triggered                             |                 `MESSAGE`                  |\n|    `message_ts`    |    `Optional[str]`    |                                   Timestamp of the message                                   |            `ACTION`, `MESSAGE`             |\n|     `metadata`     | `Optional[Metadata]`  |                                   Metadata of the message                                    |                  `ACTION`                  |\n| `private_metadata` |    `Optional[str]`    |                                 Private metadata of the view                                 |      `VIEW_SUBMISSION`, `VIEW_CLOSED`      |\n|    `request_id`    |         `str`         | Identifier such as `action_id`, `message.text`, `callback_id` which is used to match handler |                     -                      |\n|    `thread_ts`     |    `Optional[str]`    |                                   Timestamp of the thread                                    |            `ACTION`, `MESSAGE`             |\n|    `trigger_id`    |    `Optional[str]`    |                                  Trigger id from the event                                   |                  `ACTION`                  |\n|     `user_id`      |    `Optional[str]`    |                                 User who triggers the event                                  |                     -                      |\n|    `user_name`     |    `Optional[str]`    |                                 User who triggers the event                                  | `ACTION`, `VIEW_SUBMISSION`, `VIEW_CLOSED` |\n|      `bot_id`      |    `Optional[str]`    |                                 Bot which triggers the event                                 |                 `MESSAGE`                  |\n|    `view_state`    | `Optional[ViewState]` |                             View state which has selected values                             |      `VIEW_SUBMISSION`, `VIEW_CLOSED`      |\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easy Slack framework wrapping Bolt for Python",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/taekop/ezslack"
    },
    "split_keywords": [
        "slack"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5415a21bfd69ed4a86d16608f4a234ca8df996ff397b654fbc2bed1b4e2032da",
                "md5": "88d1916dcaa2700bcbacd72b2c58d969",
                "sha256": "b1d00230f5511602868aeae6ecbfe50ffc7ef32705cff5b1a304f4a85a8ef6f6"
            },
            "downloads": -1,
            "filename": "ezslack-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "88d1916dcaa2700bcbacd72b2c58d969",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 8646,
            "upload_time": "2024-02-26T09:55:56",
            "upload_time_iso_8601": "2024-02-26T09:55:56.475488Z",
            "url": "https://files.pythonhosted.org/packages/54/15/a21bfd69ed4a86d16608f4a234ca8df996ff397b654fbc2bed1b4e2032da/ezslack-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa212a7b16dc727efe4f848fc3a2c9b420e59c945be871a5debec9e8f79f2fec",
                "md5": "d0004b6e290db0476f927ae2ebf46274",
                "sha256": "d1a60081f8f382ea3ab15808f0365e564e8c9a37ef4905e2913aa1f3f1b04c3c"
            },
            "downloads": -1,
            "filename": "ezslack-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d0004b6e290db0476f927ae2ebf46274",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 7406,
            "upload_time": "2024-02-26T09:55:57",
            "upload_time_iso_8601": "2024-02-26T09:55:57.823800Z",
            "url": "https://files.pythonhosted.org/packages/fa/21/2a7b16dc727efe4f848fc3a2c9b420e59c945be871a5debec9e8f79f2fec/ezslack-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 09:55:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "taekop",
    "github_project": "ezslack",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ezslack"
}
        
Elapsed time: 0.73729s