Coder Social home page Coder Social logo

slackapi / python-slack-hooks Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 1.0 77 KB

Helper library implementing the contract between the Slack CLI and Bolt for Python

Home Page: https://pypi.org/project/slack-cli-hooks/

License: MIT License

Shell 4.74% Python 95.26%
bolt cli python python3 slack slack-api slack-cli

python-slack-hooks's Introduction

Python Slack Hooks

PyPI - Version Python Versions Codecov

This library defines the contract between the Slack CLI and Bolt for Python.

Overview

This library enables inter-process communication between the Slack CLI and applications built with Bolt for Python.

When used together, the CLI delegates various tasks to the Bolt application by invoking processes ("hooks") and then making use of the responses provided by each hook's stdout.

For a complete list of available hooks, read the Supported Hooks section.

Requirements

The latest minor version of Bolt v1 is recommended.

Usage

A Slack CLI-compatible Slack application includes a ./slack.json file that contains hooks specific to that project. Each hook is associated with commands that are available in the Slack CLI. By default, get-hooks retrieves all of the supported hooks and their corresponding scripts as defined in this library.

The CLI will always use the version of the python-slack-hooks that is specified in the project's requirements.txt.

Supported Hooks

The hooks currently supported for use within the Slack CLI include check-update, doctor, get-hooks, get-manifest, and start:

Hook Name CLI Command File Description
check-update slack update check_update.py Checks the project's Slack dependencies to determine whether or not any libraries need to be updated.
doctor slack doctor doctor.py Returns runtime versions and other system dependencies required by the application.
get-hooks All get_hooks.py Fetches the list of available hooks for the CLI from this repository.
get-manifest slack manifest get_manifest.py Converts a manifest.json file into a valid manifest JSON payload.
start slack run start.py While developing locally, the CLI manages a socket connection with Slack's backend and utilizes this hook for events received via this connection.

Overriding Hooks

To customize the behavior of a hook, add the hook to your application's /slack.json file, and provide a corresponding script to be executed.

When commands are run, the Slack CLI will look to the project's hook definitions and use those instead of what's defined in this library, if provided.

Below is an example /slack.json file that overrides the default start:

{
  "hooks": {
    "get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks",
    "start": "python3 app.py"
  }
}

Contributing

Contributions are always welcome! Please review the contributing guidelines for more information.

python-slack-hooks's People

Contributors

dependabot[bot] avatar misscoded avatar williambergamin avatar zimeg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

williambergamin

python-slack-hooks's Issues

[BUG] ModuleNotFoundError: No module named 'packaging' for the check_update hook

The slack_cli_hooks versions

slack_bolt==1.19.0rc1
slack_cli_hooks==0.0.0.dev2
slack_sdk==3.27.0

Python runtime version

Python 3.11.8

OS info

ProductName:            macOS
ProductVersion:         14.3
BuildVersion:           23D56
Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000

Describe the bug

The packaging module is not installed with this package so a ModuleNotFoundError is raised when calling the check_update hook. It seems like packaging is the only package not included in the standard library!

Steps to reproduce

$ slack create pkgs -t slack-samples/bolt-python-custom-function-template
$ cd pkgs

# Include only the slack_* modules
$ head -n 2 requirements.txt > tmp.txt && mv tmp.txt requirements.txt

$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

$ slack update

Expected result

Updates are checked without any error

Actual result

$ slack update
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/me/programming/sandbox/example/.venv/lib/python3.11/site-packages/slack_cli_hooks/hooks/check_update.py", line 10, in <module>
from packaging.version import Version
ModuleNotFoundError: No module named 'packaging'

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

[FEATURE] Improve README

Description of the problem being solved

It will be helpful for users to get information on hooks and how to override them.

Alternative solutions

In the README.md create a section that describes the purpose/function of each hook, and then advises how to override them.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

[FEATURE] windows CI support

Description of the problem being solved

This library is intended to be used on macOS, Linux and Windows the behavior of python on those operating systems may vary slightly.

Alternative solutions

It would be very useful to have an integration tests validates that the core functionality of this package is consistent across all operating systems

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

[FEATURE] Support for slack deploy hook

Description of the problem being solved

Running slack deploy --experiment=bolt requires a hook for deployment. Is this on the roadmap?

(.venv) .venv โฏ slack deploy --experiment=bolt
Check .../logs/slack-debug-20240425.log for full error logs

๐Ÿšซ A `deploy` hook was not found in the `slack.json` file (sdk_hook_not_found)

Suggestion:

Provide a command or script to run with the deploy command by adding a new hook.
The app will be re-installed to the selected team before invoking this hook.
Both SLACK_APP_TOKEN and SLACK_BOT_TOKEN environment variables will be provided.

About slack deploy: https://api.slack.com/automation/deploy

[FEATURE] Implement check-update hook

Description of the problem being solved

The Slack CLI supports a check-update hook implementation, currently the slack update command will not check if this SDK is up to date

Alternative solutions

Implement the check-update hook to enable dependency updating

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

[BUG] check update seems to be wrong

The slack_cli_hooks versions

Python runtime version

OS info

Describe the bug

If the installed package is the latest version, it seem like the check_update script reports this as there being a newer version

Steps to reproduce

  1. pip install slack-cli-hooks
  2. got to a valid project
  3. python3 -m slack_cli_hooks.hooks.check_update | jq .

Expected result

{
  "name": "Slack Bolt",
  "url": "https://api.slack.com/automation/changelog",
  "releases": [
    {
      "name": "slack_cli_hooks",
      "current": "0.0.0",
      "latest": "0.0.0",
      "update": false,
      "breaking": false
    },
    {
      "name": "slack_bolt",
      "current": "1.19.0",
      "latest": "1.18.1",
      "update": false,
      "breaking": false
    },
    {
      "name": "slack_sdk",
      "current": "3.27.1",
      "latest": "3.27.1",
      "update": false,
      "breaking": false
    }
  ]
}

Actual result

{
  "name": "Slack Bolt",
  "url": "https://api.slack.com/automation/changelog",
  "releases": [
    {
      "name": "slack_cli_hooks",
      "current": "0.0.0",
      "latest": "0.0.0",
      "update": true,
      "breaking": false
    },
    {
      "name": "slack_bolt",
      "current": "1.19.0",
      "latest": "1.18.1",
      "update": false,
      "breaking": false
    },
    {
      "name": "slack_sdk",
      "current": "3.27.1",
      "latest": "3.27.1",
      "update": false,
      "breaking": false
    }
  ]
}
โ””โ”€[$] <git:(main*)> hermes upgrade
   
๐Ÿ› ๏ธ  An update from Slack Bolt is available:

    โ€บ slack_cli_hooks
      0.0.0 โ†’ 0.0.0

   For more information about this update, visit:
   https://api.slack.com/automation/changelog

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.